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
14TOUT := $(strip $(TOUT))
16# Allow override for the cryptest.exe recipe. Change to
17# ./libcryptopp.so or ./libcryptopp.dylib to suit your
18# taste. https://github.com/weidai11/cryptopp/issues/866
19LINK_LIBRARY ?= libcryptopp.a
20LINK_LIBRARY_PATH ?= ./
22# Command and arguments
24ARFLAGS ?= -cr # ar needs the dash on OpenBSD
36LDCONF ?= /sbin/ldconfig -n
38# Solaris provides a non-Posix sed and grep at /usr/bin
39# Solaris 10 is missing AR in /usr/bin
40ifneq ($(wildcard /usr/xpg4/bin/grep),)
41 GREP := /usr/xpg4/bin/grep
43ifneq ($(wildcard /usr/xpg4/bin/sed),)
44 SED := /usr/xpg4/bin/sed
46ifneq ($(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.
52MACHINEX := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null)
53HOSTX := $(shell echo $(MACHINEX) | cut -f 1 -d '-')
55 HOSTX := $(shell uname -m 2>/dev/null)
58IS_X86 := $(shell echo "$(HOSTX)" | $(GREP) -v "64" | $(GREP) -i -c -E 'i.86|x86|i86')
59IS_X64 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E '_64|d64')
60IS_PPC32 := $(shell echo "$(HOSTX)" | $(GREP) -v "64" | $(GREP) -i -c -E 'ppc|power')
61IS_PPC64 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E 'ppc64|powerpc64|power64')
62IS_SPARC32 := $(shell echo "$(HOSTX)" | $(GREP) -v "64" | $(GREP) -i -c -E 'sun|sparc')
63IS_SPARC64 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E 'sun|sparc64')
64IS_ARM32 := $(shell echo "$(HOSTX)" | $(GREP) -v "64" | $(GREP) -i -c -E 'arm|armhf|armv7|eabihf|armv8')
65IS_ARMV8 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E 'aarch32|aarch64|arm64')
67# Attempt to determine platform
68SYSTEMX := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null)
70 SYSTEMX := $(shell uname -s 2>/dev/null)
73IS_LINUX := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "Linux")
74IS_HURD := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c -E "GNU|Hurd")
75IS_MINGW := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "MinGW")
76IS_CYGWIN := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "Cygwin")
77IS_DARWIN := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "Darwin")
78IS_NETBSD := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "NetBSD")
79IS_AIX := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "aix")
80IS_SUN := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c -E "SunOS|Solaris")
82SUN_COMPILER := $(shell $(CXX) -V 2>&1 | $(GREP) -i -c -E 'CC: (Sun|Studio)')
83GCC_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -v -E '(llvm|clang)' | $(GREP) -i -c -E '(gcc|g\+\+)')
84XLC_COMPILER := $(shell $(CXX) -qversion 2>/dev/null |$(GREP) -i -c "IBM XL")
85CLANG_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -i -c -E '(llvm|clang)')
86INTEL_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -i -c '\(icc\)')
88# Enable shared object versioning for Linux and Solaris
90ifneq ($(IS_LINUX)$(IS_HURD)$(IS_SUN),000)
91 HAS_SOLIB_VERSION := 1
94# Formerly adhoc.cpp was created from adhoc.cpp.proto when needed.
95ifeq ($(wildcard adhoc.cpp),)
96$(shell cp adhoc.cpp.proto adhoc.cpp)
99# Hack to skip CPU feature tests for some recipes
101ifneq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
104ifneq ($(findstring clean,$(MAKECMDGOALS)),)
107ifneq ($(findstring distclean,$(MAKECMDGOALS)),)
110ifneq ($(findstring trim,$(MAKECMDGOALS)),)
113ifneq ($(findstring zip,$(MAKECMDGOALS)),)
119endif # CRYPTOPP_DISABLE_ASM
121# Strip out -Wall, -Wextra and friends for feature testing. FORTIFY_SOURCE is removed
122# because it requires -O1 or higher, but we use -O0 to tame the optimizer.
123# Always print testing flags since some tests always happen, like 64-bit.
124TCXXFLAGS := $(filter-out -D_FORTIFY_SOURCE=% -M -MM -Wall -Wextra -Werror% -Wunused -Wconversion -Wp%, $(CPPFLAGS) $(CXXFLAGS))
125ifneq ($(strip $(TCXXFLAGS)),)
126 $(info Using testing flags: $(TCXXFLAGS))
129# TCOMMAND is used for just about all tests. Make will lazy-evaluate
130# the variables when executed by $(shell $(TCOMMAND) ...).
131TCOMMAND = $(CXX) -I. $(TCXXFLAGS) $(TEXTRA) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT)
135 TPROG = TestPrograms/test_64bit.cpp
137 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
138 ifeq ($(strip $(HAVE_OPT)),0)
145# Uncomment for debugging
146# $(info Here's what we found... IS_X86: $(IS_X86), IS_X64: $(IS_X64), IS_ARM32: $(IS_ARM32), IS_ARMV8: $(IS_ARMV8))
148###########################################################
149##### General Variables #####
150###########################################################
152# Base CPPFLAGS and CXXFLAGS used if the user did not specify them
153ifeq ($(filter -DDEBUG -DNDEBUG,$(CPPFLAGS)$(CXXFLAGS)),)
154 CRYPTOPP_CPPFLAGS += -DNDEBUG
156ifeq ($(filter -g%,$(CPPFLAGS)$(CXXFLAGS)),)
157 ifeq ($(SUN_COMPILER),1)
158 CRYPTOPP_CXXFLAGS += -g
160 CRYPTOPP_CXXFLAGS += -g2
163ifeq ($(filter -O% -xO%,$(CPPFLAGS)$(CXXFLAGS)),)
164 ifeq ($(SUN_COMPILER),1)
165 CRYPTOPP_CXXFLAGS += -xO3
168 CRYPTOPP_CXXFLAGS += -O3
173# Needed when the assembler is invoked
174ifeq ($(findstring -Wa,--noexecstack,$(ASFLAGS)$(CXXFLAGS)),)
175 CRYPTOPP_ASFLAGS += -Wa,--noexecstack
178# Fix CXX on Cygwin 1.1.4
183# On ARM we may compile aes_armv4.S, sha1_armv4.S, sha256_armv4.S, and
184# sha512_armv4.S through the CC compiler
185ifeq ($(GCC_COMPILER),1)
188ifeq ($(CLANG_COMPILER),1)
193# http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
196 PC_PREFIX = /usr/local
198 PC_PREFIX = $(PREFIX)
201 LIBDIR := $(PREFIX)/lib
202 PC_LIBDIR = $${prefix}/lib
204 PC_LIBDIR = $(LIBDIR)
207 DATADIR := $(PREFIX)/share
208 PC_DATADIR = $${prefix}/share
210 PC_DATADIR = $(DATADIR)
213 INCLUDEDIR := $(PREFIX)/include
214 PC_INCLUDEDIR = $${prefix}/include
216 PC_INCLUDEDIR = $(INCLUDEDIR)
219 BINDIR := $(PREFIX)/bin
222# We honor ARFLAGS, but the "v" option used by default causes a noisy make
226 ifeq ($(ARFLAGS),-rv)
231# Original MinGW targets Win2k by default, but lacks proper Win2k support
232# if target Windows version is not specified, use Windows XP instead
234ifeq ($(findstring -D_WIN32_WINNT,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
235ifeq ($(findstring -D_WIN32_WINDOWS,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
236ifeq ($(findstring -DWINVER,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
237ifeq ($(findstring -DNTDDI_VERSION,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
238 CRYPTOPP_CPPFLAGS += -D_WIN32_WINNT=0x0501
241endif # _WIN32_WINDOWS
245# Newlib needs _XOPEN_SOURCE=600 for signals
246TPROG = TestPrograms/test_newlib.cpp
248HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
249ifeq ($(strip $(HAVE_OPT)),0)
250 ifeq ($(findstring -D_XOPEN_SOURCE,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
251 CRYPTOPP_CPPFLAGS += -D_XOPEN_SOURCE=600
255###########################################################
256##### X86/X32/X64 Options #####
257###########################################################
259ifneq ($(IS_X86)$(IS_X64)$(IS_MINGW),000)
260ifeq ($(DETECT_FEATURES),1)
262 ifeq ($(SUN_COMPILER),1)
263 SSE2_FLAG = -xarch=sse2
264 SSE3_FLAG = -xarch=sse3
265 SSSE3_FLAG = -xarch=ssse3
266 SSE41_FLAG = -xarch=sse4_1
267 SSE42_FLAG = -xarch=sse4_2
268 CLMUL_FLAG = -xarch=aes
269 AESNI_FLAG = -xarch=aes
270 AVX_FLAG = -xarch=avx
271 AVX2_FLAG = -xarch=avx2
272 SHANI_FLAG = -xarch=sha
277 SSE41_FLAG = -msse4.1
278 SSE42_FLAG = -msse4.2
279 CLMUL_FLAG = -mpclmul
286 # Tell MacPorts and Homebrew GCC to use Clang integrated assembler
287 # Intel-based Macs. http://github.com/weidai11/cryptopp/issues/190
288 ifneq ($(IS_DARWIN),0)
289 ifeq ($(findstring -Wa,-q,$(CXXFLAGS)),)
290 TPROG = TestPrograms/test_cxx.cpp
292 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
293 ifeq ($(strip $(HAVE_OPT)),0)
295 CRYPTOPP_CXXFLAGS += -Wa,-q
300 TPROG = TestPrograms/test_x86_sse2.cpp
302 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
303 ifeq ($(strip $(HAVE_OPT)),0)
304 CHACHA_FLAG = $(SSE2_FLAG)
305 SUN_LDFLAGS += $(SSE2_FLAG)
307 # Make does not have useful debugging facilities. Show the user
308 # what happened by compiling again without the pipe.
309 $(info Running make again to see what failed)
310 $(info $(shell $(TCOMMAND)))
315 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ASM
318 # Need SSE2 or higher for these tests
319 ifneq ($(SSE2_FLAG),)
321 TPROG = TestPrograms/test_x86_sse3.cpp
323 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
324 ifneq ($(strip $(HAVE_OPT)),0)
328 TPROG = TestPrograms/test_x86_ssse3.cpp
330 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
331 ifeq ($(strip $(HAVE_OPT)),0)
332 ARIA_FLAG = $(SSSE3_FLAG)
333 CHAM_FLAG = $(SSSE3_FLAG)
334 KECCAK_FLAG = $(SSSE3_FLAG)
335 LEA_FLAG = $(SSSE3_FLAG)
336 LSH256_FLAG = $(SSSE3_FLAG)
337 LSH512_FLAG = $(SSSE3_FLAG)
338 SIMON128_FLAG = $(SSSE3_FLAG)
339 SPECK128_FLAG = $(SSSE3_FLAG)
340 SUN_LDFLAGS += $(SSSE3_FLAG)
345 # The first Apple MacBooks were Core2's with SSE4.1
346 ifneq ($(IS_DARWIN),0)
347 # Add SSE2 algo's here as required
348 # They get a free upgrade
351 TPROG = TestPrograms/test_x86_sse41.cpp
353 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
354 ifeq ($(strip $(HAVE_OPT)),0)
355 BLAKE2B_FLAG = $(SSE41_FLAG)
356 BLAKE2S_FLAG = $(SSE41_FLAG)
357 SUN_LDFLAGS += $(SSE41_FLAG)
362 TPROG = TestPrograms/test_x86_sse42.cpp
364 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
365 ifeq ($(strip $(HAVE_OPT)),0)
366 CRC_FLAG = $(SSE42_FLAG)
367 SUN_LDFLAGS += $(SSE42_FLAG)
372 TPROG = TestPrograms/test_x86_clmul.cpp
374 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
375 ifeq ($(strip $(HAVE_OPT)),0)
376 GCM_FLAG = $(SSSE3_FLAG) $(CLMUL_FLAG)
377 GF2N_FLAG = $(CLMUL_FLAG)
378 SUN_LDFLAGS += $(CLMUL_FLAG)
383 TPROG = TestPrograms/test_x86_aes.cpp
385 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
386 ifeq ($(strip $(HAVE_OPT)),0)
387 AES_FLAG = $(SSE41_FLAG) $(AESNI_FLAG)
388 SM4_FLAG = $(SSSE3_FLAG) $(AESNI_FLAG)
389 SUN_LDFLAGS += $(AESNI_FLAG)
394 TPROG = TestPrograms/test_x86_avx.cpp
396 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
397 ifeq ($(strip $(HAVE_OPT)),0)
398 # XXX_FLAG = $(AVX_FLAG)
399 SUN_LDFLAGS += $(AVX_FLAG)
404 TPROG = TestPrograms/test_x86_avx2.cpp
406 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
407 ifeq ($(strip $(HAVE_OPT)),0)
408 CHACHA_AVX2_FLAG = $(AVX2_FLAG)
409 LSH256_AVX2_FLAG = $(AVX2_FLAG)
410 LSH512_AVX2_FLAG = $(AVX2_FLAG)
411 SUN_LDFLAGS += $(AVX2_FLAG)
416 TPROG = TestPrograms/test_x86_sha.cpp
418 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
419 ifeq ($(strip $(HAVE_OPT)),0)
420 SHA_FLAG = $(SSE42_FLAG) $(SHANI_FLAG)
421 SUN_LDFLAGS += $(SHANI_FLAG)
426 ifeq ($(SUN_COMPILER),1)
427 CRYPTOPP_LDFLAGS += $(SUN_LDFLAGS)
431 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_SSE3
433 ifeq ($(SSSE3_FLAG),)
434 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_SSSE3
436 ifeq ($(SSE41_FLAG),)
437 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_SSE4
439 ifeq ($(SSE42_FLAG),)
440 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_SSE4
446 ifneq ($(SSE42_FLAG),)
447 # Unusual GCC/Clang on Macports. It assembles AES, but not CLMUL.
448 # test_x86_clmul.s:15: no such instruction: 'pclmulqdq $0, %xmm1,%xmm0'
449 ifeq ($(CLMUL_FLAG),)
450 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_CLMUL
452 ifeq ($(AESNI_FLAG),)
453 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_AESNI
457 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_AVX
460 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_AVX2
463 # SHANI independent of AVX per GH #1045
464 ifeq ($(SHANI_FLAG),)
465 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_SHANI
469 # Drop to SSE2 if available
471 GCM_FLAG = $(SSE2_FLAG)
474 # Most Clang cannot handle mixed asm with positional arguments, where the
475 # body is Intel style with no prefix and the templates are AT&T style.
476 # Also see https://bugs.llvm.org/show_bug.cgi?id=39895 .
478 # CRYPTOPP_DISABLE_MIXED_ASM is now being added in config_asm.h for all
479 # Clang compilers. This test will need to be re-enabled if Clang fixes it.
480 #TPROG = TestPrograms/test_asm_mixed.cpp
482 #HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
483 #ifneq ($(strip $(HAVE_OPT)),0)
484 # CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_MIXED_ASM
492ifneq ($(INTEL_COMPILER),0)
493 CRYPTOPP_CXXFLAGS += -wd68 -wd186 -wd279 -wd327 -wd161 -wd3180
495 ICC111_OR_LATER := $(shell $(CXX) --version 2>&1 | $(GREP) -c -E "\(ICC\) ([2-9][0-9]|1[2-9]|11\.[1-9])")
496 ifeq ($(ICC111_OR_LATER),0)
497 # "internal error: backend signals" occurs on some x86 inline assembly with ICC 9 and
498 # some x64 inline assembly with ICC 11.0. If you want to use Crypto++'s assembly code
499 # with ICC, try enabling it on individual files
500 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ASM
504# Allow use of "/" operator for GNU Assembler.
505# http://sourceware.org/bugzilla/show_bug.cgi?id=4572
506ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
507 ifeq ($(IS_SUN)$(GCC_COMPILER),11)
508 CRYPTOPP_CXXFLAGS += -Wa,--divide
515###########################################################
516##### ARM A-32 and NEON #####
517###########################################################
521# No need for feature detection on this platform if NEON is disabled
522ifneq ($(findstring -DCRYPTOPP_DISABLE_ARM_NEON,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
526ifeq ($(DETECT_FEATURES),1)
528 # Clang needs an option to include <arm_neon.h>
529 TPROG = TestPrograms/test_arm_neon_header.cpp
530 TOPT = -DCRYPTOPP_ARM_NEON_HEADER=1 -march=armv7-a -mfpu=neon
531 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
532 ifeq ($(strip $(HAVE_OPT)),0)
533 TEXTRA += -DCRYPTOPP_ARM_NEON_HEADER=1
536 TPROG = TestPrograms/test_arm_neon.cpp
537 TOPT = -march=armv7-a -mfpu=neon
538 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
539 ifeq ($(strip $(HAVE_OPT)),0)
540 NEON_FLAG = -march=armv7-a -mfpu=neon
541 ARIA_FLAG = -march=armv7-a -mfpu=neon
542 GCM_FLAG = -march=armv7-a -mfpu=neon
543 BLAKE2B_FLAG = -march=armv7-a -mfpu=neon
544 BLAKE2S_FLAG = -march=armv7-a -mfpu=neon
545 CHACHA_FLAG = -march=armv7-a -mfpu=neon
546 CHAM_FLAG = -march=armv7-a -mfpu=neon
547 LEA_FLAG = -march=armv7-a -mfpu=neon
548 SIMON128_FLAG = -march=armv7-a -mfpu=neon
549 SPECK128_FLAG = -march=armv7-a -mfpu=neon
550 SM4_FLAG = -march=armv7-a -mfpu=neon
552 # Make does not have useful debugging facilities. Show the user
553 # what happened by compiling again without the pipe.
554 # $(info Running make again to see what failed)
555 # $(info $(shell $(TCOMMAND)))
560 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_NEON
568###########################################################
569##### Aach32 and Aarch64 #####
570###########################################################
573ifeq ($(DETECT_FEATURES),1)
575 TPROG = TestPrograms/test_arm_neon_header.cpp
576 TOPT = -DCRYPTOPP_ARM_NEON_HEADER=1
577 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
578 ifeq ($(strip $(HAVE_OPT)),0)
579 TEXTRA += -DCRYPTOPP_ARM_NEON_HEADER=1
582 TPROG = TestPrograms/test_arm_acle_header.cpp
583 TOPT = -DCRYPTOPP_ARM_ACLE_HEADER=1 -march=armv8-a
584 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
585 ifeq ($(strip $(HAVE_OPT)),0)
586 TEXTRA += -DCRYPTOPP_ARM_ACLE_HEADER=1
589 TPROG = TestPrograms/test_arm_asimd.cpp
590 TOPT = -march=armv8-a
591 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
592 ifeq ($(strip $(HAVE_OPT)),0)
593 ASIMD_FLAG = -march=armv8-a
594 ARIA_FLAG = -march=armv8-a
595 BLAKE2B_FLAG = -march=armv8-a
596 BLAKE2S_FLAG = -march=armv8-a
597 CHACHA_FLAG = -march=armv8-a
598 CHAM_FLAG = -march=armv8-a
599 LEA_FLAG = -march=armv8-a
600 NEON_FLAG = -march=armv8-a
601 SIMON128_FLAG = -march=armv8-a
602 SPECK128_FLAG = -march=armv8-a
603 SM4_FLAG = -march=armv8-a
605 # Make does not have useful debugging facilities. Show the user
606 # what happened by compiling again without the pipe.
607 $(info Running make again to see what failed)
608 $(info $(shell $(TCOMMAND)))
612 ifeq ($(ASIMD_FLAG),)
613 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ASM
616 ifneq ($(ASIMD_FLAG),)
617 TPROG = TestPrograms/test_arm_crc.cpp
618 TOPT = -march=armv8-a+crc
619 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
620 ifeq ($(strip $(HAVE_OPT)),0)
621 CRC_FLAG = -march=armv8-a+crc
623 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_CRC32
626 TPROG = TestPrograms/test_arm_aes.cpp
627 TOPT = -march=armv8-a+crypto
628 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
629 ifeq ($(strip $(HAVE_OPT)),0)
630 AES_FLAG = -march=armv8-a+crypto
632 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_AES
635 TPROG = TestPrograms/test_arm_pmull.cpp
636 TOPT = -march=armv8-a+crypto
637 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
638 ifeq ($(strip $(HAVE_OPT)),0)
639 GCM_FLAG = -march=armv8-a+crypto
640 GF2N_FLAG = -march=armv8-a+crypto
642 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_PMULL
645 TPROG = TestPrograms/test_arm_sha1.cpp
646 TOPT = -march=armv8-a+crypto
647 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
648 ifeq ($(strip $(HAVE_OPT)),0)
649 SHA_FLAG = -march=armv8-a+crypto
651 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA1
654 TPROG = TestPrograms/test_arm_sha256.cpp
655 TOPT = -march=armv8-a+crypto
656 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
657 ifeq ($(strip $(HAVE_OPT)),0)
658 SHA_FLAG = -march=armv8-a+crypto
660 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA2
663 TPROG = TestPrograms/test_arm_sm3.cpp
664 TOPT = -march=armv8.4-a+sm3
665 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
666 ifeq ($(strip $(HAVE_OPT)),0)
667 SM3_FLAG = -march=armv8.4-a+sm3
668 SM4_FLAG = -march=armv8.4-a+sm3
670 #CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_SM3
671 #CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_SM4
674 TPROG = TestPrograms/test_arm_sha3.cpp
675 TOPT = -march=armv8.4-a+sha3
676 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
677 ifeq ($(strip $(HAVE_OPT)),0)
678 SHA3_FLAG = -march=armv8.4-a+sha3
680 #CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA3
683 TPROG = TestPrograms/test_arm_sha512.cpp
684 TOPT = -march=armv8.4-a+sha512
685 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
686 ifeq ($(strip $(HAVE_OPT)),0)
687 SHA512_FLAG = -march=armv8.4-a+sha512
689 #CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA512
700###########################################################
702###########################################################
704# PowerPC and PowerPC64. Altivec is available with POWER4 with GCC and
705# POWER6 with XLC. The tests below are crafted for IBM XLC and the LLVM
706# front-end. XLC/LLVM only supplies POWER8 so we have to set the flags for
707# XLC/LLVM to POWER8. I've got a feeling LLVM is going to cause trouble.
709ifneq ($(IS_PPC32)$(IS_PPC64),00)
710ifeq ($(DETECT_FEATURES),1)
712 # IBM XL C/C++ has the -qaltivec flag really screwed up. We can't seem
713 # to get it enabled without an -qarch= option. And -qarch= produces an
714 # error on later versions of the compiler. The only thing that seems
715 # to work consistently is -qarch=auto. -qarch=auto is equivalent to
716 # GCC's -march=native, which we don't really want.
718 # XLC requires -qaltivec in addition to Arch or CPU option
719 ifeq ($(XLC_COMPILER),1)
720 # POWER9_FLAG = -qarch=pwr9 -qaltivec
721 POWER8_FLAG = -qarch=pwr8 -qaltivec
722 POWER7_VSX_FLAG = -qarch=pwr7 -qvsx -qaltivec
723 POWER7_PWR_FLAG = -qarch=pwr7 -qaltivec
724 ALTIVEC_FLAG = -qarch=auto -qaltivec
726 # POWER9_FLAG = -mcpu=power9
727 POWER8_FLAG = -mcpu=power8
728 POWER7_VSX_FLAG = -mcpu=power7 -mvsx
729 POWER7_PWR_FLAG = -mcpu=power7
730 ALTIVEC_FLAG = -maltivec
733 # GCC 10 is giving us trouble in CPU_ProbePower9() and
734 # CPU_ProbeDARN(). GCC is generating POWER9 instructions
735 # on POWER8 for ppc_power9.cpp. The compiler folks did
736 # not think through the consequences of requiring us to
737 # use -mcpu=power9 to unlock the ISA. Epic fail.
738 # https:#github.com/weidai11/cryptopp/issues/986
741 # XLC with LLVM front-ends failed to define XLC defines.
742 #ifeq ($(findstring -qxlcompatmacros,$(CXXFLAGS)),)
743 # TPROG = TestPrograms/test_ppc_altivec.cpp
744 # TOPT = -qxlcompatmacros
745 # HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
746 # ifeq ($(strip $(HAVE_OPT)),0)
747 # CRYPTOPP_CXXFLAGS += -qxlcompatmacros
751 #####################################################################
752 # Looking for a POWER9 option
754 #TPROG = TestPrograms/test_ppc_power9.cpp
755 #TOPT = $(POWER9_FLAG)
756 #HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
757 #ifeq ($(strip $(HAVE_OPT)),0)
758 # DARN_FLAG = $(POWER9_FLAG)
763 #####################################################################
764 # Looking for a POWER8 option
766 TPROG = TestPrograms/test_ppc_power8.cpp
767 TOPT = $(POWER8_FLAG)
768 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
769 ifeq ($(strip $(HAVE_OPT)),0)
770 AES_FLAG = $(POWER8_FLAG)
771 BLAKE2B_FLAG = $(POWER8_FLAG)
772 CRC_FLAG = $(POWER8_FLAG)
773 GCM_FLAG = $(POWER8_FLAG)
774 GF2N_FLAG = $(POWER8_FLAG)
775 LEA_FLAG = $(POWER8_FLAG)
776 SHA_FLAG = $(POWER8_FLAG)
777 SHACAL2_FLAG = $(POWER8_FLAG)
782 #####################################################################
783 # Looking for a POWER7 option
785 # GCC needs -mvsx for Power7 to enable 64-bit vector elements.
786 # XLC provides 64-bit vector elements without an option.
788 TPROG = TestPrograms/test_ppc_power7.cpp
789 TOPT = $(POWER7_VSX_FLAG)
790 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
791 ifeq ($(strip $(HAVE_OPT)),0)
792 POWER7_FLAG = $(POWER7_VSX_FLAG)
794 TPROG = TestPrograms/test_ppc_power7.cpp
795 TOPT = $(POWER7_PWR_FLAG)
796 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
797 ifeq ($(strip $(HAVE_OPT)),0)
798 POWER7_FLAG = $(POWER7_PWR_FLAG)
804 #####################################################################
805 # Looking for an Altivec option
807 TPROG = TestPrograms/test_ppc_altivec.cpp
808 TOPT = $(ALTIVEC_FLAG)
809 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
810 ifeq ($(strip $(HAVE_OPT)),0)
811 ALTIVEC_FLAG := $(ALTIVEC_FLAG)
813 # Make does not have useful debugging facilities. Show the user
814 # what happened by compiling again without the pipe.
815 $(info Running make again to see what failed)
816 $(info $(shell $(TCOMMAND)))
820 ifneq ($(ALTIVEC_FLAG),)
821 BLAKE2S_FLAG = $(ALTIVEC_FLAG)
822 CHACHA_FLAG = $(ALTIVEC_FLAG)
823 SPECK128_FLAG = $(ALTIVEC_FLAG)
824 SIMON128_FLAG = $(ALTIVEC_FLAG)
827 #####################################################################
828 # Fixups for algorithms that can drop to a lower ISA, if needed
830 # Drop to Altivec if higher Power is not available
831 ifneq ($(ALTIVEC_FLAG),)
833 GCM_FLAG = $(ALTIVEC_FLAG)
837 #####################################################################
838 # Fixups for missing ISAs
840 ifeq ($(ALTIVEC_FLAG),)
841 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ALTIVEC
843 ifeq ($(POWER7_FLAG),)
844 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_POWER7
846 ifeq ($(POWER8_FLAG),)
847 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_POWER8
848 #else ifeq ($(POWER9_FLAG),)
849 # CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_POWER9
858ifeq ($(XLC_COMPILER),1)
859 ifeq ($(findstring -qmaxmem,$(CXXFLAGS)),)
860 CRYPTOPP_CXXFLAGS += -qmaxmem=-1
862 # http://www-01.ibm.com/support/docview.wss?uid=swg21007500
863 ifeq ($(findstring -qrtti,$(CXXFLAGS)),)
864 CRYPTOPP_CXXFLAGS += -qrtti
871###########################################################
873###########################################################
875# Add -fPIC for targets *except* X86, X32, Cygwin or MinGW
876ifeq ($(IS_X86)$(IS_CYGWIN)$(IS_MINGW),000)
877 ifeq ($(findstring -fpic,$(CXXFLAGS))$(findstring -fPIC,$(CXXFLAGS)),)
878 CRYPTOPP_CXXFLAGS += -fPIC
882# Fix for GH #1134 and GH #1141. We need to add -fno-devirtualize because GCC is removing
883# code we are using. https://github.com/weidai11/cryptopp/issues/1134 and
884# https://github.com/weidai11/cryptopp/issues/1141
885ifeq ($(findstring -fno-devirtualize,$(CXXFLAGS)),)
886 TPROG = TestPrograms/test_nodevirtualize.cpp
887 TOPT = -fno-devirtualize
888 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
889 ifeq ($(strip $(HAVE_OPT)),0)
890 CRYPTOPP_CXXFLAGS += -fno-devirtualize
891 endif # CRYPTOPP_CXXFLAGS
892endif # -fno-devirtualize
894# Use -pthread whenever it is available. See http://www.hpl.hp.com/techreports/2004/HPL-2004-209.pdf
895# http://stackoverflow.com/questions/2127797/gcc-significance-of-pthread-flag-when-compiling
896ifeq ($(DETECT_FEATURES),1)
897 ifeq ($(XLC_COMPILER),1)
898 ifeq ($(findstring -qthreaded,$(CXXFLAGS)),)
899 TPROG = TestPrograms/test_pthreads.cpp
901 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
902 ifeq ($(strip $(HAVE_OPT)),0)
903 CRYPTOPP_CXXFLAGS += -qthreaded
904 endif # CRYPTOPP_CXXFLAGS
907 ifeq ($(findstring -pthread,$(CXXFLAGS)),)
908 TPROG = TestPrograms/test_pthreads.cpp
910 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
911 ifeq ($(strip $(HAVE_OPT)),0)
912 CRYPTOPP_CXXFLAGS += -pthread
913 endif # CRYPTOPP_CXXFLAGS
915 endif # XLC/GCC and friends
916endif # DETECT_FEATURES
918# Remove -fPIC if present. SunCC use -KPIC, and needs the larger GOT table
919# https://docs.oracle.com/cd/E19205-01/819-5267/bkbaq/index.html
920ifeq ($(SUN_COMPILER),1)
921 CRYPTOPP_CXXFLAGS := $(subst -fPIC,-KPIC,$(CRYPTOPP_CXXFLAGS))
922 CRYPTOPP_CXXFLAGS := $(subst -fpic,-KPIC,$(CRYPTOPP_CXXFLAGS))
925# Remove -fPIC if present. IBM XL C++ uses -qpic
926ifeq ($(XLC_COMPILER),1)
927 CRYPTOPP_CXXFLAGS := $(subst -fPIC,-qpic,$(CRYPTOPP_CXXFLAGS))
928 CRYPTOPP_CXXFLAGS := $(subst -fpic,-qpic,$(CRYPTOPP_CXXFLAGS))
931# Disable IBM XL C++ "1500-036: (I) The NOSTRICT option (default at OPT(3))
932# has the potential to alter the semantics of a program."
933ifeq ($(XLC_COMPILER),1)
934 TPROG = TestPrograms/test_cxx.cpp
935 TOPT = -qsuppress=1500-036
936 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
937 ifeq ($(strip $(HAVE_OPT)),0)
938 CRYPTOPP_CXXFLAGS += -qsuppress=1500-036
940endif # IBM XL C++ compiler
942# libc++ is LLVM's standard C++ library. If we add libc++
943# here then all user programs must use it too. The open
944# question is, which choice is easier on users?
945ifneq ($(IS_DARWIN),0)
947 # CRYPTOPP_CXXFLAGS += -stdlib=libc++
948 ifeq ($(findstring -fno-common,$(CXXFLAGS)),)
949 CRYPTOPP_CXXFLAGS += -fno-common
951 IS_APPLE_LIBTOOL=$(shell libtool -V 2>&1 | $(GREP) -i -c 'Apple')
952 ifeq ($(IS_APPLE_LIBTOOL),1)
955 AR = /usr/bin/libtool
960# Add -xregs=no%appl SPARC. SunCC should not use certain registers in library code.
961# https://docs.oracle.com/cd/E18659_01/html/821-1383/bkamt.html
962ifneq ($(IS_SPARC32)$(IS_SPARC64),00)
963 ifeq ($(SUN_COMPILER),1)
964 ifeq ($(findstring -xregs=no%appl,$(CXXFLAGS)),)
965 CRYPTOPP_CXXFLAGS += -xregs=no%appl
968 ifeq ($(GCC_COMPILER),1)
969 ifeq ($(findstring -mno-app-regs,$(CXXFLAGS)),)
970 CRYPTOPP_CXXFLAGS += -mno-app-regs
975# Add -pipe for everything except IBM XL C++, SunCC and ARM.
976# Allow ARM-64 because they seems to have >1 GB of memory
977ifeq ($(XLC_COMPILER)$(SUN_COMPILER)$(IS_ARM32),000)
978 ifeq ($(findstring -save-temps,$(CXXFLAGS)),)
979 CRYPTOPP_CXXFLAGS += -pipe
983# For SunOS, create a Mapfile that allows our object files
984# to contain additional bits (like SSE4 and AES on old Xeon)
985# http://www.oracle.com/technetwork/server-storage/solaris/hwcap-modification-139536.html
986ifeq ($(IS_SUN)$(SUN_COMPILER),11)
987 ifneq ($(IS_X86)$(IS_X64),00)
988 ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
989 CRYPTOPP_LDFLAGS += -M cryptopp.mapfile
990 endif # No CRYPTOPP_DISABLE_ASM
994ifneq ($(IS_LINUX)$(IS_HURD),00)
995 ifeq ($(findstring -fopenmp,$(CXXFLAGS)),-fopenmp)
996 ifeq ($(findstring -lgomp,$(LDLIBS)),)
1000endif # IS_LINUX or IS_HURD
1002# Add -errtags=yes to get the name for a warning suppression
1003ifneq ($(SUN_COMPILER),0) # override flags for CC Sun C++ compiler
1005CRYPTOPP_CXXFLAGS += -template=no%extdef
1006SUN_CC10_BUGGY := $(shell $(CXX) -V 2>&1 | $(GREP) -c -E "CC: Sun .* 5\.10 .* (2009|2010/0[1-4])")
1007ifneq ($(SUN_CC10_BUGGY),0)
1008# -DCRYPTOPP_INCLUDE_VECTOR_CC is needed for Sun Studio 12u1 Sun C++ 5.10 SunOS_i386 128229-02 2009/09/21
1009# and was fixed in May 2010. Remove it if you get "already had a body defined" errors in vector.cc
1010CRYPTOPP_CPPFLAGS += -DCRYPTOPP_INCLUDE_VECTOR_CC
1017# Undefined Behavior Sanitizer (UBsan) testing. Issue 'make ubsan'.
1018ifeq ($(findstring ubsan,$(MAKECMDGOALS)),ubsan)
1019 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1020 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1021 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1022 ifeq ($(findstring -fsanitize=undefined,$(CXXFLAGS)),)
1023 CRYPTOPP_CXXFLAGS += -fsanitize=undefined
1024 endif # CRYPTOPP_CPPFLAGS
1025 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
1026 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1027 endif # CRYPTOPP_CPPFLAGS
1030# Address Sanitizer (Asan) testing. Issue 'make asan'.
1031ifeq ($(findstring asan,$(MAKECMDGOALS)),asan)
1032 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1033 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1034 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1035 ifeq ($(findstring -fsanitize=address,$(CXXFLAGS)),)
1036 CRYPTOPP_CXXFLAGS += -fsanitize=address
1037 endif # CRYPTOPP_CXXFLAGS
1038 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
1039 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1040 endif # CRYPTOPP_CPPFLAGS
1041 ifeq ($(findstring -fno-omit-frame-pointer,$(CXXFLAGS)),)
1042 CRYPTOPP_CXXFLAGS += -fno-omit-frame-pointer
1043 endif # CRYPTOPP_CXXFLAGS
1046# LD gold linker testing. Triggered by 'LD=ld.gold'.
1047ifeq ($(findstring ld.gold,$(LD)),ld.gold)
1048 ifeq ($(findstring -fuse-ld=gold,$(CXXFLAGS)),)
1049 LD_GOLD = $(shell command -v ld.gold)
1050 ELF_FORMAT := $(shell file $(LD_GOLD) 2>&1 | cut -d":" -f 2 | $(GREP) -i -c "elf")
1051 ifneq ($(ELF_FORMAT),0)
1052 CRYPTOPP_LDFLAGS += -fuse-ld=gold
1057# lcov code coverage. Issue 'make coverage'.
1058ifneq ($(filter lcov coverage,$(MAKECMDGOALS)),)
1059 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1060 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1061 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1062 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
1063 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1064 endif # CRYPTOPP_COVERAGE
1065 ifeq ($(findstring -coverage,$(CXXFLAGS)),)
1066 CRYPTOPP_CXXFLAGS += -coverage
1068endif # GCC code coverage
1070# gcov code coverage for Travis. Issue 'make codecov'.
1071ifneq ($(filter gcov codecov,$(MAKECMDGOALS)),)
1072 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1073 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1074 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1075 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
1076 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1077 endif # CRYPTOPP_COVERAGE
1078 ifeq ($(findstring -coverage,$(CXXFLAGS)),)
1079 CRYPTOPP_CXXFLAGS += -coverage
1081endif # GCC code coverage
1083# Valgrind testing. Issue 'make valgrind'.
1084ifneq ($(filter valgrind,$(MAKECMDGOALS)),)
1085 # Tune flags; see http://valgrind.org/docs/manual/quick-start.html
1086 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1087 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1088 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1089 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
1090 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1091 endif # CRYPTOPP_CPPFLAGS
1094# Debug testing on GNU systems. Triggered by -DDEBUG.
1095# Newlib test due to http://sourceware.org/bugzilla/show_bug.cgi?id=20268
1096ifneq ($(filter -DDEBUG -DDEBUG=1,$(CPPFLAGS)$(CXXFLAGS)),)
1097 TPROG = TestPrograms/test_cxx.cpp
1099 USING_GLIBCXX := $(shell $(CXX) $(CPPFLAGS) $(CXXFLAGS) -E $(TPROG) -c 2>&1 | $(GREP) -i -c "__GLIBCXX__")
1100 ifneq ($(USING_GLIBCXX),0)
1101 ifeq ($(HAS_NEWLIB),0)
1102 ifeq ($(findstring -D_GLIBCXX_DEBUG,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
1103 CRYPTOPP_CPPFLAGS += -D_GLIBCXX_DEBUG
1104 endif # CRYPTOPP_CPPFLAGS
1106 endif # USING_GLIBCXX
1108 ifeq ($(XLC_COMPILER),1)
1109 TPROG = TestPrograms/test_cxx.cpp
1110 TOPT = -qheapdebug -qro
1111 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
1112 ifeq ($(strip $(HAVE_OPT)),0)
1113 CRYPTOPP_CXXFLAGS += -qheapdebug -qro
1114 endif # CRYPTOPP_CXXFLAGS
1115 endif # XLC_COMPILER
1118# Dead code stripping. Issue 'make lean'.
1119ifeq ($(findstring lean,$(MAKECMDGOALS)),lean)
1120 ifeq ($(findstring -ffunction-sections,$(CXXFLAGS)),)
1121 CRYPTOPP_CXXFLAGS += -ffunction-sections
1122 endif # CRYPTOPP_CXXFLAGS
1123 ifeq ($(findstring -fdata-sections,$(CXXFLAGS)),)
1124 CRYPTOPP_CXXFLAGS += -fdata-sections
1125 endif # CRYPTOPP_CXXFLAGS
1126 ifneq ($(IS_DARWIN),0)
1127 ifeq ($(findstring -Wl,-dead_strip,$(LDFLAGS)),)
1128 CRYPTOPP_LDFLAGS += -Wl,-dead_strip
1129 endif # CRYPTOPP_CXXFLAGS
1130 else # BSD, Linux and Unix
1131 ifeq ($(findstring -Wl,--gc-sections,$(LDFLAGS)),)
1132 CRYPTOPP_LDFLAGS += -Wl,--gc-sections
1134 endif # MAKECMDGOALS
1135endif # Dead code stripping
1137# For Shared Objects, Diff, Dist/Zip rules
1138LIB_VER := $(shell $(GREP) "define CRYPTOPP_VERSION" config_ver.h | cut -d" " -f 3)
1139LIB_MAJOR := $(shell echo $(LIB_VER) | cut -c 1)
1140LIB_MINOR := $(shell echo $(LIB_VER) | cut -c 2)
1141LIB_PATCH := $(shell echo $(LIB_VER) | cut -c 3)
1143ifeq ($(strip $(LIB_PATCH)),)
1147ifeq ($(HAS_SOLIB_VERSION),1)
1148# Different patchlevels and minors are compatible since 6.1
1149SOLIB_COMPAT_SUFFIX=.$(LIB_MAJOR)
1150# Linux uses -Wl,-soname
1151ifneq ($(IS_LINUX)$(IS_HURD),00)
1152# Linux uses full version suffix for shared library
1153SOLIB_VERSION_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)
1154SOLIB_FLAGS=-Wl,-soname,libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
1156# Solaris uses -Wl,-h
1158# Solaris uses major version suffix for shared library, but we use major.minor
1159# The minor version allows previous version to remain and not overwritten.
1160# https://blogs.oracle.com/solaris/how-to-name-a-solaris-shared-object-v2
1161SOLIB_VERSION_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR)
1162SOLIB_FLAGS=-Wl,-h,libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
1164endif # HAS_SOLIB_VERSION
1166###########################################################
1167##### Temp file cleanup #####
1168###########################################################
1170# After this point no more test programs should be run.
1171# https://github.com/weidai11/cryptopp/issues/738
1172ifeq ($(findstring /dev/null,$(TOUT)),)
1173 # $(info TOUT is not /dev/null, cleaning $(TOUT))
1174 ifeq ($(wildcard $(TOUT)),$(TOUT))
1175 UNUSED := $(shell $(RM) $(TOUT) 2>/dev/null)
1177 ifeq ($(wildcard $(TOUT).dSYM/),$(TOUT).dSYM/)
1178 UNUSED := $(shell $(RM) -r $(TOUT).dSYM/ 2>/dev/null)
1182###########################################################
1183##### Source and object files #####
1184###########################################################
1186# List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
1187SRCS := cryptlib.cpp cpu.cpp integer.cpp $(filter-out cryptlib.cpp cpu.cpp integer.cpp pch.cpp simple.cpp,$(sort $(wildcard *.cpp)))
1188# For Makefile.am; resource.h is Windows
1189INCL := $(filter-out resource.h,$(sort $(wildcard *.h)))
1191ifneq ($(IS_MINGW),0)
1195# Cryptogams source files. We couple to ARMv7 and NEON due to SHA using NEON.
1196# Limit to Linux. The source files target the GNU assembler.
1197# Also see https://www.cryptopp.com/wiki/Cryptogams.
1198ifeq ($(IS_ARM32)$(IS_LINUX),11)
1199 ifeq ($(filter -DCRYPTOPP_DISABLE_ASM -DCRYPTOPP_DISABLE_ARM_NEON,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
1200 # Do not use -march=armv7 if the compiler is already targeting the ISA.
1201 # Also see https://github.com/weidai11/cryptopp/issues/1094
1202 ifeq ($(shell $(CXX) -dM -E TestPrograms/test_cxx.cpp 2>/dev/null | grep -E '__ARM_ARCH 7|__ARM_ARCH_7A__'),)
1203 CRYPTOGAMS_ARMV7_FLAG = -march=armv7-a
1205 ifeq ($(CLANG_COMPILER),1)
1206 CRYPTOGAMS_ARM_FLAG = $(CRYPTOGAMS_ARMV7_FLAG)
1207 CRYPTOGAMS_ARM_THUMB_FLAG = $(CRYPTOGAMS_ARMV7_FLAG) -mthumb
1209 # -mfpu=auto due to https://github.com/weidai11/cryptopp/issues/1094
1210 CRYPTOGAMS_ARM_FLAG = $(CRYPTOGAMS_ARMV7_FLAG)
1211 CRYPTOGAMS_ARM_THUMB_FLAG = $(CRYPTOGAMS_ARMV7_FLAG)
1213 SRCS += aes_armv4.S sha1_armv4.S sha256_armv4.S sha512_armv4.S
1217# Remove unneeded arch specific files to speed build time.
1218ifeq ($(IS_PPC32)$(IS_PPC64),00)
1219 SRCS := $(filter-out %_ppc.cpp,$(SRCS))
1221ifeq ($(IS_ARM32)$(IS_ARMV8),00)
1222 SRCS := $(filter-out arm_%,$(SRCS))
1223 SRCS := $(filter-out neon_%,$(SRCS))
1224 SRCS := $(filter-out %_armv4.S,$(SRCS))
1226ifeq ($(IS_X86)$(IS_X64),00)
1227 SRCS := $(filter-out sse_%,$(SRCS))
1228 SRCS := $(filter-out %_sse.cpp,$(SRCS))
1229 SRCS := $(filter-out %_avx.cpp,$(SRCS))
1232# If ASM is disabled we can remove the SIMD files, too.
1233ifneq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
1234 SRCS := $(filter-out arm_%,$(SRCS))
1235 SRCS := $(filter-out ppc_%,$(SRCS))
1236 SRCS := $(filter-out neon_%,$(SRCS))
1237 SRCS := $(filter-out sse_%,$(SRCS))
1238 SRCS := $(filter-out %_sse.cpp,$(SRCS))
1239 SRCS := $(filter-out %_avx.cpp,$(SRCS))
1240 SRCS := $(filter-out %_ppc.cpp,$(SRCS))
1241 SRCS := $(filter-out %_simd.cpp,$(SRCS))
1242 SRCS := $(filter-out %_armv4.S,$(SRCS))
1245# List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
1246OBJS := $(SRCS:.cpp=.o)
1247OBJS := $(OBJS:.S=.o)
1249# List test.cpp first to tame C++ static initialization problems.
1250TESTSRCS := 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
1251TESTINCL := bench.h factory.h validate.h
1254TESTOBJS := $(TESTSRCS:.cpp=.o)
1255LIBOBJS := $(filter-out $(TESTOBJS),$(OBJS))
1257# In Crypto++ 5.6.2 these were the source and object files for the FIPS DLL.
1258# Since the library is on the Historical Validation List we add all files.
1259# The 5.6.2 list is at https://github.com/weidai11/cryptopp/blob/789f81f048c9.
1261DLLOBJS := $(DLLSRCS:.cpp=.export.o)
1262DLLOBJS := $(DLLOBJS:.S=.export.o)
1265LIBIMPORTOBJS := $(LIBOBJS:.o=.import.o)
1266TESTIMPORTOBJS := $(TESTOBJS:.o=.import.o)
1267DLLTESTOBJS := dlltest.dllonly.o
1269# Clean recipe, Issue 998. Don't filter-out some artifacts from the list of objects
1270# The *.S is a hack. It makes the ASM appear like C++ so the object files make the CLEAN_OBJS list
1271CLEAN_SRCS := $(wildcard *.cpp) $(patsubst %.S,%.cpp,$(wildcard *.S))
1272CLEAN_OBJS := $(CLEAN_SRCS:.cpp=.o) $(CLEAN_SRCS:.cpp=.import.o) $(CLEAN_SRCS:.cpp=.export.o)
1274###########################################################
1275##### Add our flags to user flags #####
1276###########################################################
1278# This ensures we don't add flags when the user forbids
1279# use of customary library flags, like -fPIC. Make will
1280# ignore this assignment when CXXFLAGS is passed as an
1281# argument to the make program: make CXXFLAGS="..."
1282CPPFLAGS := $(strip $(CRYPTOPP_CPPFLAGS) $(CPPFLAGS))
1283CXXFLAGS := $(strip $(CRYPTOPP_CXXFLAGS) $(CXXFLAGS))
1284ASFLAGS := $(strip $(CRYPTOPP_ASFLAGS) $(ASFLAGS))
1285LDFLAGS := $(strip $(CRYPTOPP_LDFLAGS) $(LDFLAGS))
1287###########################################################
1288##### Targets and Recipes #####
1289###########################################################
1291# Default builds program with static library only
1293default: cryptest.exe
1295.PHONY: all static dynamic
1296all: static dynamic cryptest.exe
1298ifneq ($(IS_DARWIN),0)
1299static: libcryptopp.a
1300shared dynamic dylib: libcryptopp.dylib
1302static: libcryptopp.a
1303shared dynamic: libcryptopp.so$(SOLIB_VERSION_SUFFIX)
1306# CXXFLAGS are tuned earlier.
1307.PHONY: native no-asm asan ubsan
1308native no-asm asan ubsan: cryptest.exe
1310# CXXFLAGS are tuned earlier. Applications must use linker flags
1311# -Wl,--gc-sections (Linux and Unix) or -Wl,-dead_strip (OS X)
1313lean: static dynamic cryptest.exe
1315# May want to export CXXFLAGS="-g3 -O1"
1316.PHONY: lcov coverage
1317lcov coverage: cryptest.exe
1318 @-$(RM) -r ./TestCoverage/
1319 lcov --base-directory . --directory . --zerocounters -q
1321 ./cryptest.exe tv all
1322 ./cryptest.exe b 0.25
1323 lcov --base-directory . --directory . -c -o cryptest.info
1324 lcov --remove cryptest.info "adhoc.*" -o cryptest.info
1325 lcov --remove cryptest.info "fips140.*" -o cryptest.info
1326 lcov --remove cryptest.info "*test.*" -o cryptest.info
1327 lcov --remove cryptest.info "/usr/*" -o cryptest.info
1328 genhtml -o ./TestCoverage/ -t "Crypto++ test coverage" --num-spaces 4 cryptest.info
1330# Travis CI and CodeCov rule
1332gcov codecov: cryptest.exe
1333 @-$(RM) -r ./TestCoverage/
1335 ./cryptest.exe tv all
1338# Should use CXXFLAGS="-g3 -O1"
1340valgrind: cryptest.exe
1341 valgrind --track-origins=yes --suppressions=cryptopp.supp ./cryptest.exe v
1344test check: cryptest.exe
1347# Used to generate list of source files for Autotools, CMakeList, Android.mk, etc
1350 $(info ***** Library sources *****)
1351 $(info $(filter-out $(TESTSRCS),$(SRCS)))
1353 $(info ***** Library headers *****)
1354 $(info $(filter-out $(TESTINCL),$(INCL)))
1356 $(info ***** Test sources *****)
1359 $(info ***** Test headers *****)
1362# Directory we want (can't specify on Doygen command line)
1363DOCUMENT_DIRECTORY := ref$(LIB_VER)
1364# Directory Doxygen uses (specified in Doygen config file)
1365ifeq ($(wildcard Doxyfile),Doxyfile)
1367DOXYGEN_DIRECTORY := $(strip $(shell $(GREP) "OUTPUT_DIRECTORY" Doxyfile | $(GREP) -v $(POUND_SIGN) | cut -d "=" -f 2))
1369# Default directory (in case its missing in the config file)
1370ifeq ($(strip $(DOXYGEN_DIRECTORY)),)
1371DOXYGEN_DIRECTORY := html-docs
1374# Builds the documentation. Directory name is ref563, ref570, etc.
1377 @-$(RM) -r $(DOXYGEN_DIRECTORY)/ $(DOCUMENT_DIRECTORY)/ html-docs/
1378 @-$(RM) CryptoPPRef.zip
1379 doxygen Doxyfile -d CRYPTOPP_DOXYGEN_PROCESSING
1380 $(MV) $(DOXYGEN_DIRECTORY)/ $(DOCUMENT_DIRECTORY)/
1381 zip -9 CryptoPPRef.zip -x ".*" -x "*/.*" -r $(DOCUMENT_DIRECTORY)/
1385 -$(RM) adhoc.cpp.o adhoc.cpp.proto.o $(CLEAN_OBJS) rdrand-*.o
1386 @-$(RM) libcryptopp.a libcryptopp.dylib cryptopp.dll libcryptopp.dll.a libcryptopp.import.a
1387 @-$(RM) libcryptopp.so libcryptopp.so$(SOLIB_COMPAT_SUFFIX) libcryptopp.so$(SOLIB_VERSION_SUFFIX)
1388 @-$(RM) cryptest.exe dlltest.exe cryptest.import.exe cryptest.dat ct et
1389 @-$(RM) *.la *.lo *.gcov *.gcno *.gcda *.stackdump core core-*
1390 @-$(RM) /tmp/adhoc.exe
1391 @-$(RM) -r /tmp/cryptopp_test/
1392 @-$(RM) -r *.exe.dSYM/ *.dylib.dSYM/
1395.PHONY: autotools-clean
1397 @-$(RM) -f bootstrap.sh configure.ac configure configure.in Makefile.am Makefile.in Makefile
1398 @-$(RM) -f config.guess config.status config.sub config.h.in compile depcomp
1399 @-$(RM) -f install-sh stamp-h1 ar-lib *.lo *.la *.m4 local.* lt*.sh missing
1400 @-$(RM) -f cryptest cryptestcwd libtool* libcryptopp.la libcryptopp.pc*
1401 @-$(RM) -rf build-aux/ m4/ auto*.cache/ .deps/ .libs/
1403.PHONY: android-clean
1405 @-$(RM) -f $(patsubst %_simd.cpp,%_simd.cpp.neon,$(wildcard *_simd.cpp))
1409distclean: clean autotools-clean android-clean
1410 -$(RM) adhoc.cpp adhoc.cpp.copied GNUmakefile.deps benchmarks.html cryptest.txt
1411 -$(RM) cryptest_all.info cryptest_debug.info cryptest_noasm.info cryptest_base.info cryptest.info cryptest_release.info
1412 @-$(RM) cryptest-*.txt cryptopp.tgz libcryptopp.pc *.o *.bc *.ii *~
1413 @-$(RM) -r cryptlib.lib cryptest.exe *.suo *.sdf *.pdb Win32/ x64/ ipch/
1414 @-$(RM) -r $(LIBOBJS:.o=.obj) $(TESTOBJS:.o=.obj)
1415 @-$(RM) -r $(LIBOBJS:.o=.lst) $(TESTOBJS:.o=.lst)
1416 @-$(RM) -r TestCoverage/ ref*/
1417 @-$(RM) cryptopp$(LIB_VER)\.* CryptoPPRef.zip
1419# Install cryptest.exe, libcryptopp.a, libcryptopp.so and libcryptopp.pc.
1420# The library install was broken-out into its own recipe at GH #653.
1422install: cryptest.exe install-lib
1423 @-$(MKDIR) $(DESTDIR)$(BINDIR)
1424 $(CP) cryptest.exe $(DESTDIR)$(BINDIR)
1425 $(CHMOD) u=rwx,go=rx $(DESTDIR)$(BINDIR)/cryptest.exe
1426 @-$(MKDIR) $(DESTDIR)$(DATADIR)/cryptopp/TestData
1427 @-$(MKDIR) $(DESTDIR)$(DATADIR)/cryptopp/TestVectors
1428 $(CP) TestData/*.dat $(DESTDIR)$(DATADIR)/cryptopp/TestData
1429 $(CHMOD) u=rw,go=r $(DESTDIR)$(DATADIR)/cryptopp/TestData/*.dat
1430 $(CP) TestVectors/*.txt $(DESTDIR)$(DATADIR)/cryptopp/TestVectors
1431 $(CHMOD) u=rw,go=r $(DESTDIR)$(DATADIR)/cryptopp/TestVectors/*.txt
1433# A recipe to install only the library, and not cryptest.exe. Also
1434# see https://github.com/weidai11/cryptopp/issues/653. Some users
1435# already have a libcryptopp.pc. Install the *.pc file if the file
1436# is present. If you want one, then issue 'make libcryptopp.pc'.
1439 @-$(MKDIR) $(DESTDIR)$(INCLUDEDIR)/cryptopp
1440 $(CP) *.h $(DESTDIR)$(INCLUDEDIR)/cryptopp
1441 $(CHMOD) u=rw,go=r $(DESTDIR)$(INCLUDEDIR)/cryptopp/*.h
1442ifneq ($(wildcard libcryptopp.a),)
1443 @-$(MKDIR) $(DESTDIR)$(LIBDIR)
1444 $(CP) libcryptopp.a $(DESTDIR)$(LIBDIR)
1445 $(CHMOD) u=rw,go=r $(DESTDIR)$(LIBDIR)/libcryptopp.a
1447ifneq ($(wildcard libcryptopp.dylib),)
1448 @-$(MKDIR) $(DESTDIR)$(LIBDIR)
1449 $(CP) libcryptopp.dylib $(DESTDIR)$(LIBDIR)
1450 $(CHMOD) u=rwx,go=rx $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
1451 -install_name_tool -id $(DESTDIR)$(LIBDIR)/libcryptopp.dylib $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
1453ifneq ($(wildcard libcryptopp.so$(SOLIB_VERSION_SUFFIX)),)
1454 @-$(MKDIR) $(DESTDIR)$(LIBDIR)
1455 $(CP) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)
1456 $(CHMOD) u=rwx,go=rx $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
1457ifeq ($(HAS_SOLIB_VERSION),1)
1458 -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so
1459 -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
1460 $(LDCONF) $(DESTDIR)$(LIBDIR)
1463ifneq ($(wildcard libcryptopp.pc),)
1464 @-$(MKDIR) $(DESTDIR)$(LIBDIR)/pkgconfig
1465 $(CP) libcryptopp.pc $(DESTDIR)$(LIBDIR)/pkgconfig
1466 $(CHMOD) u=rw,go=r $(DESTDIR)$(LIBDIR)/pkgconfig/libcryptopp.pc
1469.PHONY: remove uninstall
1471 -$(RM) -r $(DESTDIR)$(INCLUDEDIR)/cryptopp
1472 -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.a
1473 -$(RM) $(DESTDIR)$(BINDIR)/cryptest.exe
1474ifneq ($(wildcard $(DESTDIR)$(LIBDIR)/libcryptopp.dylib),)
1475 -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
1477ifneq ($(wildcard $(DESTDIR)$(LIBDIR)/libcryptopp.so),)
1478 -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so
1480 @-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
1481 @-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
1482 @-$(RM) $(DESTDIR)$(LIBDIR)/pkgconfig/libcryptopp.pc
1483 @-$(RM) -r $(DESTDIR)$(DATADIR)/cryptopp
1485libcryptopp.a: $(LIBOBJS) | osx_warning
1486 $(AR) $(ARFLAGS) $@ $(LIBOBJS)
1491ifeq ($(HAS_SOLIB_VERSION),1)
1492.PHONY: libcryptopp.so
1493libcryptopp.so: libcryptopp.so$(SOLIB_VERSION_SUFFIX) | so_warning
1496libcryptopp.so$(SOLIB_VERSION_SUFFIX): $(LIBOBJS)
1497ifeq ($(XLC_COMPILER),1)
1498 $(CXX) -qmkshrobj $(SOLIB_FLAGS) -o $@ $(CXXFLAGS) $(LDFLAGS) $(LIBOBJS) $(LDLIBS)
1500 $(CXX) -shared $(SOLIB_FLAGS) -o $@ $(CXXFLAGS) $(LDFLAGS) $(LIBOBJS) $(LDLIBS)
1502ifeq ($(HAS_SOLIB_VERSION),1)
1503 -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.so
1504 -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
1507libcryptopp.dylib: $(LIBOBJS) | osx_warning
1508 $(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)
1510cryptest.exe: $(LINK_LIBRARY) $(TESTOBJS) | osx_warning
1511 $(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) $(LINK_LIBRARY_PATH)$(LINK_LIBRARY) $(LDFLAGS) $(LDLIBS)
1513# Makes it faster to test changes
1515 $(CXX) -o ct $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS)
1517dll: cryptest.import.exe dlltest.exe
1519cryptopp.dll: $(DLLOBJS)
1520 $(CXX) -shared -o $@ $(CXXFLAGS) $(DLLOBJS) $(LDFLAGS) $(LDLIBS) -Wl,--out-implib=libcryptopp.dll.a
1522libcryptopp.import.a: $(LIBIMPORTOBJS)
1523 $(AR) $(ARFLAGS) $@ $(LIBIMPORTOBJS)
1528cryptest.import.exe: cryptopp.dll libcryptopp.import.a $(TESTIMPORTOBJS)
1529 $(CXX) -o $@ $(CXXFLAGS) $(TESTIMPORTOBJS) -L. -lcryptopp.dll -lcryptopp.import $(LDFLAGS) $(LDLIBS)
1531dlltest.exe: cryptopp.dll $(DLLTESTOBJS)
1532 $(CXX) -o $@ $(CXXFLAGS) $(DLLTESTOBJS) -L. -lcryptopp.dll $(LDFLAGS) $(LDLIBS)
1534# Some users already have a libcryptopp.pc. We install it if the file
1535# is present. If you want one, then issue 'make libcryptopp.pc'. Be sure
1536# to use/verify PREFIX and LIBDIR below after writing the file.
1537cryptopp.pc libcryptopp.pc:
1538 @echo '# Crypto++ package configuration file' > libcryptopp.pc
1539 @echo '' >> libcryptopp.pc
1540 @echo 'prefix=$(PC_PREFIX)' >> libcryptopp.pc
1541 @echo 'libdir=$(PC_LIBDIR)' >> libcryptopp.pc
1542 @echo 'includedir=$(PC_INCLUDEDIR)' >> libcryptopp.pc
1543 @echo 'datadir=$(PC_DATADIR)' >> libcryptopp.pc
1544 @echo '' >> libcryptopp.pc
1545 @echo 'Name: Crypto++' >> libcryptopp.pc
1546 @echo 'Description: Crypto++ cryptographic library' >> libcryptopp.pc
1547 @echo 'Version: 8.9' >> libcryptopp.pc
1548 @echo 'URL: https://cryptopp.com/' >> libcryptopp.pc
1549 @echo '' >> libcryptopp.pc
1550 @echo 'Cflags: -I$${includedir}' >> libcryptopp.pc
1551 @echo 'Libs: -L$${libdir} -lcryptopp' >> libcryptopp.pc
1553# This recipe prepares the distro files
1554TEXT_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
1555EXEC_FILES := TestScripts/*.sh TestScripts/*.cmd
1556ifneq ($(wildcard *.sh),)
1557 EXEC_FILES += $(wildcard *.sh)
1559EXEC_DIRS := TestData/ TestVectors/ TestScripts/ TestPrograms/
1561ifeq ($(wildcard Filelist.txt),Filelist.txt)
1562DIST_FILES := $(shell cat Filelist.txt)
1567ifneq ($(IS_DARWIN),0)
1568 $(SED) -i '' -e's/[[:space:]]*$$//' *.supp *.txt .*.yml *.h *.cpp *.asm *.S
1569 $(SED) -i '' -e's/[[:space:]]*$$//' *.sln *.vcxproj *.filters *.rc GNUmakefile GNUmakefile-cross
1570 $(SED) -i '' -e's/[[:space:]]*$$//' TestData/*.dat TestVectors/*.txt TestPrograms/*.cpp TestScripts/*.*
1573 $(SED) -i -e's/[[:space:]]*$$//' *.supp *.txt .*.yml *.h *.cpp *.asm *.S
1574 $(SED) -i -e's/[[:space:]]*$$//' *.sln *.vcxproj *.filters *.rc GNUmakefile GNUmakefile-cross
1575 $(SED) -i -e's/[[:space:]]*$$//' TestData/*.dat TestVectors/*.txt TestPrograms/*.cpp TestScripts/*.*
1581 @-$(CHMOD) u=rwx,go=rx $(EXEC_DIRS)
1582 @-$(CHMOD) u=rw,go=r $(TEXT_FILES) *.supp .*.yml *.asm *.zip TestVectors/*.txt TestData/*.dat TestPrograms/*.cpp
1583 @-$(CHMOD) u=rwx,go=rx $(EXEC_FILES)
1584 -unix2dos --keepdate --quiet $(TEXT_FILES) .*.yml *.asm TestScripts/*.cmd TestScripts/*.txt TestScripts/*.cpp
1585 -dos2unix --keepdate --quiet GNUmakefile GNUmakefile-cross *.sh *.S *.supp *.mapfile TestScripts/*.sh
1586ifneq ($(IS_DARWIN),0)
1590# Build the ZIP file with source files. No documentation.
1592zip dist: | distclean convert
1593 zip -q -9 cryptopp$(LIB_VER).zip $(DIST_FILES)
1595# Build the ISO to transfer the ZIP to old distros via CDROM
1598ifneq ($(IS_DARWIN),0)
1599 $(MKDIR) $(PWD)/cryptopp$(LIB_VER)
1600 $(CP) cryptopp$(LIB_VER).zip $(PWD)/cryptopp$(LIB_VER)
1601 hdiutil makehybrid -iso -joliet -o cryptopp$(LIB_VER).iso $(PWD)/cryptopp$(LIB_VER)
1602 @-$(RM) -r $(PWD)/cryptopp$(LIB_VER)
1604ifneq ($(IS_LINUX)$(IS_HURD),00)
1605 $(MKDIR) $(PWD)/cryptopp$(LIB_VER)
1606 $(CP) cryptopp$(LIB_VER).zip $(PWD)/cryptopp$(LIB_VER)
1607 genisoimage -q -o cryptopp$(LIB_VER).iso $(PWD)/cryptopp$(LIB_VER)
1608 @-$(RM) -r $(PWD)/cryptopp$(LIB_VER)
1612# CRYPTOPP_CPU_FREQ in GHz
1613CRYPTOPP_CPU_FREQ ?= 0.0
1614.PHONY: bench benchmark benchmarks
1615bench benchmark benchmarks: cryptest.exe
1616 @-$(RM) -f benchmarks.html
1617 ./cryptest.exe b 2 $(CRYPTOPP_CPU_FREQ)
1619adhoc.cpp: adhoc.cpp.proto
1620ifeq ($(wildcard adhoc.cpp),)
1621 cp adhoc.cpp.proto adhoc.cpp
1626# Include dependencies, if present. You must issue `make deps` to create them.
1627ifeq ($(wildcard GNUmakefile.deps),GNUmakefile.deps)
1628-include GNUmakefile.deps
1631# A few recipes trigger warnings for -std=c++11 and -stdlib=c++
1632NOSTD_CXXFLAGS=$(filter-out -stdlib=%,$(filter-out -std=%,$(CXXFLAGS)))
1634# Cryptogams ARM asm implementation. AES needs -mthumb for Clang
1635aes_armv4.o : aes_armv4.S
1636 $(CXX) $(strip $(CPPFLAGS) $(ASFLAGS) $(NOSTD_CXXFLAGS) $(CRYPTOGAMS_ARM_THUMB_FLAG) -c) $<
1638# SSE, NEON or POWER7 available
1639blake2s_simd.o : blake2s_simd.cpp
1640 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(BLAKE2S_FLAG) -c) $<
1642# SSE, NEON or POWER8 available
1643blake2b_simd.o : blake2b_simd.cpp
1644 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(BLAKE2B_FLAG) -c) $<
1646# SSE2 or NEON available
1647chacha_simd.o : chacha_simd.cpp
1648 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CHACHA_FLAG) -c) $<
1651chacha_avx.o : chacha_avx.cpp
1652 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CHACHA_AVX2_FLAG) -c) $<
1655cham_simd.o : cham_simd.cpp
1656 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CHAM_FLAG) -c) $<
1658# SSE4.2 or ARMv8a available
1659crc_simd.o : crc_simd.cpp
1660 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CRC_FLAG) -c) $<
1664 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(DARN_FLAG) -c) $<
1667donna_sse.o : donna_sse.cpp
1668 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SSE2_FLAG) -c) $<
1671gcm_simd.o : gcm_simd.cpp
1672 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(GCM_FLAG) -c) $<
1675gf2n_simd.o : gf2n_simd.cpp
1676 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(GF2N_FLAG) -c) $<
1679keccak_simd.o : keccak_simd.cpp
1680 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(KECCAK_FLAG) -c) $<
1683lea_simd.o : lea_simd.cpp
1684 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LEA_FLAG) -c) $<
1687lsh256_sse.o : lsh256_sse.cpp
1688 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LSH256_FLAG) -c) $<
1691lsh256_avx.o : lsh256_avx.cpp
1692 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LSH256_AVX2_FLAG) -c) $<
1695lsh512_sse.o : lsh512_sse.cpp
1696 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LSH512_FLAG) -c) $<
1699lsh512_avx.o : lsh512_avx.cpp
1700 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LSH512_AVX2_FLAG) -c) $<
1703neon_simd.o : neon_simd.cpp
1704 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(NEON_FLAG) -c) $<
1707ppc_simd.o : ppc_simd.cpp
1708 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(ALTIVEC_FLAG) -c) $<
1710# AESNI or ARMv7a/ARMv8a available
1711rijndael_simd.o : rijndael_simd.cpp
1712 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(AES_FLAG) -c) $<
1714# SSE4.2/SHA-NI or ARMv8a available
1715sha_simd.o : sha_simd.cpp
1716 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SHA_FLAG) -c) $<
1718# Cryptogams SHA1/SHA256/SHA512 asm implementation.
1719sha%_armv4.o : sha%_armv4.S
1720 $(CXX) $(strip $(CPPFLAGS) $(ASFLAGS) $(NOSTD_CXXFLAGS) $(CRYPTOGAMS_ARM_FLAG) -c) $<
1722sha3_simd.o : sha3_simd.cpp
1723 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SHA3_FLAG) -c) $<
1725# SSE4.2/SHA-NI or ARMv8a available
1726shacal2_simd.o : shacal2_simd.cpp
1727 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SHA_FLAG) -c) $<
1729# SSSE3, NEON or POWER8 available
1730simon128_simd.o : simon128_simd.cpp
1731 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SIMON128_FLAG) -c) $<
1733# SSSE3, NEON or POWER8 available
1734speck128_simd.o : speck128_simd.cpp
1735 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SPECK128_FLAG) -c) $<
1738sm3_simd.o : sm3_simd.cpp
1739 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SM3_FLAG) -c) $<
1742sm4_simd.o : sm4_simd.cpp
1743 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SM4_FLAG) -c) $<
1745# IBM XLC -O3 optimization bug
1746ifeq ($(XLC_COMPILER),1)
1748 $(CXX) $(strip $(CPPFLAGS) $(subst -O3,-O2,$(CXXFLAGS)) -c) $<
1749donna_32.o : donna_32.cpp
1750 $(CXX) $(strip $(CPPFLAGS) $(subst -O3,-O2,$(CXXFLAGS)) -c) $<
1751donna_64.o : donna_64.cpp
1752 $(CXX) $(strip $(CPPFLAGS) $(subst -O3,-O2,$(CXXFLAGS)) -c) $<
1756sse_simd.o : sse_simd.cpp
1757 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SSE2_FLAG) -c) $<
1759# Don't build Rijndael with UBsan. Too much noise due to unaligned data accesses.
1760ifneq ($(findstring -fsanitize=undefined,$(CXXFLAGS)),)
1761rijndael.o : rijndael.cpp
1762 $(CXX) $(strip $(subst -fsanitize=undefined,,$(CXXFLAGS)) -c) $<
1765# Only use CRYPTOPP_DATA_DIR if its not set in CXXFLAGS
1766ifeq ($(findstring -DCRYPTOPP_DATA_DIR, $(CPPFLAGS)$(CXXFLAGS)),)
1767ifneq ($(strip $(CRYPTOPP_DATA_DIR)),)
1768validat%.o : validat%.cpp
1769 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" $(CXXFLAGS) -c) $<
1770bench%.o : bench%.cpp
1771 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" $(CXXFLAGS) -c) $<
1772datatest.o : datatest.cpp
1773 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" $(CXXFLAGS) -c) $<
1775 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" $(CXXFLAGS) -c) $<
1779validat1.o : validat1.cpp
1780 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(ALTIVEC_FLAG) -c) $<
1783 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DLL_ONLY $(CXXFLAGS) -c) $< -o $@
1786 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_IMPORTS $(CXXFLAGS) -c) $< -o $@
1789 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_EXPORTS $(CXXFLAGS) -c) $< -o $@
1792 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) -c) $<
1795 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) -c) $<
1799ifeq ($(HAS_SOLIB_VERSION),1)
1801 $(info WARNING: Only the symlinks to the shared-object library have been updated.)
1802 $(info WARNING: If the library is installed in a system directory you will need)
1803 $(info WARNING: to run ldconfig to update the shared-object library cache.)
1809ifeq ($(IS_DARWIN)$(CLANG_COMPILER),11)
1810 ifeq ($(findstring -stdlib=libc++,$(CRYPTOPP_CXXFLAGS)$(CXXFLAGS)),)
1812 $(info INFO: Crypto++ was built without LLVM libc++. If you are using the library)
1813 $(info INFO: with modern Xcode, then you should add -stdlib=libc++ to CXXFLAGS. It is)
1814 $(info INFO: already present in the makefile, and you only need to uncomment it.)
1819.PHONY: dep deps depend
1820dep deps depend GNUmakefile.deps:
1821 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS)) -MM *.cpp > GNUmakefile.deps