From 5d17a976070be9d66349da0ddd28361884f3461d Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 26 Sep 2021 12:50:49 +0200 Subject: Link against libopencm3 --- Makefile | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 4ef61dd..0b7e9c0 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,23 @@ -.PHONY: all clean +OBJS = main.o startup.o + +# tools +PREFIX ?= arm-none-eabi +CC = $(PREFIX)-gcc +LD = $(PREFIX)-gcc +OBJCOPY = $(PREFIX)-objcopy -all: +all: deps/libopencm3/lib/libopencm3_stm32f1.a mkdir build - arm-none-eabi-gcc -O0 -c -g -mcpu=cortex-m3 -mthumb -o build/test_program.o src/test_program.c - arm-none-eabi-gcc -O0 -c -g -mcpu=cortex-m3 -mthumb -o build/startup.o src/startup.c - arm-none-eabi-ld -Tld/stm32.ld -o build/test_program.elf build/startup.o build/test_program.o - arm-none-eabi-objcopy -O binary build/test_program.elf build/test_program.bin + $(CC) -O0 -c -g -DSTM32F1 -Ideps/libopencm3/include -mcpu=cortex-m3 -mthumb -o build/main.o src/main.c + $(CC) -O0 -c -g -DSTM32F1 -Ideps/libopencm3/include -mcpu=cortex-m3 -mthumb -o build/startup.o src/startup.c + $(LD) --static -nostartfiles -mcpu=cortex-m3 -mthumb -msoft-float -Tld/stm32f103c8t6.ld -Ldeps/libopencm3/lib build/startup.o build/main.o -lopencm3_stm32f1 -o build/ledcontrol.elf + $(OBJCOPY) -O binary build/ledcontrol.elf build/ledcontrol.bin + +deps/libopencm3/lib/libopencm3_stm32f1.a: + make -C deps/libopencm3 clean: rm -rf build + +.PHONY: all clean -- cgit v1.2.3-70-g09d2