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