forked from gitcollect/matrixssl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
273 lines (228 loc) · 10.1 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
#
# Top-level Makefile for building various versions of MatrixSSL.
#
# Copyright (c) 2016 INSIDE Secure Corporation. All Rights Reserved.
#
# @version $Format:%h%d$
# A list of the most important build targets provided by this Makefile:
# Make command Description
# make all Default target: Build all software using current
# MatrixSSL configuration
# make libs Build MatrixSSL libraries using current
# MatrixSSL configuration
# make tests Build MatrixSSL test programs using current
# MatrixSSL configuration
# make apps Build MatrixSSL example programs using current
# MatrixSSL configuration
# make check-config Apply default configuration if not present.
# make *-config (Specify *) select one of prepackaged configurations
# from configs directory.
#
# Additional targets for MatrixSSL Open Source and Commercial Editions
#
# make all-tls Build MatrixSSL using options suitable for most
# TLS use cases and the MatrixSSL stock crypto.
# make all-noecc Build MatrixSSL using options that disable ECC,
# using the MatrixSSL stock crypto.
# make all-rsaonly Build MatrixSSL using options that disable ECC and DH,
# using the MatrixSSL stock crypto.
# make all-psk Build MatrixSSL with support for only a single PSK
# ciphersuite using MatrixSSL stock crypto.
# This is the smallest possible configuration,
# except that both server- and client-side TLS are enabled
# for easier testing.
#
# Additional targets for MatrixSSL FIPS Edition
#
# make all-fips Compile MatrixSSL FIPS Edition with default
# configuration.
# make all-cl-nonfips Compile MatrixSSL FIPS Edition using CL library in
# non-FIPS Mode of operation.
# make all-combined Compile MatrixSSL FIPS Edition allowing run-time
# selection of FIPS or non-FIPS mode.
# make all-openssl-compat A configuration specially tailored for use
# with the OpenSSL compatibility layer.
# make all-combined-default-nonfips The same than make all combined, but
# non-FIPS mode is the default.
#
#
default: all
util: all-utils
CONFIG_EXTRA_DEPENDENCIES=
CORE_CONFIG_DIR=core/config
CORE_CONFIG_FILE=$(CORE_CONFIG_DIR)/coreConfig.h
# ! -e $(CORE_CONFIG_FILE) ] || ! cmp -s $(1)/coreConfig.h $(CORE_CONFIG_FILE)
define apply_core_config
@if [ ! -e $(CORE_CONFIG_FILE) ] || ! cmp -s $(1)/coreConfig.h $(CORE_CONFIG_FILE); then cp $(1)/coreConfig.h $(CORE_CONFIG_FILE); echo cp $(1)/coreConfig.h $(CORE_CONFIG_FILE); echo WARNING: Applied new configuration also to core. You may need to recompile the core.;fi
endef
# ! -e $(CORE_CONFIG_FILE) ] || ! cmp -s $(1)/coreConfig.h $(CORE_CONFIG_FILE)
define apply_core_config_non_exist
@if [ ! -e $(CORE_CONFIG_FILE) ]; then cp $(1)/coreConfig.h $(CORE_CONFIG_FILE); echo cp $(1)/coreConfig.h $(CORE_CONFIG_FILE); echo WARNING: Applied new configuration also to core. You may need to recompile the core.;fi
endef
# Use default config if no config is being used.
check-config: $(CONFIG_EXTRA_DEPENDENCIES)
@if [ ! -e crypto/cryptoConfig.h ];then \
cp configs/default/cryptoConfig.h crypto/cryptoConfig.h;\
echo NOTE: Using default configuration from configs/default/cryptoConfig.h.;\
fi
@if [ ! -e matrixssl/matrixsslConfig.h ];then \
cp configs/default/matrixsslConfig.h matrixssl/matrixsslConfig.h;\
echo NOTE: Using default configuration from configs/default/matrixsslConfig.h.;\
fi
$(call apply_core_config_non_exist,configs/default)
clean-config:
rm -f core/coreConfig.h crypto/cryptoConfig.h matrixssl/matrixsslConfig.h
# Apply any of pre-existing configurations from configs directory
%-config: configs/% $(CONFIG_EXTRA_DEPENDENCIES)
@echo Using $</*Config.h.
cp $</cryptoConfig.h crypto/cryptoConfig.h
cp $</matrixsslConfig.h matrixssl/matrixsslConfig.h
$(call apply_core_config,$<)
# Set non-fips configuration (standard configuration for MatrixSSL commercial)
# and build all libraries
all-nonfips:
$(MAKE) nonfips-config
$(MAKE) --directory=core
$(MAKE) --directory=crypto
$(MAKE) --directory=matrixssl
if $(MAKE) --directory=crypto parse-config | grep -q '#define USE_CMS'; then $(MAKE) --directory=crypto/cms;fi
if [ -e matrixssh ]; then if $(MAKE) --directory=crypto parse-config | grep -q '#define USE_AES_CTR' && $(MAKE) --directory=crypto parse-config | grep -q '#define USE_DH'; then $(MAKE) --directory=matrixssh;fi;fi
# Set non-fips configuration and build tests
test-nonfips:
$(MAKE) nonfips-config
$(MAKE) --directory=crypto/test
$(MAKE) --directory=matrixssl/test
if $(MAKE) --directory=crypto parse-config | grep -q '#define USE_CMS'; then $(MAKE) --directory=crypto/cms;fi
# Find out if MatrixSSL FIPS Edition is present
ifeq (,$(wildcard configs/fips*/matrixsslConfig.h))
CONFIG_FIPS_AVAILABLE=0
CONFIG_NONFIPS_PREFIX=
else
CONFIG_FIPS_AVAILABLE=1
CONFIG_NONFIPS_PREFIX=nonfips-
endif
ifneq (,$(findstring -DUSE_EXT_EXAMPLE_MODULE, $(CFLAGS)))
D_USE_EXT_EXAMPLE_MODULE=1
else
D_USE_EXT_EXAMPLE_MODULE=0
endif
# These are some examples of configuration selection targets for MatrixSSL.
# You can instead apply any of any of configurations in configs directory with
# make CONFIGNAME-config and then proceed with make all / make libs etc.
# Omit ECC (Only support RSA and DH, using MatrixSSL stock crypto)
all-noecc:
$(MAKE) $(CONFIG_NONFIPS_PREFIX)noecc-config
$(MAKE) all
# Only support RSA (MatrixSSL stock crypto)
all-rsaonly:
$(MAKE) $(CONFIG_NONFIPS_PREFIX)rsaonly-config
$(MAKE) all
# Only support RSA (MatrixSSL stock crypto)
all-psk:
$(MAKE) $(CONFIG_NONFIPS_PREFIX)psk-config
$(MAKE) all
# A commonly recommended set of options for MatrixSSL using stock crypto,
# for the most common TLS use cases. This configuration disables
# DH and 3DES options in rare use (which is typically considered good for
# security).
all-tls:
$(MAKE) $(CONFIG_NONFIPS_PREFIX)tls-config
$(MAKE) all
# These configurations are specific to FIPS version of MatrixSSL.
# The targets are only available on MatrixSSL FIPS Edition.
# Set fips only configuration and build all libraries
all-fips:
$(MAKE) fipsonly-config
$(MAKE) all
# Set nonfips only configuration and build all libraries
all-cl-nonfips:
$(MAKE) cl-nonfips-config
$(MAKE) all
# Set combined fips/nonfips configuration and build all libraries
all-combined:
$(MAKE) combined-config
$(MAKE) all
# Set combined-default-nonfips configuration and build all libraries
all-combined-default-nonfips:
$(MAKE) combined-default-nonfips-config
$(MAKE) all
# Set combined fips/nonfips configuration with maximum algorithm
# support, and build all libraries
all-combined-fulltest:
$(MAKE) combined-fulltest-config
$(MAKE) all
all-openssl-compat:
$(MAKE) openssl-compat-config
$(MAKE) all
ifneq (,$(findstring clean,$(MAKECMDGOALS)))
SUBARGS:=clean
endif
# Set fips only configuration and build tests
test-fips:
$(MAKE) fipsonly-config
$(MAKE) test
# Set combined fips/nonfips only configuration and build tests
test-combined:
$(MAKE) combined-config
$(MAKE) test
# Set combined nonfips/fips configuration and build tests
test-combined-default-nonfips:
$(MAKE) combined-default-nonfips-config
$(MAKE) test
.PHONY: all libs tests apps clean
ext:
if [ "$(D_USE_EXT_EXAMPLE_MODULE)" = "1" ]; then $(MAKE) --directory=ext/psext-example; \
elif $(MAKE) --directory=matrixssl parse-config | grep -q '#define USE_EXT_EXAMPLE_MODULE'; then $(MAKE) --directory=ext/psext-example; fi \
# Add dependencies
all: libs tests apps
all: check-config
libs: check-config
tests: check-config libs ext
apps: check-config libs ext
ext: check-config libs
all-utils: check-config
# Alias
test: tests
libs:
$(MAKE) --directory=core
if $(MAKE) --directory=crypto parse-config | grep -q -e '#define USE_FIPS_CRYPTO' -e '#define USE_CL_CRYPTO'; then $(MAKE) --directory=crypto-cl; else if $(MAKE) --directory=crypto parse-config | grep -q -e "#define USE_ROT_CRYPTO"; then $(MAKE) --directory=crypto-rot; else $(MAKE) --directory=crypto; fi; fi
if $(MAKE) --directory=crypto parse-config | grep -q '#define USE_CMS'; then $(MAKE) --directory=crypto/cms;fi
$(MAKE) --directory=matrixssl
if [ -e matrixssh ]; then if $(MAKE) --directory=crypto parse-config | grep -q '#define USE_AES_CTR' && $(MAKE) --directory=crypto parse-config | grep -q '#define USE_DH'; then $(MAKE) --directory=matrixssh;fi;fi
tests:
$(MAKE) --directory=crypto/test
$(MAKE) --directory=matrixssl/test
if $(MAKE) --directory=crypto parse-config | grep -q '#define USE_CMS'; then $(MAKE) --directory=crypto/cms/test;fi
# Note apps is also a direct subdirectory
#ifdef MATRIXSSL_COMMERCIAL
APPS_ADDITIONAL = apps_crypto
.PHONY: apps_crypto
apps_crypto:
if [ -e apps/crypto ];then $(MAKE) --directory=apps/crypto;fi
#endif /* MATRIXSSL_COMMERCIAL */
apps_common:
$(MAKE) --directory=apps/common
apps: apps_common $(APPS_ADDITIONAL)
$(MAKE) --directory=apps/ssl
$(MAKE) --directory=apps/dtls
clean:
$(MAKE) clean --directory=core
$(MAKE) clean --directory=crypto
$(MAKE) clean --directory=crypto/test
$(MAKE) clean --directory=matrixssl
$(MAKE) clean --directory=crypto/test
$(MAKE) clean --directory=matrixssl/test
if [ -e crypto-cl ]; then $(MAKE) clean --directory=crypto-cl;fi
if [ -e crypto-rot ]; then $(MAKE) clean --directory=crypto-rot;fi
if [ -e crypto/cms ]; then $(MAKE) clean --directory=crypto/cms;fi
$(MAKE) clean --directory=apps/common
$(MAKE) clean --directory=apps/ssl
$(MAKE) clean --directory=apps/dtls
if [ -e apps/crypto ];then $(MAKE) clean --directory=apps/crypto;fi
if [ -e crypto/cms/test ]; then $(MAKE) clean --directory=crypto/cms/test;fi
if [ -e matrixssh ]; then $(MAKE) clean --directory=matrixssh; fi
if [ -e ext/psext-example ]; then $(MAKE) clean --directory=ext/psext-example;fi
clobber: clean clean-config
# Always use common.mk for possible additional rules and processing.
COMMON_MK_NO_TARGETS:=1
include common.mk