Browse Source

refactor things a bit more into support mk files...

main
John-Mark Gurney 2 years ago
parent
commit
1a4eaedea5
3 changed files with 37 additions and 36 deletions
  1. +2
    -35
      Makefile
  2. +9
    -1
      mk/boards.mk
  3. +26
    -0
      mk/mu.progs.mk

+ 2
- 35
Makefile View File

@@ -22,14 +22,6 @@
# SUCH DAMAGE. # 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) .if $(.OBJDIR) == $(.CURDIR)
.error Need to set MAKEOBJDIR. .error Need to set MAKEOBJDIR.
.endif .endif
@@ -79,9 +71,6 @@ LIBSYOTE_TEST = libsyote_test.$(SOEXT)
$(LIBSYOTE_TEST): $(LIBSYOTE_TEST_OBJS) $(LIBSYOTE_TEST): $(LIBSYOTE_TEST_OBJS)
$(CC) -shared -o $@ $(.ALLSRC) $(CC) -shared -o $@ $(.ALLSRC)


.MAIN: all
.PHONY: all

DEPENDS = .arm_deps .test_deps DEPENDS = .arm_deps .test_deps
.PHONY: $(DEPENDS) .PHONY: $(DEPENDS)
depend: $(DEPENDS) depend: $(DEPENDS)
@@ -105,22 +94,6 @@ rng_save.c: Makefile
.test_deps: $(LIBSYOTE_TEST_SRCS) .test_deps: $(LIBSYOTE_TEST_SRCS)
$(CC) $(CFLAGS) $(.ALLSRC) -MM | sed -e 's/\.o:/\.no:/' > $@ || (rm -f $@ && false) $(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 .PHONY: runbuild
runbuild: $(SRCS) Makefile mk/*.mk 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' 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 (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_NAME = strobe
STROBE_REPO = https://git.code.sf.net/p/strobe/code STROBE_REPO = https://git.code.sf.net/p/strobe/code
STROBE_BRANCH = master STROBE_BRANCH = master
@@ -193,3 +158,5 @@ test-diag:


# hard coded dependancy for when "make depend" has not been run. # hard coded dependancy for when "make depend" has not been run.
irr_main.o: $(.OBJDIR)/shared_key.h irr_main.o: $(.OBJDIR)/shared_key.h

.include <mk/mu.progs.mk>

+ 9
- 1
mk/boards.mk View File

@@ -1,12 +1,19 @@
SRCS.NODE151+= board.c SRCS.NODE151+= board.c
SRCS.NODE151+= misc.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 <mk/mu.opts.mk> .include <mk/mu.opts.mk>


# Strobe # Strobe
.if ${MK_STROBE} == "yes" .if ${MK_STROBE} == "yes"
.PATH: $(.CURDIR)/strobe .PATH: $(.CURDIR)/strobe
CFLAGS+= -I$(.CURDIR)/strobe
CFLAGS+= -I$(.CURDIR)/strobe -DSTROBE_SINGLE_THREAD=1
STROBE_SRCS+= strobe.c \ STROBE_SRCS+= strobe.c \
x25519.c x25519.c
.endif .endif
@@ -27,6 +34,7 @@ SRCS+= adc-board.c delay-board.c gpio-board.c rtc-board.c lpm-board.c sx1276mb1l


# NODE151 Microcontroller # NODE151 Microcontroller
.if ${MK_NODE151} == "yes" .if ${MK_NODE151} == "yes"
ARMTARGET?= -mcpu=cortex-m3 -mthumb
STM32=$(.CURDIR)/stm32 STM32=$(.CURDIR)/stm32
.PATH: $(STM32)/l151ccux .PATH: $(STM32)/l151ccux
LINKER_SCRIPT=$(STM32)/l151ccux/STM32L151CCUX_FLASH.ld LINKER_SCRIPT=$(STM32)/l151ccux/STM32L151CCUX_FLASH.ld


+ 26
- 0
mk/mu.progs.mk View File

@@ -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 $@

Loading…
Cancel
Save