allows own libraries to depend on each other

This commit is contained in:
King Kévin 2017-02-08 17:22:17 +01:00
parent 0143e90939
commit 7fa8d251cd
1 changed files with 5 additions and 3 deletions

View File

@ -32,8 +32,6 @@ BOARD = BLUE_PILL
CSRC = $(wildcard *.c)
CHDR = $(wildcard *.h)
OBJ = $(patsubst %.c,%.o,$(CSRC))
# figure out based on the includes which library files are used in the main CSRC files
DEPENDENCIES = $(patsubst %.c,%.inc,$(CSRC))
# my library collection
LIB = lib
@ -42,8 +40,12 @@ LIB = lib
LIB_CSRC =
LIB_CHDR = $(patsubst %.c,%.h,$(LIB_CSRC))
LIB_OBJ = $(patsubst %.c,%.o,$(LIB_CSRC))
# figure out based on the includes which library files are used in the main CSRC files
DEPENDENCIES = $(patsubst %.c,%.inc,$(CSRC))
# populates LIB_CSRC based on the library files used
-include $(DEPENDENCIES)
$(info $(DEPENDENCIES))
# executables for linking, compiling, debugging, ...
PREFIX ?= arm-none-eabi
@ -192,7 +194,7 @@ list: $(BINARY).list
# figure out which library source files are used for later inclusion
%.inc: %.d
$(Q)grep -o -e " ${LIB}\/[^ ]*\.h" $(<) | sed -e 's/\.h$$/.c/g' -e 's/^/LIB_CSRC +=/' > $(@)
$(Q)grep -o -e " ${LIB}\/[^ ]*\.h" $(<) | sed -e 's|\(.*\)\.h$$|LIB_CSRC +=\1.c\n-include\1.inc|g' -e 's|.*${*}.*||g' > $(@)
# doxygen documentation
doc: Doxyfile README.md $(CSRC) $(CHDR) $(LIB_CSRC) $(LIB_CHDR)