summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2021-09-26 12:50:49 +0200
committerxengineering <me@xengineering.eu>2021-09-26 14:07:59 +0200
commit5d17a976070be9d66349da0ddd28361884f3461d (patch)
treeef3e2c0078863aa651008e4f2f9eb4f846bfcc50 /Makefile
parent7211bd49452e67e0b53ea06ca474f4e54af991ae (diff)
downloadledcontrol-5d17a976070be9d66349da0ddd28361884f3461d.tar
ledcontrol-5d17a976070be9d66349da0ddd28361884f3461d.tar.zst
ledcontrol-5d17a976070be9d66349da0ddd28361884f3461d.zip
Link against libopencm3
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile23
1 files changed, 17 insertions, 6 deletions
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