Crypto++ 8.2 Free C++ class library of cryptographic schemes

GNUmakefile-cross
1 # https://www.gnu.org/software/make/manual/make.html#Makefile-Conventions
2 # and https://www.gnu.org/prep/standards/standards.html
3
4 SHELL = /bin/sh
5
6 # If needed
7 TMPDIR ?= /tmp
8 # Used for ARMv7a and NEON. Android hard codes softfp
9 FP_ABI ?= hard
10 # Used for feature tests
11 TOUT ?= a.out
12 TOUT := $(strip $(TOUT))
13
14 # Allow override for the cryptest.exe recipe. Change to
15 # ./libcryptopp.so or ./libcryptopp.dylib to suit your
16 # taste. https://github.com/weidai11/cryptopp/issues/866
17 LINK_LIBRARY ?= libcryptopp.a
18 LINK_LIBRARY_PATH ?= ./
19
20 # Default CXXFLAGS if none were provided
21 CXXFLAGS ?= -DNDEBUG -g2 -O3 -fPIC -pipe
22
23 AR ?= ar
24 ARFLAGS ?= cr
25 RANLIB ?= ranlib
26 CP ?= cp
27 MV ?= mv
28 CHMOD ?= chmod
29 MKDIR ?= mkdir -p
30 GREP ?= grep
31 SED ?= sed
32
33 LN ?= ln -sf
34 LDCONF ?= /sbin/ldconfig -n
35
36 IS_IOS ?= 0
37 IS_ANDROID ?= 0
38 IS_ARM_EMBEDDED ?= 0
39
40 # Clang is reporting armv8l-unknown-linux-gnueabihf
41 # for ARMv7 images on Aarch64 hardware.
42 MACHINEX := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null)
43 HOSTX := $(shell echo $(MACHINEX) | cut -f 1 -d '-')
44 ifeq ($(HOSTX),)
45 HOSTX := $(shell uname -m 2>/dev/null)
46 endif
47
48 IS_LINUX := $(shell echo $(MACHINEX) | $(GREP) -i -c "Linux")
49
50 # Can be used by Android and Embeeded cross-compiles. Disable by default because
51 # Android and embedded users typically don't run this configuration.
52 HAS_SOLIB_VERSION ?= 0
53
54 # Formely adhoc.cpp was created from adhoc.cpp.proto when needed.
55 # This is now needed because ISA tests are performed using adhoc.cpp.
56 ifeq ($(wildcard adhoc.cpp),)
57 $(shell cp adhoc.cpp.proto adhoc.cpp)
58 endif
59
60 ###########################################################
61 ##### General Variables #####
62 ###########################################################
63
64 # Default prefix for make install
65 ifeq ($(PREFIX),)
66 PREFIX = /usr/local
67 endif
68
69 # http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
70 ifeq ($(DATADIR),)
71 DATADIR := $(PREFIX)/share
72 endif
73 ifeq ($(LIBDIR),)
74 LIBDIR := $(PREFIX)/lib
75 endif
76 ifeq ($(BINDIR),)
77 BINDIR := $(PREFIX)/bin
78 endif
79 ifeq ($(INCLUDEDIR),)
80 INCLUDEDIR := $(PREFIX)/include
81 endif
82
83 # We honor ARFLAGS, but the "v" option used by default causes a noisy make
84 ifeq ($(ARFLAGS),rv)
85 ARFLAGS = r
86 endif
87
88 # Sadly, we can't actually use GCC_PRAGMA_AWARE because of GCC bug 53431.
89 # Its a shame because GCC has so much to offer by the way of analysis.
90 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431
91 ifneq ($(CLANG_COMPILER),0)
92 CXXFLAGS += -Wall
93 endif
94
95 ###########################################################
96 ##### iOS #####
97 ###########################################################
98
99 # iOS cross-compile configuration.
100 # See http://www.cryptopp.com/wiki/iOS_(Command_Line).
101 ifeq ($(IS_IOS),1)
102 CXXFLAGS += $(IOS_CXXFLAGS) -stdlib=libc++
103 CXXFLAGS += --sysroot "$(IOS_SYSROOT)"
104
105 AR = libtool
106 ARFLAGS = -static -o
107 endif
108
109 ###########################################################
110 ##### Android #####
111 ###########################################################
112
113 # Android cross-compile configuration.
114 # See http://www.cryptopp.com/wiki/Android_(Command_Line).
115 ifeq ($(IS_ANDROID),1)
116 CXXFLAGS += $(ANDROID_CXXFLAGS) -D__ANDROID_API__=$(ANDROID_API)
117 CXXFLAGS += --sysroot=$(ANDROID_SYSROOT)
118 CXXFLAGS += -Wa,--noexecstack
119
120 # Source files copied into PWD for Android cpu-features
121 # setenv-android.sh does the copying. Its a dirty compile.
122 ANDROID_CPU_OBJ = cpu-features.o
123 endif
124
125 ###########################################################
126 ##### Embedded #####
127 ###########################################################
128
129 # ARM embedded cross-compile configuration.
130 # See http://www.cryptopp.com/wiki/ARM_Embedded_(Command_Line)
131 # and http://www.cryptopp.com/wiki/ARM_Embedded_(Bare Metal).
132 ifeq ($(IS_ARM_EMBEDDED),1)
133 # CPP, CXX, AR, RANLIB, LD, etc are set in 'setenv-embedded.sh'
134 CXXFLAGS += $(ARM_EMBEDDED_FLAGS) --sysroot=$(ARM_EMBEDDED_SYSROOT)
135 endif
136
137 ###########################################################
138 ##### Compiler and Platform #####
139 ###########################################################
140
141 # Wait until CXXFLAGS have been set by setenv scripts.
142
143 GCC_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -v -E 'llvm|clang' | $(GREP) -i -c -E '(gcc|g\+\+)')
144 CLANG_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -i -c -E 'llvm|clang')
145
146 HOSTX := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null | cut -f 1 -d '-')
147 ifeq ($(HOSTX),)
148 HOSTX := $(shell uname -m 2>/dev/null)
149 endif
150
151 # This dance is because Clang reports the host architecture instead
152 # of the target architecture. Running Clang on an x86_64 machine with
153 # -arch arm64 yields x86_64 instead of aarch64 or arm64.
154
155 ifeq ($(CLANG_COMPILER),1)
156 IS_X86 := $(shell echo $(CXXFLAGS) | $(GREP) -v 64 | $(GREP) -i -c -E 'i.86')
157 IS_X64 := $(shell echo $(CXXFLAGS) | $(GREP) -i -c -E 'x86_64|amd64')
158 IS_ARM32 := $(shell echo $(CXXFLAGS) | $(GREP) -v 64 | $(GREP) -i -c -E 'arm|armhf|arm7l|eabihf')
159 IS_ARMV8 := $(shell echo $(CXXFLAGS) | $(GREP) -i -c -E 'aarch32|aarch64|arm64|armv8')
160 else
161 IS_X86 := $(shell echo $(HOSTX) | $(GREP) -v 64 | $(GREP) -i -c -E 'i.86')
162 IS_X64 := $(shell echo $(HOSTX) | $(GREP) -i -c -E 'x86_64|amd64')
163 IS_ARM32 := $(shell echo $(HOSTX) | $(GREP) -v 64 | $(GREP) -i -c -E 'arm|armhf|arm7l|eabihf')
164 IS_ARMV8 := $(shell echo $(HOSTX) | $(GREP) -i -c -E 'aarch32|aarch64|arm64|armv8')
165 endif
166
167 ifeq ($(IS_ARMV8),1)
168 IS_ARM32 = 0
169 endif
170
171 IS_X32 := 0
172 IS_PPC32 := 0
173 IS_PPC64 := 0
174
175 $(info Here's what we found... IS_X86: $(IS_X86), IS_X64: $(IS_X64), IS_ARM32: $(IS_ARM32), IS_ARMV8: $(IS_ARMV8))
176
177 ###########################################################
178 ##### Test Program #####
179 ###########################################################
180
181 # Hack to skip CPU feature tests for some recipes
182 DETECT_FEATURES ?= 1
183 ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),-DCRYPTOPP_DISABLE_ASM)
184 DETECT_FEATURES := 0
185 else ifeq ($(findstring clean,$(MAKECMDGOALS)),clean)
186 DETECT_FEATURES := 0
187 else ifeq ($(findstring distclean,$(MAKECMDGOALS)),distclean)
188 DETECT_FEATURES := 0
189 else ifeq ($(findstring distclean,$(MAKECMDGOALS)),trim)
190 DETECT_FEATURES := 0
191 else ifeq ($(IS_IOS),1)
192 DETECT_FEATURES := 0
193 endif
194
195 # Strip out -Wall, -Wextra and friends for feature testing. FORTIFY_SOURCE is removed
196 # because it requires -O1 or higher, but we use -O0 to tame the optimizer.
197 ifeq ($(DETECT_FEATURES),1)
198 TCXXFLAGS := $(filter-out -D_FORTIFY_SOURCE=% -M -MM -Wall -Wextra -Werror% -Wunused -Wconversion -Wp%, $(CXXFLAGS))
199 ifneq ($(strip $(TCXXFLAGS)),)
200 $(info Using testing flags: $(TCXXFLAGS))
201 endif
202 #TPROG = TestPrograms/test_cxx.cxx
203 #$(info Testing compile... )
204 #$(info $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 1>/dev/null))
205 endif
206
207 # For the previous messages
208 $(info )
209
210 ###########################################################
211 ##### X86/X32/X64 Options #####
212 ###########################################################
213
214 ifneq ($(IS_X86)$(IS_X64),00)
215 ifeq ($(DETECT_FEATURES),1)
216
217 SSE2_FLAG = -msse2
218 SSE3_FLAG = -msse3
219 SSSE3_FLAG = -mssse3
220 SSE41_FLAG = -msse4.1
221 SSE42_FLAG = -msse4.2
222 CLMUL_FLAG = -mpclmul
223 AESNI_FLAG = -maes
224 AVX_FLAG = -mavx
225 AVX2_FLAG = -mavx2
226 SHANI_FLAG = -msha
227
228 TPROG = TestPrograms/test_x86_sse2.cxx
229 TOPT = $(SSE2_FLAG)
230 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
231 ifeq ($(strip $(HAVE_OPT)),0)
232 CHACHA_FLAG = $(SSE2_FLAG)
233 else
234 SSE2_FLAG =
235 endif
236
237 TPROG = TestPrograms/test_x86_ssse3.cxx
238 TOPT = $(SSSE3_FLAG)
239 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
240 ifeq ($(strip $(HAVE_OPT)),0)
241 ARIA_FLAG = $(SSSE3_FLAG)
242 CHAM_FLAG = $(SSSE3_FLAG)
243 LEA_FLAG = $(SSSE3_FLAG)
244 SIMON128_FLAG = $(SSSE3_FLAG)
245 SPECK128_FLAG = $(SSSE3_FLAG)
246 else
247 SSSE3_FLAG =
248 endif
249
250 TPROG = TestPrograms/test_x86_sse41.cxx
251 TOPT = $(SSE41_FLAG)
252 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
253 ifeq ($(strip $(HAVE_OPT)),0)
254 BLAKE2B_FLAG = $(SSE41_FLAG)
255 BLAKE2S_FLAG = $(SSE41_FLAG)
256 else
257 SSE41_FLAG =
258 endif
259
260 TPROG = TestPrograms/test_x86_sse42.cxx
261 TOPT = $(SSE42_FLAG)
262 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
263 ifeq ($(strip $(HAVE_OPT)),0)
264 CRC_FLAG = $(SSE42_FLAG)
265 else
266 SSE42_FLAG =
267 endif
268
269 TPROG = TestPrograms/test_x86_clmul.cxx
270 TOPT = $(CLMUL_FLAG)
271 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
272 ifeq ($(strip $(HAVE_OPT)),0)
273 GCM_FLAG = $(SSSE3_FLAG) $(CLMUL_FLAG)
274 GF2N_FLAG = $(CLMUL_FLAG)
275 else
276 CLMUL_FLAG =
277 endif
278
279 TPROG = TestPrograms/test_x86_aes.cxx
280 TOPT = $(AESNI_FLAG)
281 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
282 ifeq ($(strip $(HAVE_OPT)),0)
283 AES_FLAG = $(SSE41_FLAG) $(AESNI_FLAG)
284 SM4_FLAG = $(SSSE3_FLAG) $(AESNI_FLAG)
285 else
286 AESNI_FLAG =
287 endif
288
289 TPROG = TestPrograms/test_x86_avx.cxx
290 TOPT = $(AVX_FLAG)
291 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
292 ifeq ($(strip $(HAVE_OPT)),0)
293 # XXX_FLAG = $(AVX_FLAG)
294 else
295 AVX_FLAG =
296 endif
297
298 TPROG = TestPrograms/test_x86_avx2.cxx
299 TOPT = $(AVX2_FLAG)
300 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
301 ifeq ($(strip $(HAVE_OPT)),0)
302 CHACHA_AVX2_FLAG = $(AVX2_FLAG)
303 else
304 AVX2_FLAG =
305 endif
306
307 TPROG = TestPrograms/test_x86_sha.cxx
308 TOPT = $(SHANI_FLAG)
309 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
310 ifeq ($(strip $(HAVE_OPT)),0)
311 SHA_FLAG = $(SSE42_FLAG) $(SHANI_FLAG)
312 else
313 SHANI_FLAG =
314 endif
315
316 ifeq ($(SSE2_FLAG),)
317 CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
318 else ifeq ($(SSE3_FLAG),)
319 CXXFLAGS += -DCRYPTOPP_DISABLE_SSE3
320 else ifeq ($(SSSE3_FLAG),)
321 CXXFLAGS += -DCRYPTOPP_DISABLE_SSSE3
322 else ifeq ($(SSE41_FLAG),)
323 CXXFLAGS += -DCRYPTOPP_DISABLE_SSE4
324 else ifeq ($(SSE42_FLAG),)
325 CXXFLAGS += -DCRYPTOPP_DISABLE_SSE4
326 endif
327
328 ifneq ($(SSE42_FLAG),)
329
330 # Unusual GCC/Clang on Macports. It assembles AES, but not CLMUL.
331 # test_x86_clmul.s:15: no such instruction: 'pclmulqdq $0, %xmm1,%xmm0'
332 ifeq ($(CLMUL_FLAG),)
333 CXXFLAGS += -DCRYPTOPP_DISABLE_CLMUL
334 endif
335 ifeq ($(AESNI_FLAG),)
336 CXXFLAGS += -DCRYPTOPP_DISABLE_AESNI
337 endif
338
339 ifeq ($(AVX_FLAG),)
340 CXXFLAGS += -DCRYPTOPP_DISABLE_AVX
341 else ifeq ($(AVX2_FLAG),)
342 CXXFLAGS += -DCRYPTOPP_DISABLE_AVX2
343 else ifeq ($(SHANI_FLAG),)
344 CXXFLAGS += -DCRYPTOPP_DISABLE_SHANI
345 endif
346 endif
347
348 # Drop to SSE2 if available
349 ifeq ($(GCM_FLAG),)
350 ifneq ($(SSE2_FLAG),)
351 GCM_FLAG = $(SSE2_FLAG)
352 endif
353 endif
354
355 # Most Clang cannot handle mixed asm with positional arguments, where the
356 # body is Intel style with no prefix and the templates are AT&T style.
357 # Also see https://bugs.llvm.org/show_bug.cgi?id=39895 .
358
359 # CRYPTOPP_DISABLE_MIXED_ASM is now being added in config_asm.h for all
360 # Clang compilers. This test will need to be re-enabled if Clang fixes it.
361 #TPROG = TestPrograms/test_asm_mixed.cxx
362 #HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
363 #ifneq ($(strip $(HAVE_OPT)),0)
364 # CXXFLAGS += -DCRYPTOPP_DISABLE_MIXED_ASM
365 #endif
366
367 # DETECT_FEATURES
368 endif
369
370 # IS_X86, IS_X32 and IS_X64
371 endif
372
373 ###########################################################
374 ##### ARM A-32 and NEON #####
375 ###########################################################
376
377 ifneq ($(IS_ARM32),0)
378 ifeq ($(DETECT_FEATURES),1)
379
380 # Android needs -c compile flag for NEON. Otherwise there's an odd linker message.
381 ifeq ($(IS_ANDROID),1)
382 NEON_FLAG = -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -mfpu=neon
383 else
384 NEON_FLAG = -march=armv7-a -mfloat-abi=$(FP_ABI) -mfpu=neon
385 endif
386
387 # Clang needs an option to include <arm_neon.h>
388 TPROG = TestPrograms/test_arm_neon_header.cxx
389 TOPT = $(NEON_FLAG)
390 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
391 ifeq ($(strip $(HAVE_OPT)),0)
392 THEADER += -DCRYPTOPP_ARM_NEON_HEADER=1
393 endif
394
395 TPROG = TestPrograms/test_arm_neon.cxx
396 TOPT = $(NEON_FLAG)
397 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
398 ifeq ($(strip $(HAVE_OPT)),0)
399 ARIA_FLAG = $(NEON_FLAG)
400 AES_FLAG = $(NEON_FLAG)
401 CRC_FLAG = $(NEON_FLAG)
402 GCM_FLAG = $(NEON_FLAG)
403 BLAKE2B_FLAG = $(NEON_FLAG)
404 BLAKE2S_FLAG = $(NEON_FLAG)
405 CHACHA_FLAG = $(NEON_FLAG)
406 CHAM_FLAG = $(NEON_FLAG)
407 LEA_FLAG = $(NEON_FLAG)
408 SHA_FLAG = $(NEON_FLAG)
409 SIMON128_FLAG = $(NEON_FLAG)
410 SPECK128_FLAG = $(NEON_FLAG)
411 SM4_FLAG = $(NEON_FLAG)
412 else
413 NEON_FLAG =
414 CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
415 endif
416
417 # DETECT_FEATURES
418 endif
419 # IS_ARM32
420 endif
421
422 ###########################################################
423 ##### Aach32 and Aarch64 #####
424 ###########################################################
425
426 ifneq ($(IS_ARMV8),0)
427 ifeq ($(DETECT_FEATURES),1)
428
429 ifeq ($(IS_IOS),1)
430 ASIMD_FLAG =
431 CRC_FLAG =
432 AES_FLAG =
433 PMUL_FLAG =
434 SHA_FLAG =
435 else
436 ASIMD_FLAG = -march=armv8-a
437 CRC_FLAG = -march=armv8-a+crc
438 AES_FLAG = -march=armv8-a+crypto
439 GCM_FLAG = -march=armv8-a+crypto
440 GF2N_FLAG = -march=armv8-a+crypto
441 SHA_FLAG = -march=armv8-a+crypto
442 endif
443
444 TPROG = TestPrograms/test_arm_neon_header.cxx
445 TOPT =
446 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
447 ifeq ($(strip $(HAVE_OPT)),0)
448 THEADER += -DCRYPTOPP_ARM_NEON_HEADER=1
449 endif
450
451 TPROG = TestPrograms/test_arm_acle_header.cxx
452 TOPT = $(ASIMD_FLAG)
453 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
454 ifeq ($(strip $(HAVE_OPT)),0)
455 THEADER += -DCRYPTOPP_ARM_ACLE_HEADER=1
456 endif
457
458 TPROG = TestPrograms/test_arm_asimd.cxx
459 TOPT = $(ASIMD_FLAG)
460 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
461 ifeq ($(strip $(HAVE_OPT)),0)
462 ARIA_FLAG = $(ASIMD_FLAG)
463 BLAKE2B_FLAG = $(ASIMD_FLAG)
464 BLAKE2S_FLAG = $(ASIMD_FLAG)
465 CHACHA_FLAG = $(ASIMD_FLAG)
466 CHAM_FLAG = $(ASIMD_FLAG)
467 LEA_FLAG = $(ASIMD_FLAG)
468 NEON_FLAG = $(ASIMD_FLAG)
469 SIMON128_FLAG = $(ASIMD_FLAG)
470 SPECK128_FLAG = $(ASIMD_FLAG)
471 SM4_FLAG = $(ASIMD_FLAG)
472 else
473 ASIMD_FLAG =
474 CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
475 endif
476
477 TPROG = TestPrograms/test_arm_crc.cxx
478 TOPT = $(CRC_FLAG)
479 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
480 ifneq ($(strip $(HAVE_OPT)),0)
481 CRC_FLAG =
482 CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_CRC32
483 endif
484
485 TPROG = TestPrograms/test_arm_aes.cxx
486 TOPT = $(AES_FLAG)
487 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
488 ifneq ($(strip $(HAVE_OPT)),0)
489 AES_FLAG =
490 CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_AES
491 endif
492
493 TPROG = TestPrograms/test_arm_pmull.cxx
494 TOPT = $(PMULL_FLAG)
495 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
496 ifneq ($(strip $(HAVE_OPT)),0)
497 GCM_FLAG =
498 GF2N_FLAG =
499 CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_PMULL
500 endif
501
502 TPROG = TestPrograms/test_arm_sha1.cxx
503 TOPT = $(SHA_FLAG)
504 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
505 ifneq ($(strip $(HAVE_OPT)),0)
506 SHA_FLAG =
507 CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA1
508 endif
509
510 TPROG = TestPrograms/test_arm_sha256.cxx
511 TOPT = $(SHA_FLAG)
512 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
513 ifneq ($(strip $(HAVE_OPT)),0)
514 SHA_FLAG =
515 CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA2
516 endif
517
518 TPROG = TestPrograms/test_arm_sm3.cxx
519 TOPT = -march=armv8.4-a+crypto
520 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
521 ifeq ($(strip $(HAVE_OPT)),0)
522 SM3_FLAG = -march=armv8.4-a+crypto
523 SM4_FLAG = -march=armv8.4-a+crypto
524 else
525 #CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_SM3
526 #CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_SM4
527 endif
528
529 TPROG = TestPrograms/test_arm_sha3.cxx
530 TOPT = -march=armv8.4-a+crypto
531 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
532 ifeq ($(strip $(HAVE_OPT)),0)
533 SHA3_FLAG = -march=armv8.4-a+crypto
534 SHA512_FLAG = -march=armv8.4-a+crypto
535 else
536 #CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA3
537 #CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_SM4
538 endif
539
540 # DETECT_FEATURES
541 endif
542 # IS_ARMV8
543 endif
544
545 ###########################################################
546 ##### Common #####
547 ###########################################################
548
549 # No ASM for Travis testing
550 ifeq ($(findstring no-asm,$(MAKECMDGOALS)),no-asm)
551 ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),)
552 CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
553 endif # CXXFLAGS
554 endif # No ASM
555
556 # Undefined Behavior Sanitizer (UBsan) testing. Issue 'make ubsan'.
557 ifeq ($(findstring ubsan,$(MAKECMDGOALS)),ubsan)
558 ifeq ($(findstring -fsanitize=undefined,$(CXXFLAGS)),)
559 CXXFLAGS += -fsanitize=undefined
560 endif # CXXFLAGS
561 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CXXFLAGS)),)
562 CXXFLAGS += -DCRYPTOPP_COVERAGE
563 endif # CXXFLAGS
564 endif # UBsan
565
566 # Address Sanitizer (Asan) testing. Issue 'make asan'.
567 ifeq ($(findstring asan,$(MAKECMDGOALS)),asan)
568 ifeq ($(findstring -fsanitize=address,$(CXXFLAGS)),)
569 CXXFLAGS += -fsanitize=address
570 endif # CXXFLAGS
571 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CXXFLAGS)),)
572 CXXFLAGS += -DCRYPTOPP_COVERAGE
573 endif # CXXFLAGS
574 ifeq ($(findstring -fno-omit-frame-pointer,$(CXXFLAGS)),)
575 CXXFLAGS += -fno-omit-frame-pointer
576 endif # CXXFLAGS
577 endif # Asan
578
579 # LD gold linker testing. Triggered by 'LD=ld.gold'.
580 ifeq ($(findstring ld.gold,$(LD)),ld.gold)
581 ifeq ($(findstring -fuse-ld=gold,$(CXXFLAGS)),)
582 ELF_FORMAT := $(shell file `which ld.gold` 2>&1 | cut -d":" -f 2 | $(GREP) -i -c "elf")
583 ifneq ($(ELF_FORMAT),0)
584 LDFLAGS += -fuse-ld=gold
585 endif # ELF/ELF64
586 endif # CXXFLAGS
587 endif # Gold
588
589 # Valgrind testing. Issue 'make valgrind'.
590 ifneq ($(filter valgrind,$(MAKECMDGOALS)),)
591 # Tune flags; see http://valgrind.org/docs/manual/quick-start.html
592 CXXFLAGS := $(CXXFLAGS:-g%=-g3)
593 CXXFLAGS := $(CXXFLAGS:-O%=-O1)
594 CXXFLAGS := $(CXXFLAGS:-xO%=-xO1)
595 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CXXFLAGS)),)
596 CXXFLAGS += -DCRYPTOPP_COVERAGE
597 endif # -DCRYPTOPP_COVERAGE
598 endif # Valgrind
599
600 # Debug testing on GNU systems. Triggered by -DDEBUG.
601 # Newlib test due to http://sourceware.org/bugzilla/show_bug.cgi?id=20268
602 ifneq ($(filter -DDEBUG -DDEBUG=1,$(CXXFLAGS)),)
603 USING_GLIBCXX := $(shell $(CXX) $(CXXFLAGS) -E pch.cpp 2>&1 | $(GREP) -i -c "__GLIBCXX__")
604 ifneq ($(USING_GLIBCXX),0)
605 ifeq ($(HAS_NEWLIB),0)
606 ifeq ($(findstring -D_GLIBCXX_DEBUG,$(CXXFLAGS)),)
607 CXXFLAGS += -D_GLIBCXX_DEBUG
608 endif # CXXFLAGS
609 endif # HAS_NEWLIB
610 endif # USING_GLIBCXX
611 endif # GNU Debug build
612
613 # Dead code stripping. Issue 'make lean'.
614 ifeq ($(findstring lean,$(MAKECMDGOALS)),lean)
615 ifeq ($(findstring -ffunction-sections,$(CXXFLAGS)),)
616 CXXFLAGS += -ffunction-sections
617 endif # CXXFLAGS
618 ifeq ($(findstring -fdata-sections,$(CXXFLAGS)),)
619 CXXFLAGS += -fdata-sections
620 endif # CXXFLAGS
621 ifneq ($(IS_IOS),0)
622 ifeq ($(findstring -Wl,-dead_strip,$(LDFLAGS)),)
623 LDFLAGS += -Wl,-dead_strip
624 endif # CXXFLAGS
625 else # BSD, Linux and Unix
626 ifeq ($(findstring -Wl,--gc-sections,$(LDFLAGS)),)
627 LDFLAGS += -Wl,--gc-sections
628 endif # LDFLAGS
629 endif # MAKECMDGOALS
630 endif # Dead code stripping
631
632 ###########################################################
633 ##### Source and object files #####
634 ###########################################################
635
636 # List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
637 SRCS := cryptlib.cpp cpu.cpp integer.cpp $(filter-out cryptlib.cpp cpu.cpp integer.cpp pch.cpp simple.cpp,$(sort $(wildcard *.cpp)))
638 # For Makefile.am; resource.h is Windows
639 INCL := $(filter-out resource.h,$(sort $(wildcard *.h)))
640
641 # Cryptogams source files. We couple to ARMv7.
642 # Limit to Linux. The source files target the GNU assembler.
643 # Also see https://www.cryptopp.com/wiki/Cryptogams.
644 ifeq ($(IS_ARM32)$(IS_LINUX),11)
645 ifeq ($(CLANG_COMPILER),1)
646 CRYPTOGAMS_ARMV4_FLAG = -march=armv7-a -Wa,--noexecstack
647 CRYPTOGAMS_ARMV4_THUMB_FLAG = -march=armv7-a -mthumb -Wa,--noexecstack
648 else
649 CRYPTOGAMS_ARMV4_FLAG = -march=armv7-a -Wa,--noexecstack
650 CRYPTOGAMS_ARMV4_THUMB_FLAG = -march=armv7-a -Wa,--noexecstack
651 endif
652 SRCS += aes_armv4.S sha1_armv4.S sha256_armv4.S sha512_armv4.S
653 endif
654
655 # Remove unneeded arch specific files to speed build time.
656 ifeq ($(IS_PPC32)$(IS_PPC64),00)
657 SRCS := $(filter-out ppc_%,$(SRCS))
658 endif
659 ifeq ($(IS_ARM32)$(IS_ARMV8),00)
660 SRCS := $(filter-out arm_%,$(SRCS))
661 SRCS := $(filter-out neon_%,$(SRCS))
662 endif
663 ifeq ($(IS_X86)$(IS_X32)$(IS_X64),000)
664 SRCS := $(filter-out sse_%,$(SRCS))
665 endif
666
667 # List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
668 OBJS := $(SRCS:.cpp=.o)
669 OBJS := $(OBJS:.S=.o)
670
671 # List test.cpp first to tame C++ static initialization problems.
672 TESTSRCS := adhoc.cpp test.cpp bench1.cpp bench2.cpp bench3.cpp datatest.cpp dlltest.cpp fipsalgt.cpp validat0.cpp validat1.cpp validat2.cpp validat3.cpp validat4.cpp validat5.cpp validat6.cpp validat7.cpp validat8.cpp validat9.cpp validat10.cpp regtest1.cpp regtest2.cpp regtest3.cpp regtest4.cpp
673 TESTINCL := bench.h factory.h validate.h
674
675 # Test objects
676 TESTOBJS := $(TESTSRCS:.cpp=.o)
677 LIBOBJS := $(filter-out $(TESTOBJS),$(OBJS))
678
679 # For Shared Objects, Diff, Dist/Zip rules
680 LIB_VER := $(shell $(GREP) "define CRYPTOPP_VERSION" config_ver.h | cut -d" " -f 3)
681 LIB_MAJOR := $(shell echo $(LIB_VER) | cut -c 1)
682 LIB_MINOR := $(shell echo $(LIB_VER) | cut -c 2)
683 LIB_PATCH := $(shell echo $(LIB_VER) | cut -c 3)
684
685 ifeq ($(strip $(LIB_PATCH)),)
686 LIB_PATCH := 0
687 endif
688
689 ifeq ($(HAS_SOLIB_VERSION),1)
690 # Full version suffix for shared library
691 SOLIB_VERSION_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)
692 # Different patchlevels and minors are compatible since 6.1
693 SOLIB_COMPAT_SUFFIX=.$(LIB_MAJOR)
694 SOLIB_FLAGS=-Wl,-soname,libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
695 endif # HAS_SOLIB_VERSION
696
697 ###########################################################
698 ##### Targets and Recipes #####
699 ###########################################################
700
701 # Default builds program with static library only
702 .PHONY: default
703 default: cryptest.exe
704
705 .PHONY: all static dynamic
706 all: static dynamic cryptest.exe
707
708 ifneq ($(IS_IOS),0)
709 static: libcryptopp.a
710 shared dynamic dylib: libcryptopp.dylib
711 else
712 static: libcryptopp.a
713 shared dynamic: libcryptopp.so$(SOLIB_VERSION_SUFFIX)
714 endif
715
716 .PHONY: test check
717 test check: cryptest.exe
718 ./cryptest.exe v
719
720 # CXXFLAGS are tuned earlier. Applications must use linker flags
721 # -Wl,--gc-sections (Linux and Unix) or -Wl,-dead_strip (OS X)
722 .PHONY: lean
723 lean: static dynamic cryptest.exe
724
725 .PHONY: clean
726 clean:
727 -$(RM) adhoc.cpp.o adhoc.cpp.proto.o $(LIBOBJS) $(ANDROID_CPU_OBJ) rdrand-*.o $(TESTOBJS) $(DLLOBJS) $(LIBIMPORTOBJS) $(TESTIMPORTOBJS) $(DLLTESTOBJS)
728 @-$(RM) libcryptopp.a libcryptopp.dylib cryptopp.dll libcryptopp.dll.a libcryptopp.import.a
729 @-$(RM) libcryptopp.so libcryptopp.so$(SOLIB_COMPAT_SUFFIX) libcryptopp.so$(SOLIB_VERSION_SUFFIX)
730 @-$(RM) cryptest.exe dlltest.exe cryptest.import.exe cryptest.info ct et
731 @-$(RM) *.la *.lo *.gcov *.gcno *.gcda *.stackdump core core-*
732 @-$(RM) /tmp/adhoc.exe
733 @-$(RM) -r /tmp/cryptopp_test/
734 @-$(RM) -r *.exe.dSYM/
735 @-$(RM) -r *.dylib.dSYM/
736 @-$(RM) -r cov-int/
737
738 .PHONY: autotools-clean
739 autotools-clean:
740 @-$(RM) -f configure.ac configure configure.in Makefile.am Makefile.in Makefile
741 @-$(RM) -f config.guess config.status config.sub config.h.in compile depcomp
742 @-$(RM) -f install-sh stamp-h1 ar-lib *.lo *.la *.m4 local.* lt*.sh missing
743 @-$(RM) -f cryptest cryptestcwd libtool* libcryptopp.la libcryptopp.pc*
744 @-$(RM) -rf build-aux/ m4/ auto*.cache/ .deps/ .libs/
745
746 .PHONY: cmake-clean
747 cmake-clean:
748 @-$(RM) -f cryptopp-config.cmake CMakeLists.txt
749 @-$(RM) -rf cmake_build/
750
751 .PHONY: android-clean
752 android-clean:
753 @-$(RM) -f $(patsubst %_simd.cpp,%_simd.cpp.neon,$(wildcard *_simd.cpp))
754 @-$(RM) -rf obj/
755
756 .PHONY: distclean
757 distclean: clean autotools-clean cmake-clean android-clean
758 -$(RM) adhoc.cpp adhoc.cpp.copied GNUmakefile.deps benchmarks.html cryptest.txt
759 @-$(RM) cryptest-*.txt cryptopp.tgz libcryptopp.pc *.o *.bc *.ii *~
760 @-$(RM) -r cryptlib.lib cryptest.exe *.suo *.sdf *.pdb Win32/ x64/ ipch/
761 @-$(RM) -r $(LIBOBJS:.o=.obj) $(TESTOBJS:.o=.obj)
762 @-$(RM) -r $(LIBOBJS:.o=.lst) $(TESTOBJS:.o=.lst)
763 @-$(RM) -r TestCoverage/ ref*/
764 @-$(RM) cryptopp$(LIB_VER)\.* CryptoPPRef.zip
765
766 # Install cryptest.exe, libcryptopp.a and libcryptopp.so.
767 # The library install was broken-out into its own recipe at GH #653.
768 .PHONY: install
769 install: cryptest.exe install-lib
770 @-$(MKDIR) $(DESTDIR)$(BINDIR)
771 $(CP) cryptest.exe $(DESTDIR)$(BINDIR)
772 $(CHMOD) 0755 $(DESTDIR)$(BINDIR)/cryptest.exe
773 @-$(MKDIR) $(DESTDIR)$(DATADIR)/cryptopp/TestData
774 @-$(MKDIR) $(DESTDIR)$(DATADIR)/cryptopp/TestVectors
775 $(CP) TestData/*.dat $(DESTDIR)$(DATADIR)/cryptopp/TestData
776 $(CHMOD) 0644 $(DESTDIR)$(DATADIR)/cryptopp/TestData/*.dat
777 $(CP) TestVectors/*.txt $(DESTDIR)$(DATADIR)/cryptopp/TestVectors
778 $(CHMOD) 0644 $(DESTDIR)$(DATADIR)/cryptopp/TestVectors/*.txt
779
780 # A recipe to install only the library, and not cryptest.exe. Also
781 # see https://github.com/weidai11/cryptopp/issues/653.
782 .PHONY: install-lib
783 install-lib:
784 @-$(MKDIR) $(DESTDIR)$(INCLUDEDIR)/cryptopp
785 $(CP) *.h $(DESTDIR)$(INCLUDEDIR)/cryptopp
786 $(CHMOD) 0644 $(DESTDIR)$(INCLUDEDIR)/cryptopp/*.h
787 ifneq ($(wildcard libcryptopp.a),)
788 @-$(MKDIR) $(DESTDIR)$(LIBDIR)
789 $(CP) libcryptopp.a $(DESTDIR)$(LIBDIR)
790 $(CHMOD) 0644 $(DESTDIR)$(LIBDIR)/libcryptopp.a
791 endif
792 ifneq ($(wildcard libcryptopp.dylib),)
793 @-$(MKDIR) $(DESTDIR)$(LIBDIR)
794 $(CP) libcryptopp.dylib $(DESTDIR)$(LIBDIR)
795 $(CHMOD) 0755 $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
796 -install_name_tool -id $(DESTDIR)$(LIBDIR)/libcryptopp.dylib $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
797 endif
798 ifneq ($(wildcard libcryptopp.so$(SOLIB_VERSION_SUFFIX)),)
799 @-$(MKDIR) $(DESTDIR)$(LIBDIR)
800 $(CP) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)
801 $(CHMOD) 0755 $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
802 ifeq ($(HAS_SOLIB_VERSION),1)
803 -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so
804 $(LDCONF) $(DESTDIR)$(LIBDIR)
805 endif
806 endif
807 ifneq ($(wildcard libcryptopp.pc),)
808 @-$(MKDIR) $(DESTDIR)$(LIBDIR)/pkgconfig
809 $(CP) libcryptopp.pc $(DESTDIR)$(LIBDIR)/pkgconfig
810 $(CHMOD) 0644 $(DESTDIR)$(LIBDIR)/pkgconfig/libcryptopp.pc
811 endif
812
813 .PHONY: remove uninstall
814 remove uninstall:
815 -$(RM) -r $(DESTDIR)$(INCLUDEDIR)/cryptopp
816 -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.a
817 -$(RM) $(DESTDIR)$(BINDIR)/cryptest.exe
818 @-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
819 @-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
820 @-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
821 @-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so
822
823 libcryptopp.a: $(LIBOBJS) $(ANDROID_CPU_OBJ)
824 $(AR) $(ARFLAGS) $@ $(LIBOBJS) $(ANDROID_CPU_OBJ)
825 $(RANLIB) $@
826
827 ifeq ($(HAS_SOLIB_VERSION),1)
828 .PHONY: libcryptopp.so
829 libcryptopp.so: libcryptopp.so$(SOLIB_VERSION_SUFFIX)
830 endif
831
832 libcryptopp.so$(SOLIB_VERSION_SUFFIX): $(LIBOBJS) $(ANDROID_CPU_OBJ)
833 $(CXX) -shared $(SOLIB_FLAGS) -o $@ $(strip $(CXXFLAGS)) -Wl,--exclude-libs,ALL $(LIBOBJS) $(ANDROID_CPU_OBJ) $(LDFLAGS) $(LDLIBS)
834 ifeq ($(HAS_SOLIB_VERSION),1)
835 -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.so
836 -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
837 endif
838
839 libcryptopp.dylib: $(LIBOBJS)
840 $(CXX) -dynamiclib -o $@ $(strip $(CXXFLAGS)) -install_name "$@" -current_version "$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)" -compatibility_version "$(LIB_MAJOR).$(LIB_MINOR)" -headerpad_max_install_names $(LDFLAGS) $(LIBOBJS)
841
842 cryptest.exe: $(LINK_LIBRARY) $(TESTOBJS)
843 $(CXX) -o $@ $(strip $(CXXFLAGS)) $(TESTOBJS) $(LINK_LIBRARY_PATH)$(LINK_LIBRARY) $(LDFLAGS) $(LDLIBS)
844
845 # Used to generate list of source files for Autotools, CMakeList and Android.mk
846 .PHONY: sources
847 sources:
848 $(info ***** Library sources *****)
849 $(info $(filter-out $(TESTSRCS),$(SRCS)))
850 $(info )
851 $(info ***** Library headers *****)
852 $(info $(filter-out $(TESTINCL),$(INCL)))
853 $(info )
854 $(info ***** Test sources *****)
855 $(info $(TESTSRCS))
856 $(info )
857 $(info ***** Test headers *****)
858 $(info $(TESTINCL))
859
860 adhoc.cpp: adhoc.cpp.proto
861 ifeq ($(wildcard adhoc.cpp),)
862 cp adhoc.cpp.proto adhoc.cpp
863 else
864 touch adhoc.cpp
865 endif
866
867 # Include dependencies, if present. You must issue `make deps` to create them.
868 ifeq ($(wildcard GNUmakefile.deps),GNUmakefile.deps)
869 -include GNUmakefile.deps
870 endif # Dependencies
871
872 # Cryptogams ARM asm implementation. AES needs -mthumb for Clang
873 aes_armv4.o : aes_armv4.S
874 $(CXX) $(strip $(CXXFLAGS) $(CRYPTOGAMS_ARMV4_THUMB_FLAG) -c) $<
875
876 # Use C++ compiler on C source after patching.
877 # https://github.com/weidai11/cryptopp/issues/926
878 cpu-features.o: cpu-features.h cpu-features.c
879 $(CXX) -x c $(strip $(CXXFLAGS) -c) cpu-features.c
880
881 # SSSE3 or NEON available
882 aria_simd.o : aria_simd.cpp
883 $(CXX) $(strip $(CXXFLAGS) $(ARIA_FLAG) -c) $<
884
885 # SSE, NEON or POWER7 available
886 blake2s_simd.o : blake2s_simd.cpp
887 $(CXX) $(strip $(CXXFLAGS) $(BLAKE2S_FLAG) -c) $<
888
889 # SSE, NEON or POWER8 available
890 blake2b_simd.o : blake2b_simd.cpp
891 $(CXX) $(strip $(CXXFLAGS) $(BLAKE2B_FLAG) -c) $<
892
893 # SSE2 or NEON available
894 chacha_simd.o : chacha_simd.cpp
895 $(CXX) $(strip $(CXXFLAGS) $(CHACHA_FLAG) -c) $<
896
897 # AVX2 available
898 chacha_avx.o : chacha_avx.cpp
899 $(CXX) $(strip $(CXXFLAGS) $(CHACHA_AVX2_FLAG) -c) $<
900
901 # SSSE3 available
902 cham_simd.o : cham_simd.cpp
903 $(CXX) $(strip $(CXXFLAGS) $(CHAM_FLAG) -c) $<
904
905 # Power9 available
906 darn.o : darn.cpp
907 $(CXX) $(strip $(CXXFLAGS) $(DARN_FLAG) -c) $<
908
909 # SSE2 on i686
910 donna_sse.o : donna_sse.cpp
911 $(CXX) $(strip $(CXXFLAGS) $(SSE2_FLAG) -c) $<
912
913 # SSE2 on i686
914 sse_simd.o : sse_simd.cpp
915 $(CXX) $(strip $(CXXFLAGS) $(SSE2_FLAG) -c) $<
916
917 # SSE4.2 or ARMv8a available
918 crc_simd.o : crc_simd.cpp
919 $(CXX) $(strip $(CXXFLAGS) $(CRC_FLAG) -c) $<
920
921 # PCLMUL or ARMv7a/ARMv8a available
922 gcm_simd.o : gcm_simd.cpp
923 $(CXX) $(strip $(CXXFLAGS) $(GCM_FLAG) -c) $<
924
925 # Carryless multiply
926 gf2n_simd.o : gf2n_simd.cpp
927 $(CXX) $(strip $(CXXFLAGS) $(GF2N_FLAG) -c) $<
928
929 # SSSE3 available
930 lea_simd.o : lea_simd.cpp
931 $(CXX) $(strip $(CXXFLAGS) $(LEA_FLAG) -c) $<
932
933 # NEON available
934 neon_simd.o : neon_simd.cpp
935 $(CXX) $(strip $(CXXFLAGS) $(NEON_FLAG) -c) $<
936
937 # AESNI or ARMv7a/ARMv8a available
938 rijndael_simd.o : rijndael_simd.cpp
939 $(CXX) $(strip $(CXXFLAGS) $(AES_FLAG) -c) $<
940
941 # SSE4.2/SHA-NI or ARMv8a available
942 sha_simd.o : sha_simd.cpp
943 $(CXX) $(strip $(CXXFLAGS) $(SHA_FLAG) -c) $<
944
945 # Cryptogams SHA1 asm implementation.
946 sha1_armv4.o : sha1_armv4.S
947 $(CXX) $(strip $(CXXFLAGS) $(CRYPTOGAMS_ARMV4_FLAG) -c) $<
948
949 # Cryptogams SHA256 asm implementation.
950 sha256_armv4.o : sha256_armv4.S
951 $(CXX) $(strip $(CXXFLAGS) $(CRYPTOGAMS_ARMV4_FLAG) -c) $<
952
953 # Cryptogams SHA512 asm implementation.
954 sha512_armv4.o : sha512_armv4.S
955 $(CXX) $(strip $(CXXFLAGS) $(CRYPTOGAMS_ARMV4_FLAG) -c) $<
956
957 # SSE4.2/SHA-NI or ARMv8a available
958 shacal2_simd.o : shacal2_simd.cpp
959 $(CXX) $(strip $(CXXFLAGS) $(SHA_FLAG) -c) $<
960
961 # SSSE3, NEON or POWER8 available
962 simon128_simd.o : simon128_simd.cpp
963 $(CXX) $(strip $(CXXFLAGS) $(SIMON128_FLAG) -c) $<
964
965 # SSSE3, NEON or POWER8 available
966 speck128_simd.o : speck128_simd.cpp
967 $(CXX) $(strip $(CXXFLAGS) $(SPECK128_FLAG) -c) $<
968
969 # ARMv8.4 available
970 sm3_simd.o : sm3_simd.cpp
971 $(CXX) $(strip $(CXXFLAGS) $(SM3_FLAG) -c) $<
972
973 # AESNI available
974 sm4_simd.o : sm4_simd.cpp
975 $(CXX) $(strip $(CXXFLAGS) $(SM4_FLAG) -c) $<
976
977 %.o : %.cpp
978 $(CXX) $(strip $(CXXFLAGS) -c) $<
979
980 .PHONY: dep deps depend
981 dep deps depend GNUmakefile.deps:
982 $(CXX) $(strip $(CXXFLAGS)) -MM *.cpp > GNUmakefile.deps
983