1 ###########################################################
2 ##### System Attributes and Programs #####
3 ###########################################################
5 # https://www.gnu.org/software/make/manual/make.html#Makefile-Conventions
6 # and https://www.gnu.org/prep/standards/standards.html
12 # Used for feature tests
14 TOUT := $(strip $(TOUT))
16 # Allow override for the cryptest recipe. Change to
17 # ./libcrypto++.so or ./libcrypto++.dylib to suit your
18 # taste. https://github.com/weidai11/cryptopp/issues/866
19 LINK_LIBRARY ?= libcrypto++.a
20 LINK_LIBRARY_PATH ?= ./
22 # Command and arguments
24 ARFLAGS ?= -cr # ar needs the dash on OpenBSD
36 LDCONF ?= /sbin/ldconfig -n
38 # Solaris provides a non-Posix sed and grep at /usr/bin
39 # Solaris 10 is missing AR in /usr/bin
40 ifneq ($(wildcard /usr/xpg4/bin/grep),)
41 GREP := /usr/xpg4/bin/grep
43 ifneq ($(wildcard /usr/xpg4/bin/sed),)
44 SED := /usr/xpg4/bin/sed
46 ifneq ($(wildcard /usr/xpg4/bin/ar),)
47 AR := /usr/xpg4/bin/ar
50 # Clang is reporting armv8l-unknown-linux-gnueabihf
51 # for ARMv7 images on Aarch64 hardware.
52 MACHINEX := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null)
53 HOSTX := $(shell echo $(MACHINEX) | cut -f 1 -d '-')
55 HOSTX := $(shell uname -m 2>/dev/null)
58 IS_X86 := $(shell echo "$(HOSTX)" | $(GREP) -v "64" | $(GREP) -i -c -E 'i.86|x86|i86')
59 IS_X64 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E '_64|d64')
60 IS_PPC32 := $(shell echo "$(HOSTX)" | $(GREP) -v "64" | $(GREP) -i -c -E 'ppc|power')
61 IS_PPC64 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E 'ppc64|powerpc64|power64')
62 IS_SPARC32 := $(shell echo "$(HOSTX)" | $(GREP) -v "64" | $(GREP) -i -c -E 'sun|sparc')
63 IS_SPARC64 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E 'sun|sparc64')
64 IS_ARM32 := $(shell echo "$(HOSTX)" | $(GREP) -v "64" | $(GREP) -i -c -E 'arm|armhf|armv7|eabihf|armv8')
65 IS_ARMV8 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E 'aarch32|aarch64|arm64')
67 # Attempt to determine platform
68 SYSTEMX := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null)
70 SYSTEMX := $(shell uname -s 2>/dev/null)
73 IS_LINUX := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "Linux")
74 IS_HURD := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c -E "GNU|Hurd")
75 IS_MINGW := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "MinGW")
76 IS_CYGWIN := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "Cygwin")
77 IS_DARWIN := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "Darwin")
78 IS_NETBSD := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "NetBSD")
79 IS_AIX := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "aix")
80 IS_SUN := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c -E "SunOS|Solaris")
82 SUN_COMPILER := $(shell $(CXX) -V 2>&1 | $(GREP) -i -c -E 'CC: (Sun|Studio)')
83 GCC_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -v -E '(llvm|clang)' | $(GREP) -i -c -E '(gcc|g\+\+)')
84 XLC_COMPILER := $(shell $(CXX) -qversion 2>/dev/null |$(GREP) -i -c "IBM XL")
85 CLANG_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -i -c -E '(llvm|clang)')
86 INTEL_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -i -c '\(icc\)')
88 # Enable shared object versioning for Linux and Solaris
89 HAS_SOLIB_VERSION ?= 0
90 ifneq ($(IS_LINUX)$(IS_HURD)$(IS_SUN),000)
91 HAS_SOLIB_VERSION := 1
94 # Formerly adhoc.cpp was created from adhoc.cpp.proto when needed.
95 ifeq ($(wildcard adhoc.cpp),)
96 $(shell cp adhoc.cpp.proto adhoc.cpp)
99 # Hack to skip CPU feature tests for some recipes
101 ifneq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CPPFLAGS)$(CXXFLAGS)),)
103 else ifneq ($(findstring clean,$(MAKECMDGOALS)),)
105 else ifneq ($(findstring distclean,$(MAKECMDGOALS)),)
107 else ifneq ($(findstring trim,$(MAKECMDGOALS)),)
109 else ifneq ($(findstring zip,$(MAKECMDGOALS)),)
113 # Strip out -Wall, -Wextra and friends for feature testing. FORTIFY_SOURCE is removed
114 # because it requires -O1 or higher, but we use -O0 to tame the optimizer.
115 # Always print testing flags since some tests always happen, like 64-bit.
116 TCXXFLAGS := $(filter-out -D_FORTIFY_SOURCE=% -M -MM -Wall -Wextra -Werror% -Wunused -Wconversion -Wp%, $(CPPFLAGS) $(CXXFLAGS))
117 ifneq ($(strip $(TCXXFLAGS)),)
118 $(info Using testing flags: $(TCXXFLAGS))
121 # TCOMMAND is used for just about all tests. Make will lazy-evaluate
122 # the variables when executed by $(shell $(TCOMMAND) ...).
123 TCOMMAND = $(CXX) $(TCXXFLAGS) $(TEXTRA) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT)
127 TPROG = TestPrograms/test_64bit.cpp
129 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
130 ifeq ($(strip $(HAVE_OPT)),0)
137 # Uncomment for debugging
138 # $(info Here's what we found... IS_X86: $(IS_X86), IS_X64: $(IS_X64), IS_ARM32: $(IS_ARM32), IS_ARMV8: $(IS_ARMV8))
140 ###########################################################
141 ##### General Variables #####
142 ###########################################################
144 # Base CPPFLAGS and CXXFLAGS used if the user did not specify them
146 CRYPTOPP_CPPFLAGS += -DNDEBUG
149 ifeq ($(SUN_COMPILER),1)
150 CRYPTOPP_CXXFLAGS += -g -xO3
153 CRYPTOPP_CXXFLAGS += -g2 -O3
158 # Needed when the assembler is invoked
159 ifeq ($(findstring $(ASFLAGS),-Wa,--noexecstack),)
160 CRYPTOPP_ASFLAGS ?= -Wa,--noexecstack
163 # Fix CXX on Cygwin 1.1.4
168 # On ARM we may compile aes_armv4.S, sha1_armv4.S, sha256_armv4.S, and
169 # sha512_armv4.S through the CC compiler
170 ifeq ($(GCC_COMPILER),1)
172 else ifeq ($(CLANG_COMPILER),1)
176 # http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
179 PC_PREFIX = /usr/local
181 PC_PREFIX = $(PREFIX)
184 LIBDIR := $(PREFIX)/lib
185 PC_LIBDIR = $${prefix}/lib
187 PC_LIBDIR = $(LIBDIR)
190 DATADIR := $(PREFIX)/share
191 PC_DATADIR = $${prefix}/share
193 PC_DATADIR = $(DATADIR)
195 ifeq ($(INCLUDEDIR),)
196 INCLUDEDIR := $(PREFIX)/include
197 PC_INCLUDEDIR = $${prefix}/include
199 PC_INCLUDEDIR = $(INCLUDEDIR)
202 BINDIR := $(PREFIX)/bin
205 # We honor ARFLAGS, but the "v" option used by default causes a noisy make
210 # Original MinGW targets Win2k by default, but lacks proper Win2k support
211 # if target Windows version is not specified, use Windows XP instead
213 ifeq ($(findstring -D_WIN32_WINNT,$(CPPFLAGS)$(CXXFLAGS)),)
214 ifeq ($(findstring -D_WIN32_WINDOWS,$(CPPFLAGS)$(CXXFLAGS)),)
215 ifeq ($(findstring -DWINVER,$(CPPFLAGS)$(CXXFLAGS)),)
216 ifeq ($(findstring -DNTDDI_VERSION,$(CPPFLAGS)$(CXXFLAGS)),)
217 CRYPTOPP_CPPFLAGS += -D_WIN32_WINNT=0x0501
218 endif # NTDDI_VERSION
220 endif # _WIN32_WINDOWS
224 # Newlib needs _XOPEN_SOURCE=600 for signals
225 TPROG = TestPrograms/test_newlib.cpp
227 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
228 ifeq ($(strip $(HAVE_OPT)),0)
229 ifeq ($(findstring -D_XOPEN_SOURCE,$(CPPFLAGS)$(CXXFLAGS)),)
230 CRYPTOPP_CPPFLAGS += -D_XOPEN_SOURCE=600
234 ###########################################################
235 ##### X86/X32/X64 Options #####
236 ###########################################################
238 ifneq ($(IS_X86)$(IS_X64)$(IS_MINGW),000)
239 ifeq ($(DETECT_FEATURES),1)
241 ifeq ($(SUN_COMPILER),1)
242 SSE2_FLAG = -xarch=sse2
243 SSE3_FLAG = -xarch=sse3
244 SSSE3_FLAG = -xarch=ssse3
245 SSE41_FLAG = -xarch=sse4_1
246 SSE42_FLAG = -xarch=sse4_2
247 CLMUL_FLAG = -xarch=aes
248 AESNI_FLAG = -xarch=aes
249 AVX_FLAG = -xarch=avx
250 AVX2_FLAG = -xarch=avx2
251 SHANI_FLAG = -xarch=sha
256 SSE41_FLAG = -msse4.1
257 SSE42_FLAG = -msse4.2
258 CLMUL_FLAG = -mpclmul
265 # Tell MacPorts and Homebrew GCC to use Clang integrated assembler
266 # Intel-based Macs. http://github.com/weidai11/cryptopp/issues/190
267 ifneq ($(IS_DARWIN),0)
268 ifeq ($(findstring -Wa,-q,$(CXXFLAGS)),)
269 TPROG = TestPrograms/test_cxx.cpp
271 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
272 ifeq ($(strip $(HAVE_OPT)),0)
274 CRYPTOPP_CXXFLAGS += -Wa,-q
279 TPROG = TestPrograms/test_x86_sse2.cpp
281 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
282 ifeq ($(strip $(HAVE_OPT)),0)
283 CHACHA_FLAG = $(SSE2_FLAG)
284 SUN_LDFLAGS += $(SSE2_FLAG)
286 # Make does not have useful debugging facilities. Show the user
287 # what happened by compiling again without the pipe.
288 $(info Running make again to see what failed)
289 $(info $(shell $(TCOMMAND)))
294 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ASM
297 # Need SSE2 or higher for these tests
298 ifneq ($(SSE2_FLAG),)
300 TPROG = TestPrograms/test_x86_ssse3.cpp
302 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
303 ifeq ($(strip $(HAVE_OPT)),0)
304 ARIA_FLAG = $(SSSE3_FLAG)
305 CHAM_FLAG = $(SSSE3_FLAG)
306 KECCAK_FLAG = $(SSSE3_FLAG)
307 LEA_FLAG = $(SSSE3_FLAG)
308 LSH256_FLAG = $(SSSE3_FLAG)
309 LSH512_FLAG = $(SSSE3_FLAG)
310 SIMON128_FLAG = $(SSSE3_FLAG)
311 SPECK128_FLAG = $(SSSE3_FLAG)
312 SUN_LDFLAGS += $(SSSE3_FLAG)
317 # The first Apple MacBooks were Core2's with SSE4.1
318 ifneq ($(IS_DARWIN),0)
319 # Add SSE2 algo's here as required
320 # They get a free upgrade
323 TPROG = TestPrograms/test_x86_sse41.cpp
325 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
326 ifeq ($(strip $(HAVE_OPT)),0)
327 BLAKE2B_FLAG = $(SSE41_FLAG)
328 BLAKE2S_FLAG = $(SSE41_FLAG)
329 SUN_LDFLAGS += $(SSE41_FLAG)
334 TPROG = TestPrograms/test_x86_sse42.cpp
336 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
337 ifeq ($(strip $(HAVE_OPT)),0)
338 CRC_FLAG = $(SSE42_FLAG)
339 SUN_LDFLAGS += $(SSE42_FLAG)
344 TPROG = TestPrograms/test_x86_clmul.cpp
346 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
347 ifeq ($(strip $(HAVE_OPT)),0)
348 GCM_FLAG = $(SSSE3_FLAG) $(CLMUL_FLAG)
349 GF2N_FLAG = $(CLMUL_FLAG)
350 SUN_LDFLAGS += $(CLMUL_FLAG)
355 TPROG = TestPrograms/test_x86_aes.cpp
357 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
358 ifeq ($(strip $(HAVE_OPT)),0)
359 AES_FLAG = $(SSE41_FLAG) $(AESNI_FLAG)
360 SM4_FLAG = $(SSSE3_FLAG) $(AESNI_FLAG)
361 SUN_LDFLAGS += $(AESNI_FLAG)
366 TPROG = TestPrograms/test_x86_avx.cpp
368 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
369 ifeq ($(strip $(HAVE_OPT)),0)
370 # XXX_FLAG = $(AVX_FLAG)
371 SUN_LDFLAGS += $(AVX_FLAG)
376 TPROG = TestPrograms/test_x86_avx2.cpp
378 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
379 ifeq ($(strip $(HAVE_OPT)),0)
380 CHACHA_AVX2_FLAG = $(AVX2_FLAG)
381 LSH256_AVX2_FLAG = $(AVX2_FLAG)
382 LSH512_AVX2_FLAG = $(AVX2_FLAG)
383 SUN_LDFLAGS += $(AVX2_FLAG)
388 TPROG = TestPrograms/test_x86_sha.cpp
390 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
391 ifeq ($(strip $(HAVE_OPT)),0)
392 SHA_FLAG = $(SSE42_FLAG) $(SHANI_FLAG)
393 SUN_LDFLAGS += $(SHANI_FLAG)
398 ifeq ($(SUN_COMPILER),1)
399 CRYPTOPP_LDFLAGS += $(SUN_LDFLAGS)
403 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_SSE3
404 else ifeq ($(SSSE3_FLAG),)
405 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_SSSE3
406 else ifeq ($(SSE41_FLAG),)
407 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_SSE4
408 else ifeq ($(SSE42_FLAG),)
409 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_SSE4
412 ifneq ($(SSE42_FLAG),)
413 # Unusual GCC/Clang on Macports. It assembles AES, but not CLMUL.
414 # test_x86_clmul.s:15: no such instruction: 'pclmulqdq $0, %xmm1,%xmm0'
415 ifeq ($(CLMUL_FLAG),)
416 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_CLMUL
418 ifeq ($(AESNI_FLAG),)
419 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_AESNI
423 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_AVX
424 else ifeq ($(AVX2_FLAG),)
425 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_AVX2
427 # SHANI independent of AVX per GH #1045
428 ifeq ($(SHANI_FLAG),)
429 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_SHANI
433 # Drop to SSE2 if available
435 GCM_FLAG = $(SSE2_FLAG)
438 # Most Clang cannot handle mixed asm with positional arguments, where the
439 # body is Intel style with no prefix and the templates are AT&T style.
440 # Also see https://bugs.llvm.org/show_bug.cgi?id=39895 .
442 # CRYPTOPP_DISABLE_MIXED_ASM is now being added in config_asm.h for all
443 # Clang compilers. This test will need to be re-enabled if Clang fixes it.
444 #TPROG = TestPrograms/test_asm_mixed.cpp
446 #HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
447 #ifneq ($(strip $(HAVE_OPT)),0)
448 # CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_MIXED_ASM
456 ifneq ($(INTEL_COMPILER),0)
457 CRYPTOPP_CXXFLAGS += -wd68 -wd186 -wd279 -wd327 -wd161 -wd3180
459 ICC111_OR_LATER := $(shell $(CXX) --version 2>&1 | $(GREP) -c -E "\(ICC\) ([2-9][0-9]|1[2-9]|11\.[1-9])")
460 ifeq ($(ICC111_OR_LATER),0)
461 # "internal error: backend signals" occurs on some x86 inline assembly with ICC 9 and
462 # some x64 inline assembly with ICC 11.0. If you want to use Crypto++'s assembly code
463 # with ICC, try enabling it on individual files
464 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ASM
468 # Allow use of "/" operator for GNU Assembler.
469 # http://sourceware.org/bugzilla/show_bug.cgi?id=4572
470 ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CPPFLAGS)$(CXXFLAGS)),)
471 ifeq ($(IS_SUN)$(GCC_COMPILER),11)
472 CRYPTOPP_CXXFLAGS += -Wa,--divide
476 # IS_X86, IS_X32 and IS_X64
479 ###########################################################
480 ##### ARM A-32 and NEON #####
481 ###########################################################
483 ifneq ($(IS_ARM32),0)
485 # No need for feature detection on this platform if NEON is disabled
486 ifneq ($(findstring -DCRYPTOPP_DISABLE_ARM_NEON,$(CPPFLAGS)$(CXXFLAGS)),)
490 ifeq ($(DETECT_FEATURES),1)
492 # Clang needs an option to include <arm_neon.h>
493 TPROG = TestPrograms/test_arm_neon_header.cpp
494 TOPT = -DCRYPTOPP_ARM_NEON_HEADER=1 -march=armv7-a -mfpu=neon
495 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
496 ifeq ($(strip $(HAVE_OPT)),0)
497 TEXTRA += -DCRYPTOPP_ARM_NEON_HEADER=1
500 TPROG = TestPrograms/test_arm_neon.cpp
501 TOPT = -march=armv7-a -mfpu=neon
502 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
503 ifeq ($(strip $(HAVE_OPT)),0)
504 NEON_FLAG = -march=armv7-a -mfpu=neon
505 ARIA_FLAG = -march=armv7-a -mfpu=neon
506 GCM_FLAG = -march=armv7-a -mfpu=neon
507 BLAKE2B_FLAG = -march=armv7-a -mfpu=neon
508 BLAKE2S_FLAG = -march=armv7-a -mfpu=neon
509 CHACHA_FLAG = -march=armv7-a -mfpu=neon
510 CHAM_FLAG = -march=armv7-a -mfpu=neon
511 LEA_FLAG = -march=armv7-a -mfpu=neon
512 SIMON128_FLAG = -march=armv7-a -mfpu=neon
513 SPECK128_FLAG = -march=armv7-a -mfpu=neon
514 SM4_FLAG = -march=armv7-a -mfpu=neon
516 # Make does not have useful debugging facilities. Show the user
517 # what happened by compiling again without the pipe.
518 $(info Running make again to see what failed)
519 $(info $(shell $(TCOMMAND)))
524 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ASM
532 ###########################################################
533 ##### Aach32 and Aarch64 #####
534 ###########################################################
536 ifneq ($(IS_ARMV8),0)
537 ifeq ($(DETECT_FEATURES),1)
539 TPROG = TestPrograms/test_arm_neon_header.cpp
540 TOPT = -DCRYPTOPP_ARM_NEON_HEADER=1
541 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
542 ifeq ($(strip $(HAVE_OPT)),0)
543 TEXTRA += -DCRYPTOPP_ARM_NEON_HEADER=1
546 TPROG = TestPrograms/test_arm_acle_header.cpp
547 TOPT = -DCRYPTOPP_ARM_ACLE_HEADER=1 -march=armv8-a
548 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
549 ifeq ($(strip $(HAVE_OPT)),0)
550 TEXTRA += -DCRYPTOPP_ARM_ACLE_HEADER=1
553 TPROG = TestPrograms/test_arm_asimd.cpp
554 TOPT = -march=armv8-a
555 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
556 ifeq ($(strip $(HAVE_OPT)),0)
557 ASIMD_FLAG = -march=armv8-a
558 ARIA_FLAG = -march=armv8-a
559 BLAKE2B_FLAG = -march=armv8-a
560 BLAKE2S_FLAG = -march=armv8-a
561 CHACHA_FLAG = -march=armv8-a
562 CHAM_FLAG = -march=armv8-a
563 LEA_FLAG = -march=armv8-a
564 NEON_FLAG = -march=armv8-a
565 SIMON128_FLAG = -march=armv8-a
566 SPECK128_FLAG = -march=armv8-a
567 SM4_FLAG = -march=armv8-a
569 # Make does not have useful debugging facilities. Show the user
570 # what happened by compiling again without the pipe.
571 $(info Running make again to see what failed)
572 $(info $(shell $(TCOMMAND)))
576 ifeq ($(ASIMD_FLAG),)
577 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ASM
580 ifneq ($(ASIMD_FLAG),)
581 TPROG = TestPrograms/test_arm_crc.cpp
582 TOPT = -march=armv8-a+crc
583 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
584 ifeq ($(strip $(HAVE_OPT)),0)
585 CRC_FLAG = -march=armv8-a+crc
587 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_CRC32
590 TPROG = TestPrograms/test_arm_aes.cpp
591 TOPT = -march=armv8-a+crypto
592 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
593 ifeq ($(strip $(HAVE_OPT)),0)
594 AES_FLAG = -march=armv8-a+crypto
596 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_AES
599 TPROG = TestPrograms/test_arm_pmull.cpp
600 TOPT = -march=armv8-a+crypto
601 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
602 ifeq ($(strip $(HAVE_OPT)),0)
603 GCM_FLAG = -march=armv8-a+crypto
604 GF2N_FLAG = -march=armv8-a+crypto
606 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_PMULL
609 TPROG = TestPrograms/test_arm_sha1.cpp
610 TOPT = -march=armv8-a+crypto
611 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
612 ifeq ($(strip $(HAVE_OPT)),0)
613 SHA_FLAG = -march=armv8-a+crypto
615 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA1
618 TPROG = TestPrograms/test_arm_sha256.cpp
619 TOPT = -march=armv8-a+crypto
620 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
621 ifeq ($(strip $(HAVE_OPT)),0)
622 SHA_FLAG = -march=armv8-a+crypto
624 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA2
627 TPROG = TestPrograms/test_arm_sm3.cpp
628 TOPT = -march=armv8.4-a+sm3
629 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
630 ifeq ($(strip $(HAVE_OPT)),0)
631 SM3_FLAG = -march=armv8.4-a+sm3
632 SM4_FLAG = -march=armv8.4-a+sm3
634 #CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_SM3
635 #CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_SM4
638 TPROG = TestPrograms/test_arm_sha3.cpp
639 TOPT = -march=armv8.4-a+sha3
640 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
641 ifeq ($(strip $(HAVE_OPT)),0)
642 SHA3_FLAG = -march=armv8.4-a+sha3
644 #CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA3
647 TPROG = TestPrograms/test_arm_sha512.cpp
648 TOPT = -march=armv8.4-a+sha512
649 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
650 ifeq ($(strip $(HAVE_OPT)),0)
651 SHA512_FLAG = -march=armv8.4-a+sha512
653 #CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA512
664 ###########################################################
666 ###########################################################
668 # PowerPC and PowerPC64. Altivec is available with POWER4 with GCC and
669 # POWER6 with XLC. The tests below are crafted for IBM XLC and the LLVM
670 # front-end. XLC/LLVM only supplies POWER8 so we have to set the flags for
671 # XLC/LLVM to POWER8. I've got a feeling LLVM is going to cause trouble.
673 ifneq ($(IS_PPC32)$(IS_PPC64),00)
674 ifeq ($(DETECT_FEATURES),1)
676 # IBM XL C/C++ has the -qaltivec flag really screwed up. We can't seem
677 # to get it enabled without an -qarch= option. And -qarch= produces an
678 # error on later versions of the compiler. The only thing that seems
679 # to work consistently is -qarch=auto. -qarch=auto is equivalent to
680 # GCC's -march=native, which we don't really want.
682 # XLC requires -qaltivec in addition to Arch or CPU option
683 ifeq ($(XLC_COMPILER),1)
684 # POWER9_FLAG = -qarch=pwr9 -qaltivec
685 POWER8_FLAG = -qarch=pwr8 -qaltivec
686 POWER7_VSX_FLAG = -qarch=pwr7 -qvsx -qaltivec
687 POWER7_PWR_FLAG = -qarch=pwr7 -qaltivec
688 ALTIVEC_FLAG = -qarch=auto -qaltivec
690 # POWER9_FLAG = -mcpu=power9
691 POWER8_FLAG = -mcpu=power8
692 POWER7_VSX_FLAG = -mcpu=power7 -mvsx
693 POWER7_PWR_FLAG = -mcpu=power7
694 ALTIVEC_FLAG = -maltivec
697 # GCC 10 is giving us trouble in CPU_ProbePower9() and
698 # CPU_ProbeDARN(). GCC is generating POWER9 instructions
699 # on POWER8 for ppc_power9.cpp. The compiler folks did
700 # not think through the consequences of requiring us to
701 # use -mcpu=power9 to unlock the ISA. Epic fail.
702 # https:#github.com/weidai11/cryptopp/issues/986
705 # XLC with LLVM front-ends failed to define XLC defines.
706 #ifeq ($(findstring -qxlcompatmacros,$(CXXFLAGS)),)
707 # TPROG = TestPrograms/test_ppc_altivec.cpp
708 # TOPT = -qxlcompatmacros
709 # HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
710 # ifeq ($(strip $(HAVE_OPT)),0)
711 # CRYPTOPP_CXXFLAGS += -qxlcompatmacros
715 #####################################################################
716 # Looking for a POWER9 option
718 #TPROG = TestPrograms/test_ppc_power9.cpp
719 #TOPT = $(POWER9_FLAG)
720 #HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
721 #ifeq ($(strip $(HAVE_OPT)),0)
722 # DARN_FLAG = $(POWER9_FLAG)
727 #####################################################################
728 # Looking for a POWER8 option
730 TPROG = TestPrograms/test_ppc_power8.cpp
731 TOPT = $(POWER8_FLAG)
732 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
733 ifeq ($(strip $(HAVE_OPT)),0)
734 AES_FLAG = $(POWER8_FLAG)
735 BLAKE2B_FLAG = $(POWER8_FLAG)
736 CRC_FLAG = $(POWER8_FLAG)
737 GCM_FLAG = $(POWER8_FLAG)
738 GF2N_FLAG = $(POWER8_FLAG)
739 LEA_FLAG = $(POWER8_FLAG)
740 SHA_FLAG = $(POWER8_FLAG)
741 SHACAL2_FLAG = $(POWER8_FLAG)
746 #####################################################################
747 # Looking for a POWER7 option
749 # GCC needs -mvsx for Power7 to enable 64-bit vector elements.
750 # XLC provides 64-bit vector elements without an option.
752 TPROG = TestPrograms/test_ppc_power7.cpp
753 TOPT = $(POWER7_VSX_FLAG)
754 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
755 ifeq ($(strip $(HAVE_OPT)),0)
756 POWER7_FLAG = $(POWER7_VSX_FLAG)
758 TPROG = TestPrograms/test_ppc_power7.cpp
759 TOPT = $(POWER7_PWR_FLAG)
760 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
761 ifeq ($(strip $(HAVE_OPT)),0)
762 POWER7_FLAG = $(POWER7_PWR_FLAG)
768 #####################################################################
769 # Looking for an Altivec option
771 TPROG = TestPrograms/test_ppc_altivec.cpp
772 TOPT = $(ALTIVEC_FLAG)
773 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
774 ifeq ($(strip $(HAVE_OPT)),0)
775 ALTIVEC_FLAG := $(ALTIVEC_FLAG)
777 # Make does not have useful debugging facilities. Show the user
778 # what happened by compiling again without the pipe.
779 $(info Running make again to see what failed)
780 $(info $(shell $(TCOMMAND)))
784 ifneq ($(ALTIVEC_FLAG),)
785 BLAKE2S_FLAG = $(ALTIVEC_FLAG)
786 CHACHA_FLAG = $(ALTIVEC_FLAG)
787 SPECK128_FLAG = $(ALTIVEC_FLAG)
788 SIMON128_FLAG = $(ALTIVEC_FLAG)
791 #####################################################################
792 # Fixups for algorithms that can drop to a lower ISA, if needed
794 # Drop to Altivec if higher Power is not available
795 ifneq ($(ALTIVEC_FLAG),)
797 GCM_FLAG = $(ALTIVEC_FLAG)
801 #####################################################################
802 # Fixups for missing ISAs
804 ifeq ($(ALTIVEC_FLAG),)
805 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ALTIVEC
806 else ifeq ($(POWER7_FLAG),)
807 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_POWER7
808 else ifeq ($(POWER8_FLAG),)
809 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_POWER8
810 #else ifeq ($(POWER9_FLAG),)
811 # CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_POWER9
817 # IBM XL C++ compiler
818 ifeq ($(XLC_COMPILER),1)
819 ifeq ($(findstring -qmaxmem,$(CXXFLAGS)),)
820 CRYPTOPP_CXXFLAGS += -qmaxmem=-1
822 # http://www-01.ibm.com/support/docview.wss?uid=swg21007500
823 ifeq ($(findstring -qrtti,$(CXXFLAGS)),)
824 CRYPTOPP_CXXFLAGS += -qrtti
831 ###########################################################
833 ###########################################################
835 # Add -fPIC for targets *except* X86, X32, Cygwin or MinGW
836 ifeq ($(IS_X86)$(IS_CYGWIN)$(IS_MINGW),000)
837 ifeq ($(findstring -fpic,$(CXXFLAGS))$(findstring -fPIC,$(CXXFLAGS)),)
838 CRYPTOPP_CXXFLAGS += -fPIC
842 # Use -pthread whenever it is available. See http://www.hpl.hp.com/techreports/2004/HPL-2004-209.pdf
843 # http://stackoverflow.com/questions/2127797/gcc-significance-of-pthread-flag-when-compiling
844 ifeq ($(DETECT_FEATURES),1)
845 ifeq ($(XLC_COMPILER),1)
846 ifeq ($(findstring -qthreaded,$(CXXFLAGS)),)
847 TPROG = TestPrograms/test_pthreads.cpp
849 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
850 ifeq ($(strip $(HAVE_OPT)),0)
851 CRYPTOPP_CXXFLAGS += -qthreaded
852 endif # CRYPTOPP_CXXFLAGS
855 ifeq ($(findstring -pthread,$(CXXFLAGS)),)
856 TPROG = TestPrograms/test_pthreads.cpp
858 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
859 ifeq ($(strip $(HAVE_OPT)),0)
860 CRYPTOPP_CXXFLAGS += -pthread
861 endif # CRYPTOPP_CXXFLAGS
863 endif # XLC/GCC and friends
864 endif # DETECT_FEATURES
866 # Remove -fPIC if present. SunCC use -KPIC, and needs the larger GOT table
867 # https://docs.oracle.com/cd/E19205-01/819-5267/bkbaq/index.html
868 ifeq ($(SUN_COMPILER),1)
869 CRYPTOPP_CXXFLAGS := $(subst -fPIC,-KPIC,$(CRYPTOPP_CXXFLAGS))
870 CRYPTOPP_CXXFLAGS := $(subst -fpic,-KPIC,$(CRYPTOPP_CXXFLAGS))
873 # Remove -fPIC if present. IBM XL C++ uses -qpic
874 ifeq ($(XLC_COMPILER),1)
875 CRYPTOPP_CXXFLAGS := $(subst -fPIC,-qpic,$(CRYPTOPP_CXXFLAGS))
876 CRYPTOPP_CXXFLAGS := $(subst -fpic,-qpic,$(CRYPTOPP_CXXFLAGS))
879 # Disable IBM XL C++ "1500-036: (I) The NOSTRICT option (default at OPT(3))
880 # has the potential to alter the semantics of a program."
881 ifeq ($(XLC_COMPILER),1)
882 TPROG = TestPrograms/test_cxx.cpp
883 TOPT = -qsuppress=1500-036
884 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
885 ifeq ($(strip $(HAVE_OPT)),0)
886 CRYPTOPP_CXXFLAGS += -qsuppress=1500-036
888 endif # IBM XL C++ compiler
890 # libc++ is LLVM's standard C++ library. If we add libc++
891 # here then all user programs must use it too. The open
892 # question is, which choice is easier on users?
893 ifneq ($(IS_DARWIN),0)
895 # CRYPTOPP_CXXFLAGS += -stdlib=libc++
896 ifeq ($(findstring -fno-common,$(CXXFLAGS)),)
897 CRYPTOPP_CXXFLAGS += -fno-common
899 IS_APPLE_LIBTOOL=$(shell libtool -V 2>&1 | $(GREP) -i -c 'Apple')
900 ifeq ($(IS_APPLE_LIBTOOL),1)
903 AR = /usr/bin/libtool
908 # Add -xregs=no%appl SPARC. SunCC should not use certain registers in library code.
909 # https://docs.oracle.com/cd/E18659_01/html/821-1383/bkamt.html
910 ifneq ($(IS_SPARC32)$(IS_SPARC64),00)
911 ifeq ($(SUN_COMPILER),1)
912 ifeq ($(findstring -xregs=no%appl,$(CXXFLAGS)),)
913 CRYPTOPP_CXXFLAGS += -xregs=no%appl
916 ifeq ($(GCC_COMPILER),1)
917 ifeq ($(findstring -mno-app-regs,$(CXXFLAGS)),)
918 CRYPTOPP_CXXFLAGS += -mno-app-regs
923 # Add -pipe for everything except IBM XL C++, SunCC and ARM.
924 # Allow ARM-64 because they seems to have >1 GB of memory
925 ifeq ($(XLC_COMPILER)$(SUN_COMPILER)$(IS_ARM32),000)
926 ifeq ($(findstring -save-temps,$(CXXFLAGS)),)
927 CRYPTOPP_CXXFLAGS += -pipe
931 # For SunOS, create a Mapfile that allows our object files
932 # to contain additional bits (like SSE4 and AES on old Xeon)
933 # http://www.oracle.com/technetwork/server-storage/solaris/hwcap-modification-139536.html
934 ifeq ($(IS_SUN)$(SUN_COMPILER),11)
935 ifneq ($(IS_X86)$(IS_X64),00)
936 ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CPPFLAGS)$(CXXFLAGS)),)
937 CRYPTOPP_LDFLAGS += -M cryptopp.mapfile
938 endif # No CRYPTOPP_DISABLE_ASM
942 ifneq ($(IS_LINUX)$(IS_HURD),00)
943 ifeq ($(findstring -fopenmp,$(CXXFLAGS)),-fopenmp)
944 ifeq ($(findstring -lgomp,$(LDLIBS)),)
948 endif # IS_LINUX or IS_HURD
950 # Add -errtags=yes to get the name for a warning suppression
951 ifneq ($(SUN_COMPILER),0) # override flags for CC Sun C++ compiler
953 CRYPTOPP_CXXFLAGS += -template=no%extdef
954 SUN_CC10_BUGGY := $(shell $(CXX) -V 2>&1 | $(GREP) -c -E "CC: Sun .* 5\.10 .* (2009|2010/0[1-4])")
955 ifneq ($(SUN_CC10_BUGGY),0)
956 # -DCRYPTOPP_INCLUDE_VECTOR_CC is needed for Sun Studio 12u1 Sun C++ 5.10 SunOS_i386 128229-02 2009/09/21
957 # and was fixed in May 2010. Remove it if you get "already had a body defined" errors in vector.cc
958 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_INCLUDE_VECTOR_CC
965 # Native build testing. Issue 'make native'.
966 ifeq ($(findstring native,$(MAKECMDGOALS)),native)
969 # Try GCC and compatibles first
970 TPROG = TestPrograms/test_cxx.cpp
972 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
973 ifeq ($(strip $(HAVE_OPT)),0)
974 NATIVE_OPT = -march=native
978 ifeq ($(NATIVE_OPT),)
980 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
981 ifeq ($(strip $(HAVE_OPT)),0)
982 NATIVE_OPT = -mtune=native
987 ifeq ($(NATIVE_OPT),)
989 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
990 ifeq ($(strip $(HAVE_OPT)),0)
995 ifneq ($(NATIVE_OPT),)
996 CRYPTOPP_CXXFLAGS += $(NATIVE_OPT)
1001 # Undefined Behavior Sanitizer (UBsan) testing. Issue 'make ubsan'.
1002 ifeq ($(findstring ubsan,$(MAKECMDGOALS)),ubsan)
1003 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1004 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1005 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1006 ifeq ($(findstring -fsanitize=undefined,$(CXXFLAGS)),)
1007 CRYPTOPP_CXXFLAGS += -fsanitize=undefined
1008 endif # CRYPTOPP_CPPFLAGS
1009 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CPPFLAGS)$(CXXFLAGS)),)
1010 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1011 endif # CRYPTOPP_CPPFLAGS
1014 # Address Sanitizer (Asan) testing. Issue 'make asan'.
1015 ifeq ($(findstring asan,$(MAKECMDGOALS)),asan)
1016 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1017 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1018 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1019 ifeq ($(findstring -fsanitize=address,$(CXXFLAGS)),)
1020 CRYPTOPP_CXXFLAGS += -fsanitize=address
1021 endif # CRYPTOPP_CXXFLAGS
1022 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CPPFLAGS)$(CXXFLAGS)),)
1023 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1024 endif # CRYPTOPP_CPPFLAGS
1025 ifeq ($(findstring -fno-omit-frame-pointer,$(CXXFLAGS)),)
1026 CRYPTOPP_CXXFLAGS += -fno-omit-frame-pointer
1027 endif # CRYPTOPP_CXXFLAGS
1030 # LD gold linker testing. Triggered by 'LD=ld.gold'.
1031 ifeq ($(findstring ld.gold,$(LD)),ld.gold)
1032 ifeq ($(findstring -fuse-ld=gold,$(CXXFLAGS)),)
1033 LD_GOLD = $(shell command -v ld.gold)
1034 ELF_FORMAT := $(shell file $(LD_GOLD) 2>&1 | cut -d":" -f 2 | $(GREP) -i -c "elf")
1035 ifneq ($(ELF_FORMAT),0)
1036 CRYPTOPP_LDFLAGS += -fuse-ld=gold
1041 # lcov code coverage. Issue 'make coverage'.
1042 ifneq ($(filter lcov coverage,$(MAKECMDGOALS)),)
1043 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1044 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1045 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1046 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CPPFLAGS)$(CXXFLAGS)),)
1047 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1048 endif # CRYPTOPP_COVERAGE
1049 ifeq ($(findstring -coverage,$(CXXFLAGS)),)
1050 CRYPTOPP_CXXFLAGS += -coverage
1052 endif # GCC code coverage
1054 # gcov code coverage for Travis. Issue 'make codecov'.
1055 ifneq ($(filter gcov codecov,$(MAKECMDGOALS)),)
1056 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1057 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1058 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1059 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CPPFLAGS)$(CXXFLAGS)),)
1060 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1061 endif # CRYPTOPP_COVERAGE
1062 ifeq ($(findstring -coverage,$(CXXFLAGS)),)
1063 CRYPTOPP_CXXFLAGS += -coverage
1065 endif # GCC code coverage
1067 # Valgrind testing. Issue 'make valgrind'.
1068 ifneq ($(filter valgrind,$(MAKECMDGOALS)),)
1069 # Tune flags; see http://valgrind.org/docs/manual/quick-start.html
1070 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1071 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1072 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1073 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CPPFLAGS)$(CXXFLAGS)),)
1074 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1075 endif # CRYPTOPP_CPPFLAGS
1078 # Debug testing on GNU systems. Triggered by -DDEBUG.
1079 # Newlib test due to http://sourceware.org/bugzilla/show_bug.cgi?id=20268
1080 ifneq ($(filter -DDEBUG -DDEBUG=1,$(CXXFLAGS)),)
1081 TPROG = TestPrograms/test_cxx.cpp
1083 USING_GLIBCXX := $(shell $(CXX)$(CXXFLAGS) -E $(TPROG) -c 2>&1 | $(GREP) -i -c "__GLIBCXX__")
1084 ifneq ($(USING_GLIBCXX),0)
1085 ifeq ($(HAS_NEWLIB),0)
1086 ifeq ($(findstring -D_GLIBCXX_DEBUG,$(CPPFLAGS)$(CXXFLAGS)),)
1087 CRYPTOPP_CPPFLAGS += -D_GLIBCXX_DEBUG
1088 endif # CRYPTOPP_CPPFLAGS
1090 endif # USING_GLIBCXX
1092 ifeq ($(XLC_COMPILER),1)
1093 TPROG = TestPrograms/test_cxx.cpp
1094 TOPT = -qheapdebug -qro
1095 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
1096 ifeq ($(strip $(HAVE_OPT)),0)
1097 CRYPTOPP_CXXFLAGS += -qheapdebug -qro
1098 endif # CRYPTOPP_CXXFLAGS
1099 endif # XLC_COMPILER
1102 # Dead code stripping. Issue 'make lean'.
1103 ifeq ($(findstring lean,$(MAKECMDGOALS)),lean)
1104 ifeq ($(findstring -ffunction-sections,$(CXXFLAGS)),)
1105 CRYPTOPP_CXXFLAGS += -ffunction-sections
1106 endif # CRYPTOPP_CXXFLAGS
1107 ifeq ($(findstring -fdata-sections,$(CXXFLAGS)),)
1108 CRYPTOPP_CXXFLAGS += -fdata-sections
1109 endif # CRYPTOPP_CXXFLAGS
1110 ifneq ($(IS_DARWIN),0)
1111 ifeq ($(findstring -Wl,-dead_strip,$(LDFLAGS)),)
1112 CRYPTOPP_LDFLAGS += -Wl,-dead_strip
1113 endif # CRYPTOPP_CXXFLAGS
1114 else # BSD, Linux and Unix
1115 ifeq ($(findstring -Wl,--gc-sections,$(LDFLAGS)),)
1116 CRYPTOPP_LDFLAGS += -Wl,--gc-sections
1118 endif # MAKECMDGOALS
1119 endif # Dead code stripping
1121 # For Shared Objects, Diff, Dist/Zip rules
1122 LIB_VER := $(shell $(GREP) "define CRYPTOPP_VERSION" config_ver.h | cut -d" " -f 3)
1123 LIB_MAJOR := $(shell echo $(LIB_VER) | cut -c 1)
1124 LIB_MINOR := $(shell echo $(LIB_VER) | cut -c 2)
1125 LIB_PATCH := $(shell echo $(LIB_VER) | cut -c 3)
1127 ifeq ($(strip $(LIB_PATCH)),)
1131 ifeq ($(HAS_SOLIB_VERSION),1)
1132 # Different patchlevels and minors are compatible since 6.1
1133 SOLIB_COMPAT_SUFFIX=.$(LIB_MAJOR)
1134 # Linux uses -Wl,-soname
1135 ifneq ($(IS_LINUX)$(IS_HURD),00)
1136 # Linux uses full version suffix for shared library
1137 SOLIB_VERSION_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)
1138 SOLIB_FLAGS=-Wl,-soname,libcrypto++.so$(SOLIB_COMPAT_SUFFIX)
1140 # Solaris uses -Wl,-h
1142 # Solaris uses major version suffix for shared library, but we use major.minor
1143 # The minor version allows previous version to remain and not overwritten.
1144 # https://blogs.oracle.com/solaris/how-to-name-a-solaris-shared-object-v2
1145 SOLIB_VERSION_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR)
1146 SOLIB_FLAGS=-Wl,-h,libcrypto++.so$(SOLIB_COMPAT_SUFFIX)
1148 endif # HAS_SOLIB_VERSION
1150 ###########################################################
1151 ##### Temp file cleanup #####
1152 ###########################################################
1154 # After this point no more test programs should be run.
1155 # https://github.com/weidai11/cryptopp/issues/738
1156 ifeq ($(findstring /dev/null,$(TOUT)),)
1157 # $(info TOUT is not /dev/null, cleaning $(TOUT))
1158 ifeq ($(wildcard $(TOUT)),$(TOUT))
1159 UNUSED := $(shell $(RM) $(TOUT) 2>/dev/null)
1161 ifeq ($(wildcard $(TOUT).dSYM/),$(TOUT).dSYM/)
1162 UNUSED := $(shell $(RM) -r $(TOUT).dSYM/ 2>/dev/null)
1166 ###########################################################
1167 ##### Source and object files #####
1168 ###########################################################
1170 # List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
1171 SRCS := cryptlib.cpp cpu.cpp integer.cpp $(filter-out cryptlib.cpp cpu.cpp integer.cpp pch.cpp simple.cpp,$(sort $(wildcard *.cpp)))
1172 # For Makefile.am; resource.h is Windows
1173 INCL := $(filter-out resource.h,$(sort $(wildcard *.h)))
1175 ifneq ($(IS_MINGW),0)
1179 # Cryptogams source files. We couple to ARMv7 and NEON.
1180 # Limit to Linux. The source files target the GNU assembler.
1181 # Also see https://www.cryptopp.com/wiki/Cryptogams.
1182 ifeq ($(IS_ARM32)$(IS_LINUX),11)
1183 ifeq ($(filter -DCRYPTOPP_DISABLE_ASM -DCRYPTOPP_DISABLE_ARM_NEON,$(CPPFLAGS)$(CXXFLAGS)),)
1184 # Do not use -march=armv7 if the compiler is already targeting the ISA.
1185 # Also see https://github.com/weidai11/cryptopp/issues/1094
1186 ifneq ($($(CXX) ++ -dM -E - </dev/null 2>/dev/null| grep 'ARM_ARCH 7|_ARM_ARCH_7A__'),)
1187 CRYPTOGAMS_ARMV7_FLAG = -march=armv7-a
1189 ifeq ($(CLANG_COMPILER),1)
1190 CRYPTOGAMS_ARM_FLAG = $(CRYPTOGAMS_ARMV7_FLAG)
1191 CRYPTOGAMS_ARM_THUMB_FLAG = $(CRYPTOGAMS_ARMV7_FLAG) -mthumb
1193 # -mfpu=auto due to https://github.com/weidai11/cryptopp/issues/1094
1194 CRYPTOGAMS_ARM_FLAG = $(CRYPTOGAMS_ARMV7_FLAG)
1195 CRYPTOGAMS_ARM_THUMB_FLAG = $(CRYPTOGAMS_ARMV7_FLAG)
1197 SRCS += aes_armv4.S sha1_armv4.S sha256_armv4.S sha512_armv4.S
1201 # Remove unneeded arch specific files to speed build time.
1202 ifeq ($(IS_PPC32)$(IS_PPC64),00)
1203 SRCS := $(filter-out ppc_%,$(SRCS))
1205 ifeq ($(IS_ARM32)$(IS_ARMV8),00)
1206 SRCS := $(filter-out arm_%,$(SRCS))
1207 SRCS := $(filter-out neon_%,$(SRCS))
1209 ifeq ($(IS_X86)$(IS_X32)$(IS_X64),000)
1210 SRCS := $(filter-out sse_%,$(SRCS))
1213 # List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
1214 OBJS := $(SRCS:.cpp=.o)
1215 OBJS := $(OBJS:.S=.o)
1217 # List test.cpp first to tame C++ static initialization problems.
1218 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
1219 TESTINCL := bench.h factory.h validate.h
1222 TESTOBJS := $(TESTSRCS:.cpp=.o)
1223 LIBOBJS := $(filter-out $(TESTOBJS),$(OBJS))
1225 # In Crypto++ 5.6.2 these were the source and object files for the FIPS DLL.
1226 # Since the library is on the Historical Validation List we add all files.
1227 # The 5.6.2 list is at https://github.com/weidai11/cryptopp/blob/789f81f048c9.
1229 DLLOBJS := $(DLLSRCS:.cpp=.export.o)
1230 DLLOBJS := $(DLLOBJS:.S=.export.o)
1232 # Import lib testing
1233 LIBIMPORTOBJS := $(LIBOBJS:.o=.import.o)
1234 TESTIMPORTOBJS := $(TESTOBJS:.o=.import.o)
1235 DLLTESTOBJS := dlltest.dllonly.o
1237 # Clean recipe, Issue 998. Don't filter-out some artifacts from the list of objects
1238 # The *.S is a hack. It makes the ASM appear like C++ so the object files make the CLEAN_OBJS list
1239 CLEAN_SRCS := $(wildcard *.cpp) $(patsubst %.S,%.cpp,$(wildcard *.S))
1240 CLEAN_OBJS := $(CLEAN_SRCS:.cpp=.o) $(CLEAN_SRCS:.cpp=.import.o) $(CLEAN_SRCS:.cpp=.export.o)
1242 ###########################################################
1243 ##### Add our flags to user flags #####
1244 ###########################################################
1246 # This ensures we don't add flags when the user forbids
1247 # use of customary library flags, like -fPIC. Make will
1248 # ignore this assignment when CXXFLAGS is passed as an
1249 # argument to the make program: make CXXFLAGS="..."
1250 CPPFLAGS := $(strip $(CRYPTOPP_CPPFLAGS) $(CPPFLAGS))
1251 CXXFLAGS := $(strip $(CRYPTOPP_CXXFLAGS) $(CXXFLAGS))
1252 ASFLAGS := $(strip $(CRYPTOPP_ASFLAGS) $(ASFLAGS))
1253 LDFLAGS := $(strip $(CRYPTOPP_LDFLAGS) $(LDFLAGS))
1255 ###########################################################
1256 ##### Targets and Recipes #####
1257 ###########################################################
1259 # Default builds program with static library only
1263 .PHONY: all static dynamic
1264 all: static dynamic cryptest
1266 ifneq ($(IS_DARWIN),0)
1267 static: libcrypto++.a
1268 shared dynamic dylib: libcrypto++.dylib
1270 static: libcrypto++.a
1271 shared dynamic: libcrypto++.so$(SOLIB_VERSION_SUFFIX)
1274 # CXXFLAGS are tuned earlier.
1275 .PHONY: native no-asm asan ubsan
1276 native no-asm asan ubsan: cryptest
1278 # CXXFLAGS are tuned earlier. Applications must use linker flags
1279 # -Wl,--gc-sections (Linux and Unix) or -Wl,-dead_strip (OS X)
1281 lean: static dynamic cryptest
1283 # May want to export CXXFLAGS="-g3 -O1"
1284 .PHONY: lcov coverage
1285 lcov coverage: cryptest
1286 @-$(RM) -r ./TestCoverage/
1287 lcov --base-directory . --directory . --zerocounters -q
1291 lcov --base-directory . --directory . -c -o cryptest.info
1292 lcov --remove cryptest.info "adhoc.*" -o cryptest.info
1293 lcov --remove cryptest.info "fips140.*" -o cryptest.info
1294 lcov --remove cryptest.info "*test.*" -o cryptest.info
1295 lcov --remove cryptest.info "/usr/*" -o cryptest.info
1296 genhtml -o ./TestCoverage/ -t "Crypto++ test coverage" --num-spaces 4 cryptest.info
1298 # Travis CI and CodeCov rule
1299 .PHONY: gcov codecov
1300 gcov codecov: cryptest
1301 @-$(RM) -r ./TestCoverage/
1306 # Should use CXXFLAGS="-g3 -O1"
1309 valgrind --track-origins=yes --suppressions=cryptopp.supp ./cryptest v
1312 test check: cryptest
1315 # Used to generate list of source files for Autotools, CMakeList, Android.mk, etc
1318 $(info ***** Library sources *****)
1319 $(info $(filter-out $(TESTSRCS),$(SRCS)))
1321 $(info ***** Library headers *****)
1322 $(info $(filter-out $(TESTINCL),$(INCL)))
1324 $(info ***** Test sources *****)
1327 $(info ***** Test headers *****)
1330 # Directory we want (can't specify on Doygen command line)
1331 DOCUMENT_DIRECTORY := ref$(LIB_VER)
1332 # Directory Doxygen uses (specified in Doygen config file)
1333 ifeq ($(wildcard Doxyfile),Doxyfile)
1334 DOXYGEN_DIRECTORY := $(strip $(shell $(GREP) "OUTPUT_DIRECTORY" Doxyfile | $(GREP) -v "\#" | cut -d "=" -f 2))
1336 # Default directory (in case its missing in the config file)
1337 ifeq ($(strip $(DOXYGEN_DIRECTORY)),)
1338 DOXYGEN_DIRECTORY := html-docs
1341 # Builds the documentation. Directory name is ref563, ref570, etc.
1344 @-$(RM) -r $(DOXYGEN_DIRECTORY)/ $(DOCUMENT_DIRECTORY)/ html-docs/
1345 @-$(RM) CryptoPPRef.zip
1346 doxygen Doxyfile -d CRYPTOPP_DOXYGEN_PROCESSING
1347 $(MV) $(DOXYGEN_DIRECTORY)/ $(DOCUMENT_DIRECTORY)/
1348 zip -9 CryptoPPRef.zip -x ".*" -x "*/.*" -r $(DOCUMENT_DIRECTORY)/
1352 -$(RM) adhoc.cpp.o adhoc.cpp.proto.o $(CLEAN_OBJS) rdrand-*.o
1353 @-$(RM) libcrypto++.a libcrypto++.dylib cryptopp.dll libcrypto++.dll.a libcrypto++.import.a
1354 @-$(RM) libcrypto++.so libcrypto++.so$(SOLIB_COMPAT_SUFFIX) libcrypto++.so$(SOLIB_VERSION_SUFFIX)
1355 @-$(RM) cryptest dlltest cryptest.import cryptest.dat ct et
1356 @-$(RM) *.la *.lo *.gcov *.gcno *.gcda *.stackdump core core-*
1358 @-$(RM) -r /tmp/cryptopp_test/
1359 @-$(RM) -r *.dSYM/ *.dylib.dSYM/
1362 .PHONY: autotools-clean
1364 @-$(RM) -f configure.ac configure configure.in Makefile.am Makefile.in Makefile
1365 @-$(RM) -f config.guess config.status config.sub config.h.in compile depcomp
1366 @-$(RM) -f install-sh stamp-h1 ar-lib *.lo *.la *.m4 local.* lt*.sh missing
1367 @-$(RM) -f cryptest cryptestcwd libtool* libcrypto++.la libcrypto++.pc*
1368 @-$(RM) -rf build-aux/ m4/ auto*.cache/ .deps/ .libs/
1372 @-$(RM) -f cryptopp-config.cmake CMakeLists.txt
1373 @-$(RM) -rf cmake_build/
1375 .PHONY: android-clean
1377 @-$(RM) -f $(patsubst %_simd.cpp,%_simd.cpp.neon,$(wildcard *_simd.cpp))
1381 distclean: clean autotools-clean cmake-clean android-clean
1382 -$(RM) adhoc.cpp adhoc.cpp.copied GNUmakefile.deps benchmarks.html cryptest.txt
1383 -$(RM) cryptest_all.info cryptest_debug.info cryptest_noasm.info cryptest_base.info cryptest.info cryptest_release.info
1384 @-$(RM) cryptest-*.txt cryptopp.tgz libcrypto++.pc *.o *.bc *.ii *~
1385 @-$(RM) -r cryptlib.lib cryptest *.suo *.sdf *.pdb Win32/ x64/ ipch/
1386 @-$(RM) -r $(LIBOBJS:.o=.obj) $(TESTOBJS:.o=.obj)
1387 @-$(RM) -r $(LIBOBJS:.o=.lst) $(TESTOBJS:.o=.lst)
1388 @-$(RM) -r TestCoverage/ ref*/
1389 @-$(RM) cryptopp$(LIB_VER)\.* CryptoPPRef.zip
1391 # Install cryptest, libcrypto++.a, libcrypto++.so and libcrypto++.pc.
1392 # The library install was broken-out into its own recipe at GH #653.
1394 install: cryptest install-lib
1395 @-$(MKDIR) $(DESTDIR)$(BINDIR)
1396 $(CP) cryptest $(DESTDIR)$(BINDIR)
1397 $(CHMOD) u=rwx,go=rx $(DESTDIR)$(BINDIR)/cryptest
1398 @-$(MKDIR) $(DESTDIR)$(DATADIR)/crypto++/TestData
1399 @-$(MKDIR) $(DESTDIR)$(DATADIR)/crypto++/TestVectors
1400 $(CP) TestData/*.dat $(DESTDIR)$(DATADIR)/crypto++/TestData
1401 $(CHMOD) u=rw,go=r $(DESTDIR)$(DATADIR)/crypto++/TestData/*.dat
1402 $(CP) TestVectors/*.txt $(DESTDIR)$(DATADIR)/crypto++/TestVectors
1403 $(CHMOD) u=rw,go=r $(DESTDIR)$(DATADIR)/crypto++/TestVectors/*.txt
1405 # A recipe to install only the library, and not cryptest. Also
1406 # see https://github.com/weidai11/cryptopp/issues/653. Some users
1407 # already have a libcrypto++.pc. Install the *.pc file if the file
1408 # is present. If you want one, then issue 'make libcrypto++.pc'.
1411 @-$(MKDIR) $(DESTDIR)$(INCLUDEDIR)/crypto++
1412 $(CP) *.h $(DESTDIR)$(INCLUDEDIR)/crypto++
1413 $(CHMOD) u=rw,go=r $(DESTDIR)$(INCLUDEDIR)/crypto++/*.h
1414 ifneq ($(wildcard libcrypto++.a),)
1415 @-$(MKDIR) $(DESTDIR)$(LIBDIR)
1416 $(CP) libcrypto++.a $(DESTDIR)$(LIBDIR)
1417 $(CHMOD) u=rw,go=r $(DESTDIR)$(LIBDIR)/libcrypto++.a
1419 ifneq ($(wildcard libcryptopp.dylib),)
1420 @-$(MKDIR) $(DESTDIR)$(LIBDIR)
1421 $(CP) libcryptopp.dylib $(DESTDIR)$(LIBDIR)
1422 $(CHMOD) u=rwx,go=rx $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
1423 -install_name_tool -id $(DESTDIR)$(LIBDIR)/libcryptopp.dylib $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
1425 ifneq ($(wildcard libcrypto++.so$(SOLIB_VERSION_SUFFIX)),)
1426 @-$(MKDIR) $(DESTDIR)$(LIBDIR)
1427 $(CP) libcrypto++.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)
1428 $(CHMOD) u=rwx,go=rx $(DESTDIR)$(LIBDIR)/libcrypto++.so$(SOLIB_VERSION_SUFFIX)
1429 ifeq ($(HAS_SOLIB_VERSION),1)
1430 -$(LN) libcrypto++.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcrypto++.so
1431 -$(LN) libcrypto++.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcrypto++.so$(SOLIB_COMPAT_SUFFIX)
1432 $(LDCONF) $(DESTDIR)$(LIBDIR)
1435 ifneq ($(wildcard libcrypto++.pc),)
1436 @-$(MKDIR) $(DESTDIR)$(LIBDIR)/pkgconfig
1437 $(CP) libcrypto++.pc $(DESTDIR)$(LIBDIR)/pkgconfig
1438 $(CHMOD) u=rw,go=r $(DESTDIR)$(LIBDIR)/pkgconfig/libcrypto++.pc
1441 .PHONY: remove uninstall
1443 -$(RM) -r $(DESTDIR)$(INCLUDEDIR)/crypto++
1444 -$(RM) $(DESTDIR)$(LIBDIR)/libcrypto++.a
1445 -$(RM) $(DESTDIR)$(BINDIR)/cryptest
1446 ifneq ($(wildcard $(DESTDIR)$(LIBDIR)/libcryptopp.dylib),)
1447 -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
1449 ifneq ($(wildcard $(DESTDIR)$(LIBDIR)/libcrypto++.so),)
1450 -$(RM) $(DESTDIR)$(LIBDIR)/libcrypto++.so
1452 @-$(RM) $(DESTDIR)$(LIBDIR)/libcrypto++.so$(SOLIB_VERSION_SUFFIX)
1453 @-$(RM) $(DESTDIR)$(LIBDIR)/libcrypto++.so$(SOLIB_COMPAT_SUFFIX)
1454 @-$(RM) $(DESTDIR)$(LIBDIR)/pkgconfig/libcrypto++.pc
1455 @-$(RM) -r $(DESTDIR)$(DATADIR)/crypto++
1457 libcrypto++.a: $(LIBOBJS) | osx_warning
1458 $(AR) $(ARFLAGS) $@ $(LIBOBJS)
1463 ifeq ($(HAS_SOLIB_VERSION),1)
1464 .PHONY: libcrypto++.so
1465 libcryptopp.so: libcrypto++.so$(SOLIB_VERSION_SUFFIX) | so_warning
1468 libcrypto++.so$(SOLIB_VERSION_SUFFIX): $(LIBOBJS)
1469 ifeq ($(XLC_COMPILER),1)
1470 $(CXX) -qmkshrobj $(SOLIB_FLAGS) -o $@ $(CXXFLAGS) $(LDFLAGS) $(LIBOBJS) $(LDLIBS)
1472 $(CXX) -shared $(SOLIB_FLAGS) -o $@ $(CXXFLAGS) $(LDFLAGS) $(LIBOBJS) $(LDLIBS)
1474 ifeq ($(HAS_SOLIB_VERSION),1)
1475 -$(LN) libcrypto++.so$(SOLIB_VERSION_SUFFIX) libcrypto++.so
1476 -$(LN) libcrypto++.so$(SOLIB_VERSION_SUFFIX) libcrypto++.so$(SOLIB_COMPAT_SUFFIX)
1479 libcryptopp.dylib: $(LIBOBJS) | osx_warning
1480 $(CXX) -dynamiclib -o $@ $(CXXFLAGS) -install_name "$@" -current_version "$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)" -compatibility_version "$(LIB_MAJOR).$(LIB_MINOR)" -headerpad_max_install_names $(LDFLAGS) $(LIBOBJS)
1482 cryptest: $(LINK_LIBRARY) $(TESTOBJS) | osx_warning
1483 $(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) $(LINK_LIBRARY_PATH)$(LINK_LIBRARY) $(LDFLAGS) $(LDLIBS)
1485 # Makes it faster to test changes
1487 $(CXX) -o ct $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS)
1489 dll: cryptest.import.exe dlltest.exe
1491 cryptopp.dll: $(DLLOBJS)
1492 $(CXX) -shared -o $@ $(CXXFLAGS) $(DLLOBJS) $(LDFLAGS) $(LDLIBS) -Wl,--out-implib=libcryptopp.dll.a
1494 libcryptopp.import.a: $(LIBIMPORTOBJS)
1495 $(AR) $(ARFLAGS) $@ $(LIBIMPORTOBJS)
1500 cryptest.import.exe: cryptopp.dll libcryptopp.import.a $(TESTIMPORTOBJS)
1501 $(CXX) -o $@ $(CXXFLAGS) $(TESTIMPORTOBJS) -L. -lcryptopp.dll -lcryptopp.import $(LDFLAGS) $(LDLIBS)
1503 dlltest.exe: cryptopp.dll $(DLLTESTOBJS)
1504 $(CXX) -o $@ $(CXXFLAGS) $(DLLTESTOBJS) -L. -lcryptopp.dll $(LDFLAGS) $(LDLIBS)
1506 # Some users already have a libcryptopp.pc. We install it if the file
1507 # is present. If you want one, then issue 'make libcryptopp.pc'. Be sure
1508 # to use/verify PREFIX and LIBDIR below after writing the file.
1509 cryptopp.pc libcrypto++.pc:
1510 @echo '# Crypto++ package configuration file' > libcrypto++.pc
1511 @echo '' >> libcrypto++.pc
1512 @echo 'prefix=$(PC_PREFIX)' >> libcrypto++.pc
1513 @echo 'libdir=$(PC_LIBDIR)' >> libcrypto++.pc
1514 @echo 'includedir=$(PC_INCLUDEDIR)' >> libcrypto++.pc
1515 @echo 'datadir=$(PC_DATADIR)' >> libcrypto++.pc
1516 @echo '' >> libcrypto++.pc
1517 @echo 'Name: Crypto++' >> libcrypto++.pc
1518 @echo 'Description: Crypto++ cryptographic library' >> libcrypto++.pc
1519 @echo 'Version: 8.7' >> libcrypto++.pc
1520 @echo 'URL: https://cryptopp.com/' >> libcrypto++.pc
1521 @echo '' >> libcrypto++.pc
1522 @echo 'Cflags: -I$${includedir}' >> libcrypto++.pc
1523 @echo 'Libs: -L$${libdir} -lcryptopp' >> libcrypto++.pc
1525 # This recipe prepares the distro files
1526 TEXT_FILES := *.h *.cpp *.S GNUmakefile GNUmakefile-cross License.txt Readme.txt Install.txt Filelist.txt Doxyfile cryptest* cryptlib* dlltest* cryptdll* *.sln *.vcxproj *.filters cryptopp.rc TestVectors/*.txt TestData/*.dat TestPrograms/*.cpp
1527 EXEC_FILES := TestScripts/*.sh TestScripts/*.cmd
1528 ifneq ($(wildcard *.sh),)
1529 EXEC_FILES += $(wildcard *.sh)
1531 EXEC_DIRS := TestData/ TestVectors/ TestScripts/ TestPrograms/
1533 ifeq ($(wildcard Filelist.txt),Filelist.txt)
1534 DIST_FILES := $(shell cat Filelist.txt)
1539 ifneq ($(IS_DARWIN),0)
1540 $(SED) -i '' -e's/[[:space:]]*$$//' *.supp *.txt .*.yml *.h *.cpp *.asm *.S
1541 $(SED) -i '' -e's/[[:space:]]*$$//' *.sln *.vcxproj *.filters GNUmakefile GNUmakefile-cross
1542 $(SED) -i '' -e's/[[:space:]]*$$//' TestData/*.dat TestVectors/*.txt TestPrograms/*.cpp TestScripts/*.*
1545 $(SED) -i -e's/[[:space:]]*$$//' *.supp *.txt .*.yml *.h *.cpp *.asm *.S
1546 $(SED) -i -e's/[[:space:]]*$$//' *.sln *.vcxproj *.filters GNUmakefile GNUmakefile-cross
1547 $(SED) -i -e's/[[:space:]]*$$//' TestData/*.dat TestVectors/*.txt TestPrograms/*.cpp TestScripts/*.*
1553 @-$(CHMOD) u=rwx,go=rx $(EXEC_DIRS)
1554 @-$(CHMOD) u=rw,go=r $(TEXT_FILES) *.supp .*.yml *.asm *.zip TestVectors/*.txt TestData/*.dat TestPrograms/*.cpp
1555 @-$(CHMOD) u=rwx,go=rx $(EXEC_FILES)
1556 -unix2dos --keepdate --quiet $(TEXT_FILES) .*.yml *.asm TestScripts/*.cmd TestScripts/*.txt TestScripts/*.cpp
1557 -dos2unix --keepdate --quiet GNUmakefile GNUmakefile-cross *.sh *.S *.supp *.mapfile TestScripts/*.sh
1558 ifneq ($(IS_DARWIN),0)
1562 # Build the ZIP file with source files. No documentation.
1564 zip dist: | distclean convert
1565 zip -q -9 cryptopp$(LIB_VER).zip $(DIST_FILES)
1567 # Build the ISO to transfer the ZIP to old distros via CDROM
1570 ifneq ($(IS_DARWIN),0)
1571 $(MKDIR) $(PWD)/cryptopp$(LIB_VER)
1572 $(CP) cryptopp$(LIB_VER).zip $(PWD)/cryptopp$(LIB_VER)
1573 hdiutil makehybrid -iso -joliet -o cryptopp$(LIB_VER).iso $(PWD)/cryptopp$(LIB_VER)
1574 @-$(RM) -r $(PWD)/cryptopp$(LIB_VER)
1575 else ifneq ($(IS_LINUX)$(IS_HURD),00)
1576 $(MKDIR) $(PWD)/cryptopp$(LIB_VER)
1577 $(CP) cryptopp$(LIB_VER).zip $(PWD)/cryptopp$(LIB_VER)
1578 genisoimage -q -o cryptopp$(LIB_VER).iso $(PWD)/cryptopp$(LIB_VER)
1579 @-$(RM) -r $(PWD)/cryptopp$(LIB_VER)
1582 # CRYPTOPP_CPU_FREQ in GHz
1583 CRYPTOPP_CPU_FREQ ?= 0.0
1584 .PHONY: bench benchmark benchmarks
1585 bench benchmark benchmarks: cryptest
1586 @-$(RM) -f benchmarks.html
1587 ./cryptest b 2 $(CRYPTOPP_CPU_FREQ)
1589 adhoc.cpp: adhoc.cpp.proto
1590 ifeq ($(wildcard adhoc.cpp),)
1591 cp adhoc.cpp.proto adhoc.cpp
1596 # Include dependencies, if present. You must issue `make deps` to create them.
1597 ifeq ($(wildcard GNUmakefile.deps),GNUmakefile.deps)
1598 -include GNUmakefile.deps
1599 endif # Dependencies
1601 # A few recipes trigger warnings for -std=c++11 and -stdlib=c++
1602 NOSTD_CXXFLAGS=$(filter-out -stdlib=%,$(filter-out -std=%,$(CXXFLAGS)))
1604 # Cryptogams ARM asm implementation. AES needs -mthumb for Clang
1605 aes_armv4.o : aes_armv4.S
1606 $(CXX) $(strip $(CPPFLAGS) $(ASFLAGS) $(NOSTD_CXXFLAGS) $(CRYPTOGAMS_ARM_THUMB_FLAG) -c) $<
1608 # SSSE3 or NEON available
1609 aria_simd.o : aria_simd.cpp
1610 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(ARIA_FLAG) -c) $<
1612 # SSE, NEON or POWER7 available
1613 blake2s_simd.o : blake2s_simd.cpp
1614 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(BLAKE2S_FLAG) -c) $<
1616 # SSE, NEON or POWER8 available
1617 blake2b_simd.o : blake2b_simd.cpp
1618 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(BLAKE2B_FLAG) -c) $<
1620 # SSE2 or NEON available
1621 chacha_simd.o : chacha_simd.cpp
1622 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CHACHA_FLAG) -c) $<
1625 chacha_avx.o : chacha_avx.cpp
1626 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CHACHA_AVX2_FLAG) -c) $<
1629 cham_simd.o : cham_simd.cpp
1630 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CHAM_FLAG) -c) $<
1632 # SSE4.2 or ARMv8a available
1633 crc_simd.o : crc_simd.cpp
1634 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CRC_FLAG) -c) $<
1638 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(DARN_FLAG) -c) $<
1641 donna_sse.o : donna_sse.cpp
1642 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SSE2_FLAG) -c) $<
1644 # Carryless multiply
1645 gcm_simd.o : gcm_simd.cpp
1646 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(GCM_FLAG) -c) $<
1648 # Carryless multiply
1649 gf2n_simd.o : gf2n_simd.cpp
1650 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(GF2N_FLAG) -c) $<
1653 keccak_simd.o : keccak_simd.cpp
1654 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(KECCAK_FLAG) -c) $<
1657 lea_simd.o : lea_simd.cpp
1658 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LEA_FLAG) -c) $<
1661 lsh256_sse.o : lsh256_sse.cpp
1662 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LSH256_FLAG) -c) $<
1665 lsh256_avx.o : lsh256_avx.cpp
1666 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LSH256_AVX2_FLAG) -c) $<
1669 lsh512_sse.o : lsh512_sse.cpp
1670 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LSH512_FLAG) -c) $<
1673 lsh512_avx.o : lsh512_avx.cpp
1674 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LSH512_AVX2_FLAG) -c) $<
1677 neon_simd.o : neon_simd.cpp
1678 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(NEON_FLAG) -c) $<
1681 ppc_simd.o : ppc_simd.cpp
1682 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(ALTIVEC_FLAG) -c) $<
1685 ppc_power7.o : ppc_power7.cpp
1686 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(POWER7_FLAG) -c) $<
1689 ppc_power8.o : ppc_power8.cpp
1690 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(POWER8_FLAG) -c) $<
1693 ppc_power9.o : ppc_power9.cpp
1694 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(POWER9_FLAG) -c) $<
1696 # AESNI or ARMv7a/ARMv8a available
1697 rijndael_simd.o : rijndael_simd.cpp
1698 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(AES_FLAG) -c) $<
1700 # SSE4.2/SHA-NI or ARMv8a available
1701 sha_simd.o : sha_simd.cpp
1702 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SHA_FLAG) -c) $<
1704 # Cryptogams SHA1 asm implementation.
1705 sha1_armv4.o : sha1_armv4.S
1706 $(CXX) $(strip $(CPPFLAGS) $(ASFLAGS) $(NOSTD_CXXFLAGS) $(CRYPTOGAMS_ARM_FLAG) -c) $<
1708 # Cryptogams SHA256 asm implementation.
1709 sha256_armv4.o : sha256_armv4.S
1710 $(CXX) $(strip $(CPPFLAGS) $(ASFLAGS) $(NOSTD_CXXFLAGS) $(CRYPTOGAMS_ARM_FLAG) -c) $<
1712 # Cryptogams SHA512 asm implementation.
1713 sha512_armv4.o : sha512_armv4.S
1714 $(CXX) $(strip $(CPPFLAGS) $(ASFLAGS) $(NOSTD_CXXFLAGS) $(CRYPTOGAMS_ARM_FLAG) -c) $<
1716 sha3_simd.o : sha3_simd.cpp
1717 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SHA3_FLAG) -c) $<
1719 # SSE4.2/SHA-NI or ARMv8a available
1720 shacal2_simd.o : shacal2_simd.cpp
1721 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SHA_FLAG) -c) $<
1723 # SSSE3, NEON or POWER8 available
1724 simon128_simd.o : simon128_simd.cpp
1725 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SIMON128_FLAG) -c) $<
1727 # SSSE3, NEON or POWER8 available
1728 speck128_simd.o : speck128_simd.cpp
1729 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SPECK128_FLAG) -c) $<
1732 sm3_simd.o : sm3_simd.cpp
1733 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SM3_FLAG) -c) $<
1736 sm4_simd.o : sm4_simd.cpp
1737 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SM4_FLAG) -c) $<
1739 # IBM XLC -O3 optimization bug
1740 ifeq ($(XLC_COMPILER),1)
1742 $(CXX) $(strip $(CPPFLAGS) $(subst -O3,-O2,$(CXXFLAGS)) -c) $<
1743 donna_32.o : donna_32.cpp
1744 $(CXX) $(strip $(CPPFLAGS) $(subst -O3,-O2,$(CXXFLAGS)) -c) $<
1745 donna_64.o : donna_64.cpp
1746 $(CXX) $(strip $(CPPFLAGS) $(subst -O3,-O2,$(CXXFLAGS)) -c) $<
1750 sse_simd.o : sse_simd.cpp
1751 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SSE2_FLAG) -c) $<
1753 # Don't build Rijndael with UBsan. Too much noise due to unaligned data accesses.
1754 ifneq ($(findstring -fsanitize=undefined,$(CXXFLAGS)),)
1755 rijndael.o : rijndael.cpp
1756 $(CXX) $(strip $(subst -fsanitize=undefined,,$(CXXFLAGS)) -c) $<
1759 # Only use CRYPTOPP_DATA_DIR if its not set in CXXFLAGS
1760 ifeq ($(findstring -DCRYPTOPP_DATA_DIR, $(CPPFLAGS)$(CXXFLAGS)),)
1761 ifneq ($(strip $(CRYPTOPP_DATA_DIR)),)
1762 validat%.o : validat%.cpp
1763 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" $(CXXFLAGS) -c) $<
1764 bench%.o : bench%.cpp
1765 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" $(CXXFLAGS) -c) $<
1766 datatest.o : datatest.cpp
1767 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" $(CXXFLAGS) -c) $<
1769 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" $(CXXFLAGS) -c) $<
1773 validat1.o : validat1.cpp
1774 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(ALTIVEC_FLAG) -c) $<
1777 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DLL_ONLY $(CXXFLAGS) -c) $< -o $@
1780 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_IMPORTS $(CXXFLAGS) -c) $< -o $@
1783 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_EXPORTS $(CXXFLAGS) -c) $< -o $@
1786 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) -c) $<
1789 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) -c) $<
1793 ifeq ($(HAS_SOLIB_VERSION),1)
1795 $(info WARNING: Only the symlinks to the shared-object library have been updated.)
1796 $(info WARNING: If the library is installed in a system directory you will need)
1797 $(info WARNING: to run 'ldconfig' to update the shared-object library cache.)
1803 ifeq ($(IS_DARWIN)$(CLANG_COMPILER),11)
1804 ifeq ($(findstring -stdlib=libc++,$(CRYPTOPP_CXXFLAGS)$(CXXFLAGS)),)
1806 $(info INFO: Crypto++ was built without LLVM's libc++. If you are using the library)
1807 $(info INFO: with modern Xcode, then you should add -stdlib=libc++ to CXXFLAGS. It is)
1808 $(info INFO: already present in the makefile, and you only need to uncomment it.)
1813 .PHONY: dep deps depend
1814 dep deps depend GNUmakefile.deps:
1815 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS)) -MM *.cpp > GNUmakefile.deps