]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - Makefile
backporting uart_i and cli
[avr-crypto-lib.git] / Makefile
index 359e592f636474b632aa4e0ffd111e359c5ab988..7afbe74b8c47f36e106884ae7a15f761797877cb 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,21 @@
-# Makefile for the micro-crypt project
+# Makefile for the AVR-Crypto-Lib project
 # author: Daniel Otte
+SHELL = sh
 
 BLOCK_CIPHERS  := 
 STREAM_CIPHERS := 
 HASHES         :=
 MACS           :=
 PRNGS          := 
+ENCODINGS      :=
+AUX            :=
 
 # we use the gnu make standard library
 include gmsl
 include avr-makefile.inc
 include mkfiles/*.mk
 
-ALGORITHMS = $(BLOCK_CIPHERS) $(STREAM_CIPHERS) $(HASHES) $(PRNGS) $(MACS)
+ALGORITHMS = $(BLOCK_CIPHERS) $(STREAM_CIPHERS) $(HASHES) $(PRNGS) $(MACS) $(ENCODINGS) $(AUX)
 ALGORITHMS_OBJ = $(patsubst %,%_OBJ, $(ALGORITHMS))
 ALGORITHMS_TEST_BIN = $(patsubst %,%_TEST_BIN, $(ALGORITHMS))
 
@@ -43,7 +46,7 @@ all: $(foreach algo, $(ALGORITHMS), $(algo)_OBJ)
 
 define MAIN_OBJ_TEMPLATE
 $(2): $(3) $(4)
-       @echo "[ld]: $$@"
+       @echo "[ld] : $$@"
 #      echo $$^
        @$(CC) $(CFLAGS) $(LDFLAGS)$(patsubst %.elf,%.map,$(2)) -o \
        $(2) \
@@ -65,7 +68,7 @@ $(foreach algo, $(ALGORITHMS), $(eval $(call MAIN_OBJ_TEMPLATE, \
 help: info
 
 info:
-       @echo "infos on micro-crypt:"
+       @echo "infos on AVR-Crypto-lib:"
        @echo "  block ciphers:"
        @echo "    $(BLOCK_CIPHERS)"
        @echo "  stream ciphers:"
@@ -76,14 +79,41 @@ info:
        @echo "    $(MACS)"
        @echo "  PRNG functions:"
        @echo "    $(PRNGS)"
+       @echo "  encodings:"
+       @echo "    $(ENCODINGS)"
 #      @echo "  ALGORITHMS_TEST_BIN:"
 #      @echo "    $(ALGORITHMS_TEST_BIN)"
 #      @echo "  ALGORITHMS_TEST_TARGET_ELF:"
 #      @echo "    $(ALGORITHMS_TEST_TARGET_ELF)"
+       @echo " targets:"
+       @echo "  all           - all algorithm cores"
+       @echo "  cores         - all algorithm cores"
+       @echo "  listings      - all algorithm core listings"
+       @echo "  tests         - all algorithm test programs"
+       @echo "  stats         - all algorithm size statistics"
+       @echo "  blockciphers  - all blockcipher cores"
+       @echo "  streamciphers - all streamcipher cores"
+       @echo "  hashes        - all hash cores"
+       @echo "  macs          - all MAC cores"
+       @echo "  prngs         - all PRNG cores"
+       @echo "  all_testrun   - testrun all algorithms"
+       @echo "  docu          - build doxygen documentation"
+       @echo "  clean         - remove a lot of builded files"
+       @echo "  xclean        - also remove dependency files"
+       @echo "  *_TEST_BIN    - build test program"
+       @echo "  *_TESTRUN     - run nessie test"
+       @echo "  *_OBJ         - build algorithm core"
+       @echo "  *_FLASH       - flash test program"
+       @echo "  *_LIST        - build assembler listing"
 
 #-------------------------------------------------------------------------------
        
+define SOURCEFILE_TEMPLATE
+$(BIN_DIR)$(1): $(2)/$(3).c
+       $(CC) $(CFLAGS) -c -o $@ $<
+endef
 
+#-------------------------------------------------------------------------------
 $(BIN_DIR)%.o: %.c
        @echo "[gcc]:  $@"
        @$(CC) $(CFLAGS)  -c -o $@ $<
@@ -100,6 +130,15 @@ $(TESTBIN_DIR)%.o: $(TESTSRC_DIR)%.S
        @echo "[as] :  $@"
        @$(CC) $(ASFLAGS) -c -o $@ $<
 
+$(TESTBIN_DIR)%.o: %.c
+       @echo "[gcc]:  $@"
+       @$(CC) $(CFLAGS)  -c -o $@ $<
+
+$(TESTBIN_DIR)%.o: %.S
+       @echo "[as] :  $@"
+       @$(CC) $(ASFLAGS) -c -o $@ $<
+
+
 
 %.o: %.c
        @echo "[gcc]:  $@"
@@ -135,6 +174,7 @@ $(STREAM_CIPHERS_OBJ): $(patsubst %,%_OBJ, $(STREAM_CIPHERS))
 $(HASHES_OBJ): $(patsubst %,%_OBJ, $(HASHES))
 $(PRNGS_OBJ): $(patsubst %,%_OBJ, $(PRNGS))
 $(MACS_OBJ): $(patsubst %,%_OBJ, $(MACS))
+$(ENCODINGS_OBJ): $(patsubst %,%_OBJ, $(ENCODINGS))
 
 #-------------------------------------------------------------------------------
 
@@ -161,12 +201,26 @@ $(foreach algo, $(ALGORITHMS),$(eval $(call FLASH_TEMPLATE, $(algo), $(TESTBIN_D
 define TESTRUN_TEMPLATE
 $(1)_TESTRUN: $(1)_FLASH
        @echo "[test]: $(1)"
-       $(RUBY) get_test.rb  $(TESTPORT) $(TESTPORTBAUDR) 8 1 nessie $(TESTLOG_DIR)$(TESTPREFIX) $(2)
+       $(RUBY) $(GET_TEST)  $(TESTPORT) $(TESTPORTBAUDR) 8 1 nessie $(TESTLOG_DIR)$(TESTPREFIX) $(2)
 endef
 
 $(foreach algo, $(ALGORITHMS),$(eval $(call TESTRUN_TEMPLATE, $(algo), $(call lc,$(algo)) )))
 
-ALL_TESTRUN: $(foreach algo, $(ALGORITHMS), $(algo)_TESTRUN)
+all_testrun: $(foreach algo, $(ALGORITHMS), $(algo)_TESTRUN)
+
+#-------------------------------------------------------------------------------
+
+define TESTSPEED_TEMPLATE
+$(1)_TESTSPEED: $(1)_FLASH
+       @echo "[speed]: $(1)"
+       $(RUBY) $(GET_PERFORMANCE)  $(TESTPORT) $(TESTPORTBAUDR) 8 1 performance $(SPEEDLOG_DIR)$(SPEEDPREFIX) $(2)
+endef
+
+$(foreach algo, $(ALGORITHMS),$(eval $(call TESTSPEED_TEMPLATE, $(algo), $(call lc,$(algo)) )))
+
+all_testspeed: $(foreach algo, $(ALGORITHMS), $(algo)_TESTSPEED)
+hash_testspeed: $(foreach algo, $(HASHES), $(algo)_TESTSPEED)
+
 
 #-------------------------------------------------------------------------------
 
@@ -212,6 +266,9 @@ macs: $(patsubst %, %_OBJ, $(MACS))
 .PHONY:  prngs
 prngs: $(patsubst %, %_OBJ, $(PRNGS))
 
+.PHONY:  encodings
+encodings: $(patsubst %, %_OBJ, $(ENCODINGS))
+
 tests: $(ALGORITHMS_TEST_BIN) \
        $(ALGORITHMS_TEST_TARGET_ELF) \
        $(ALGORITHMS_TEST_TARGET_HEX)
@@ -231,11 +288,25 @@ clean:
        rm -rf $(BIN_DIR)*.o *.o $(TESTBIN_DIR)*.elf $(TESTBIN_DIR)* *.elf *.eps *.png *.pdf *.bak
        rm -rf *.lst *.map $(EXTRA_CLEAN_FILES) $(STAT_DIR)$(SIZESTAT_FILE) $(STAT_DIR)*_size.txt
 xclean: clean
-       rm -rf $(DEP_DIR)*.d
+       rm -rf $(DEP_DIR)*.d $(AUTOASM_DIR)*.s
 
 docu:
        doxygen
 
+make.dump: Makefile
+       $(MAKE) -p -B -n -f $^ > $@
+
+make.dot: make.dump
+       $(MAKE2GRAPH) $^ > $@
+
+make.png: make.dot
+       $(TWOPI) -Tpng -o $@ $^
+
+make.svg: make.dot
+       $(TWOPI) -Tsvg -o $@ $^
+
+.PHONY: make-info
+make-info: make.png make.svg
 
 
 # Rules for building the .text rom images
@@ -267,10 +338,14 @@ docu:
        @echo "[objcopy]: $@"
        @$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
        
-       
-# Every thing below here is used by avr-libc's build system and can be ignored
-# by the casual user.
+#-------------------------------------------------------------------------------
+$(AUTOASM_DIR)%.s: %.c
+       $(CC) $(CFLAGS) $(AUTOASM_OPT) -o $@ $<
+
+%.s: %.c
+       $(CC) $(CFLAGS) $(AUTOASM_OPT) -o $@ $<
 
+#-------------------------------------------------------------------------------
 FIG2DEV                 = fig2dev
 EXTRA_CLEAN_FILES       = *.hex *.bin *.srec