-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
184 lines (141 loc) · 5.18 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
ifeq ($(V),)
Q := @
else
Q :=
endif
out:=./build
obj := $(out)
$(shell mkdir -p $(out))
CFLAGS += -fPIC
CFLAGS += -fshort-enums
CFLAGS += -g
CFLAGS += -fno-unwind-tables
CFLAGS += -fno-exceptions
export CFLAGS
#AR := arm-none-eabi-ar
#export AR
all: $(out)/libhello-full.a $(out)/libhmac-test-full.a $(out)/libbsearch-full.a $(out)/libaes-test-full.a
all-elf: $(out)/hello.elf $(out)/hmac-test.elf $(out)/bsearch.elf $(out)/aes-test.elf
### common targets
LIBCRYPTO := $(realpath ./third_party/cryptoc)
libcrypto:
$(MAKE) obj=$(realpath $(out))/cryptoc -C $(LIBCRYPTO)
LDFLAGS_EXTRA += -L$(realpath $(out))/cryptoc -lcryptoc
EXTRA_AR += $(realpath $(out))/cryptoc/libcryptoc.a
LIBIO := $(realpath ./common/)
libio:
$(MAKE) obj=$(realpath $(out))/libio -C $(LIBIO)
LDFLAGS_EXTRA += -L$(realpath $(out))/libio -lio-common
EXTRA_AR += $(realpath $(out))/libio/libio-common.a
#### endif
# stdlib or board specific library
ifeq ($(CONFIG_USE_BOARD),)
EXTRA_AR += $(realpath $(out))/libio/libio-stdlib.a
else
EXTRA_AR += $(realpath $(out))/libio/libio-board.a
endif
ifeq ($(CONFIG_USE_BOARD),)
LDFLAGS_EXTRA += -lio-stdlib
else
LDFLAGS_EXTRA += -lio-board
endif
### Hello World project
THIN_TARGETS += $(out)/libhello-full-thin.a
LIBHELO := $(realpath ./hello-world/)
libhello:
$(MAKE) obj=$(realpath $(out))/libhello -C $(LIBHELO)
LDFLAGS_EXTRA += -L$(realpath $(out))/libhello -lhello
EXTRA_AR_HELLO := $(EXTRA_AR)
EXTRA_AR_HELLO += $(realpath $(out))/libhello/libhello.a
#this is the main target of this project
$(out)/libhello-full.a: libhello libio libcrypto
@echo " AR $(notdir $@)"
$(Q)$(AR) rcs $@ $(EXTRA_AR_HELLO)
## this is library is a thin one, not portable, but it can be used to generate the elf file
$(out)/libhello-full-thin.a: libhello libio libcrypto
@echo " AR $(notdir $@)"
$(Q)$(AR) rcT $@ $(EXTRA_AR_HELLO)
$(out)/hello.elf: $(out)/libhello-full-thin.a
@echo " LD $(notdir $@)"
$(Q)$(CC) $(LDFLAGS) -static $(CFLAGS) real_main.c -L$(out) -lhello-full-thin -o $@
####
### HMAC Test project
THIN_TARGETS += $(out)/libhmac-test-full-thin.a
LIBHMAC := $(realpath ./hmac/)
libhmac-test:
$(MAKE) obj=$(realpath $(out))/libhmac-test -C $(LIBHMAC)
LDFLAGS_EXTRA += -L$(realpath $(out))/libhmac-test -lhmac-test
EXTRA_AR_HMAC := $(EXTRA_AR)
EXTRA_AR_HMAC += $(realpath $(out))/libhmac-test/libhmac-test.a
#this is the main target of this project
$(out)/libhmac-test-full.a: libhmac-test libio libcrypto
@echo " AR $(notdir $@)"
$(Q)$(AR) rcs $@ $(EXTRA_AR_HMAC)
## this is library is a thin one, not portable, but it can be used to generate the elf file
$(out)/libhmac-test-full-thin.a: libhmac-test libio libcrypto
@echo " AR $(notdir $@)"
$(Q)$(AR) rcT $@ $(EXTRA_AR_HMAC)
$(out)/hmac-test.elf: $(out)/libhmac-test-full-thin.a
@echo " LD $(notdir $@)"
$(Q)$(CC) $(LDFLAGS) -static $(CFLAGS) real_main.c -L$(out) -lhmac-test-full-thin -o $@
###
### AES Test project
THIN_TARGETS += $(out)/libaes-test-full-thin.a
LIBAES := $(realpath ./aes/)
libaes-test:
$(MAKE) obj=$(realpath $(out))/libaes-test -C $(LIBAES)
LDFLAGS_EXTRA += -L$(realpath $(out))/libaes-test -laes-test
EXTRA_AR_AES := $(EXTRA_AR)
EXTRA_AR_AES += $(realpath $(out))/libaes-test/libaes-test.a
#this is the main target of this project
$(out)/libaes-test-full.a: libaes-test libio libcrypto
@echo " AR $(notdir $@)"
$(Q)$(AR) rcs $@ $(EXTRA_AR_AES)
## this is library is a thin one, not portable, but it can be used to generate the elf file
$(out)/libaes-test-full-thin.a: libaes-test libio libcrypto
@echo " AR $(notdir $@)"
$(Q)$(AR) rcT $@ $(EXTRA_AR_AES)
$(out)/aes-test.elf: $(out)/libaes-test-full-thin.a
@echo " LD $(notdir $@)"
$(Q)$(CC) $(LDFLAGS) -static $(CFLAGS) real_main.c -L$(out) -laes-test-full-thin -o $@
###
### BSearch
THIN_TARGETS += $(out)/libbsearch-full-thin.a
LIBBSEARCH := $(realpath ./bsearch/)
libbsearch:
$(MAKE) obj=$(realpath $(out))/libbsearch -C $(LIBBSEARCH)
LDFLAGS_EXTRA += -L$(realpath $(out))/libbsearch -lbsearch
EXTRA_AR_BSEARCH := $(EXTRA_AR)
EXTRA_AR_BSEARCH += $(realpath $(out))/libbsearch/libbsearch.a
#this is the main target of this project
$(out)/libbsearch-full.a: libbsearch libio libcrypto
@echo " AR $(notdir $@)"
$(Q)$(AR) rcs $@ $(EXTRA_AR_BSEARCH)
## this is library is a thin one, not portable, but it can be used to generate the elf file
$(out)/libbsearch-full-thin.a: libbsearch libio libcrypto
@echo " AR $(notdir $@)"
$(Q)$(AR) rcT $@ $(EXTRA_AR_BSEARCH)
$(out)/bsearch.elf: $(out)/libbsearch-full-thin.a
@echo " LD $(notdir $@)"
$(Q)$(CC) $(LDFLAGS) -static $(CFLAGS) real_main.c -L$(out) -lbsearch-full-thin -o $@
###
CFLAGS += -I./common/
thin: $(THIN_TARGETS)
tmpdir := /tmp/itests-external-to-send
tar:
$(Q)rm -rf $(tmpdir)
$(Q)rsync -a -m \
--exclude-from=internal.list \
$(shell pwd) $(tmpdir)
$(Q)rm -f $(shell pwd)/iskip-tests-$(shell git describe --tags --long).tar.gz
$(Q)tar czvf $(shell pwd)/iskip-tests-$(shell git describe --tags --long).tar.gz -C $(tmpdir) .
build-zip:
@echo " ZIP $(notdir $@)"
$(Q)zip -r iskip-tests-build.`date +%s`.zip $(out)
.PHONY: clean
clean:
@echo " RM $(out)"
$(Q)rm -rf $(out)
rm -f ./third_party/mini-printf/mini-printf.o
rm -f *.tar.gz
rm -f *.zip