2009-01-29 11:49:40 +00:00
|
|
|
# Makefile for the AVR-Crypto-Lib project
|
2008-04-05 17:57:46 +00:00
|
|
|
# author: Daniel Otte
|
2009-05-14 20:25:38 +00:00
|
|
|
SHELL = sh
|
2007-06-18 04:50:39 +00:00
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
BLOCK_CIPHERS :=
|
|
|
|
STREAM_CIPHERS :=
|
2008-04-06 02:42:32 +00:00
|
|
|
HASHES :=
|
|
|
|
MACS :=
|
2009-08-06 13:31:40 +00:00
|
|
|
PRNGS :=
|
2009-02-25 20:22:32 +00:00
|
|
|
ENCODINGS :=
|
2009-05-14 20:25:38 +00:00
|
|
|
AUX :=
|
2006-07-31 16:04:26 +00:00
|
|
|
|
2008-04-11 17:54:24 +00:00
|
|
|
# we use the gnu make standard library
|
|
|
|
include gmsl
|
2008-04-05 17:57:46 +00:00
|
|
|
include avr-makefile.inc
|
2009-08-06 13:31:40 +00:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# inclusion of make stubs
|
2008-07-03 12:14:14 +00:00
|
|
|
include mkfiles/*.mk
|
2006-07-31 16:04:26 +00:00
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
ALGORITHMS = $(BLOCK_CIPHERS) $(STREAM_CIPHERS) $(HASHES) $(PRNGS) $(MACS) \
|
|
|
|
$(ENCODINGS) $(AUX)
|
2008-04-05 17:57:46 +00:00
|
|
|
ALGORITHMS_OBJ = $(patsubst %,%_OBJ, $(ALGORITHMS))
|
2008-11-25 01:23:22 +00:00
|
|
|
ALGORITHMS_TEST_BIN = $(patsubst %,%_TEST_BIN, $(ALGORITHMS))
|
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# define binary object in $(BIN_DIR)$(ALGO)/<obj>
|
|
|
|
define Assert_Template
|
2008-07-03 12:14:14 +00:00
|
|
|
$(1) = $(2)
|
|
|
|
endef
|
2008-11-25 01:23:22 +00:00
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
$(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)_TEST_BIN)) \
|
|
|
|
)))
|
|
|
|
|
|
|
|
|
|
|
|
#$(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, \
|
|
|
|
# . \
|
|
|
|
# ) \
|
|
|
|
# )) \
|
|
|
|
#)
|
2006-10-08 14:02:29 +00:00
|
|
|
|
2008-04-13 13:51:26 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
2009-08-06 13:31:40 +00:00
|
|
|
#
|
|
|
|
### 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)
|
2008-04-05 17:57:46 +00:00
|
|
|
endef
|
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
$(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) \
|
|
|
|
)) \
|
|
|
|
) \
|
|
|
|
)
|
|
|
|
|
|
|
|
$(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) \
|
|
|
|
)) \
|
|
|
|
) \
|
|
|
|
)
|
2008-04-13 13:51:26 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
2008-08-19 12:18:25 +00:00
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
define MainTestElf_Template
|
|
|
|
$(1): $(2) $(3)
|
|
|
|
@echo "[ld]: $(1)"
|
|
|
|
@$(CC) $(CFLAGS_A) $(LDFLAGS)$(patsubst %.elf,%.map,$(1)) -o \
|
|
|
|
$(1) \
|
|
|
|
$(2) $(3) \
|
|
|
|
$(LIBS)
|
2009-07-29 09:49:57 +00:00
|
|
|
endef
|
2008-07-03 12:14:14 +00:00
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
$(foreach a, $(ALGORITHMS), \
|
|
|
|
$(eval $(call MainTestElf_Template, \
|
|
|
|
$(BIN_DIR)$(call lc, $(a))/$(TEST_DIR)main-$(call lc, $(a))-test.elf, \
|
|
|
|
$($(a)_BINOBJ), \
|
|
|
|
$($(a)_TESTBINOBJ) \
|
|
|
|
)) \
|
|
|
|
)
|
2008-04-08 03:21:13 +00:00
|
|
|
|
2008-08-19 12:18:25 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
2008-04-08 03:21:13 +00:00
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
all: $(foreach algo, $(ALGORITHMS), $($(algo)_BINOBJ))
|
2008-11-25 01:23:22 +00:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
define TestBin_TEMPLATE
|
2008-11-25 01:23:22 +00:00
|
|
|
$(1)_TEST_BIN: $(2)
|
|
|
|
endef
|
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
$(foreach algo, $(ALGORITHMS), $(eval $(call TestBin_TEMPLATE, \
|
|
|
|
$(algo), \
|
|
|
|
$(BIN_DIR)$(call lc, $(algo))/$(TEST_DIR)main-$(call lc, $(algo))-test.elf \
|
|
|
|
)))
|
2008-11-25 01:23:22 +00:00
|
|
|
|
2008-04-13 13:51:26 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
2008-04-08 03:21:13 +00:00
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
%.hex: %.elf
|
|
|
|
@echo "[objcopy]: $@"
|
|
|
|
@$(OBJCOPY) -j .text -j .data -O ihex $< $@
|
2008-04-11 17:54:24 +00:00
|
|
|
|
2008-04-13 13:51:26 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
define Flash_Template
|
2008-04-13 13:51:26 +00:00
|
|
|
$(1)_FLASH: $(2)
|
|
|
|
@echo "[flash]: $(2)"
|
2008-04-14 18:36:02 +00:00
|
|
|
@$(FLASHCMD)$(call first,$(2))
|
2008-04-13 13:51:26 +00:00
|
|
|
endef
|
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
$(foreach algo, $(ALGORITHMS), $(eval $(call Flash_Template, \
|
|
|
|
$(algo), \
|
|
|
|
$(BIN_DIR)$(call lc, $(algo))/$(TEST_DIR)main-$(call lc, $(algo))-test.hex \
|
|
|
|
)))
|
2008-04-11 17:54:24 +00:00
|
|
|
|
2008-04-13 13:51:26 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
2008-04-05 17:57:46 +00:00
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
.PHONY: tests
|
|
|
|
tests: $(foreach a, $(ALGORITHMS), $(a)_TEST_BIN)
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
define TestRun_Template
|
2008-07-18 20:51:00 +00:00
|
|
|
$(1)_TESTRUN: $(1)_FLASH
|
|
|
|
@echo "[test]: $(1)"
|
2009-08-06 13:31:40 +00:00
|
|
|
$(RUBY) $(GET_TEST) $(TESTPORT) $(TESTPORTBAUDR) 8 1 nessie $(TESTLOG_DIR)$(TESTPREFIX) $(2)
|
2008-07-18 20:51:00 +00:00
|
|
|
endef
|
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
$(foreach algo, $(ALGORITHMS),$(eval $(call TestRun_Template, $(algo), $(call lc,$(algo)) )))
|
2008-07-18 20:51:00 +00:00
|
|
|
|
2008-12-19 22:40:58 +00:00
|
|
|
all_testrun: $(foreach algo, $(ALGORITHMS), $(algo)_TESTRUN)
|
2008-07-18 20:51:00 +00:00
|
|
|
|
2009-05-14 20:25:38 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
define Obj_Template
|
|
|
|
$(1)_OBJ: $(2)
|
2009-05-14 20:25:38 +00:00
|
|
|
endef
|
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
$(foreach algo, $(ALGORITHMS), \
|
|
|
|
$(eval $(call Obj_Template, \
|
|
|
|
$(algo), \
|
|
|
|
$($(algo)_BINOBJ)\
|
|
|
|
))\
|
|
|
|
)
|
2009-05-14 20:25:38 +00:00
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
.PHONY: cores
|
|
|
|
cores: $(foreach algo, $(ALGORITHMS), $(algo)_OBJ)
|
2009-05-14 20:25:38 +00:00
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
.PHONY: blockchiphers
|
|
|
|
blockciphers: $(foreach algo, $(BLOCK_CIPHERS), $(algo)_OBJ)
|
2008-07-18 20:51:00 +00:00
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
.PHONY: streamchiphers
|
|
|
|
streamciphers: $(foreach algo, $(STREAM_CIPHERS), $(algo)_OBJ)
|
2008-08-19 12:18:25 +00:00
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
.PHONY: hashes
|
|
|
|
hashes: $(foreach algo, $(HASHES), $(algo)_OBJ)
|
2008-08-19 12:18:25 +00:00
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
.PHONY: macs
|
|
|
|
macs: $(foreach algo, $(MACS), $(algo)_OBJ)
|
2008-08-19 12:18:25 +00:00
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
.PHONY: prngs
|
|
|
|
prngs: $(foreach algo, $(PRNGS), $(algo)_OBJ)
|
2008-08-19 12:18:25 +00:00
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
.PHONY: encodings
|
|
|
|
encodings: $(foreach algo, $(ENCODINGS), $(algo)_OBJ)
|
2008-08-19 12:18:25 +00:00
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
.PHONY: aux
|
|
|
|
aux: $(foreach algo, $(AUX), $(algo)_OBJ)
|
2008-08-19 12:18:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
.PHONY: help
|
|
|
|
help: info
|
|
|
|
.PHONY: info
|
|
|
|
info:
|
|
|
|
@echo "infos on AVR-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 " encodings:"
|
|
|
|
@echo " $(ENCODINGS)"
|
|
|
|
@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 " depclean - 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"
|
2008-08-19 12:18:25 +00:00
|
|
|
|
2008-07-18 20:51:00 +00:00
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
2008-07-18 20:51:00 +00:00
|
|
|
|
2008-04-05 17:57:46 +00:00
|
|
|
.PHONY: clean
|
2006-07-31 16:04:26 +00:00
|
|
|
clean:
|
2009-08-06 13:31:40 +00:00
|
|
|
rm -rf $(BIN_DIR)*
|
2008-08-02 04:38:17 +00:00
|
|
|
|
2009-08-06 13:31:40 +00:00
|
|
|
.PHONY: depclean
|
|
|
|
depclean: clean
|
|
|
|
rm $(DEP_DIR)*.d
|
2006-07-31 16:04:26 +00:00
|
|
|
|
2009-04-29 18:50:37 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
2009-08-06 13:31:40 +00:00
|
|
|
# dependency inclusion
|
|
|
|
#
|
2008-05-26 19:13:21 +00:00
|
|
|
|
2008-07-03 12:14:14 +00:00
|
|
|
DEPS := $(wildcard $(DEP_DIR)*.d)
|
|
|
|
|
2008-05-26 19:13:21 +00:00
|
|
|
ifneq ($(DEPS),)
|
|
|
|
include $(DEPS)
|
|
|
|
endif
|
|
|
|
|