2 ###########################################################
3 ##### System Attributes and Programs #####
4 ###########################################################
6 # https://www.gnu.org/software/make/manual/make.html#Makefile-Conventions
7 # and https://www.gnu.org/prep/standards/standards.html
13 # Used for feature tests
15 TOUT := $(strip $(TOUT))
17 # Allow override for the cryptest.exe recipe. Change to
18 # ./libcryptopp.so or ./libcryptopp.dylib to suit your
19 # taste. https://github.com/weidai11/cryptopp/issues/866
20 LINK_LIBRARY ?= libcryptopp.a
21 LINK_LIBRARY_PATH ?= ./
23 # Command and arguments
25 ARFLAGS ?= -cr # ar needs the dash on OpenBSD
37 LDCONF ?= /sbin/ldconfig -n
39 # Solaris provides a non-Posix sed and grep at /usr/bin
40 # Solaris 10 is missing AR in /usr/bin
41 ifneq ($(wildcard /usr/xpg4/bin/grep),)
42 GREP := /usr/xpg4/bin/grep
44 ifneq ($(wildcard /usr/xpg4/bin/sed),)
45 SED := /usr/xpg4/bin/sed
47 ifneq ($(wildcard /usr/xpg4/bin/ar),)
48 AR := /usr/xpg4/bin/ar
51 # Clang is reporting armv8l-unknown-linux-gnueabihf
52 # for ARMv7 images on Aarch64 hardware.
53 MACHINEX := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null)
54 HOSTX := $(shell echo $(MACHINEX) | cut -f 1 -d '-')
56 HOSTX := $(shell uname -m 2>/dev/null)
59 IS_X86 := $(shell echo "$(HOSTX)" | $(GREP) -v "64" | $(GREP) -i -c -E 'i.86|x86|i86')
60 IS_X64 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E '_64|d64')
61 IS_PPC32 := $(shell echo "$(HOSTX)" | $(GREP) -v "64" | $(GREP) -i -c -E 'ppc|power')
62 IS_PPC64 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E 'ppc64|powerpc64|power64')
63 IS_SPARC32 := $(shell echo "$(HOSTX)" | $(GREP) -v "64" | $(GREP) -i -c -E 'sun|sparc')
64 IS_SPARC64 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E 'sun|sparc64')
65 IS_ARM32 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E 'arm|armhf|armv7|eabihf|armv8')
66 IS_ARMV8 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E 'aarch32|aarch64|arm64')
68 # Attempt to determine platform
69 SYSTEMX := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null)
71 SYSTEMX := $(shell uname -s 2>/dev/null)
74 IS_LINUX := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "Linux")
75 IS_HURD := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c -E "GNU|Hurd")
76 IS_MINGW := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "MinGW")
77 IS_CYGWIN := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "Cygwin")
78 IS_DARWIN := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "Darwin")
79 IS_NETBSD := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "NetBSD")
80 IS_AIX := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "aix")
81 IS_SUN := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c -E "SunOS|Solaris")
83 SUN_COMPILER := $(shell $(CXX) -V 2>&1 | $(GREP) -i -c -E 'CC: (Sun|Studio)')
84 GCC_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -v -E '(llvm|clang)' | $(GREP) -i -c -E '(gcc|g\+\+)')
85 XLC_COMPILER := $(shell $(CXX) -qversion 2>/dev/null |$(GREP) -i -c "IBM XL")
86 CLANG_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -i -c -E '(llvm|clang)')
87 INTEL_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -i -c '\(icc\)')
89 # Various Port compilers on OS X
90 MACPORTS_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -i -c "macports")
91 HOMEBREW_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -i -c "homebrew")
93 ifneq ($(MACPORTS_COMPILER)$(HOMEBREW_COMPILER),00)
98 # Enable shared object versioning for Linux and Solaris
99 HAS_SOLIB_VERSION ?= 0
100 ifneq ($(IS_LINUX)$(IS_HURD)$(IS_SUN),000)
101 HAS_SOLIB_VERSION := 1
104 # Formely adhoc.cpp was created from adhoc.cpp.proto when needed.
105 ifeq ($(wildcard adhoc.cpp),)
106 $(shell cp adhoc.cpp.proto adhoc.cpp)
109 # Tell MacPorts and Homebrew GCC to use Clang integrated assembler (only on Intel-based Macs)
110 # http://github.com/weidai11/cryptopp/issues/190
111 ifeq ($(GCC_COMPILER)$(OSXPORT_COMPILER)$(IS_PPC32)$(IS_PPC64),1100)
112 ifeq ($(findstring -Wa,-q,$(CXXFLAGS)),)
113 CRYPTOPP_CXXFLAGS += -Wa,-q
117 # Hack to skip CPU feature tests for some recipes
119 ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),-DCRYPTOPP_DISABLE_ASM)
121 else ifeq ($(findstring clean,$(MAKECMDGOALS)),clean)
123 else ifeq ($(findstring distclean,$(MAKECMDGOALS)),distclean)
125 else ifeq ($(findstring distclean,$(MAKECMDGOALS)),trim)
129 # Strip out -Wall, -Wextra and friends for feature testing. FORTIFY_SOURCE is removed
130 # because it requires -O1 or higher, but we use -O0 to tame the optimizer.
131 ifeq ($(DETECT_FEATURES),1)
132 TCXXFLAGS := $(filter-out -D_FORTIFY_SOURCE=% -M -MM -Wall -Wextra -Werror% -Wunused -Wconversion -Wp%, $(CXXFLAGS))
133 ifneq ($(strip $(TCXXFLAGS)),)
134 $(info Using testing flags: $(TCXXFLAGS))
136 #TPROG = TestPrograms/test_cxx.cxx
137 #$(info Testing compile... )
138 #$(info $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 1>/dev/null))
143 TPROG = TestPrograms/test_64bit.cxx
144 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
145 ifeq ($(strip $(HAVE_OPT)),0)
152 # libc++ is LLVM's standard C++ library. If we add libc++
153 # here then all user programs must use it too. The open
154 # question is, which choice is easier on users?
155 ifneq ($(IS_DARWIN),0)
157 # CRYPTOPP_CXXFLAGS += -stdlib=libc++
162 ###########################################################
163 ##### General Variables #####
164 ###########################################################
166 # Base CXXFLAGS used if the user did not specify them
168 ifeq ($(SUN_COMPILER),1)
169 CRYPTOPP_CXXFLAGS += -DNDEBUG -g -xO3
172 CRYPTOPP_CXXFLAGS += -DNDEBUG -g2 -O3
177 # Fix CXX on Cygwin 1.1.4
182 # On ARM we may compile aes_armv4.S though the CC compiler
183 ifeq ($(GCC_COMPILER),1)
185 else ifeq ($(CLANG_COMPILER),1)
189 # http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
192 PC_PREFIX = /usr/local
194 PC_PREFIX = $(PREFIX)
197 LIBDIR := $(PREFIX)/lib
198 PC_LIBDIR = $${prefix}/lib
200 PC_LIBDIR = $(LIBDIR)
203 DATADIR := $(PREFIX)/share
204 PC_DATADIR = $${prefix}/share
206 PC_DATADIR = $(DATADIR)
208 ifeq ($(INCLUDEDIR),)
209 INCLUDEDIR := $(PREFIX)/include
210 PC_INCLUDEDIR = $${prefix}/include
212 PC_INCLUDEDIR = $(INCLUDEDIR)
215 BINDIR := $(PREFIX)/bin
218 # We honor ARFLAGS, but the "v" option used by default causes a noisy make
223 # Original MinGW targets Win2k by default, but lacks proper Win2k support
224 # if target Windows version is not specified, use Windows XP instead
226 ifeq ($(findstring -D_WIN32_WINNT,$(CXXFLAGS)),)
227 ifeq ($(findstring -D_WIN32_WINDOWS,$(CXXFLAGS)),)
228 ifeq ($(findstring -DWINVER,$(CXXFLAGS)),)
229 ifeq ($(findstring -DNTDDI_VERSION,$(CXXFLAGS)),)
230 CRYPTOPP_CXXFLAGS += -D_WIN32_WINNT=0x0501
231 endif # NTDDI_VERSION
233 endif # _WIN32_WINDOWS
237 # Newlib needs _XOPEN_SOURCE=600 for signals
238 TPROG = TestPrograms/test_newlib.cxx
239 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
240 ifeq ($(strip $(HAVE_OPT)),0)
241 ifeq ($(findstring -D_XOPEN_SOURCE,$(CXXFLAGS)),)
242 CRYPTOPP_CXXFLAGS += -D_XOPEN_SOURCE=600
246 ###########################################################
247 ##### X86/X32/X64 Options #####
248 ###########################################################
250 ifneq ($(IS_X86)$(IS_X64)$(IS_MINGW),000)
251 ifeq ($(DETECT_FEATURES),1)
253 ifeq ($(SUN_COMPILER),1)
254 SSE2_FLAG = -xarch=sse2
255 SSE3_FLAG = -xarch=sse3
256 SSSE3_FLAG = -xarch=ssse3
257 SSE41_FLAG = -xarch=sse4_1
258 SSE42_FLAG = -xarch=sse4_2
259 CLMUL_FLAG = -xarch=aes
260 AESNI_FLAG = -xarch=aes
261 AVX_FLAG = -xarch=avx
262 AVX2_FLAG = -xarch=avx2
263 SHANI_FLAG = -xarch=sha
268 SSE41_FLAG = -msse4.1
269 SSE42_FLAG = -msse4.2
270 CLMUL_FLAG = -mpclmul
277 TPROG = TestPrograms/test_x86_sse2.cxx
279 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
280 ifeq ($(strip $(HAVE_OPT)),0)
281 CHACHA_FLAG = $(SSE2_FLAG)
282 SUN_LDFLAGS += $(SSE2_FLAG)
287 TPROG = TestPrograms/test_x86_ssse3.cxx
289 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
290 ifeq ($(strip $(HAVE_OPT)),0)
291 ARIA_FLAG = $(SSSE3_FLAG)
292 CHAM_FLAG = $(SSSE3_FLAG)
293 KECCAK_FLAG = $(SSSE3_FLAG)
294 LEA_FLAG = $(SSSE3_FLAG)
295 SIMON128_FLAG = $(SSSE3_FLAG)
296 SPECK128_FLAG = $(SSSE3_FLAG)
297 SUN_LDFLAGS += $(SSSE3_FLAG)
302 TPROG = TestPrograms/test_x86_sse41.cxx
304 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
305 ifeq ($(strip $(HAVE_OPT)),0)
306 BLAKE2B_FLAG = $(SSE41_FLAG)
307 BLAKE2S_FLAG = $(SSE41_FLAG)
308 SUN_LDFLAGS += $(SSE41_FLAG)
313 TPROG = TestPrograms/test_x86_sse42.cxx
315 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
316 ifeq ($(strip $(HAVE_OPT)),0)
317 CRC_FLAG = $(SSE42_FLAG)
318 SUN_LDFLAGS += $(SSE42_FLAG)
323 TPROG = TestPrograms/test_x86_clmul.cxx
325 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
326 ifeq ($(strip $(HAVE_OPT)),0)
327 GCM_FLAG = $(SSSE3_FLAG) $(CLMUL_FLAG)
328 GF2N_FLAG = $(CLMUL_FLAG)
329 SUN_LDFLAGS += $(CLMUL_FLAG)
334 TPROG = TestPrograms/test_x86_aes.cxx
336 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
337 ifeq ($(strip $(HAVE_OPT)),0)
338 AES_FLAG = $(SSE41_FLAG) $(AESNI_FLAG)
339 SM4_FLAG = $(SSSE3_FLAG) $(AESNI_FLAG)
340 SUN_LDFLAGS += $(AESNI_FLAG)
345 TPROG = TestPrograms/test_x86_avx.cxx
347 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
348 ifeq ($(strip $(HAVE_OPT)),0)
349 # XXX_FLAG = $(AVX_FLAG)
350 SUN_LDFLAGS += $(AVX_FLAG)
355 TPROG = TestPrograms/test_x86_avx2.cxx
357 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
358 ifeq ($(strip $(HAVE_OPT)),0)
359 CHACHA_AVX2_FLAG = $(AVX2_FLAG)
360 SUN_LDFLAGS += $(AVX2_FLAG)
365 TPROG = TestPrograms/test_x86_sha.cxx
367 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
368 ifeq ($(strip $(HAVE_OPT)),0)
369 SHA_FLAG = $(SSE42_FLAG) $(SHANI_FLAG)
370 SUN_LDFLAGS += $(SHANI_FLAG)
375 ifeq ($(SUN_COMPILER),1)
376 CRYPTOPP_LDFLAGS += $(SUN_LDFLAGS)
380 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
381 else ifeq ($(SSE3_FLAG),)
382 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_SSE3
383 else ifeq ($(SSSE3_FLAG),)
384 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_SSSE3
385 else ifeq ($(SSE41_FLAG),)
386 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_SSE4
387 else ifeq ($(SSE42_FLAG),)
388 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_SSE4
391 ifneq ($(SSE42_FLAG),)
393 # Unusual GCC/Clang on Macports. It assembles AES, but not CLMUL.
394 # test_x86_clmul.s:15: no such instruction: 'pclmulqdq $0, %xmm1,%xmm0'
395 ifeq ($(CLMUL_FLAG),)
396 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_CLMUL
398 ifeq ($(AESNI_FLAG),)
399 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_AESNI
403 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_AVX
404 else ifeq ($(AVX2_FLAG),)
405 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_AVX2
406 else ifeq ($(SHANI_FLAG),)
407 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_SHANI
411 # Drop to SSE2 if available
413 ifneq ($(SSE2_FLAG),)
414 GCM_FLAG = $(SSE2_FLAG)
418 # Most Clang cannot handle mixed asm with positional arguments, where the
419 # body is Intel style with no prefix and the templates are AT&T style.
420 # Also see https://bugs.llvm.org/show_bug.cgi?id=39895 .
422 # CRYPTOPP_DISABLE_MIXED_ASM is now being added in config_asm.h for all
423 # Clang compilers. This test will need to be re-enabled if Clang fixes it.
424 #TPROG = TestPrograms/test_asm_mixed.cxx
425 #HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
426 #ifneq ($(strip $(HAVE_OPT)),0)
427 # CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_MIXED_ASM
433 ifneq ($(INTEL_COMPILER),0)
434 CRYPTOPP_CXXFLAGS += -wd68 -wd186 -wd279 -wd327 -wd161 -wd3180
436 ICC111_OR_LATER := $(shell $(CXX) --version 2>&1 | $(GREP) -c -E "\(ICC\) ([2-9][0-9]|1[2-9]|11\.[1-9])")
437 ifeq ($(ICC111_OR_LATER),0)
438 # "internal error: backend signals" occurs on some x86 inline assembly with ICC 9 and
439 # some x64 inline assembly with ICC 11.0. If you want to use Crypto++'s assembly code
440 # with ICC, try enabling it on individual files
441 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
445 # Allow use of "/" operator for GNU Assembler.
446 # http://sourceware.org/bugzilla/show_bug.cgi?id=4572
447 ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),)
448 ifeq ($(IS_SUN)$(GCC_COMPILER),11)
449 CRYPTOPP_CXXFLAGS += -Wa,--divide
453 # IS_X86, IS_X32 and IS_X64
456 ###########################################################
457 ##### ARM A-32 and NEON #####
458 ###########################################################
460 ifneq ($(IS_ARM32),0)
461 ifeq ($(DETECT_FEATURES),1)
463 # Clang needs an option to include <arm_neon.h>
464 TPROG = TestPrograms/test_arm_neon_header.cxx
465 TOPT = -march=armv7-a -mfpu=neon
466 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
467 ifeq ($(strip $(HAVE_OPT)),0)
468 THEADER += -DCRYPTOPP_ARM_NEON_HEADER=1
471 TPROG = TestPrograms/test_arm_neon.cxx
472 TOPT = -march=armv7-a -mfpu=neon
473 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
474 ifeq ($(strip $(HAVE_OPT)),0)
475 NEON_FLAG = -march=armv7-a -mfpu=neon
476 ARIA_FLAG = -march=armv7-a -mfpu=neon
477 AES_FLAG = -march=armv7-a -mfpu=neon
478 CRC_FLAG = -march=armv7-a -mfpu=neon
479 GCM_FLAG = -march=armv7-a -mfpu=neon
480 BLAKE2B_FLAG = -march=armv7-a -mfpu=neon
481 BLAKE2S_FLAG = -march=armv7-a -mfpu=neon
482 CHACHA_FLAG = -march=armv7-a -mfpu=neon
483 CHAM_FLAG = -march=armv7-a -mfpu=neon
484 LEA_FLAG = -march=armv7-a -mfpu=neon
485 SHA_FLAG = -march=armv7-a -mfpu=neon
486 SIMON128_FLAG = -march=armv7-a -mfpu=neon
487 SPECK128_FLAG = -march=armv7-a -mfpu=neon
488 SM4_FLAG = -march=armv7-a -mfpu=neon
490 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
498 ###########################################################
499 ##### Aach32 and Aarch64 #####
500 ###########################################################
502 ifneq ($(IS_ARMV8),0)
503 ifeq ($(DETECT_FEATURES),1)
505 TPROG = TestPrograms/test_arm_neon_header.cxx
507 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
508 ifeq ($(strip $(HAVE_OPT)),0)
509 THEADER += -DCRYPTOPP_ARM_NEON_HEADER=1
512 TPROG = TestPrograms/test_arm_acle_header.cxx
513 TOPT = -march=armv8-a
514 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
515 ifeq ($(strip $(HAVE_OPT)),0)
516 THEADER += -DCRYPTOPP_ARM_ACLE_HEADER=1
519 TPROG = TestPrograms/test_arm_asimd.cxx
520 TOPT = -march=armv8-a
521 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
522 ifeq ($(strip $(HAVE_OPT)),0)
523 ASIMD_FLAG = -march=armv8-a
524 ARIA_FLAG = -march=armv8-a
525 BLAKE2B_FLAG = -march=armv8-a
526 BLAKE2S_FLAG = -march=armv8-a
527 CHACHA_FLAG = -march=armv8-a
528 CHAM_FLAG = -march=armv8-a
529 LEA_FLAG = -march=armv8-a
530 NEON_FLAG = -march=armv8-a
531 SIMON128_FLAG = -march=armv8-a
532 SPECK128_FLAG = -march=armv8-a
533 SM4_FLAG = -march=armv8-a
535 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
538 ifneq ($(ASIMD_FLAG),)
539 TPROG = TestPrograms/test_arm_crc.cxx
540 TOPT = -march=armv8-a+crc
541 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
542 ifeq ($(strip $(HAVE_OPT)),0)
543 CRC_FLAG = -march=armv8-a+crc
545 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_CRC32
548 TPROG = TestPrograms/test_arm_aes.cxx
549 TOPT = -march=armv8-a+crypto
550 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
551 ifeq ($(strip $(HAVE_OPT)),0)
552 AES_FLAG = -march=armv8-a+crypto
554 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_AES
557 TPROG = TestPrograms/test_arm_pmull.cxx
558 TOPT = -march=armv8-a+crypto
559 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
560 ifeq ($(strip $(HAVE_OPT)),0)
561 GCM_FLAG = -march=armv8-a+crypto
562 GF2N_FLAG = -march=armv8-a+crypto
564 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_PMULL
567 TPROG = TestPrograms/test_arm_sha1.cxx
568 TOPT = -march=armv8-a+crypto
569 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
570 ifeq ($(strip $(HAVE_OPT)),0)
571 SHA_FLAG = -march=armv8-a+crypto
573 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA1
576 TPROG = TestPrograms/test_arm_sha256.cxx
577 TOPT = -march=armv8-a+crypto
578 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
579 ifeq ($(strip $(HAVE_OPT)),0)
580 SHA_FLAG = -march=armv8-a+crypto
582 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA2
585 TPROG = TestPrograms/test_arm_sm3.cxx
586 TOPT = -march=armv8.4-a+crypto
587 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
588 ifeq ($(strip $(HAVE_OPT)),0)
589 SM3_FLAG = -march=armv8.4-a+crypto
590 SM4_FLAG = -march=armv8.4-a+crypto
592 #CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_SM3
593 #CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_SM4
596 TPROG = TestPrograms/test_arm_sha3.cxx
597 TOPT = -march=armv8.4-a+crypto
598 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
599 ifeq ($(strip $(HAVE_OPT)),0)
600 SHA3_FLAG = -march=armv8.4-a+crypto
602 #CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA3
605 TPROG = TestPrograms/test_arm_sha512.cxx
606 TOPT = -march=armv8.4-a+crypto
607 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
608 ifeq ($(strip $(HAVE_OPT)),0)
609 SHA512_FLAG = -march=armv8.4-a+crypto
611 #CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA512
622 ###########################################################
624 ###########################################################
626 # PowerPC and PowerPC64. Altivec is available with POWER4 with GCC and
627 # POWER6 with XLC. The tests below are crafted for IBM XLC and the LLVM
628 # front-end. XLC/LLVM only supplies POWER8 so we have to set the flags for
629 # XLC/LLVM to POWER8. I've got a feeling LLVM is going to cause trouble.
631 ifneq ($(IS_PPC32)$(IS_PPC64),00)
632 ifeq ($(DETECT_FEATURES),1)
634 # IBM XL C/C++ has the -qaltivec flag really screwed up. We can't seem
635 # to get it enabled without an -qarch= option. And -qarch= produces an
636 # error on later versions of the compiler. The only thing that seems
637 # to work consistently is -qarch=auto. -qarch=auto is equivalent to
638 # GCC's -march=native, which we don't really want.
640 # XLC requires -qaltivec in addition to Arch or CPU option
641 ifeq ($(XLC_COMPILER),1)
642 # POWER9_FLAG = -qarch=pwr9 -qaltivec
643 POWER8_FLAG = -qarch=pwr8 -qaltivec
644 POWER7_VSX_FLAG = -qarch=pwr7 -qvsx -qaltivec
645 POWER7_PWR_FLAG = -qarch=pwr7 -qaltivec
646 ALTIVEC_FLAG = -qarch=auto -qaltivec
648 # POWER9_FLAG = -mcpu=power9
649 POWER8_FLAG = -mcpu=power8
650 POWER7_VSX_FLAG = -mcpu=power7 -mvsx
651 POWER7_PWR_FLAG = -mcpu=power7
652 ALTIVEC_FLAG = -maltivec
655 # GCC 10 is giving us trouble in CPU_ProbePower9() and
656 # CPU_ProbeDARN(). GCC is generating POWER9 instructions
657 # on POWER8 for ppc_power9.cpp. The compiler folks did
658 # not think through the consequences of requiring us to
659 # use -mcpu=power9 to unlock the ISA. Epic fail.
660 # https:#github.com/weidai11/cryptopp/issues/986
663 # XLC with LLVM front-ends failed to define XLC defines.
664 #ifeq ($(findstring -qxlcompatmacros,$(CXXFLAGS)),)
665 # TPROG = TestPrograms/test_ppc_altivec.cxx
666 # TOPT = -qxlcompatmacros
667 # HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
668 # ifeq ($(strip $(HAVE_OPT)),0)
669 # CRYPTOPP_CXXFLAGS += -qxlcompatmacros
673 #####################################################################
674 # Looking for a POWER9 option
676 #TPROG = TestPrograms/test_ppc_power9.cxx
677 #TOPT = $(POWER9_FLAG)
678 #HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
679 #ifeq ($(strip $(HAVE_OPT)),0)
680 # DARN_FLAG = $(POWER9_FLAG)
685 #####################################################################
686 # Looking for a POWER8 option
688 TPROG = TestPrograms/test_ppc_power8.cxx
689 TOPT = $(POWER8_FLAG)
690 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
691 ifeq ($(strip $(HAVE_OPT)),0)
692 AES_FLAG = $(POWER8_FLAG)
693 BLAKE2B_FLAG = $(POWER8_FLAG)
694 CRC_FLAG = $(POWER8_FLAG)
695 GCM_FLAG = $(POWER8_FLAG)
696 GF2N_FLAG = $(POWER8_FLAG)
697 LEA_FLAG = $(POWER8_FLAG)
698 SHA_FLAG = $(POWER8_FLAG)
699 SHACAL2_FLAG = $(POWER8_FLAG)
704 #####################################################################
705 # Looking for a POWER7 option
707 # GCC needs -mvsx for Power7 to enable 64-bit vector elements.
708 # XLC provides 64-bit vector elements without an option.
710 TPROG = TestPrograms/test_ppc_power7.cxx
711 TOPT = $(POWER7_VSX_FLAG)
712 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
713 ifeq ($(strip $(HAVE_OPT)),0)
714 POWER7_FLAG = $(POWER7_VSX_FLAG)
716 TPROG = TestPrograms/test_ppc_power7.cxx
717 TOPT = $(POWER7_PWR_FLAG)
718 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
719 ifeq ($(strip $(HAVE_OPT)),0)
720 POWER7_FLAG = $(POWER7_PWR_FLAG)
726 #####################################################################
727 # Looking for an Altivec option
729 TPROG = TestPrograms/test_ppc_altivec.cxx
730 TOPT = $(ALTIVEC_FLAG)
731 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
732 ifeq ($(strip $(HAVE_OPT)),0)
733 ALTIVEC_FLAG := $(ALTIVEC_FLAG)
738 ifneq ($(ALTIVEC_FLAG),)
739 BLAKE2S_FLAG = $(ALTIVEC_FLAG)
740 CHACHA_FLAG = $(ALTIVEC_FLAG)
741 SPECK128_FLAG = $(ALTIVEC_FLAG)
742 SIMON128_FLAG = $(ALTIVEC_FLAG)
745 #####################################################################
746 # Fixups for algorithms that can drop to a lower ISA, if needed
748 # Drop to Altivec if higher Power is not available
749 ifneq ($(ALTIVEC_FLAG),)
751 GCM_FLAG = $(ALTIVEC_FLAG)
755 #####################################################################
756 # Fixups for missing ISAs
758 ifeq ($(ALTIVEC_FLAG),)
759 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_ALTIVEC
760 else ifeq ($(POWER7_FLAG),)
761 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_POWER7
762 else ifeq ($(POWER8_FLAG),)
763 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_POWER8
764 #else ifeq ($(POWER9_FLAG),)
765 # CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_POWER9
771 # IBM XL C++ compiler
772 ifeq ($(XLC_COMPILER),1)
773 ifeq ($(findstring -qmaxmem,$(CXXFLAGS)),)
774 CRYPTOPP_CXXFLAGS += -qmaxmem=-1
776 # http://www-01.ibm.com/support/docview.wss?uid=swg21007500
777 ifeq ($(findstring -qrtti,$(CXXFLAGS)),)
778 CRYPTOPP_CXXFLAGS += -qrtti
785 ###########################################################
787 ###########################################################
789 # Add -fPIC for targets *except* X86, X32, Cygwin or MinGW
790 ifeq ($(IS_X86)$(IS_CYGWIN)$(IS_MINGW),000)
791 ifeq ($(findstring -fpic,$(CXXFLAGS))$(findstring -fPIC,$(CXXFLAGS)),)
792 CRYPTOPP_CXXFLAGS += -fPIC
796 # Use -pthread whenever it is available. See http://www.hpl.hp.com/techreports/2004/HPL-2004-209.pdf
797 # http://stackoverflow.com/questions/2127797/gcc-significance-of-pthread-flag-when-compiling
798 ifeq ($(DETECT_FEATURES),1)
799 ifeq ($(XLC_COMPILER),1)
800 ifeq ($(findstring -qthreaded,$(CXXFLAGS)),)
801 TPROG = TestPrograms/test_pthreads.cxx
803 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
804 ifeq ($(strip $(HAVE_OPT)),0)
805 CRYPTOPP_CXXFLAGS += -qthreaded
806 endif # CRYPTOPP_CXXFLAGS
809 ifeq ($(findstring -pthread,$(CXXFLAGS)),)
810 TPROG = TestPrograms/test_pthreads.cxx
812 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
813 ifeq ($(strip $(HAVE_OPT)),0)
814 CRYPTOPP_CXXFLAGS += -pthread
815 endif # CRYPTOPP_CXXFLAGS
817 endif # XLC/GCC and friends
818 endif # DETECT_FEATURES
820 # Remove -fPIC if present. SunCC use -KPIC, and needs the larger GOT table
821 # https://docs.oracle.com/cd/E19205-01/819-5267/bkbaq/index.html
822 ifeq ($(SUN_COMPILER),1)
823 CRYPTOPP_CXXFLAGS := $(subst -fPIC,-KPIC,$(CRYPTOPP_CXXFLAGS))
824 CRYPTOPP_CXXFLAGS := $(subst -fpic,-KPIC,$(CRYPTOPP_CXXFLAGS))
827 # Remove -fPIC if present. IBM XL C++ uses -qpic
828 ifeq ($(XLC_COMPILER),1)
829 CRYPTOPP_CXXFLAGS := $(subst -fPIC,-qpic,$(CRYPTOPP_CXXFLAGS))
830 CRYPTOPP_CXXFLAGS := $(subst -fpic,-qpic,$(CRYPTOPP_CXXFLAGS))
833 # Disable IBM XL C++ "1500-036: (I) The NOSTRICT option (default at OPT(3))
834 # has the potential to alter the semantics of a program."
835 ifeq ($(XLC_COMPILER),1)
836 TPROG = TestPrograms/test_cxx.cxx
837 TOPT = -qsuppress=1500-036
838 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
839 ifeq ($(strip $(HAVE_OPT)),0)
840 CRYPTOPP_CXXFLAGS += -qsuppress=1500-036
842 endif # IBM XL C++ compiler
844 # Add -xregs=no%appl SPARC. SunCC should not use certain registers in library code.
845 # https://docs.oracle.com/cd/E18659_01/html/821-1383/bkamt.html
846 ifneq ($(IS_SPARC32)$(IS_SPARC64),00)
847 ifeq ($(SUN_COMPILER),1)
848 ifeq ($(findstring -xregs=no%appl,$(CXXFLAGS)),)
849 CRYPTOPP_CXXFLAGS += -xregs=no%appl
852 ifeq ($(GCC_COMPILER),1)
853 ifeq ($(findstring -mno-app-regs,$(CXXFLAGS)),)
854 CRYPTOPP_CXXFLAGS += -mno-app-regs
859 # Add -pipe for everything except IBM XL C++, SunCC and ARM.
860 # Allow ARM-64 because they seems to have >1 GB of memory
861 ifeq ($(XLC_COMPILER)$(SUN_COMPILER)$(IS_ARM32),000)
862 ifeq ($(findstring -save-temps,$(CXXFLAGS)),)
863 CRYPTOPP_CXXFLAGS += -pipe
867 # For SunOS, create a Mapfile that allows our object files
868 # to contain additional bits (like SSE4 and AES on old Xeon)
869 # http://www.oracle.com/technetwork/server-storage/solaris/hwcap-modification-139536.html
870 ifeq ($(IS_SUN)$(SUN_COMPILER),11)
871 ifneq ($(IS_X86)$(IS_X64),00)
872 ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CRYPTOPP_CXXFLAGS) $(CXXFLAGS)),)
873 CRYPTOPP_LDFLAGS += -M cryptopp.mapfile
874 endif # No CRYPTOPP_DISABLE_ASM
878 ifneq ($(IS_LINUX)$(IS_HURD),00)
879 ifeq ($(findstring -fopenmp,$(CXXFLAGS)),-fopenmp)
880 ifeq ($(findstring -lgomp,$(LDLIBS)),)
884 endif # IS_LINUX or IS_HURD
886 # Add -errtags=yes to get the name for a warning suppression
887 ifneq ($(SUN_COMPILER),0) # override flags for CC Sun C++ compiler
889 CRYPTOPP_CXXFLAGS += -template=no%extdef
890 SUN_CC10_BUGGY := $(shell $(CXX) -V 2>&1 | $(GREP) -c -E "CC: Sun .* 5\.10 .* (2009|2010/0[1-4])")
891 ifneq ($(SUN_CC10_BUGGY),0)
892 # -DCRYPTOPP_INCLUDE_VECTOR_CC is needed for Sun Studio 12u1 Sun C++ 5.10 SunOS_i386 128229-02 2009/09/21
893 # and was fixed in May 2010. Remove it if you get "already had a body defined" errors in vector.cc
894 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_INCLUDE_VECTOR_CC
901 # No ASM for Travis testing
902 ifeq ($(findstring no-asm,$(MAKECMDGOALS)),no-asm)
903 ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CRYPTOPP_CXXFLAGS) $(CXXFLAGS)),)
904 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
905 endif # CRYPTOPP_CXXFLAGS
908 # Native build testing. Issue 'make native'.
909 ifeq ($(findstring native,$(MAKECMDGOALS)),native)
912 # Try GCC and compatibles first
913 TPROG = TestPrograms/test_cxx.cxx
915 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
916 ifeq ($(strip $(HAVE_OPT)),0)
917 NATIVE_OPT = -march=native
921 ifeq ($(NATIVE_OPT),)
923 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
924 ifeq ($(strip $(HAVE_OPT)),0)
925 NATIVE_OPT = -mtune=native
930 ifeq ($(NATIVE_OPT),)
932 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
933 ifeq ($(strip $(HAVE_OPT)),0)
938 ifneq ($(NATIVE_OPT),)
939 CRYPTOPP_CXXFLAGS += $(NATIVE_OPT)
944 # Undefined Behavior Sanitizer (UBsan) testing. Issue 'make ubsan'.
945 ifeq ($(findstring ubsan,$(MAKECMDGOALS)),ubsan)
946 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
947 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
948 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
949 ifeq ($(findstring -fsanitize=undefined,$(CXXFLAGS)),)
950 CRYPTOPP_CXXFLAGS += -fsanitize=undefined
951 endif # CRYPTOPP_CXXFLAGS
952 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CXXFLAGS)),)
953 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_COVERAGE
954 endif # CRYPTOPP_CXXFLAGS
957 # Address Sanitizer (Asan) testing. Issue 'make asan'.
958 ifeq ($(findstring asan,$(MAKECMDGOALS)),asan)
959 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
960 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
961 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
962 ifeq ($(findstring -fsanitize=address,$(CXXFLAGS)),)
963 CRYPTOPP_CXXFLAGS += -fsanitize=address
964 endif # CRYPTOPP_CXXFLAGS
965 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CXXFLAGS)),)
966 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_COVERAGE
967 endif # CRYPTOPP_CXXFLAGS
968 ifeq ($(findstring -fno-omit-frame-pointer,$(CXXFLAGS)),)
969 CRYPTOPP_CXXFLAGS += -fno-omit-frame-pointer
970 endif # CRYPTOPP_CXXFLAGS
973 # LD gold linker testing. Triggered by 'LD=ld.gold'.
974 ifeq ($(findstring ld.gold,$(LD)),ld.gold)
975 ifeq ($(findstring -fuse-ld=gold,$(CXXFLAGS)),)
976 LD_GOLD = $(shell command -v ld.gold)
977 ELF_FORMAT := $(shell file $(LD_GOLD) 2>&1 | cut -d":" -f 2 | $(GREP) -i -c "elf")
978 ifneq ($(ELF_FORMAT),0)
979 CRYPTOPP_LDFLAGS += -fuse-ld=gold
984 # lcov code coverage. Issue 'make coverage'.
985 ifneq ($(filter lcov coverage,$(MAKECMDGOALS)),)
986 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
987 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
988 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
989 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CXXFLAGS)),)
990 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_COVERAGE
991 endif # CRYPTOPP_COVERAGE
992 ifeq ($(findstring -coverage,$(CXXFLAGS)),)
993 CRYPTOPP_CXXFLAGS += -coverage
995 endif # GCC code coverage
997 # gcov code coverage for Travis. Issue 'make codecov'.
998 ifneq ($(filter gcov codecov,$(MAKECMDGOALS)),)
999 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1000 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1001 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1002 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CXXFLAGS)),)
1003 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_COVERAGE
1004 endif # CRYPTOPP_COVERAGE
1005 ifeq ($(findstring -coverage,$(CXXFLAGS)),)
1006 CRYPTOPP_CXXFLAGS += -coverage
1008 endif # GCC code coverage
1010 # Valgrind testing. Issue 'make valgrind'.
1011 ifneq ($(filter valgrind,$(MAKECMDGOALS)),)
1012 # Tune flags; see http://valgrind.org/docs/manual/quick-start.html
1013 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1014 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1015 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1016 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CXXFLAGS)),)
1017 CRYPTOPP_CXXFLAGS += -DCRYPTOPP_COVERAGE
1018 endif # -DCRYPTOPP_COVERAGE
1021 # Debug testing on GNU systems. Triggered by -DDEBUG.
1022 # Newlib test due to http://sourceware.org/bugzilla/show_bug.cgi?id=20268
1023 ifneq ($(filter -DDEBUG -DDEBUG=1,$(CXXFLAGS)),)
1024 TPROG = TestPrograms/test_cxx.cxx
1025 USING_GLIBCXX := $(shell $(CXX)$(CXXFLAGS) -E $(TPROG) -o $(TOUT) 2>&1 | $(GREP) -i -c "__GLIBCXX__")
1026 ifneq ($(USING_GLIBCXX),0)
1027 ifeq ($(HAS_NEWLIB),0)
1028 ifeq ($(findstring -D_GLIBCXX_DEBUG,$(CXXFLAGS)),)
1029 CRYPTOPP_CXXFLAGS += -D_GLIBCXX_DEBUG
1030 endif # CRYPTOPP_CXXFLAGS
1032 endif # USING_GLIBCXX
1034 ifeq ($(XLC_COMPILER),1)
1035 TPROG = TestPrograms/test_cxx.cxx
1036 TOPT = -qheapdebug -qro
1037 HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
1038 ifeq ($(strip $(HAVE_OPT)),0)
1039 CRYPTOPP_CXXFLAGS += -qheapdebug -qro
1040 endif # CRYPTOPP_CXXFLAGS
1041 endif # XLC_COMPILER
1044 # Dead code stripping. Issue 'make lean'.
1045 ifeq ($(findstring lean,$(MAKECMDGOALS)),lean)
1046 ifeq ($(findstring -ffunction-sections,$(CXXFLAGS)),)
1047 CRYPTOPP_CXXFLAGS += -ffunction-sections
1048 endif # CRYPTOPP_CXXFLAGS
1049 ifeq ($(findstring -fdata-sections,$(CXXFLAGS)),)
1050 CRYPTOPP_CXXFLAGS += -fdata-sections
1051 endif # CRYPTOPP_CXXFLAGS
1052 ifneq ($(IS_DARWIN),0)
1053 ifeq ($(findstring -Wl,-dead_strip,$(LDFLAGS)),)
1054 CRYPTOPP_LDFLAGS += -Wl,-dead_strip
1055 endif # CRYPTOPP_CXXFLAGS
1056 else # BSD, Linux and Unix
1057 ifeq ($(findstring -Wl,--gc-sections,$(LDFLAGS)),)
1058 CRYPTOPP_LDFLAGS += -Wl,--gc-sections
1060 endif # MAKECMDGOALS
1061 endif # Dead code stripping
1063 # For Shared Objects, Diff, Dist/Zip rules
1064 LIB_VER := $(shell $(GREP) "define CRYPTOPP_VERSION" config_ver.h | cut -d" " -f 3)
1065 LIB_MAJOR := $(shell echo $(LIB_VER) | cut -c 1)
1066 LIB_MINOR := $(shell echo $(LIB_VER) | cut -c 2)
1067 LIB_PATCH := $(shell echo $(LIB_VER) | cut -c 3)
1069 ifeq ($(strip $(LIB_PATCH)),)
1073 ifeq ($(HAS_SOLIB_VERSION),1)
1074 # Different patchlevels and minors are compatible since 6.1
1075 SOLIB_COMPAT_SUFFIX=.$(LIB_MAJOR)
1076 # Linux uses -Wl,-soname
1077 ifneq ($(IS_LINUX)$(IS_HURD),00)
1078 # Linux uses full version suffix for shared library
1079 SOLIB_VERSION_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)
1080 SOLIB_FLAGS=-Wl,-soname,libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
1082 # Solaris uses -Wl,-h
1084 # Solaris uses major version suffix for shared library, but we use major.minor
1085 # The minor version allows previous version to remain and not overwritten.
1086 # https://blogs.oracle.com/solaris/how-to-name-a-solaris-shared-object-v2
1087 SOLIB_VERSION_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR)
1088 SOLIB_FLAGS=-Wl,-h,libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
1090 endif # HAS_SOLIB_VERSION
1092 ###########################################################
1093 ##### Temp file cleanup #####
1094 ###########################################################
1096 # After this point no more test programs should be run.
1097 # https://github.com/weidai11/cryptopp/issues/738
1098 ifeq ($(findstring /dev/null,$(TOUT)),)
1099 # $(info TOUT is not /dev/null, cleaning $(TOUT))
1100 ifeq ($(wildcard $(TOUT)),$(TOUT))
1101 UNUSED := $(shell $(RM) $(TOUT) 2>/dev/null)
1103 ifeq ($(wildcard $(TOUT).dSYM/),$(TOUT).dSYM/)
1104 UNUSED := $(shell $(RM) -r $(TOUT).dSYM/ 2>/dev/null)
1108 ###########################################################
1109 ##### Source and object files #####
1110 ###########################################################
1112 # List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
1113 SRCS := cryptlib.cpp cpu.cpp integer.cpp $(filter-out cryptlib.cpp cpu.cpp integer.cpp pch.cpp simple.cpp,$(sort $(wildcard *.cpp)))
1114 # For Makefile.am; resource.h is Windows
1115 INCL := $(filter-out resource.h,$(sort $(wildcard *.h)))
1117 ifneq ($(IS_MINGW),0)
1121 # Cryptogams source files. We couple to ARMv7.
1122 # Limit to Linux. The source files target the GNU assembler.
1123 # Also see https://www.cryptopp.com/wiki/Cryptogams.
1124 ifeq ($(IS_ARM32)$(IS_LINUX),11)
1125 ifeq ($(CLANG_COMPILER),1)
1126 CRYPTOGAMS_ARMV4_FLAG = -march=armv7-a -Wa,--noexecstack
1127 CRYPTOGAMS_ARMV4_THUMB_FLAG = -march=armv7-a -mthumb -Wa,--noexecstack
1129 CRYPTOGAMS_ARMV4_FLAG = -march=armv7-a -Wa,--noexecstack
1130 CRYPTOGAMS_ARMV4_THUMB_FLAG = -march=armv7-a -Wa,--noexecstack
1132 SRCS += aes_armv4.S sha1_armv4.S sha256_armv4.S sha512_armv4.S
1135 # Remove unneeded arch specific files to speed build time.
1136 ifeq ($(IS_PPC32)$(IS_PPC64),00)
1137 SRCS := $(filter-out ppc_%,$(SRCS))
1139 ifeq ($(IS_ARM32)$(IS_ARMV8),00)
1140 SRCS := $(filter-out arm_%,$(SRCS))
1141 SRCS := $(filter-out neon_%,$(SRCS))
1143 ifeq ($(IS_X86)$(IS_X32)$(IS_X64),000)
1144 SRCS := $(filter-out sse_%,$(SRCS))
1147 # List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
1148 OBJS := $(SRCS:.cpp=.o)
1149 OBJS := $(OBJS:.S=.o)
1151 # List test.cpp first to tame C++ static initialization problems.
1152 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
1153 TESTINCL := bench.h factory.h validate.h
1156 TESTOBJS := $(TESTSRCS:.cpp=.o)
1157 LIBOBJS := $(filter-out $(TESTOBJS),$(OBJS))
1159 # In Crypto++ 5.6.2 these were the source and object files for the FIPS DLL.
1160 # Since the library is on the Historical Validation List we add all files.
1161 # The 5.6.2 list is at https://github.com/weidai11/cryptopp/blob/789f81f048c9.
1163 DLLOBJS := $(DLLSRCS:.cpp=.export.o)
1164 DLLOBJS := $(DLLOBJS:.S=.export.o)
1166 # Import lib testing
1167 LIBIMPORTOBJS := $(LIBOBJS:.o=.import.o)
1168 TESTIMPORTOBJS := $(TESTOBJS:.o=.import.o)
1169 DLLTESTOBJS := dlltest.dllonly.o
1171 # Clean recipe, Issue 998. Don't filter-out some artifacts from the list of objects
1172 # The *.S is a hack. It makes the ASM appear like C++ so the object files make the CLEAN_OBJS list
1173 CLEAN_SRCS := $(wildcard *.cpp) $(patsubst %.S,%.cpp,$(wildcard *.S))
1174 CLEAN_OBJS := $(CLEAN_SRCS:.cpp=.o) $(CLEAN_SRCS:.cpp=.import.o) $(CLEAN_SRCS:.cpp=.export.o)
1176 ###########################################################
1177 ##### Add our flags to user flags #####
1178 ###########################################################
1180 # This ensures we don't add flags when the user forbids
1181 # use of customary library flags, like -fPIC. Make will
1182 # ignore this assignment when CXXFLAGS is passed as an
1183 # argument to the make program: make CXXFLAGS="..."
1184 CPPFLAGS := $(strip $(CRYPTOPP_CPPFLAGS) $(CPPFLAGS))
1185 CXXFLAGS := $(strip $(CRYPTOPP_CXXFLAGS) $(CXXFLAGS))
1186 LDFLAGS := $(strip $(CRYPTOPP_LDFLAGS) $(LDFLAGS))
1188 ###########################################################
1189 ##### Targets and Recipes #####
1190 ###########################################################
1192 # Default builds program with static library only
1194 default: cryptest.exe
1196 .PHONY: all static dynamic
1197 all: static dynamic cryptest.exe
1199 ifneq ($(IS_DARWIN),0)
1200 static: libcryptopp.a
1201 shared dynamic dylib: libcryptopp.dylib
1203 static: libcryptopp.a
1204 shared dynamic: libcryptopp.so$(SOLIB_VERSION_SUFFIX)
1207 # CXXFLAGS are tuned earlier.
1208 .PHONY: native no-asm asan ubsan
1209 native no-asm asan ubsan: cryptest.exe
1211 # CXXFLAGS are tuned earlier. Applications must use linker flags
1212 # -Wl,--gc-sections (Linux and Unix) or -Wl,-dead_strip (OS X)
1214 lean: static dynamic cryptest.exe
1216 # May want to export CXXFLAGS="-g3 -O1"
1217 .PHONY: lcov coverage
1218 lcov coverage: cryptest.exe
1219 @-$(RM) -r ./TestCoverage/
1220 lcov --base-directory . --directory . --zerocounters -q
1222 ./cryptest.exe tv all
1223 ./cryptest.exe b 0.25
1224 lcov --base-directory . --directory . -c -o cryptest.info
1225 lcov --remove cryptest.info "adhoc.*" -o cryptest.info
1226 lcov --remove cryptest.info "fips140.*" -o cryptest.info
1227 lcov --remove cryptest.info "*test.*" -o cryptest.info
1228 lcov --remove cryptest.info "/usr/*" -o cryptest.info
1229 genhtml -o ./TestCoverage/ -t "Crypto++ test coverage" --num-spaces 4 cryptest.info
1231 # Travis CI and CodeCov rule
1232 .PHONY: gcov codecov
1233 gcov codecov: cryptest.exe
1234 @-$(RM) -r ./TestCoverage/
1236 ./cryptest.exe tv all
1239 # Should use CXXFLAGS="-g3 -O1"
1241 valgrind: cryptest.exe
1242 valgrind --track-origins=yes --suppressions=cryptopp.supp ./cryptest.exe v
1245 test check: cryptest.exe
1248 # Used to generate list of source files for Autotools, CMakeList, Android.mk, etc
1251 $(info ***** Library sources *****)
1252 $(info $(filter-out $(TESTSRCS),$(SRCS)))
1254 $(info ***** Library headers *****)
1255 $(info $(filter-out $(TESTINCL),$(INCL)))
1257 $(info ***** Test sources *****)
1260 $(info ***** Test headers *****)
1263 # Directory we want (can't specify on Doygen command line)
1264 DOCUMENT_DIRECTORY := ref$(LIB_VER)
1265 # Directory Doxygen uses (specified in Doygen config file)
1266 ifeq ($(wildcard Doxyfile),Doxyfile)
1267 DOXYGEN_DIRECTORY := $(strip $(shell $(GREP) "OUTPUT_DIRECTORY" Doxyfile | $(GREP) -v "\#" | cut -d "=" -f 2))
1269 # Default directory (in case its missing in the config file)
1270 ifeq ($(strip $(DOXYGEN_DIRECTORY)),)
1271 DOXYGEN_DIRECTORY := html-docs
1274 # Builds the documentation. Directory name is ref563, ref570, etc.
1277 @-$(RM) -r $(DOXYGEN_DIRECTORY)/ $(DOCUMENT_DIRECTORY)/ html-docs/
1278 @-$(RM) CryptoPPRef.zip
1279 doxygen Doxyfile -d CRYPTOPP_DOXYGEN_PROCESSING
1280 $(MV) $(DOXYGEN_DIRECTORY)/ $(DOCUMENT_DIRECTORY)/
1281 zip -9 CryptoPPRef.zip -x ".*" -x "*/.*" -r $(DOCUMENT_DIRECTORY)/
1285 -$(RM) adhoc.cpp.o adhoc.cpp.proto.o $(CLEAN_OBJS) rdrand-*.o
1286 @-$(RM) libcryptopp.a libcryptopp.dylib cryptopp.dll libcryptopp.dll.a libcryptopp.import.a
1287 @-$(RM) libcryptopp.so libcryptopp.so$(SOLIB_COMPAT_SUFFIX) libcryptopp.so$(SOLIB_VERSION_SUFFIX)
1288 @-$(RM) cryptest.exe dlltest.exe cryptest.import.exe cryptest.info ct et
1289 @-$(RM) *.la *.lo *.gcov *.gcno *.gcda *.stackdump core core-*
1290 @-$(RM) /tmp/adhoc.exe
1291 @-$(RM) -r /tmp/cryptopp_test/
1292 @-$(RM) -r *.exe.dSYM/ *.dylib.dSYM/
1295 .PHONY: autotools-clean
1297 @-$(RM) -f configure.ac configure configure.in Makefile.am Makefile.in Makefile
1298 @-$(RM) -f config.guess config.status config.sub config.h.in compile depcomp
1299 @-$(RM) -f install-sh stamp-h1 ar-lib *.lo *.la *.m4 local.* lt*.sh missing
1300 @-$(RM) -f cryptest cryptestcwd libtool* libcryptopp.la libcryptopp.pc*
1301 @-$(RM) -rf build-aux/ m4/ auto*.cache/ .deps/ .libs/
1305 @-$(RM) -f cryptopp-config.cmake CMakeLists.txt
1306 @-$(RM) -rf cmake_build/
1308 .PHONY: android-clean
1310 @-$(RM) -f $(patsubst %_simd.cpp,%_simd.cpp.neon,$(wildcard *_simd.cpp))
1314 distclean: clean autotools-clean cmake-clean android-clean
1315 -$(RM) adhoc.cpp adhoc.cpp.copied GNUmakefile.deps benchmarks.html cryptest.txt
1316 @-$(RM) cryptest-*.txt cryptopp.tgz libcryptopp.pc *.o *.bc *.ii *~
1317 @-$(RM) -r cryptlib.lib cryptest.exe *.suo *.sdf *.pdb Win32/ x64/ ipch/
1318 @-$(RM) -r $(LIBOBJS:.o=.obj) $(TESTOBJS:.o=.obj)
1319 @-$(RM) -r $(LIBOBJS:.o=.lst) $(TESTOBJS:.o=.lst)
1320 @-$(RM) -r TestCoverage/ ref*/
1321 @-$(RM) cryptopp$(LIB_VER)\.* CryptoPPRef.zip
1323 # Install cryptest.exe, libcryptopp.a, libcryptopp.so and libcryptopp.pc.
1324 # The library install was broken-out into its own recipe at GH #653.
1326 install: cryptest.exe install-lib
1327 @-$(MKDIR) $(DESTDIR)$(BINDIR)
1328 $(CP) cryptest.exe $(DESTDIR)$(BINDIR)
1329 $(CHMOD) 0755 $(DESTDIR)$(BINDIR)/cryptest.exe
1330 @-$(MKDIR) $(DESTDIR)$(DATADIR)/cryptopp/TestData
1331 @-$(MKDIR) $(DESTDIR)$(DATADIR)/cryptopp/TestVectors
1332 $(CP) TestData/*.dat $(DESTDIR)$(DATADIR)/cryptopp/TestData
1333 $(CHMOD) 0644 $(DESTDIR)$(DATADIR)/cryptopp/TestData/*.dat
1334 $(CP) TestVectors/*.txt $(DESTDIR)$(DATADIR)/cryptopp/TestVectors
1335 $(CHMOD) 0644 $(DESTDIR)$(DATADIR)/cryptopp/TestVectors/*.txt
1337 # A recipe to install only the library, and not cryptest.exe. Also
1338 # see https://github.com/weidai11/cryptopp/issues/653. Some users
1339 # already have a libcryptopp.pc. Install the *.pc file if the file
1340 # is present. If you want one, then issue 'make libcryptopp.pc'.
1343 @-$(MKDIR) $(DESTDIR)$(INCLUDEDIR)/cryptopp
1344 $(CP) *.h $(DESTDIR)$(INCLUDEDIR)/cryptopp
1345 $(CHMOD) 0644 $(DESTDIR)$(INCLUDEDIR)/cryptopp/*.h
1346 ifneq ($(wildcard libcryptopp.a),)
1347 @-$(MKDIR) $(DESTDIR)$(LIBDIR)
1348 $(CP) libcryptopp.a $(DESTDIR)$(LIBDIR)
1349 $(CHMOD) 0644 $(DESTDIR)$(LIBDIR)/libcryptopp.a
1351 ifneq ($(wildcard libcryptopp.dylib),)
1352 @-$(MKDIR) $(DESTDIR)$(LIBDIR)
1353 $(CP) libcryptopp.dylib $(DESTDIR)$(LIBDIR)
1354 $(CHMOD) 0755 $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
1355 -install_name_tool -id $(DESTDIR)$(LIBDIR)/libcryptopp.dylib $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
1357 ifneq ($(wildcard libcryptopp.so$(SOLIB_VERSION_SUFFIX)),)
1358 @-$(MKDIR) $(DESTDIR)$(LIBDIR)
1359 $(CP) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)
1360 $(CHMOD) 0755 $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
1361 ifeq ($(HAS_SOLIB_VERSION),1)
1362 -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so
1363 $(LDCONF) $(DESTDIR)$(LIBDIR)
1366 ifneq ($(wildcard libcryptopp.pc),)
1367 @-$(MKDIR) $(DESTDIR)$(LIBDIR)/pkgconfig
1368 $(CP) libcryptopp.pc $(DESTDIR)$(LIBDIR)/pkgconfig
1369 $(CHMOD) 0644 $(DESTDIR)$(LIBDIR)/pkgconfig/libcryptopp.pc
1372 .PHONY: remove uninstall
1374 -$(RM) -r $(DESTDIR)$(INCLUDEDIR)/cryptopp
1375 -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.a
1376 -$(RM) $(DESTDIR)$(BINDIR)/cryptest.exe
1377 ifneq ($(wildcard $(DESTDIR)$(LIBDIR)/libcryptopp.dylib),)
1378 -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
1380 ifneq ($(wildcard $(DESTDIR)$(LIBDIR)/libcryptopp.so),)
1381 -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so
1383 @-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
1384 @-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
1385 @-$(RM) $(DESTDIR)$(LIBDIR)/pkgconfig/libcryptopp.pc
1386 @-$(RM) -r $(DESTDIR)$(DATADIR)/cryptopp
1388 libcryptopp.a: $(LIBOBJS)
1389 $(AR) $(ARFLAGS) $@ $(LIBOBJS)
1394 ifeq ($(HAS_SOLIB_VERSION),1)
1395 .PHONY: libcryptopp.so
1396 libcryptopp.so: libcryptopp.so$(SOLIB_VERSION_SUFFIX) | so_warning
1399 libcryptopp.so$(SOLIB_VERSION_SUFFIX): $(LIBOBJS)
1400 ifeq ($(XLC_COMPILER),1)
1401 $(CXX) -qmkshrobj $(SOLIB_FLAGS) -o $@ $(CXXFLAGS) $(LDFLAGS) $(LIBOBJS) $(LDLIBS)
1403 $(CXX) -shared $(SOLIB_FLAGS) -o $@ $(CXXFLAGS) $(LDFLAGS) $(LIBOBJS) $(LDLIBS)
1405 ifeq ($(HAS_SOLIB_VERSION),1)
1406 -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.so
1407 -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
1410 libcryptopp.dylib: $(LIBOBJS)
1411 $(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)
1413 cryptest.exe: $(LINK_LIBRARY) $(TESTOBJS)
1414 $(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) $(LINK_LIBRARY_PATH)$(LINK_LIBRARY) $(LDFLAGS) $(LDLIBS)
1416 # Makes it faster to test changes
1418 $(CXX) -o ct $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS)
1420 dll: cryptest.import.exe dlltest.exe
1422 cryptopp.dll: $(DLLOBJS)
1423 $(CXX) -shared -o $@ $(CXXFLAGS) $(DLLOBJS) $(LDFLAGS) $(LDLIBS) -Wl,--out-implib=libcryptopp.dll.a
1425 libcryptopp.import.a: $(LIBIMPORTOBJS)
1426 $(AR) $(ARFLAGS) $@ $(LIBIMPORTOBJS)
1431 cryptest.import.exe: cryptopp.dll libcryptopp.import.a $(TESTIMPORTOBJS)
1432 $(CXX) -o $@ $(CXXFLAGS) $(TESTIMPORTOBJS) -L. -lcryptopp.dll -lcryptopp.import $(LDFLAGS) $(LDLIBS)
1434 dlltest.exe: cryptopp.dll $(DLLTESTOBJS)
1435 $(CXX) -o $@ $(CXXFLAGS) $(DLLTESTOBJS) -L. -lcryptopp.dll $(LDFLAGS) $(LDLIBS)
1437 # Some users already have a libcryptopp.pc. We install it if the file
1438 # is present. If you want one, then issue 'make libcryptopp.pc'. Be sure
1439 # to use/verify PREFIX and LIBDIR below after writing the file.
1441 @echo '# Crypto++ package configuration file' > libcryptopp.pc
1442 @echo '' >> libcryptopp.pc
1443 @echo 'prefix=$(PC_PREFIX)' >> libcryptopp.pc
1444 @echo 'libdir=$(PC_LIBDIR)' >> libcryptopp.pc
1445 @echo 'includedir=$(PC_INCLUDEDIR)' >> libcryptopp.pc
1446 @echo 'datadir=$(PC_DATADIR)' >> libcryptopp.pc
1447 @echo '' >> libcryptopp.pc
1448 @echo 'Name: Crypto++' >> libcryptopp.pc
1449 @echo 'Description: Crypto++ cryptographic library' >> libcryptopp.pc
1450 @echo 'Version: 8.4' >> libcryptopp.pc
1451 @echo 'URL: https://cryptopp.com/' >> libcryptopp.pc
1452 @echo '' >> libcryptopp.pc
1453 @echo 'Cflags: -I$${includedir}' >> libcryptopp.pc
1454 @echo 'Libs: -L$${libdir} -lcryptopp' >> libcryptopp.pc
1456 # This recipe prepares the distro files
1457 TEXT_FILES := *.h *.cpp License.txt Readme.txt Install.txt Filelist.txt Doxyfile cryptest* cryptlib* dlltest* cryptdll* *.sln *.vcxproj *.filters cryptopp.rc TestVectors/*.txt TestData/*.dat TestPrograms/*.cxx TestScripts/*.sh TestScripts/*.cmd
1458 EXEC_FILES := GNUmakefile GNUmakefile-cross TestData/ TestVectors/ TestScripts/ TestPrograms/
1460 ifeq ($(wildcard Filelist.txt),Filelist.txt)
1461 DIST_FILES := $(shell cat Filelist.txt)
1466 ifneq ($(IS_DARWIN),0)
1467 $(SED) -i '' -e's/[[:space:]]*$$//' *.supp *.txt .*.yml *.h *.cpp *.asm *.S
1468 $(SED) -i '' -e's/[[:space:]]*$$//' *.sln *.vcxproj *.filters GNUmakefile GNUmakefile-cross
1469 $(SED) -i '' -e's/[[:space:]]*$$//' TestData/*.dat TestVectors/*.txt TestPrograms/*.cxx TestScripts/*.*
1472 $(SED) -i -e's/[[:space:]]*$$//' *.supp *.txt .*.yml *.h *.cpp *.asm *.S
1473 $(SED) -i -e's/[[:space:]]*$$//' *.sln *.vcxproj *.filters GNUmakefile GNUmakefile-cross
1474 $(SED) -i -e's/[[:space:]]*$$//' TestData/*.dat TestVectors/*.txt TestPrograms/*.cxx TestScripts/*.*
1480 @-$(CHMOD) 0700 TestVectors/ TestData/ TestPrograms/ TestScripts/
1481 @-$(CHMOD) 0600 $(TEXT_FILES) *.supp .*.yml *.asm *.zip TestVectors/*.txt TestData/*.dat TestPrograms/*.cxx TestScripts/*.*
1482 @-$(CHMOD) 0700 $(EXEC_FILES) TestScripts/*.sh TestScripts/*.cmd
1483 @-$(CHMOD) 0700 GNUmakefile GNUmakefile-cross TestScripts/*.sh
1484 -unix2dos --keepdate --quiet $(TEXT_FILES) .*.yml *.asm TestScripts/*.*
1485 -dos2unix --keepdate --quiet GNUmakefile* *.supp *.mapfile TestScripts/*.sh
1486 ifneq ($(IS_DARWIN),0)
1490 # Build the ZIP file with source files. No documentation.
1492 zip dist: | distclean convert
1493 zip -q -9 cryptopp$(LIB_VER).zip $(DIST_FILES)
1495 # Build the ISO to transfer the ZIP to old distros via CDROM
1498 ifneq ($(IS_DARWIN),0)
1499 $(MKDIR) $(PWD)/cryptopp$(LIB_VER)
1500 $(CP) cryptopp$(LIB_VER).zip $(PWD)/cryptopp$(LIB_VER)
1501 hdiutil makehybrid -iso -joliet -o cryptopp$(LIB_VER).iso $(PWD)/cryptopp$(LIB_VER)
1502 @-$(RM) -r $(PWD)/cryptopp$(LIB_VER)
1503 else ifneq ($(IS_LINUX)$(IS_HURD),00)
1504 $(MKDIR) $(PWD)/cryptopp$(LIB_VER)
1505 $(CP) cryptopp$(LIB_VER).zip $(PWD)/cryptopp$(LIB_VER)
1506 genisoimage -q -o cryptopp$(LIB_VER).iso $(PWD)/cryptopp$(LIB_VER)
1507 @-$(RM) -r $(PWD)/cryptopp$(LIB_VER)
1510 # CRYPTOPP_CPU_FREQ in GHz
1511 CRYPTOPP_CPU_FREQ ?= 0.0
1512 .PHONY: bench benchmark benchmarks
1513 bench benchmark benchmarks: cryptest.exe
1514 @-$(RM) -f benchmarks.html
1515 ./cryptest.exe b 2 $(CRYPTOPP_CPU_FREQ)
1517 adhoc.cpp: adhoc.cpp.proto
1518 ifeq ($(wildcard adhoc.cpp),)
1519 cp adhoc.cpp.proto adhoc.cpp
1524 # Include dependencies, if present. You must issue `make deps` to create them.
1525 ifeq ($(wildcard GNUmakefile.deps),GNUmakefile.deps)
1526 -include GNUmakefile.deps
1527 endif # Dependencies
1529 # Cryptogams ARM asm implementation. AES needs -mthumb for Clang
1530 aes_armv4.o : aes_armv4.S
1531 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CRYPTOGAMS_ARMV4_THUMB_FLAG) -c) $<
1533 # SSSE3 or NEON available
1534 aria_simd.o : aria_simd.cpp
1535 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(ARIA_FLAG) -c) $<
1537 # SSE, NEON or POWER7 available
1538 blake2s_simd.o : blake2s_simd.cpp
1539 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(BLAKE2S_FLAG) -c) $<
1541 # SSE, NEON or POWER8 available
1542 blake2b_simd.o : blake2b_simd.cpp
1543 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(BLAKE2B_FLAG) -c) $<
1545 # SSE2 or NEON available
1546 chacha_simd.o : chacha_simd.cpp
1547 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CHACHA_FLAG) -c) $<
1550 chacha_avx.o : chacha_avx.cpp
1551 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CHACHA_AVX2_FLAG) -c) $<
1554 cham_simd.o : cham_simd.cpp
1555 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CHAM_FLAG) -c) $<
1557 # SSE4.2 or ARMv8a available
1558 crc_simd.o : crc_simd.cpp
1559 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CRC_FLAG) -c) $<
1563 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(DARN_FLAG) -c) $<
1566 donna_sse.o : donna_sse.cpp
1567 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SSE2_FLAG) -c) $<
1569 # Carryless multiply
1570 gcm_simd.o : gcm_simd.cpp
1571 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(GCM_FLAG) -c) $<
1573 # Carryless multiply
1574 gf2n_simd.o : gf2n_simd.cpp
1575 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(GF2N_FLAG) -c) $<
1578 keccak_simd.o : keccak_simd.cpp
1579 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(KECCAK_FLAG) -c) $<
1582 lea_simd.o : lea_simd.cpp
1583 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LEA_FLAG) -c) $<
1586 neon_simd.o : neon_simd.cpp
1587 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(NEON_FLAG) -c) $<
1590 ppc_simd.o : ppc_simd.cpp
1591 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(ALTIVEC_FLAG) -c) $<
1594 ppc_power7.o : ppc_power7.cpp
1595 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(POWER7_FLAG) -c) $<
1598 ppc_power8.o : ppc_power8.cpp
1599 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(POWER8_FLAG) -c) $<
1602 ppc_power9.o : ppc_power9.cpp
1603 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(POWER9_FLAG) -c) $<
1605 # AESNI or ARMv7a/ARMv8a available
1606 rijndael_simd.o : rijndael_simd.cpp
1607 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(AES_FLAG) -c) $<
1609 # SSE4.2/SHA-NI or ARMv8a available
1610 sha_simd.o : sha_simd.cpp
1611 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SHA_FLAG) -c) $<
1613 # Cryptogams SHA1 asm implementation.
1614 sha1_armv4.o : sha1_armv4.S
1615 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CRYPTOGAMS_ARMV4_FLAG) -c) $<
1617 # Cryptogams SHA256 asm implementation.
1618 sha256_armv4.o : sha256_armv4.S
1619 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CRYPTOGAMS_ARMV4_FLAG) -c) $<
1621 # Cryptogams SHA512 asm implementation.
1622 sha512_armv4.o : sha512_armv4.S
1623 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CRYPTOGAMS_ARMV4_FLAG) -c) $<
1625 sha3_simd.o : sha3_simd.cpp
1626 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SHA3_FLAG) -c) $<
1628 # SSE4.2/SHA-NI or ARMv8a available
1629 shacal2_simd.o : shacal2_simd.cpp
1630 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SHA_FLAG) -c) $<
1632 # SSSE3, NEON or POWER8 available
1633 simon128_simd.o : simon128_simd.cpp
1634 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SIMON128_FLAG) -c) $<
1636 # SSSE3, NEON or POWER8 available
1637 speck128_simd.o : speck128_simd.cpp
1638 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SPECK128_FLAG) -c) $<
1641 sm3_simd.o : sm3_simd.cpp
1642 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SM3_FLAG) -c) $<
1645 sm4_simd.o : sm4_simd.cpp
1646 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SM4_FLAG) -c) $<
1648 # IBM XLC -O3 optimization bug
1649 ifeq ($(XLC_COMPILER),1)
1651 $(CXX) $(strip $(CPPFLAGS) $(subst -O3,-O2,$(CXXFLAGS)) -c) $<
1652 donna_32.o : donna_32.cpp
1653 $(CXX) $(strip $(CPPFLAGS) $(subst -O3,-O2,$(CXXFLAGS)) -c) $<
1654 donna_64.o : donna_64.cpp
1655 $(CXX) $(strip $(CPPFLAGS) $(subst -O3,-O2,$(CXXFLAGS)) -c) $<
1659 sse_simd.o : sse_simd.cpp
1660 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SSE2_FLAG) -c) $<
1662 # Don't build Rijndael with UBsan. Too much noise due to unaligned data accesses.
1663 ifneq ($(findstring -fsanitize=undefined,$(CXXFLAGS)),)
1664 rijndael.o : rijndael.cpp
1665 $(CXX) $(strip $(subst -fsanitize=undefined,,$(CXXFLAGS)) -c) $<
1668 # Only use CRYPTOPP_DATA_DIR if its not set in CXXFLAGS
1669 ifeq ($(findstring -DCRYPTOPP_DATA_DIR, $(CXXFLAGS)),)
1670 ifneq ($(strip $(CRYPTOPP_DATA_DIR)),)
1671 validat%.o : validat%.cpp
1672 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" -c) $<
1673 bench%.o : bench%.cpp
1674 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" -c) $<
1675 datatest.o : datatest.cpp
1676 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" -c) $<
1678 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" -c) $<
1682 validat1.o : validat1.cpp
1683 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(ALTIVEC_FLAG) -c) $<
1686 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) -DCRYPTOPP_DLL_ONLY -c) $< -o $@
1689 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) -DCRYPTOPP_IMPORTS -c) $< -o $@
1692 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) -DCRYPTOPP_EXPORTS -c) $< -o $@
1695 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) -c) $<
1698 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) -c) $<
1702 ifeq ($(HAS_SOLIB_VERSION),1)
1703 $(info WARNING: Only the symlinks to the shared-object library have been updated.)
1704 $(info WARNING: If the library is installed in a system directory you will need)
1705 $(info WARNING: to run 'ldconfig' to update the shared-object library cache.)
1709 .PHONY: dep deps depend
1710 dep deps depend GNUmakefile.deps:
1711 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS)) -MM *.cpp > GNUmakefile.deps