diff options
author | Florin Iucha <[email protected]> | 2016-04-27 00:13:00 -0400 |
---|---|---|
committer | Florin Iucha <[email protected]> | 2016-04-27 00:13:00 -0400 |
commit | cc85eb7cf897ae694693dcd775829edd9bce1656 (patch) | |
tree | d720838dbe625f1c554fab072bad54843eca2a74 | |
parent | 297706a14d4024d0e98bbbcae45ce0dcfbcc5c4c (diff) |
Makefile updates for MinGW
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | config.mk | 16 | ||||
-rw-r--r-- | lib/Makefile | 28 | ||||
-rw-r--r-- | tests/Makefile | 96 |
4 files changed, 61 insertions, 82 deletions
@@ -1,2 +1,5 @@ *.o *~ +*.d +*.exe +*.a @@ -6,12 +6,16 @@ # ################################################################################ -CC=gcc -CFLAGS = -Os -std=c99 -Wall -Wextra -I../lib/include/ -I../lib/source/ -I../tests/include/ -VPATH = ../lib/include/tinycrypt/ ../lib/source/ +CC:=gcc +CFLAGS:=-Os -std=c99 -Wall -Wextra -D_ISOC99_SOURCE -MMD -I../lib/include/ -I../lib/source/ -I../tests/include/ +vpath %.c ../lib/source/ -export CC -export CFLAGS -export VPATH +# override MinGW built-in recipe +%.o: %.c + $(COMPILE.c) $(OUTPUT_OPTION) $< + +ifeq ($(OS),Windows_NT) +DOTEXE:=.exe +endif ################################################################################ diff --git a/lib/Makefile b/lib/Makefile index 8ac4220..ee831e8 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -9,7 +9,7 @@ include ../config.mk # Edit the OBJS content to add/remove primitives needed from TinyCrypt library: -OBJS = aes_decrypt.o \ +OBJS:=aes_decrypt.o \ aes_encrypt.o \ cbc_mode.o \ ctr_mode.o \ @@ -24,26 +24,16 @@ OBJS = aes_decrypt.o \ cmac_mode.o \ utils.o -all: $(OBJS) +DEPS:=$(OBJS:.o=.d) + +all: libtinycrypt.a + +libtinycrypt.a: $(OBJS) + $(AR) $(ARFLAGS) $@ $^ .PHONY: clean clean: - -$(RM) *.exe *.o *~ - -# Dependencies -aes_decrypt.o: aes.h constants.h utils.h -aes_encrypt.o: aes.h constants.h utils.h -cbc_mode.o: cbc_mode.h constants.h utils.h -ctr_mode.o: ctr_mode.h constants.h utils.h -ctr_prng.o: ctr_prng.h constants.h utils.h -ccm_mode.o: ccm_mode.h constants.h utils.h -cmac_mode.o: cmac_mode.h aes.h constants.h utils.h -hmac.o: hmac.h constants.h utils.h -hmac_prng.o: hmac_prng.h constants.h utils.h -sha256.o: sha256.h constants.h utils.h -ecc.o: ecc.h -ecc_dh.o: ecc_dh.h -ecc_dsa.o: ecc_dsa.h -utils.o: utils.h + -$(RM) *.exe $(OBJS) $(DEPS) *~ libtinycrypt.a +-include $(DEPS) diff --git a/tests/Makefile b/tests/Makefile index 305c78c..37e0b13 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -8,78 +8,60 @@ include ../config.mk +TEST_LIB_FILE:=test_ecc_utils.c +TEST_SOURCE:=$(filter-out $(TEST_LIB_FILE), $(wildcard test_*.c)) + +TEST_OBJECTS:=$(TEST_SOURCE.c=.o) +TEST_DEPS:=$(TEST_SOURCE.c=.d) +TEST_BINARY:=$(TEST_SOURCE:.c=$(DOTEXE)) + # Edit the 'all' content to add/remove tests needed from TinyCrypt library: -all: test_aes \ - test_cbc_mode \ - test_ctr_mode \ - test_cmac_mode \ - test_ccm_mode \ - test_ctr_prng \ - test_hmac \ - test_hmac_prng \ - test_sha256 \ - test_ecc_dh \ - test_ecc_dsa +all: $(TEST_BINARY) clean: -$(RM) *.o *~ - -$(RM) test_aes - -$(RM) test_cbc_mode - -$(RM) test_ctr_mode - -$(RM) test_ctr_prng - -$(RM) test_hmac - -$(RM) test_hmac_prng - -$(RM) test_sha256 - -$(RM) test_ecc_dh - -$(RM) test_ecc_dsa - -$(RM) test_cmac_mode - -$(RM) test_ccm_mode + -$(RM) $(TEST_BINARY) $(TEST_OBJECTS) $(TEST_DEPS) # Dependencies -test_aes: test_aes.o ../lib/aes_encrypt.o \ - ../lib/aes_decrypt.o ../lib/utils.o - -test_cbc_mode: test_cbc_mode.o ../lib/cbc_mode.o \ - ../lib/aes_encrypt.o ../lib/aes_decrypt.o \ - ../lib/utils.o +test_aes$(DOTEXE): test_aes.o aes_encrypt.o aes_decrypt.o utils.o + $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ -test_ctr_mode: test_ctr_mode.o ../lib/ctr_mode.o \ - ../lib/aes_encrypt.o ../lib/utils.o +test_cbc_mode$(DOTEXE): test_cbc_mode.o cbc_mode.o \ + aes_encrypt.o aes_decrypt.o utils.o + $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ -test_ctr_prng: test_ctr_prng.o ../lib/ctr_prng.o \ - ../lib/aes_encrypt.o ../lib/utils.o +test_ctr_mode$(DOTEXE): test_ctr_mode.o ctr_mode.o \ + aes_encrypt.o utils.o + $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ -test_cmac_mode: test_cmac_mode.o ../lib/aes_encrypt.o ../lib/utils.o \ - ../lib/cmac_mode.o +test_ctr_prng$(DOTEXE): test_ctr_prng.o ctr_prng.o \ + aes_encrypt.o utils.o + $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ -test_ccm_mode: test_ccm_mode.o ../lib/aes_encrypt.o \ - ../lib/utils.o ../lib/ccm_mode.o +test_cmac_mode$(DOTEXE): test_cmac_mode.o aes_encrypt.o utils.o \ + cmac_mode.o + $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ -test_hmac: test_hmac.o ../lib/hmac.o ../lib/sha256.o \ - ../lib/utils.o +test_ccm_mode$(DOTEXE): test_ccm_mode.o aes_encrypt.o \ + utils.o ccm_mode.o + $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ -test_hmac_prng: test_hmac_prng.o ../lib/hmac_prng.o ../lib/hmac.o \ - ../lib/sha256.o ../lib/utils.o +test_hmac$(DOTEXE): test_hmac.o hmac.o sha256.o utils.o + $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ -test_sha256: test_sha256.o ../lib/sha256.o ../lib/utils.o +test_hmac_prng$(DOTEXE): test_hmac_prng.o hmac_prng.o hmac.o \ + sha256.o utils.o + $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ -test_ecc_dh: test_ecc_dh.o ../lib/ecc.o ../lib/ecc_dh.o test_ecc_utils.o +test_sha256$(DOTEXE): test_sha256.o sha256.o utils.o + $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ -test_ecc_dsa: test_ecc_dsa.o ../lib/ecc.o ../lib/utils.o ../lib/ecc_dh.o \ - ../lib/ecc_dsa.o ../lib/sha256.o test_ecc_utils.o +test_ecc_dh$(DOTEXE): test_ecc_dh.o ecc.o ecc_dh.o test_ecc_utils.o + $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ +test_ecc_dsa$(DOTEXE): test_ecc_dsa.o ecc.o utils.o ecc_dh.o \ + ecc_dsa.o sha256.o test_ecc_utils.o + $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ -# Sub-dependencies -test_aes.o: aes.h constants.h -test_cbc_mode.o: cbc_mode.h constants.h -test_ctr_mode.o: ctr_mode.h constants.h -test_ctr_prng.o: ctr_prng.h constants.h -test_cmac_mode.o: cmac_mode.h aes.h -test_ccm_mode.o: ccm_mode.h constants.h -test_hmac.o: hmac.h sha256.h constants.h -test_hmac_prng.o: hmac_prng.h constants.h -test_sha256.o: sha256.h constants.h -test_ecc_dh.o: ecc.h ecc_dh.h constants.h -test_ecc_dsa.o: ecc.h sha256.h constants.h -test_ecc_utils.o: ecc.h ecc_dh.h +-include $(TEST_DEPS) |