X-Git-Url: https://git.cryptolib.org/?p=avr-crypto-lib.git;a=blobdiff_plain;f=Makefile;h=d569a5fb3b0f7b4d4022f14c7abdfac8045e6911;hp=ebc4a6e75e7657b4951b3cfa89bf8529d19c2d42;hb=69d6349f8ad9d35c2acdb4e4e38ad42cd28b426c;hpb=794b705a0b4dedf4eab3aabcf39f76bf9856ee3f diff --git a/Makefile b/Makefile index ebc4a6e..d569a5f 100644 --- a/Makefile +++ b/Makefile @@ -28,10 +28,14 @@ SIGNATURE := PK_CIPHERS := AUX := + # we use the gnu make standard library include gmsl include avr-makefile.inc + +GLOBAL_INCDIR := ./ $(TESTSRC_DIR) + #------------------------------------------------------------------------------- # inclusion of make stubs include mkfiles/*.mk @@ -59,43 +63,38 @@ $(foreach a, $(ALGORITHMS), $(eval $(call Assert_Template, \ ))) -#$(foreach a, $(ALGORITHMS), \ -# $(if $(def $(a)_DIR), \ -# $(eval $(call Assert_Template, \ -# $(a)_DIR, \ -# . \ -# ) \ -# )) \ -#) -# -#$(foreach a, $(ALGORITHMS), \ -# $(if $(call seq($(strip($($(a)_DIR))),)), \ -# $(eval $(call Assert_Template, \ -# $(a)_DIR, \ -# . \ -# ) \ -# )) \ -#) #------------------------------------------------------------------------------- -# -### ifeq 'blafoo' '' -### $(error no source ($(2)) for $(1) in TargetSource_Template) -### endif define TargetSource_Template $(1): $(2) @echo "[cc]: $(1) <-- $(2)" @mkdir -p $(dir $(1)) - @$(CC) $(CFLAGS_A) -I./$(strip $(3)) -c -o $(1) $(2) + @$(CC) $(CFLAGS_A) $(addprefix -I./,$(3)) $(addprefix -D, $(4)) -c -o $(1) $(2) endef +# ---------------------------------------------------------------------------- +# Function: find_source_file +# Arguments: 1: name of the binary file (.o extension) to search +# 2: list of directorys to search for file +# Returns: Returns paths to source file (mathing the pattern in +# $(SOURCE_PATTERN) +# ---------------------------------------------------------------------------- +SOURCE_PATTERN := %.S %.c +find_source_file = $(firstword $(foreach d, $(2), \ + $(filter $(SOURCE_PATTERN), \ + $(wildcard $(d)$(notdir $(patsubst %.o,%,$1)).*) \ + ) \ + ) ) + + $(foreach a, $(ALGORITHMS), \ $(foreach b, $($(a)_OBJ), \ $(eval $(call TargetSource_Template, \ $(BIN_DIR)$(call lc, $(a))/$(b), \ - $(filter %.S %.c, $(wildcard $($(a)_DIR)$(notdir $(patsubst %.o,%,$(b))).*)), \ - $($(a)_DIR) \ + $(call find_source_file, $(b), $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR) ),\ + $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR), \ + $($(a)_DEF), \ )) \ ) \ ) @@ -103,15 +102,14 @@ $(foreach a, $(ALGORITHMS), \ $(foreach a, $(ALGORITHMS), \ $(foreach b, $($(a)_TEST_BIN), \ $(eval $(call TargetSource_Template, \ - $(BIN_DIR)$(call lc, $(a))/$(TEST_DIR)$(b), \ - $(if $(call sne,$(strip $(filter %.S %.c, $(wildcard $(TESTSRC_DIR)$(notdir $(patsubst %.o,%,$(b))).*))),), \ - $(filter %.S %.c, $(wildcard $(TESTSRC_DIR)$(notdir $(patsubst %.o,%,$(b))).*)), \ - $(filter %.S %.c, $(wildcard ./$(notdir $(patsubst %.o,%,$(b))).*))\ - ), \ - $($(a)_DIR) \ + $(BIN_DIR)$(call lc, $(a))/$(TEST_DIR)$(b), \ + $(call find_source_file, $(b), $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR) ),\ + $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR), \ + $($(a)_DEF) \ )) \ ) \ ) + #------------------------------------------------------------------------------- define MainTestElf_Template @@ -138,7 +136,7 @@ all: $(foreach algo, $(ALGORITHMS), $($(algo)_BINOBJ)) #------------------------------------------------------------------------------- define TestBin_TEMPLATE -$(1)_TEST_BIN: $(2) +$(1)_TESTBIN: $(2) endef $(foreach algo, $(ALGORITHMS), $(eval $(call TestBin_TEMPLATE, \ @@ -230,6 +228,9 @@ $(foreach algo, $(ALGORITHMS), \ ))\ ) +.PHONY: all +all: cores + .PHONY: cores cores: $(foreach algo, $(ALGORITHMS), $(algo)_OBJ) @@ -300,7 +301,7 @@ info: @echo " docu - build doxygen documentation" @echo " clean - remove a lot of builded files" @echo " depclean - also remove dependency files" - @echo " *_TEST_BIN - build test program" + @echo " *_TESTBIN - build test program" @echo " *_TESTRUN - run nessie test" @echo " *_OBJ - build algorithm core" @echo " *_FLASH - flash test program"