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