Skip to content
This repository was archived by the owner on Mar 5, 2024. It is now read-only.

Commit a1da379

Browse files
author
hackermnementh
committed
Merge pull request #4 from 0x8000-0000/master
Updates for building on Windows using MinGW-64
2 parents 297706a + 0fa076c commit a1da379

File tree

4 files changed

+62
-83
lines changed

4 files changed

+62
-83
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
*.o
22
*~
3+
*.d
4+
*.exe
5+
*.a

config.mk

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
#
77
################################################################################
88

9-
CC=gcc
10-
CFLAGS = -Os -std=c99 -Wall -Wextra -I../lib/include/ -I../lib/source/ -I../tests/include/
11-
VPATH = ../lib/include/tinycrypt/ ../lib/source/
9+
CC:=gcc
10+
CFLAGS:=-Os -std=c99 -Wall -Wextra -D_ISOC99_SOURCE -MMD -I../lib/include/ -I../lib/source/ -I../tests/include/
11+
vpath %.c ../lib/source/
1212

13-
export CC
14-
export CFLAGS
15-
export VPATH
13+
# override MinGW built-in recipe
14+
%.o: %.c
15+
$(COMPILE.c) $(OUTPUT_OPTION) $<
16+
17+
ifeq ($(OS),Windows_NT)
18+
DOTEXE:=.exe
19+
endif
1620

1721
################################################################################

lib/Makefile

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
include ../config.mk
1010

1111
# Edit the OBJS content to add/remove primitives needed from TinyCrypt library:
12-
OBJS = aes_decrypt.o \
12+
OBJS:=aes_decrypt.o \
1313
aes_encrypt.o \
1414
cbc_mode.o \
1515
ctr_mode.o \
@@ -24,26 +24,16 @@ OBJS = aes_decrypt.o \
2424
cmac_mode.o \
2525
utils.o
2626

27-
all: $(OBJS)
27+
DEPS:=$(OBJS:.o=.d)
28+
29+
all: libtinycrypt.a
30+
31+
libtinycrypt.a: $(OBJS)
32+
$(AR) $(ARFLAGS) $@ $^
2833

2934
.PHONY: clean
3035

3136
clean:
32-
-$(RM) *.exe *.o *~
33-
34-
# Dependencies
35-
aes_decrypt.o: aes.h constants.h utils.h
36-
aes_encrypt.o: aes.h constants.h utils.h
37-
cbc_mode.o: cbc_mode.h constants.h utils.h
38-
ctr_mode.o: ctr_mode.h constants.h utils.h
39-
ctr_prng.o: ctr_prng.h constants.h utils.h
40-
ccm_mode.o: ccm_mode.h constants.h utils.h
41-
cmac_mode.o: cmac_mode.h aes.h constants.h utils.h
42-
hmac.o: hmac.h constants.h utils.h
43-
hmac_prng.o: hmac_prng.h constants.h utils.h
44-
sha256.o: sha256.h constants.h utils.h
45-
ecc.o: ecc.h
46-
ecc_dh.o: ecc_dh.h
47-
ecc_dsa.o: ecc_dsa.h
48-
utils.o: utils.h
37+
-$(RM) *.exe $(OBJS) $(DEPS) *~ libtinycrypt.a
4938

39+
-include $(DEPS)

tests/Makefile

Lines changed: 40 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,78 +8,60 @@
88

99
include ../config.mk
1010

11+
TEST_LIB_FILE:=test_ecc_utils.c
12+
TEST_SOURCE:=$(filter-out $(TEST_LIB_FILE), $(wildcard test_*.c))
13+
14+
TEST_OBJECTS:=$(TEST_SOURCE:.c=.o)
15+
TEST_DEPS:=$(TEST_SOURCE:.c=.d)
16+
TEST_BINARY:=$(TEST_SOURCE:.c=$(DOTEXE))
17+
1118
# Edit the 'all' content to add/remove tests needed from TinyCrypt library:
12-
all: test_aes \
13-
test_cbc_mode \
14-
test_ctr_mode \
15-
test_cmac_mode \
16-
test_ccm_mode \
17-
test_ctr_prng \
18-
test_hmac \
19-
test_hmac_prng \
20-
test_sha256 \
21-
test_ecc_dh \
22-
test_ecc_dsa
19+
all: $(TEST_BINARY)
2320

2421
clean:
25-
-$(RM) *.o *~
26-
-$(RM) test_aes
27-
-$(RM) test_cbc_mode
28-
-$(RM) test_ctr_mode
29-
-$(RM) test_ctr_prng
30-
-$(RM) test_hmac
31-
-$(RM) test_hmac_prng
32-
-$(RM) test_sha256
33-
-$(RM) test_ecc_dh
34-
-$(RM) test_ecc_dsa
35-
-$(RM) test_cmac_mode
36-
-$(RM) test_ccm_mode
22+
-$(RM) $(TEST_BINARY) $(TEST_OBJECTS) $(TEST_DEPS)
23+
-$(RM) *~ *.o *.d
3724

3825
# Dependencies
39-
test_aes: test_aes.o ../lib/aes_encrypt.o \
40-
../lib/aes_decrypt.o ../lib/utils.o
41-
42-
test_cbc_mode: test_cbc_mode.o ../lib/cbc_mode.o \
43-
../lib/aes_encrypt.o ../lib/aes_decrypt.o \
44-
../lib/utils.o
26+
test_aes$(DOTEXE): test_aes.o aes_encrypt.o aes_decrypt.o utils.o
27+
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
4528

46-
test_ctr_mode: test_ctr_mode.o ../lib/ctr_mode.o \
47-
../lib/aes_encrypt.o ../lib/utils.o
29+
test_cbc_mode$(DOTEXE): test_cbc_mode.o cbc_mode.o \
30+
aes_encrypt.o aes_decrypt.o utils.o
31+
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
4832

49-
test_ctr_prng: test_ctr_prng.o ../lib/ctr_prng.o \
50-
../lib/aes_encrypt.o ../lib/utils.o
33+
test_ctr_mode$(DOTEXE): test_ctr_mode.o ctr_mode.o \
34+
aes_encrypt.o utils.o
35+
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
5136

52-
test_cmac_mode: test_cmac_mode.o ../lib/aes_encrypt.o ../lib/utils.o \
53-
../lib/cmac_mode.o
37+
test_ctr_prng$(DOTEXE): test_ctr_prng.o ctr_prng.o \
38+
aes_encrypt.o utils.o
39+
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
5440

55-
test_ccm_mode: test_ccm_mode.o ../lib/aes_encrypt.o \
56-
../lib/utils.o ../lib/ccm_mode.o
41+
test_cmac_mode$(DOTEXE): test_cmac_mode.o aes_encrypt.o utils.o \
42+
cmac_mode.o
43+
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
5744

58-
test_hmac: test_hmac.o ../lib/hmac.o ../lib/sha256.o \
59-
../lib/utils.o
45+
test_ccm_mode$(DOTEXE): test_ccm_mode.o aes_encrypt.o \
46+
utils.o ccm_mode.o
47+
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
6048

61-
test_hmac_prng: test_hmac_prng.o ../lib/hmac_prng.o ../lib/hmac.o \
62-
../lib/sha256.o ../lib/utils.o
49+
test_hmac$(DOTEXE): test_hmac.o hmac.o sha256.o utils.o
50+
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
6351

64-
test_sha256: test_sha256.o ../lib/sha256.o ../lib/utils.o
52+
test_hmac_prng$(DOTEXE): test_hmac_prng.o hmac_prng.o hmac.o \
53+
sha256.o utils.o
54+
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
6555

66-
test_ecc_dh: test_ecc_dh.o ../lib/ecc.o ../lib/ecc_dh.o test_ecc_utils.o
56+
test_sha256$(DOTEXE): test_sha256.o sha256.o utils.o
57+
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
6758

68-
test_ecc_dsa: test_ecc_dsa.o ../lib/ecc.o ../lib/utils.o ../lib/ecc_dh.o \
69-
../lib/ecc_dsa.o ../lib/sha256.o test_ecc_utils.o
59+
test_ecc_dh$(DOTEXE): test_ecc_dh.o ecc.o ecc_dh.o test_ecc_utils.o
60+
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
7061

62+
test_ecc_dsa$(DOTEXE): test_ecc_dsa.o ecc.o utils.o ecc_dh.o \
63+
ecc_dsa.o sha256.o test_ecc_utils.o
64+
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
7165

72-
# Sub-dependencies
73-
test_aes.o: aes.h constants.h
74-
test_cbc_mode.o: cbc_mode.h constants.h
75-
test_ctr_mode.o: ctr_mode.h constants.h
76-
test_ctr_prng.o: ctr_prng.h constants.h
77-
test_cmac_mode.o: cmac_mode.h aes.h
78-
test_ccm_mode.o: ccm_mode.h constants.h
79-
test_hmac.o: hmac.h sha256.h constants.h
80-
test_hmac_prng.o: hmac_prng.h constants.h
81-
test_sha256.o: sha256.h constants.h
82-
test_ecc_dh.o: ecc.h ecc_dh.h constants.h
83-
test_ecc_dsa.o: ecc.h sha256.h constants.h
84-
test_ecc_utils.o: ecc.h ecc_dh.h
8566

67+
-include $(TEST_DEPS)

0 commit comments

Comments
 (0)