diff --git a/Makefile b/Makefile index c530388..4e7508b 100644 --- a/Makefile +++ b/Makefile @@ -22,14 +22,6 @@ # SUCH DAMAGE. # -ARMOBJDUMP?= arm-none-eabi-objdump -ARMCC?= arm-none-eabi-gcc -ARMTARGET?= -mcpu=cortex-m3 -mthumb -DSTROBE_SINGLE_THREAD=1 - -# Clang doesn't work due to no-nano libc -#ARMCC?=clang-mp-9.0 -#ARMTARGET?= -nostdlib -ffreestanding -target arm-none-eabi -mcpu=cortex-m3 -mfloat-abi=soft -mthumb - .if $(.OBJDIR) == $(.CURDIR) .error Need to set MAKEOBJDIR. .endif @@ -79,9 +71,6 @@ LIBSYOTE_TEST = libsyote_test.$(SOEXT) $(LIBSYOTE_TEST): $(LIBSYOTE_TEST_OBJS) $(CC) -shared -o $@ $(.ALLSRC) -.MAIN: all -.PHONY: all - DEPENDS = .arm_deps .test_deps .PHONY: $(DEPENDS) depend: $(DEPENDS) @@ -105,22 +94,6 @@ rng_save.c: Makefile .test_deps: $(LIBSYOTE_TEST_SRCS) $(CC) $(CFLAGS) $(.ALLSRC) -MM | sed -e 's/\.o:/\.no:/' > $@ || (rm -f $@ && false) -.for i in $(PROGS) -ALLTGTS+= $(i)$(PROGEXT) $(i).list -ASRCS.$(i) = $(SRCS) $(SRCS.$(i)) -OBJS.$(i) = $(ASRCS.$(i):C/.c$/.o/) - -.arm_deps: $(ASRCS.$(i)) - -$(i)$(PROGEXT) $(i).map: $(OBJS.$(i)) - $(ARMCC) $(ARMTARGET) -o $(i)$(PROGEXT) $(.ALLSRC) -T$(LINKER_SCRIPT) --specs=nosys.specs -Wl,-Map="$(i).map" -Wl,--gc-sections -static --specs=nano.specs -Wl,--start-group -lc -lm -Wl,--end-group - -$(i).list: $(i)$(PROGEXT) - $(ARMOBJDUMP) -h -S $(.ALLSRC) > $@ || (rm -f $@ && false) -.endfor - -all: $(ALLTGTS) - .PHONY: runbuild runbuild: $(SRCS) Makefile mk/*.mk for i in $(.MAKEFILE_LIST) $(.ALLSRC) $$(cat $(DEPENDS) | gsed ':x; /\\$$/ { N; s/\\\n//; tx }' | sed -e 's/^[^:]*://'); do if [ "$$i" != ".." ]; then echo $$i; fi; done | sort -u | entr -d sh -c 'echo starting...; cd $(.CURDIR) && $(MAKE) $(.MAKEFLAGS) depend && $(MAKE) $(.MAKEFLAGS) all' @@ -149,14 +122,6 @@ $(.OBJDIR)/shared_key.h: (cmp shared_key.h.tmp shared_key.h >/dev/null 2>&1 && rm shared_key.h.tmp) || mv shared_key.h.tmp shared_key.h -# native objects -.SUFFIXES: .no -.c.no: - $(CC) $(CFLAGS) -c $< -o $@ - -.c.o: - $(ARMCC) $(ARMTARGET) $(CFLAGS) -c $< -o $@ - STROBE_NAME = strobe STROBE_REPO = https://git.code.sf.net/p/strobe/code STROBE_BRANCH = master @@ -193,3 +158,5 @@ test-diag: # hard coded dependancy for when "make depend" has not been run. irr_main.o: $(.OBJDIR)/shared_key.h + +.include diff --git a/mk/boards.mk b/mk/boards.mk index 8d53689..ce5e6a9 100644 --- a/mk/boards.mk +++ b/mk/boards.mk @@ -1,12 +1,19 @@ SRCS.NODE151+= board.c SRCS.NODE151+= misc.c +ARMOBJDUMP?= arm-none-eabi-objdump +ARMCC?= arm-none-eabi-gcc + +# Clang doesn't work due to no-nano libc +#ARMCC?=clang-mp-9.0 +#ARMTARGET?= -nostdlib -ffreestanding -target arm-none-eabi -mcpu=cortex-m3 -mfloat-abi=soft -mthumb + .include # Strobe .if ${MK_STROBE} == "yes" .PATH: $(.CURDIR)/strobe -CFLAGS+= -I$(.CURDIR)/strobe +CFLAGS+= -I$(.CURDIR)/strobe -DSTROBE_SINGLE_THREAD=1 STROBE_SRCS+= strobe.c \ x25519.c .endif @@ -27,6 +34,7 @@ SRCS+= adc-board.c delay-board.c gpio-board.c rtc-board.c lpm-board.c sx1276mb1l # NODE151 Microcontroller .if ${MK_NODE151} == "yes" +ARMTARGET?= -mcpu=cortex-m3 -mthumb STM32=$(.CURDIR)/stm32 .PATH: $(STM32)/l151ccux LINKER_SCRIPT=$(STM32)/l151ccux/STM32L151CCUX_FLASH.ld diff --git a/mk/mu.progs.mk b/mk/mu.progs.mk new file mode 100644 index 0000000..a50a7ed --- /dev/null +++ b/mk/mu.progs.mk @@ -0,0 +1,26 @@ +.MAIN: all +.PHONY: all + +.for i in $(PROGS) +ALLTGTS+= $(i)$(PROGEXT) $(i).list +ASRCS.$(i) = $(SRCS) $(SRCS.$(i)) +OBJS.$(i) = $(ASRCS.$(i):C/.c$/.o/) + +.arm_deps: $(ASRCS.$(i)) + +$(i)$(PROGEXT) $(i).map: $(OBJS.$(i)) + $(ARMCC) $(ARMTARGET) -o $(i)$(PROGEXT) $(.ALLSRC) -T$(LINKER_SCRIPT) --specs=nosys.specs -Wl,-Map="$(i).map" -Wl,--gc-sections -static --specs=nano.specs -Wl,--start-group -lc -lm -Wl,--end-group + +$(i).list: $(i)$(PROGEXT) + $(ARMOBJDUMP) -h -S $(.ALLSRC) > $@ || (rm -f $@ && false) +.endfor + +all: $(ALLTGTS) + +# native objects +.SUFFIXES: .no +.c.no: + $(CC) $(CFLAGS) -c $< -o $@ + +.c.o: + $(ARMCC) $(ARMTARGET) $(CFLAGS) -c $< -o $@