]> git.cryptolib.org Git - arm-crypto-lib.git/commitdiff
new make system
authorbg <daniel.otte@rub.de>
Tue, 18 Sep 2012 18:03:01 +0000 (20:03 +0200)
committerbg <daniel.otte@rub.de>
Tue, 18 Sep 2012 18:03:01 +0000 (20:03 +0200)
Makefile [deleted file]
Makefile_arm7tdmi [new file with mode: 0644]
Makefile_arm7tdmi_conf.inc [new file with mode: 0644]
Makefile_cortexm3 [new file with mode: 0644]
Makefile_cortexm3_conf.inc [new file with mode: 0644]
Makefile_m644 [new file with mode: 0644]
Makefile_m644_conf.inc [new file with mode: 0644]
Makefile_main.inc [new file with mode: 0644]
Makefile_sys_conf.inc [new file with mode: 0644]
Makefile_sys_conf.inc.ref [new file with mode: 0644]

diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index 9570d5c..0000000
--- a/Makefile
+++ /dev/null
@@ -1,403 +0,0 @@
-# Makefile for the ARM-Crypto-Lib project
-#
-#    This file is part of the ARM-Crypto-Lib.
-#    Copyright (C) 2010 Daniel Otte (daniel.otte@rub.de)
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-SHELL = sh
-
-BLOCK_CIPHERS  :=
-STREAM_CIPHERS :=
-HASHES         :=
-MACS           :=
-PRNGS          :=
-ENCODINGS      :=
-SIGNATURE      :=
-PK_CIPHERS     :=
-AUX            :=
-LIB_ALGOS      :=
-
-# we use the gnu make standard library
-include gmsl
-include arm-makefile.inc
-
-
-GLOBAL_INCDIR := ./ $(TESTSRC_DIR)
-
-#-------------------------------------------------------------------------------
-# inclusion of make stubs
-
-include $(sort $(wildcard mkfiles/*.mk))
-
-define Assert_Template
-$(1) = $(2)
-endef
-
-define Add_Template
-$(1) += $(2)
-endef
-
-#-------------------------------------------------------------------------------
-ALGORITHMS = $(BLOCK_CIPHERS) $(STREAM_CIPHERS) $(HASHES) $(PRNGS) $(MACS) \
-                        $(ENCODINGS) $(SIGNATURE) $(PK_CIPHERS) $(AUX)
-ALGORITHMS_OBJ = $(patsubst %,%_OBJ, $(ALGORITHMS))
-ALGORITHMS_TESTBIN = $(patsubst %,%_TESTBIN, $(ALGORITHMS))
-
-LIB_OBJECTS := 
-LIB_SRCDIRS := 
-LIB_DEFINES :=
-
-$(foreach a, $(LIB_ALGOS), $(eval $(call Add_Template, \
-  LIB_OBJECTS, \
-  $($(a)_OBJ)  \
-)))
-LIB_OBJECTS := $(addprefix $(BIN_DIR)$(LIB_DIR), $(sort $(LIB_OBJECTS)))
-
-$(foreach a, $(LIB_ALGOS), $(eval $(call Add_Template, \
-  LIB_SRCDIRS, \
-  $($(a)_DIR)  \
-)))
-
-$(foreach a, $(LIB_ALGOS), $(eval $(call Add_Template, \
-  LIB_SRCDIRS, \
-  $($(a)_INCDIR)  \
-)))
-LIB_SRCDIRS := $(sort $(LIB_SRCDIRS)) 
-
-$(foreach a, $(LIB_ALGOS), $(eval $(call Add_Template, \
-  LIB_DEFINES, \
-  $($(a)_DEF)  \
-)))
-LIB_DEFINES := $(sort $(LIB_DEFINES)) 
-
-
-#-------------------------------------------------------------------------------
-# define binary object in $(BIN_DIR)$(ALGO)/<obj>
-$(foreach a, $(ALGORITHMS), $(eval $(call Assert_Template, \
-    $(a)_BINOBJ, \
-    $(addprefix $(BIN_DIR)$(call lc,$(a))/,$($(a)_OBJ)) \
-)))
-
-$(foreach a, $(ALGORITHMS), $(eval $(call Assert_Template, \
-    $(a)_TESTBINOBJ, \
-    $(addprefix $(BIN_DIR)$(call lc,$(a))/$(TEST_DIR),$($(a)_TESTBIN)) \
-)))
-
-
-
-#-------------------------------------------------------------------------------
-
-define TargetSource_Template
-$(1): $(2)
-       @echo "[cc]: $(1) <-- $(2)"
-       @mkdir -p $(dir $(1))
-       @$(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), \
-      $(call find_source_file, $(b), $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR) ),\
-      $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR), \
-      $($(a)_DEF) \
-    )) \
-  ) \
-)
-
-$(foreach a, $(ALGORITHMS), \
-  $(foreach b, $($(a)_TESTBIN), \
-    $(eval $(call TargetSource_Template, \
-      $(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) \
-    )) \
-  ) \
-)
-
-$(foreach a, $(LIB_OBJECTS), \
-  $(eval $(call TargetSource_Template, \
-    $(a), \
-    $(call find_source_file, $(notdir $(a)), $(LIB_SRCDIRS) ),\
-    $(LIB_SRCDIRS) $(GLOBAL_INCDIR), \
-    $(LIB_DEFINES) \
-    ) \
-  ) \
-)
-
-#-------------------------------------------------------------------------------
-
-define MainTestElf_Template
-$(1): $(2) $(3)
-       @echo "[ld]: $(1)"
-       @mkdir -p $(dir $(1))
-       @$(CC) $(CFLAGS_A) $(LDFLAGS)$(patsubst %.elf,%.map,$(1)) -o \
-       $(1) \
-       $(2) $(3) \
-       $(addprefix -l, $(LIBS))
-endef
-
-$(foreach a, $(ALGORITHMS), \
-    $(eval $(call MainTestElf_Template,  \
-        $(BIN_DIR)$(call lc, $(a))/$(TEST_DIR)main-$(call lc, $(a))-test.elf, \
-        $($(a)_BINOBJ), \
-        $($(a)_TESTBINOBJ) \
-       )) \
-)
-
-#-------------------------------------------------------------------------------
-
-all: $(foreach algo, $(ALGORITHMS), $($(algo)_BINOBJ))
-
-#-------------------------------------------------------------------------------
-
-define TestBin_TEMPLATE
-$(1)_TESTBIN: $(2)
-endef
-
-$(foreach algo, $(ALGORITHMS), $(eval $(call TestBin_TEMPLATE, \
-    $(algo), \
-    $(BIN_DIR)$(call lc, $(algo))/$(TEST_DIR)main-$(call lc, $(algo))-test.elf \
-)))
-
-#-------------------------------------------------------------------------------
-
-%.bin: %.elf
-       @echo "[objcopy]: $@"
-       @$(OBJCOPY) -O binary $< $@
-       
-%.hex: %.elf
-       @echo "[objcopy]: $@"
-       @$(OBJCOPY) -j .text -j .data -O ihex $< $@
-
-#-------------------------------------------------------------------------------
-
-define Flash_Template
-$(1)_FLASH: $(2)
-       @echo "[flash]: $(2)"
-       @$(call FLASHCMD, $(call first,$(2)))
-endef
-
-$(foreach algo, $(ALGORITHMS), $(eval $(call Flash_Template, \
-    $(algo), \
-    $(BIN_DIR)$(call lc, $(algo))/$(TEST_DIR)main-$(call lc, $(algo))-test.bin \
-)))
-
-#-------------------------------------------------------------------------------
-
-define Speed_Template
-$(1)_SPEED:  $(1)_FLASH
-       @$(RUBY) $(SPEEDTOOL) -c $(SPEEDCMD) -t $(SPEEDLOG_DIR) -a $(call lc, $(1))
-endef
-
-$(foreach algo, $(ALGORITHMS), $(eval $(call Speed_Template, \
-    $(algo), $(algo) \
-)))
-
-.PHONY: hash_speed
-hash_speed: $(foreach algo, $(HASHES), $(algo)_SPEED)
-
-.PHONY: blockcipher_speed
-blockcipher_speed: $(foreach algo, $(BLOCK_CIPHERS), $(algo)_SPEED)
-#-------------------------------------------------------------------------------
-
-
-define Size_Template
-$(1)_SIZE:  $(2)
-       @echo "[size] $(1)"
-       $(SIZE) $(2) > $(strip $(SIZE_DIR))$(strip $(call lc, $(1))).size
-endef
-
-$(foreach algo, $(ALGORITHMS), $(eval $(call Size_Template, \
-    $(strip $(algo)), $($(algo)_BINOBJ) \
-)))
-
-.PHONY: hash_size
-hash_size: $(foreach algo, $(HASHES), $(algo)_SIZE)
-
-.PHONY: blockcipher_size
-blockcipher_size: $(foreach algo, $(BLOCK_CIPHERS), $(algo)_SIZE)
-
-#-------------------------------------------------------------------------------
-
-.PHONY: tests
-tests: $(foreach a, $(ALGORITHMS), $(a)_TESTBIN)
-
-#-------------------------------------------------------------------------------
-
-define TestRun_Template
-$(1)_TESTRUN: $(1)_FLASH
-       @echo "[test]: $(1)"
-       $(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)
-
-#-------------------------------------------------------------------------------
-
-define Obj_Template
-$(1)_OBJ: $(2)
-endef
-
-$(foreach algo, $(ALGORITHMS), \
-    $(eval $(call Obj_Template, \
-        $(algo), \
-        $($(algo)_BINOBJ)\
-       ))\
-)
-
-.PHONY: cores
-cores: $(foreach algo, $(ALGORITHMS), $(algo)_OBJ)
-
-.PHONY: blockchiphers
-blockciphers: $(foreach algo, $(BLOCK_CIPHERS), $(algo)_OBJ)
-
-.PHONY: streamchiphers
-streamciphers: $(foreach algo, $(STREAM_CIPHERS), $(algo)_OBJ)
-
-.PHONY: hashes
-hashes: $(foreach algo, $(HASHES), $(algo)_OBJ)
-
-.PHONY: macs
-macs: $(foreach algo, $(MACS), $(algo)_OBJ)
-
-.PHONY: prngs
-prngs: $(foreach algo, $(PRNGS), $(algo)_OBJ)
-
-.PHONY: encodings
-encodings: $(foreach algo, $(ENCODINGS), $(algo)_OBJ)
-
-.PHONY: aux
-aux: $(foreach algo, $(AUX), $(algo)_OBJ)
-
-
-
-
-.PHONY: lib_info
-lib_info:
-       @echo "LIB_ALGOS ="
-       @echo  $(foreach a, $(LIB_ALGOS), '\t$(a)\n')
-       @echo "LIB_OBJECTS ="
-       @echo  $(foreach a, $(LIB_OBJECTS), '\t$(a)\n')
-       @echo "LIB_SRCDIRS ="
-       @echo  $(foreach a, $(LIB_SRCDIRS), '\t$(a)\n')
-
-$(BIN_DIR)$(LIB_DIR)$(LIB_NAME): $(LIB_OBJECTS)
-       @echo "[rm]:  old $@"
-       @$(RM) -f $@
-       @echo "[chmod]: <objects>"
-       @$(CHMOD) 644 $^
-#      $(CHGRP) root $^
-#      $(CHOWN) root $^
-       @echo "[ar]:  $@ <-- <objects>"
-       @$(AR) qc $@ $^
-
-.PHONY: lib
-lib: $(BIN_DIR)$(LIB_DIR)$(LIB_NAME)
-
-
-#-------------------------------------------------------------------------------
-
-
-.PHONY: help
-help: info
-.PHONY: info
-info:
-       @echo "infos on ARM-Crypto-lib:"
-       @echo "  block ciphers:"
-       @echo "    $(BLOCK_CIPHERS)"
-       @echo "  stream ciphers:"
-       @echo "    $(STREAM_CIPHERS)"
-       @echo "  hash functions:"
-       @echo "    $(HASHES)"
-       @echo "  MAC functions:"
-       @echo "    $(MACS)"
-       @echo "  PRNG functions:"
-       @echo "    $(PRNGS)"
-       @echo "  signature functions:"
-       @echo "    $(SIGNATURE)"
-       @echo "  public key ciphers:"
-       @echo "    $(PK_CIPHERS)"
-       @echo "  encodings:"
-       @echo "    $(ENCODINGS)"
-       @echo "  auxiliary functions:"
-       @echo "    $(AUX)"
-       @echo " targets:"
-       @echo "  all                - all algorithm cores"
-       @echo "  cores              - all algorithm cores"
-       @echo "  lib                - make library archive"
-       @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 "  hash_size          - measure size of all hash functions"
-       @echo "  hash_speed         - measure performance of all hash functions"
-       @echo "  blockcipher_size   - measure size of all blockciphers"
-       @echo "  blockcipher_speed  - measure performance of all blockciphers"
-       @echo "  docu               - build doxygen documentation"
-       @echo "  clean              - remove a lot of builded files"
-       @echo "  depclean           - also remove dependency files"
-       @echo "  *_TESTBIN          - build test program"
-       @echo "  *_TESTRUN          - run nessie test"
-       @echo "  *_OBJ              - build algorithm core"
-       @echo "  *_FLASH            - flash test program"
-       @echo "  *_LIST             - build assembler listing"
-
-
-#-------------------------------------------------------------------------------
-
-.PHONY: clean
-clean:
-       @echo "[rm]:  $(BIN_DIR)*"
-       @$(RM) -rf $(BIN_DIR)*
-
-.PHONY: depclean
-depclean: clean
-       @echo "[rm]:  $(DEP_DIR)*.d"
-       @$(RM) -f $(DEP_DIR)*.d
-
-#-------------------------------------------------------------------------------
-# dependency inclusion
-#
-
-DEPS := $(wildcard $(DEP_DIR)*.d)
-
-ifneq ($(DEPS),)
-include $(DEPS)
-endif
-
diff --git a/Makefile_arm7tdmi b/Makefile_arm7tdmi
new file mode 100644 (file)
index 0000000..3ec7855
--- /dev/null
@@ -0,0 +1,25 @@
+# Makefile for the ARM-Crypto-Lib project
+#
+#    This file is part of the AVR-Crypto-Lib.
+#    Copyright (C) 2010 Daniel Otte (daniel.otte@rub.de)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+SHELL = sh
+
+include Makefile_sys_conf.inc
+include Makefile_arm7tdmi_conf.inc
+include Makefile_main.inc
+
+
diff --git a/Makefile_arm7tdmi_conf.inc b/Makefile_arm7tdmi_conf.inc
new file mode 100644 (file)
index 0000000..e4bdaa4
--- /dev/null
@@ -0,0 +1,22 @@
+BOARD          = arm7tdmi_generic
+MCU_TARGET     = arm7tdmi 
+MCU_OPTS       = -marm -mthumb-interwork
+OPTIMIZE       = -Os
+FLASHCMD       = $(OPENOCD) -f openocd.cfg \
+                    -c "init" \
+                    -c "halt" \
+                    -c "flash write_image erase $(1) 0 bin" \
+                    -c "reset run" \
+                    -c "shutdown"
+
+override CFLAGS_A      = $(COMMON_FLAGS) \
+                      -MF$(DEP_DIR)$(patsubst %.o,%.d,$(notdir $(1))) 
+override CFLAGS        = $(COMMON_FLAGS) \
+                      -MF$(DEP_DIR)$(patsubst %.o,%.d,$(notdir $@))
+                      
+override LDFLAGS       =  -g -Wl,--gc-sections \
+                         -Wl,--entry=reset_isr  \
+                         -Wl,-Map,# no space at the end
+                          
+override ASFLAGS          =  -mcpu=$(MCU_TARGET) 
+
diff --git a/Makefile_cortexm3 b/Makefile_cortexm3
new file mode 100644 (file)
index 0000000..1357e80
--- /dev/null
@@ -0,0 +1,25 @@
+# Makefile for the ARM-Crypto-Lib project
+#
+#    This file is part of the AVR-Crypto-Lib.
+#    Copyright (C) 2010 Daniel Otte (daniel.otte@rub.de)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+SHELL = sh
+
+include Makefile_sys_conf.inc
+include Makefile_cortexm3_conf.inc
+include Makefile_main.inc
+
+
diff --git a/Makefile_cortexm3_conf.inc b/Makefile_cortexm3_conf.inc
new file mode 100644 (file)
index 0000000..491b7ed
--- /dev/null
@@ -0,0 +1,22 @@
+BOARD          = lm3s9b90_cm3
+MCU_TARGET     = cortex-m3  
+MCU_OPTS       = -mthumb 
+OPTIMIZE       = -Os -fomit-frame-pointer  
+FLASHCMD       = $(OPENOCD) -f openocd.cfg \
+                    -c "init" \
+                    -c "halt" \
+                    -c "flash write_image erase $(1) 0 bin" \
+                    -c "reset run" \
+                    -c "shutdown"
+
+override CFLAGS_A      = $(COMMON_FLAGS) \
+                      -MF$(DEP_DIR)$(patsubst %.o,%.d,$(notdir $(1))) 
+override CFLAGS        = $(COMMON_FLAGS) \
+                      -MF$(DEP_DIR)$(patsubst %.o,%.d,$(notdir $@))
+                      
+override LDFLAGS       = -g -T lm3s9b90.ld -Wl,--gc-sections    \
+                         -Wl,--entry=reset_isr  \
+                         -Wl,-Map,# no space at the end
+                          
+override ASFLAGS          =  -mcpu=$(MCU_TARGET) 
+
diff --git a/Makefile_m644 b/Makefile_m644
new file mode 100644 (file)
index 0000000..4912740
--- /dev/null
@@ -0,0 +1,25 @@
+# Makefile for the AVR-Crypto-Lib project
+#
+#    This file is part of the AVR-Crypto-Lib.
+#    Copyright (C) 2010 Daniel Otte (daniel.otte@rub.de)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+SHELL = sh
+
+include Makefile_sys_conf.inc
+include Makefile_m644_conf.inc
+include Makefile_main.inc
+
+
diff --git a/Makefile_m644_conf.inc b/Makefile_m644_conf.inc
new file mode 100644 (file)
index 0000000..8d698e3
--- /dev/null
@@ -0,0 +1,20 @@
+
+MCU_TARGET     = atmega644
+F_CPU          = 20000000
+OPTIMIZE       = -Os # -Os
+EXTRALINK      = 
+DEFS           = -D$(call uc, $(MCU_TARGET)) -DF_CPU=$(F_CPU)
+BOARD_NAME     = pollin_eval_m644
+
+override CFLAGS_A      = -MMD -MF$(DEP_DIR)$(patsubst %.o,%.d,$(notdir $(1))) $(DEBUG) $(WARNING) -std=$(CSTD) $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
+override CFLAGS        = -MMD -MF$(DEP_DIR)$(patsubst %.o,%.d,$(notdir $@))   $(DEBUG) $(WARNING) -std=$(CSTD) $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
+
+override LDFLAGS       = -gdwarf-2 -Wl,-Map,
+override ASFLAGS          = -mmcu=$(MCU_TARGET) -Wa,--gdwarf-2
+
+PROGRAMMER     = avr911
+PROG_PORT      = /dev/ttyUSB1
+DEFS           = -D$(call uc, $(MCU_TARGET)) -DF_CPU=$(F_CPU)
+FLASHCMD       = avrdude -p $(MCU_TARGET) -P $(PROG_PORT) -c $(PROGRAMMER) -U flash:w:# no space at the end
+#FLASHCMD       = avrdude -p $(MCU_TARGET) -c usbasp -U flash:w:# no space at the end
+RESETCMD       = avrdude -p $(MCU_TARGET) -P $(PROG_PORT) -c $(PROGRAMMER)
diff --git a/Makefile_main.inc b/Makefile_main.inc
new file mode 100644 (file)
index 0000000..d884642
--- /dev/null
@@ -0,0 +1,467 @@
+# vim:set ft=make
+# Makefile for the AVR-Crypto-Lib project
+#
+#    This file is part of the AVR-Crypto-Lib.
+#    Copyright (C) 2010 Daniel Otte (daniel.otte@rub.de)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+BLOCK_CIPHERS  :=
+STREAM_CIPHERS :=
+HASHES         :=
+MACS           :=
+PRNGS          :=
+ENCODINGS      :=
+SIGNATURE      :=
+PK_CIPHERS     :=
+AUX            :=
+
+LIB_ALGOS      :=
+
+# we use the gnu make standard library
+include gmsl
+
+GLOBAL_INCDIR := ./ $(TESTSRC_DIR)
+
+#-------------------------------------------------------------------------------
+# inclusion of make stubs
+include $(sort $(wildcard mkfiles/*.mk))
+
+#-------------------------------------------------------------------------------
+# define binary object in $(BIN_DIR)$(ALGO)/<obj>
+define Assert_Template
+$(1) = $(2)
+endef
+
+define Add_Template
+$(1) += $(2)
+endef
+
+#-------------------------------------------------------------------------------
+ALGORITHMS = $(BLOCK_CIPHERS) $(STREAM_CIPHERS) $(HASHES) $(PRNGS) $(MACS) \
+                        $(ENCODINGS) $(SIGNATURE) $(PK_CIPHERS) $(AUX)
+ALGORITHMS_OBJ = $(patsubst %,%_OBJ, $(ALGORITHMS))
+ALGORITHMS_TESTBIN = $(patsubst %,%_TESTBIN, $(ALGORITHMS))
+
+LIB_OBJECTS := 
+LIB_SRCDIRS := 
+LIB_DEFINES :=
+
+$(foreach a, $(LIB_ALGOS), $(eval $(call Add_Template, \
+  LIB_OBJECTS, \
+  $($(a)_OBJ)  \
+)))
+LIB_OBJECTS := $(addprefix $(BIN_DIR)$(LIB_DIR), $(sort $(LIB_OBJECTS)))
+
+$(foreach a, $(LIB_ALGOS), $(eval $(call Add_Template, \
+  LIB_SRCDIRS, \
+  $($(a)_DIR)  \
+)))
+
+$(foreach a, $(LIB_ALGOS), $(eval $(call Add_Template, \
+  LIB_SRCDIRS, \
+  $($(a)_INCDIR)  \
+)))
+LIB_SRCDIRS := $(sort $(LIB_SRCDIRS)) 
+
+$(foreach a, $(LIB_ALGOS), $(eval $(call Add_Template, \
+  LIB_DEFINES, \
+  $($(a)_DEF)  \
+)))
+LIB_DEFINES := $(sort $(LIB_DEFINES)) 
+
+
+#-------------------------------------------------------------------------------
+# define binary object in $(BIN_DIR)$(ALGO)/<obj>
+$(foreach a, $(ALGORITHMS), $(eval $(call Assert_Template, \
+    $(a)_BINOBJ, \
+    $(addprefix $(BIN_DIR)$(call lc,$(a))/,$($(a)_OBJ)) \
+)))
+
+$(foreach a, $(ALGORITHMS), $(eval $(call Assert_Template, \
+    $(a)_TESTBINOBJ, \
+    $(addprefix $(BIN_DIR)$(call lc,$(a))/$(TEST_DIR),$($(a)_TESTBIN)) \
+)))
+
+
+
+#-------------------------------------------------------------------------------
+
+define TargetSource_Template
+$(1): $(2)
+       @mkdir -p  $(dir $(1)) $(DEP_DIR)
+       @echo "[cc]: $(1) <-- $(2)"
+       @$(CC) $(CFLAGS_A) $(addprefix -I./,$(3)) $(addprefix -D, $(4)) -c -o $(1) $(2)
+endef
+
+
+
+define TargetSourceList_Template
+$(1): $(2)
+       @mkdir -p $(dir $(1)) $(DEP_DIR)
+       @echo "[cc]: $(1) <-- $(2)"
+       @$(CC) $(CFLAGS_A) $(addprefix -I./,$(3)) $(addprefix -D, $(4)) $(LIST_OPT) -c -o /dev/null $(2) > $(1)
+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), \
+      $(call find_source_file, $(b), $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR) ),\
+      $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR), \
+      $($(a)_DEF), \
+    )) \
+  ) \
+)
+
+$(foreach a, $(ALGORITHMS), \
+  $(foreach b, $($(a)_TESTBIN), \
+    $(eval $(call TargetSource_Template, \
+      $(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) \
+    )) \
+  ) \
+)
+
+             
+$(foreach a, $(ALGORITHMS), \
+  $(foreach b, $($(a)_OBJ), \
+    $(eval $(call TargetSourceList_Template, \
+      $(LIST_DIR)$(call lc, $(a))/$(patsubst %.o,%.s,$(b)), \
+      $(call find_source_file, $(b), $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR) ),\
+      $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR), \
+      $($(a)_DEF), \
+    )) \
+  ) \
+)
+
+EXTRALINK_BINOBJ = $(patsubst %, $(BIN_DIR)%, $(EXTRALINK))
+
+$(foreach a, $(EXTRALINK), \
+  $(eval $(call TargetSource_Template, \
+    $(BIN_DIR)$(a), \
+    $(call find_source_file, $(a), $(GLOBAL_INCDIR) ),\
+    $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR), \
+    $($(a)_DEF), \
+  )) \
+)
+
+
+$(foreach a, $(LIB_OBJECTS), \
+  $(eval $(call TargetSource_Template, \
+    $(a), \
+    $(call find_source_file, $(notdir $(a)), $(LIB_SRCDIRS) ),\
+    $(LIB_SRCDIRS) $(GLOBAL_INCDIR), \
+    $(LIB_DEFINES) \
+    ) \
+  ) \
+)
+
+#-------------------------------------------------------------------------------
+
+define MainTestElf_Template
+$(1): $(2) $(3) $(4)
+       @mkdir -p $(dir $(1))
+       @echo "[ld]: $(1)"
+       @$(CC) $(CFLAGS_A) $(LDFLAGS)$(patsubst %.elf,%.map,$(1)) -o \
+       $(1) \
+       $(2) $(3) $(EXTRALINK_BINOBJ)\
+       $(addprefix -l,$(LIBS))
+endef
+
+$(foreach a, $(ALGORITHMS), \
+    $(eval $(call MainTestElf_Template,  \
+        $(BIN_DIR)$(call lc, $(a))/$(TEST_DIR)main-$(call lc, $(a))-test.elf, \
+        $($(a)_BINOBJ), \
+        $($(a)_TESTBINOBJ), \
+        $(EXTRALINK_BINOBJ) \
+       )) \
+)
+
+#-------------------------------------------------------------------------------
+
+all: $(foreach algo, $(ALGORITHMS), $($(algo)_BINOBJ))
+
+#-------------------------------------------------------------------------------
+
+define MakeDir_TEMPLATE
+$(1):
+       @echo [mkdir] $(1)
+       @mkdir -p $(1)
+endef
+
+$(foreach d, DEP_DIR BIN_DIR TESTSRC_DIR TESTLOG_DIR SPEEDLOG_DIR SIZE_DIR LIST_DIR STAT_DIR AUTOASM_DIR, $(eval $(call MakeDir_TEMPLATE, \
+   $($(d)) \
+)))
+
+$(foreach algo, $(ALGORITHMS), $(eval $(call MakeDir__TEMPLATE, \
+   $(BIN_DIR)$(call lc, $(algo))/$(TEST_DIR) \
+)))
+
+define TestBin_TEMPLATE
+$(1)_TESTBIN: $(2)
+endef
+
+$(foreach algo, $(ALGORITHMS), $(eval $(call TestBin_TEMPLATE, \
+    $(algo), \
+    $(BIN_DIR)$(call lc, $(algo))/$(TEST_DIR)main-$(call lc, $(algo))-test.elf \
+)))
+
+#-------------------------------------------------------------------------------
+
+define Listing_TEMPLATE
+$(1)_LIST: $(2)
+endef
+
+$(foreach algo, $(ALGORITHMS), $(eval $(call Listing_TEMPLATE, \
+    $(algo), \
+    $(foreach obj,$($(algo)_OBJ), $(LIST_DIR)$(call lc, $(algo))/$(obj:.o=.s)) \
+)))
+
+#-------------------------------------------------------------------------------
+%.bin: %.elf
+       @echo "[objcopy]: $@"
+       @$(OBJCOPY) -O binary $< $@
+
+%.hex: %.elf
+       @echo "[objcopy]: $@"
+       @$(OBJCOPY) -j .text -j .data -O ihex $< $@
+
+#-------------------------------------------------------------------------------
+
+define Flash_Template
+$(1)_FLASH: $(2)
+       @echo "[flash]: $(2)"
+       @$(call FLASHCMD, $(call first,$(2)))
+endef
+
+$(foreach algo, $(ALGORITHMS), $(eval $(call Flash_Template, \
+    $(algo), \
+    $(BIN_DIR)$(call lc, $(algo))/$(TEST_DIR)main-$(call lc, $(algo))-test.bin \
+)))
+
+#-------------------------------------------------------------------------------
+
+define Speed_Template
+$(1)_SPEED:  $(1)_FLASH
+       @$(RUBY) $(SPEEDTOOL) -c $(SPEEDCMD) -t $(SPEEDLOG_DIR) -a $(call lc, $(1))
+endef
+
+$(foreach algo, $(ALGORITHMS), $(eval $(call Speed_Template, \
+    $(algo), $(algo) \
+)))
+
+.PHONY: hash_speed
+hash_speed: $(foreach algo, $(HASHES), $(algo)_SPEED)
+
+.PHONY: blockcipher_speed
+blockcipher_speed: $(foreach algo, $(BLOCK_CIPHERS), $(algo)_SPEED)
+#-------------------------------------------------------------------------------
+
+
+define Size_Template
+$(1)_SIZE:  $(2)
+       @echo "[size] $(1)"
+       $(SIZE) $(2) > $(strip $(SIZE_DIR))$(strip $(call lc, $(1))).size
+endef
+
+$(foreach algo, $(ALGORITHMS), $(eval $(call Size_Template, \
+    $(strip $(algo)), $($(algo)_BINOBJ) \
+)))
+
+.PHONY: hash_size
+hash_size: $(foreach algo, $(HASHES), $(algo)_SIZE)
+
+.PHONY: blockcipher_size
+blockcipher_size: $(foreach algo, $(BLOCK_CIPHERS), $(algo)_SIZE)
+
+#-------------------------------------------------------------------------------
+
+.PHONY: tests
+tests: $(foreach a, $(ALGORITHMS), $(a)_TESTBIN)
+
+#-------------------------------------------------------------------------------
+
+define TestRun_Template
+$(1)_TESTRUN: $(1)_FLASH
+       @echo "[reset]"
+       @sleep 3
+       @$(RESETCMD)
+       @sleep 1
+       @echo "[test]: $(1)"
+       $(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)
+
+#-------------------------------------------------------------------------------
+
+define Obj_Template
+$(1)_OBJ: $(2)
+endef
+
+$(foreach algo, $(ALGORITHMS), \
+    $(eval $(call Obj_Template, \
+        $(algo), \
+        $($(algo)_BINOBJ)\
+       ))\
+)
+
+.PHONY: all
+all: cores
+
+.PHONY: reset
+reset:
+       $(RESETCMD)
+
+.PHONY: cores
+cores: $(foreach algo, $(ALGORITHMS), $(algo)_OBJ)
+
+.PHONY: blockchiphers
+blockciphers: $(foreach algo, $(BLOCK_CIPHERS), $(algo)_OBJ)
+
+.PHONY: streamchiphers
+streamciphers: $(foreach algo, $(STREAM_CIPHERS), $(algo)_OBJ)
+
+.PHONY: hashes
+hashes: $(foreach algo, $(HASHES), $(algo)_OBJ)
+
+.PHONY: macs
+macs: $(foreach algo, $(MACS), $(algo)_OBJ)
+
+.PHONY: prngs
+prngs: $(foreach algo, $(PRNGS), $(algo)_OBJ)
+
+.PHONY: encodings
+encodings: $(foreach algo, $(ENCODINGS), $(algo)_OBJ)
+
+.PHONY: aux
+aux: $(foreach algo, $(AUX), $(algo)_OBJ)
+
+.PHONY: lib_info
+lib_info:
+       @echo "LIB_ALGOS ="
+       @echo  $(foreach a, $(LIB_ALGOS), '\t$(a)\n')
+       @echo "LIB_OBJECTS ="
+       @echo  $(foreach a, $(LIB_OBJECTS), '\t$(a)\n')
+       @echo "LIB_SRCDIRS ="
+       @echo  $(foreach a, $(LIB_SRCDIRS), '\t$(a)\n')
+
+$(BIN_DIR)$(LIB_DIR)$(LIB_NAME): $(LIB_OBJECTS)
+       @echo "[rm]:  old $@"
+       @$(RM) -f $@
+       @echo "[chmod]: <objects>"
+       @$(CHMOD) 644 $^
+#      $(CHGRP) root $^
+#      $(CHOWN) root $^
+       @echo "[ar]:  $@ <-- <objects>"
+       @$(AR) qc $@ $^
+
+.PHONY: lib
+lib: $(BIN_DIR)$(LIB_DIR)$(LIB_NAME)
+
+#-------------------------------------------------------------------------------
+
+
+.PHONY: help
+help: info
+.PHONY: info
+info:
+       @echo "infos on ARM-Crypto-lib:"
+       @echo "  block ciphers:"
+       @echo "    $(BLOCK_CIPHERS)"
+       @echo "  stream ciphers:"
+       @echo "    $(STREAM_CIPHERS)"
+       @echo "  hash functions:"
+       @echo "    $(HASHES)"
+       @echo "  MAC functions:"
+       @echo "    $(MACS)"
+       @echo "  PRNG functions:"
+       @echo "    $(PRNGS)"
+       @echo "  signature functions:"
+       @echo "    $(SIGNATURE)"
+       @echo "  public key ciphers:"
+       @echo "    $(PK_CIPHERS)"
+       @echo "  encodings:"
+       @echo "    $(ENCODINGS)"
+       @echo "  auxiliary functions:"
+       @echo "    $(AUX)"
+       @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 "  lib                - create library
+       @echo "  all_testrun        - testrun all algorithms"
+       @echo "  hash_size          - measure size of all hash functions"
+       @echo "  hash_speed         - measure performance of all hash functions"
+       @echo "  blockcipher_size   - measure size of all blockciphers"
+       @echo "  blockcipher_speed  - measure performance of all blockciphers"
+       @echo "  docu               - build doxygen documentation"
+       @echo "  clean              - remove a lot of builded files"
+       @echo "  depclean           - also remove dependency files"
+       @echo "  *_TESTBIN          - build test program"
+       @echo "  *_TESTRUN          - run nessie test"
+       @echo "  *_OBJ              - build algorithm core"
+       @echo "  *_FLASH            - flash test program"
+       @echo "  *_LIST             - build assembler listing"
+
+
+#-------------------------------------------------------------------------------
+
+.PHONY: clean
+clean:
+       @echo "[rm]:  $(BIN_DIR)*"
+       rm -rf $(BIN_DIR)*
+
+.PHONY: depclean
+depclean: clean
+       @echo "[rm]:  $(DEP_DIR)*.d"
+       rm -f $(DEP_DIR)*.d
+
+#-------------------------------------------------------------------------------
+# dependency inclusion
+#
+
+DEPS := $(wildcard $(DEP_DIR)*.d)
+
+ifneq ($(DEPS),)
+include $(DEPS)
+endif
+
diff --git a/Makefile_sys_conf.inc b/Makefile_sys_conf.inc
new file mode 100644 (file)
index 0000000..15d8978
--- /dev/null
@@ -0,0 +1,51 @@
+TOOLCHAIN      = arm-elf-#
+DEBUG          = -gdwarf-2
+WARNING        = -pedantic -Wall -Wstrict-prototypes -Werror
+DEFS           = -D$(call uc, $(subst -,_,$(MCU_TARGET)))
+DEP_DIR        = deps/$(BOARD)/#
+TEST_DIR       = test/#
+BIN_DIR        = bin/$(BOARD)/#
+TESTSRC_DIR    = test_src/#
+ERASECMD       =
+TESTPORT       = /dev/ttyUSB2
+TESTPORTBAUDR  = 115200
+TESTLOG_DIR    = testlog/#
+TESTPREFIX     = nessie-#
+SPEEDTOOL      = host/get_performance.rb
+SPEEDLOG_DIR   = speed_log/$(BOARD)/#
+SPEEDPREFIX    =
+SPEEDCMD       = performance
+SIZE_DIR       = size_log/#
+LIST_DIR       = listings/$(BOARD)/#
+STAT_DIR       = stats/#
+AUTOASM_DIR    = autoasm/$(BOARD)/#
+LIB_DIR        = lib/#
+LIB_NAME       = libcrypto.a
+AUTOASM_OPT    = -S
+CSTD           = gnu99
+LIBS           = c gcc
+
+COMMON_FLAGS   =   \
+                  $(DEBUG) $(WARNING) -std=$(CSTD) $(OPTIMIZE) \
+                  -mcpu=$(MCU_TARGET) $(MCU_OPTS) $(DEFS) -MMD
+                 
+                #  -ffunction-sections -fdata-sections          \
+
+SIZESTAT_FILE = sizestats.txt
+
+CC                 = $(TOOLCHAIN)gcc
+OBJCOPY         = $(TOOLCHAIN)objcopy
+OBJDUMP         = $(TOOLCHAIN)objdump
+SIZE            = $(TOOLCHAIN)size
+OPENOCD         = openocd
+READELF         = readelf
+AR              = $(TOOLCHAIN)ar
+CHMOD           = chmod
+CHOWN           = chown
+CHGRP           = chgrp
+RM              = rm
+RUBY            = ruby
+GET_TEST        = host/get_test.rb
+MAKE            = make
+MAKE2GRAPH      = ~/bin/make2graph.rb
+TWOPI           = twopi
diff --git a/Makefile_sys_conf.inc.ref b/Makefile_sys_conf.inc.ref
new file mode 100644 (file)
index 0000000..b617523
--- /dev/null
@@ -0,0 +1,42 @@
+DEBUG          = -gdwarf-2
+WARNING        = -pedantic -Wall -Werror -Wstrict-prototypes
+PROGRAMMER     = jtagmkII
+PROG_PORT      = usb
+FLASHCMD       = avrdude -p $(MCU_TARGET) -P $(PROG_PORT) -c $(PROGRAMMER) -U flash:w:# no space at the end
+#FLASHCMD       = avrdude -p $(MCU_TARGET) -c usbasp -U flash:w:# no space at the end
+#RESETCMD       = avrdude -p $(MCU_TARGET) -P $(PROG_PORT) -c $(PROGRAMMER) 
+RESETCMD       = avarice -2 -R -j usb
+DEP_DIR        = deps/$(BOARD_NAME)/#
+TEST_DIR       = test/#
+BIN_DIR        = bin/$(BOARD_NAME)/#
+TESTSRC_DIR    = test_src/
+#uisp -dprog=bsd -dlpt=/dev/parport1 --upload if=$(PRG).hex
+ERASECMD       =
+TESTPORT       = /dev/ttyUSB0
+TESTPORTBAUDR  = 115200
+TESTLOG_DIR    = testlog/#
+TESTPREFIX     = nessie-
+SPEEDTOOL      = host/get_performance.rb
+SPEEDLOG_DIR   = speed_log/$(BOARD_NAME)/#
+SPEEDPREFIX    =
+SPEEDCMD       = performance
+SIZE_DIR       = size_log/$(BOARD_NAME)/#
+LIST_DIR       = listings/$(BOARD_NAME)/#
+LIST_OPT       = -Wa,-adhln -g
+STAT_DIR       = stats/$(BOARD_NAME)/#
+AUTOASM_DIR    = autoasm/$(BOARD_NAME)/#
+AUTOASM_OPT    = -S
+CC                = avr-gcc
+CSTD           = gnu99
+
+SIZESTAT_FILE = sizestats.txt
+
+OBJCOPY         = avr-objcopy
+OBJDUMP         = avr-objdump
+SIZE            = avr-size
+READELF         = readelf
+RUBY            = ruby
+GET_TEST        = host/get_test.rb
+MAKE            = make
+MAKE2GRAPH      = ~/bin/make2graph.rb
+TWOPI           = twopi