Crypto++  8.6
Free C++ class library of cryptographic schemes
GNUmakefile
1 ###########################################################
2 ##### System Attributes and Programs #####
3 ###########################################################
4 
5 # https://www.gnu.org/software/make/manual/make.html#Makefile-Conventions
6 # and https://www.gnu.org/prep/standards/standards.html
7 
8 SHELL = /bin/sh
9 
10 # If needed
11 TMPDIR ?= /tmp
12 # Used for feature tests
13 TOUT ?= a.out
14 TOUT := $(strip $(TOUT))
15 
16 # Allow override for the cryptest recipe. Change to
17 # ./libcrypto++.so or ./libcrypto++.dylib to suit your
18 # taste. https://github.com/weidai11/cryptopp/issues/866
19 LINK_LIBRARY ?= libcrypto++.a
20 LINK_LIBRARY_PATH ?= ./
21 
22 # Command and arguments
23 AR ?= ar
24 ARFLAGS ?= -cr # ar needs the dash on OpenBSD
25 RANLIB ?= ranlib
26 
27 CP ?= cp
28 MV ?= mv
29 RM ?= rm -f
30 GREP ?= grep
31 SED ?= sed
32 CHMOD ?= chmod
33 MKDIR ?= mkdir -p
34 
35 LN ?= ln -sf
36 LDCONF ?= /sbin/ldconfig -n
37 
38 # Solaris provides a non-Posix sed and grep at /usr/bin
39 # Solaris 10 is missing AR in /usr/bin
40 ifneq ($(wildcard /usr/xpg4/bin/grep),)
41  GREP := /usr/xpg4/bin/grep
42 endif
43 ifneq ($(wildcard /usr/xpg4/bin/sed),)
44  SED := /usr/xpg4/bin/sed
45 endif
46 ifneq ($(wildcard /usr/xpg4/bin/ar),)
47  AR := /usr/xpg4/bin/ar
48 endif
49 
50 # Clang is reporting armv8l-unknown-linux-gnueabihf
51 # for ARMv7 images on Aarch64 hardware.
52 MACHINEX := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null)
53 HOSTX := $(shell echo $(MACHINEX) | cut -f 1 -d '-')
54 ifeq ($(HOSTX),)
55  HOSTX := $(shell uname -m 2>/dev/null)
56 endif
57 
58 IS_X86 := $(shell echo "$(HOSTX)" | $(GREP) -v "64" | $(GREP) -i -c -E 'i.86|x86|i86')
59 IS_X64 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E '_64|d64')
60 IS_PPC32 := $(shell echo "$(HOSTX)" | $(GREP) -v "64" | $(GREP) -i -c -E 'ppc|power')
61 IS_PPC64 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E 'ppc64|powerpc64|power64')
62 IS_SPARC32 := $(shell echo "$(HOSTX)" | $(GREP) -v "64" | $(GREP) -i -c -E 'sun|sparc')
63 IS_SPARC64 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E 'sun|sparc64')
64 IS_ARM32 := $(shell echo "$(HOSTX)" | $(GREP) -v "64" | $(GREP) -i -c -E 'arm|armhf|armv7|eabihf|armv8')
65 IS_ARMV8 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E 'aarch32|aarch64|arm64')
66 
67 # Attempt to determine platform
68 SYSTEMX := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null)
69 ifeq ($(SYSTEMX),)
70  SYSTEMX := $(shell uname -s 2>/dev/null)
71 endif
72 
73 IS_LINUX := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "Linux")
74 IS_HURD := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c -E "GNU|Hurd")
75 IS_MINGW := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "MinGW")
76 IS_CYGWIN := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "Cygwin")
77 IS_DARWIN := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "Darwin")
78 IS_NETBSD := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "NetBSD")
79 IS_AIX := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c "aix")
80 IS_SUN := $(shell echo "$(SYSTEMX)" | $(GREP) -i -c -E "SunOS|Solaris")
81 
82 SUN_COMPILER := $(shell $(CXX) -V 2>&1 | $(GREP) -i -c -E 'CC: (Sun|Studio)')
83 GCC_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -v -E '(llvm|clang)' | $(GREP) -i -c -E '(gcc|g\+\+)')
84 XLC_COMPILER := $(shell $(CXX) -qversion 2>/dev/null |$(GREP) -i -c "IBM XL")
85 CLANG_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -i -c -E '(llvm|clang)')
86 INTEL_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -i -c '\‍(icc\‍)')
87 
88 # Enable shared object versioning for Linux and Solaris
89 HAS_SOLIB_VERSION ?= 0
90 ifneq ($(IS_LINUX)$(IS_HURD)$(IS_SUN),000)
91  HAS_SOLIB_VERSION := 1
92 endif
93 
94 # Formerly adhoc.cpp was created from adhoc.cpp.proto when needed.
95 ifeq ($(wildcard adhoc.cpp),)
96 $(shell cp adhoc.cpp.proto adhoc.cpp)
97 endif
98 
99 # Hack to skip CPU feature tests for some recipes
100 DETECT_FEATURES ?= 1
101 ifneq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CPPFLAGS)$(CXXFLAGS)),)
102  DETECT_FEATURES := 0
103 else ifneq ($(findstring clean,$(MAKECMDGOALS)),)
104  DETECT_FEATURES := 0
105 else ifneq ($(findstring distclean,$(MAKECMDGOALS)),)
106  DETECT_FEATURES := 0
107 else ifneq ($(findstring trim,$(MAKECMDGOALS)),)
108  DETECT_FEATURES := 0
109 else ifneq ($(findstring zip,$(MAKECMDGOALS)),)
110  DETECT_FEATURES := 0
111 endif
112 
113 # Strip out -Wall, -Wextra and friends for feature testing. FORTIFY_SOURCE is removed
114 # because it requires -O1 or higher, but we use -O0 to tame the optimizer.
115 # Always print testing flags since some tests always happen, like 64-bit.
116 TCXXFLAGS := $(filter-out -D_FORTIFY_SOURCE=% -M -MM -Wall -Wextra -Werror% -Wunused -Wconversion -Wp%, $(CPPFLAGS) $(CXXFLAGS))
117 ifneq ($(strip $(TCXXFLAGS)),)
118  $(info Using testing flags: $(TCXXFLAGS))
119 endif
120 
121 # TCOMMAND is used for just about all tests. Make will lazy-evaluate
122 # the variables when executed by $(shell $(TCOMMAND) ...).
123 TCOMMAND = $(CXX) $(TCXXFLAGS) $(TEXTRA) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT)
124 
125 # Fixup AIX
126 ifeq ($(IS_AIX),1)
127  TPROG = TestPrograms/test_64bit.cpp
128  TOPT =
129  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
130  ifeq ($(strip $(HAVE_OPT)),0)
131  IS_PPC64=1
132  else
133  IS_PPC32=1
134  endif
135 endif
136 
137 # Uncomment for debugging
138 # $(info Here's what we found... IS_X86: $(IS_X86), IS_X64: $(IS_X64), IS_ARM32: $(IS_ARM32), IS_ARMV8: $(IS_ARMV8))
139 
140 ###########################################################
141 ##### General Variables #####
142 ###########################################################
143 
144 # Base CPPFLAGS and CXXFLAGS used if the user did not specify them
145 ifeq ($(CPPFLAGS),)
146  CRYPTOPP_CPPFLAGS += -DNDEBUG
147 endif
148 ifeq ($(CXXFLAGS),)
149  ifeq ($(SUN_COMPILER),1)
150  CRYPTOPP_CXXFLAGS += -g -xO3
151  ZOPT = -xO0
152  else
153  CRYPTOPP_CXXFLAGS += -g2 -O3
154  ZOPT = -O0
155  endif
156 endif
157 
158 # Needed when the assembler is invoked
159 ifeq ($(findstring $(ASFLAGS),-Wa,--noexecstack),)
160  CRYPTOPP_ASFLAGS ?= -Wa,--noexecstack
161 endif
162 
163 # Fix CXX on Cygwin 1.1.4
164 ifeq ($(CXX),gcc)
165  CXX := g++
166 endif
167 
168 # On ARM we may compile aes_armv4.S, sha1_armv4.S, sha256_armv4.S, and
169 # sha512_armv4.S through the CC compiler
170 ifeq ($(GCC_COMPILER),1)
171  CC=gcc
172 else ifeq ($(CLANG_COMPILER),1)
173  CC=clang
174 endif
175 
176 # http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
177 ifeq ($(PREFIX),)
178  PREFIX = /usr/local
179  PC_PREFIX = /usr/local
180 else
181  PC_PREFIX = $(PREFIX)
182 endif
183 ifeq ($(LIBDIR),)
184  LIBDIR := $(PREFIX)/lib
185  PC_LIBDIR = $${prefix}/lib
186 else
187  PC_LIBDIR = $(LIBDIR)
188 endif
189 ifeq ($(DATADIR),)
190  DATADIR := $(PREFIX)/share
191  PC_DATADIR = $${prefix}/share
192 else
193  PC_DATADIR = $(DATADIR)
194 endif
195 ifeq ($(INCLUDEDIR),)
196  INCLUDEDIR := $(PREFIX)/include
197  PC_INCLUDEDIR = $${prefix}/include
198 else
199  PC_INCLUDEDIR = $(INCLUDEDIR)
200 endif
201 ifeq ($(BINDIR),)
202  BINDIR := $(PREFIX)/bin
203 endif
204 
205 # We honor ARFLAGS, but the "v" option used by default causes a noisy make
206 ifeq ($(ARFLAGS),rv)
207 ARFLAGS = r
208 endif
209 
210 # Original MinGW targets Win2k by default, but lacks proper Win2k support
211 # if target Windows version is not specified, use Windows XP instead
212 ifeq ($(IS_MINGW),1)
213 ifeq ($(findstring -D_WIN32_WINNT,$(CPPFLAGS)$(CXXFLAGS)),)
214 ifeq ($(findstring -D_WIN32_WINDOWS,$(CPPFLAGS)$(CXXFLAGS)),)
215 ifeq ($(findstring -DWINVER,$(CPPFLAGS)$(CXXFLAGS)),)
216 ifeq ($(findstring -DNTDDI_VERSION,$(CPPFLAGS)$(CXXFLAGS)),)
217  CRYPTOPP_CPPFLAGS += -D_WIN32_WINNT=0x0501
218 endif # NTDDI_VERSION
219 endif # WINVER
220 endif # _WIN32_WINDOWS
221 endif # _WIN32_WINNT
222 endif # IS_MINGW
223 
224 # Newlib needs _XOPEN_SOURCE=600 for signals
225 TPROG = TestPrograms/test_newlib.cpp
226 TOPT =
227 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
228 ifeq ($(strip $(HAVE_OPT)),0)
229  ifeq ($(findstring -D_XOPEN_SOURCE,$(CPPFLAGS)$(CXXFLAGS)),)
230  CRYPTOPP_CPPFLAGS += -D_XOPEN_SOURCE=600
231  endif
232 endif
233 
234 ###########################################################
235 ##### X86/X32/X64 Options #####
236 ###########################################################
237 
238 ifneq ($(IS_X86)$(IS_X64)$(IS_MINGW),000)
239 ifeq ($(DETECT_FEATURES),1)
240 
241  ifeq ($(SUN_COMPILER),1)
242  SSE2_FLAG = -xarch=sse2
243  SSE3_FLAG = -xarch=sse3
244  SSSE3_FLAG = -xarch=ssse3
245  SSE41_FLAG = -xarch=sse4_1
246  SSE42_FLAG = -xarch=sse4_2
247  CLMUL_FLAG = -xarch=aes
248  AESNI_FLAG = -xarch=aes
249  AVX_FLAG = -xarch=avx
250  AVX2_FLAG = -xarch=avx2
251  SHANI_FLAG = -xarch=sha
252  else
253  SSE2_FLAG = -msse2
254  SSE3_FLAG = -msse3
255  SSSE3_FLAG = -mssse3
256  SSE41_FLAG = -msse4.1
257  SSE42_FLAG = -msse4.2
258  CLMUL_FLAG = -mpclmul
259  AESNI_FLAG = -maes
260  AVX_FLAG = -mavx
261  AVX2_FLAG = -mavx2
262  SHANI_FLAG = -msha
263  endif
264 
265  # Tell MacPorts and Homebrew GCC to use Clang integrated assembler
266  # Intel-based Macs. http://github.com/weidai11/cryptopp/issues/190
267  ifneq ($(IS_DARWIN),0)
268  ifeq ($(findstring -Wa,-q,$(CXXFLAGS)),)
269  TPROG = TestPrograms/test_cxx.cpp
270  TOPT = -Wa,-q
271  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
272  ifeq ($(strip $(HAVE_OPT)),0)
273  TEXTRA += -Wa,-q
274  CRYPTOPP_CXXFLAGS += -Wa,-q
275  endif
276  endif
277  endif
278 
279  TPROG = TestPrograms/test_x86_sse2.cpp
280  TOPT = $(SSE2_FLAG)
281  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
282  ifeq ($(strip $(HAVE_OPT)),0)
283  CHACHA_FLAG = $(SSE2_FLAG)
284  SUN_LDFLAGS += $(SSE2_FLAG)
285  else
286  # Make does not have useful debugging facilities. Show the user
287  # what happened by compiling again without the pipe.
288  $(info Running make again to see what failed)
289  $(info $(shell $(TCOMMAND)))
290  SSE2_FLAG =
291  endif
292 
293  ifeq ($(SSE2_FLAG),)
294  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ASM
295  endif
296 
297  # Need SSE2 or higher for these tests
298  ifneq ($(SSE2_FLAG),)
299 
300  TPROG = TestPrograms/test_x86_ssse3.cpp
301  TOPT = $(SSSE3_FLAG)
302  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
303  ifeq ($(strip $(HAVE_OPT)),0)
304  ARIA_FLAG = $(SSSE3_FLAG)
305  CHAM_FLAG = $(SSSE3_FLAG)
306  KECCAK_FLAG = $(SSSE3_FLAG)
307  LEA_FLAG = $(SSSE3_FLAG)
308  LSH256_FLAG = $(SSSE3_FLAG)
309  LSH512_FLAG = $(SSSE3_FLAG)
310  SIMON128_FLAG = $(SSSE3_FLAG)
311  SPECK128_FLAG = $(SSSE3_FLAG)
312  SUN_LDFLAGS += $(SSSE3_FLAG)
313  else
314  SSSE3_FLAG =
315  endif
316 
317  # The first Apple MacBooks were Core2's with SSE4.1
318  ifneq ($(IS_DARWIN),0)
319  # Add SSE2 algo's here as required
320  # They get a free upgrade
321  endif
322 
323  TPROG = TestPrograms/test_x86_sse41.cpp
324  TOPT = $(SSE41_FLAG)
325  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
326  ifeq ($(strip $(HAVE_OPT)),0)
327  BLAKE2B_FLAG = $(SSE41_FLAG)
328  BLAKE2S_FLAG = $(SSE41_FLAG)
329  SUN_LDFLAGS += $(SSE41_FLAG)
330  else
331  SSE41_FLAG =
332  endif
333 
334  TPROG = TestPrograms/test_x86_sse42.cpp
335  TOPT = $(SSE42_FLAG)
336  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
337  ifeq ($(strip $(HAVE_OPT)),0)
338  CRC_FLAG = $(SSE42_FLAG)
339  SUN_LDFLAGS += $(SSE42_FLAG)
340  else
341  SSE42_FLAG =
342  endif
343 
344  TPROG = TestPrograms/test_x86_clmul.cpp
345  TOPT = $(CLMUL_FLAG)
346  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
347  ifeq ($(strip $(HAVE_OPT)),0)
348  GCM_FLAG = $(SSSE3_FLAG) $(CLMUL_FLAG)
349  GF2N_FLAG = $(CLMUL_FLAG)
350  SUN_LDFLAGS += $(CLMUL_FLAG)
351  else
352  CLMUL_FLAG =
353  endif
354 
355  TPROG = TestPrograms/test_x86_aes.cpp
356  TOPT = $(AESNI_FLAG)
357  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
358  ifeq ($(strip $(HAVE_OPT)),0)
359  AES_FLAG = $(SSE41_FLAG) $(AESNI_FLAG)
360  SM4_FLAG = $(SSSE3_FLAG) $(AESNI_FLAG)
361  SUN_LDFLAGS += $(AESNI_FLAG)
362  else
363  AESNI_FLAG =
364  endif
365 
366  TPROG = TestPrograms/test_x86_avx.cpp
367  TOPT = $(AVX_FLAG)
368  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
369  ifeq ($(strip $(HAVE_OPT)),0)
370  # XXX_FLAG = $(AVX_FLAG)
371  SUN_LDFLAGS += $(AVX_FLAG)
372  else
373  AVX_FLAG =
374  endif
375 
376  TPROG = TestPrograms/test_x86_avx2.cpp
377  TOPT = $(AVX2_FLAG)
378  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
379  ifeq ($(strip $(HAVE_OPT)),0)
380  CHACHA_AVX2_FLAG = $(AVX2_FLAG)
381  LSH256_AVX2_FLAG = $(AVX2_FLAG)
382  LSH512_AVX2_FLAG = $(AVX2_FLAG)
383  SUN_LDFLAGS += $(AVX2_FLAG)
384  else
385  AVX2_FLAG =
386  endif
387 
388  TPROG = TestPrograms/test_x86_sha.cpp
389  TOPT = $(SHANI_FLAG)
390  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
391  ifeq ($(strip $(HAVE_OPT)),0)
392  SHA_FLAG = $(SSE42_FLAG) $(SHANI_FLAG)
393  SUN_LDFLAGS += $(SHANI_FLAG)
394  else
395  SHANI_FLAG =
396  endif
397 
398  ifeq ($(SUN_COMPILER),1)
399  CRYPTOPP_LDFLAGS += $(SUN_LDFLAGS)
400  endif
401 
402  ifeq ($(SSE3_FLAG),)
403  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_SSE3
404  else ifeq ($(SSSE3_FLAG),)
405  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_SSSE3
406  else ifeq ($(SSE41_FLAG),)
407  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_SSE4
408  else ifeq ($(SSE42_FLAG),)
409  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_SSE4
410  endif
411 
412  ifneq ($(SSE42_FLAG),)
413  # Unusual GCC/Clang on Macports. It assembles AES, but not CLMUL.
414  # test_x86_clmul.s:15: no such instruction: 'pclmulqdq $0, %xmm1,%xmm0'
415  ifeq ($(CLMUL_FLAG),)
416  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_CLMUL
417  endif
418  ifeq ($(AESNI_FLAG),)
419  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_AESNI
420  endif
421 
422  ifeq ($(AVX_FLAG),)
423  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_AVX
424  else ifeq ($(AVX2_FLAG),)
425  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_AVX2
426  endif
427  # SHANI independent of AVX per GH #1045
428  ifeq ($(SHANI_FLAG),)
429  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_SHANI
430  endif
431  endif
432 
433  # Drop to SSE2 if available
434  ifeq ($(GCM_FLAG),)
435  GCM_FLAG = $(SSE2_FLAG)
436  endif
437 
438  # Most Clang cannot handle mixed asm with positional arguments, where the
439  # body is Intel style with no prefix and the templates are AT&T style.
440  # Also see https://bugs.llvm.org/show_bug.cgi?id=39895 .
441 
442  # CRYPTOPP_DISABLE_MIXED_ASM is now being added in config_asm.h for all
443  # Clang compilers. This test will need to be re-enabled if Clang fixes it.
444  #TPROG = TestPrograms/test_asm_mixed.cpp
445  #TOPT =
446  #HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
447  #ifneq ($(strip $(HAVE_OPT)),0)
448  # CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_MIXED_ASM
449  #endif
450 
451  # SSE2_FLAGS
452  endif
453 # DETECT_FEATURES
454 endif
455 
456 ifneq ($(INTEL_COMPILER),0)
457  CRYPTOPP_CXXFLAGS += -wd68 -wd186 -wd279 -wd327 -wd161 -wd3180
458 
459  ICC111_OR_LATER := $(shell $(CXX) --version 2>&1 | $(GREP) -c -E "\‍(ICC\‍) ([2-9][0-9]|1[2-9]|11\.[1-9])")
460  ifeq ($(ICC111_OR_LATER),0)
461  # "internal error: backend signals" occurs on some x86 inline assembly with ICC 9 and
462  # some x64 inline assembly with ICC 11.0. If you want to use Crypto++'s assembly code
463  # with ICC, try enabling it on individual files
464  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ASM
465  endif
466 endif
467 
468 # Allow use of "/" operator for GNU Assembler.
469 # http://sourceware.org/bugzilla/show_bug.cgi?id=4572
470 ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CPPFLAGS)$(CXXFLAGS)),)
471  ifeq ($(IS_SUN)$(GCC_COMPILER),11)
472  CRYPTOPP_CXXFLAGS += -Wa,--divide
473  endif
474 endif
475 
476 # IS_X86, IS_X32 and IS_X64
477 endif
478 
479 ###########################################################
480 ##### ARM A-32 and NEON #####
481 ###########################################################
482 
483 ifneq ($(IS_ARM32),0)
484 
485 # No need for feature detection on this platform if NEON is disabled
486 ifneq ($(findstring -DCRYPTOPP_DISABLE_ARM_NEON,$(CPPFLAGS)$(CXXFLAGS)),)
487  DETECT_FEATURES := 0
488 endif
489 
490 ifeq ($(DETECT_FEATURES),1)
491 
492  # Clang needs an option to include <arm_neon.h>
493  TPROG = TestPrograms/test_arm_neon_header.cpp
494  TOPT = -DCRYPTOPP_ARM_NEON_HEADER=1 -march=armv7-a -mfpu=neon
495  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
496  ifeq ($(strip $(HAVE_OPT)),0)
497  TEXTRA += -DCRYPTOPP_ARM_NEON_HEADER=1
498  endif
499 
500  TPROG = TestPrograms/test_arm_neon.cpp
501  TOPT = -march=armv7-a -mfpu=neon
502  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
503  ifeq ($(strip $(HAVE_OPT)),0)
504  NEON_FLAG = -march=armv7-a -mfpu=neon
505  ARIA_FLAG = -march=armv7-a -mfpu=neon
506  GCM_FLAG = -march=armv7-a -mfpu=neon
507  BLAKE2B_FLAG = -march=armv7-a -mfpu=neon
508  BLAKE2S_FLAG = -march=armv7-a -mfpu=neon
509  CHACHA_FLAG = -march=armv7-a -mfpu=neon
510  CHAM_FLAG = -march=armv7-a -mfpu=neon
511  LEA_FLAG = -march=armv7-a -mfpu=neon
512  SIMON128_FLAG = -march=armv7-a -mfpu=neon
513  SPECK128_FLAG = -march=armv7-a -mfpu=neon
514  SM4_FLAG = -march=armv7-a -mfpu=neon
515  else
516  # Make does not have useful debugging facilities. Show the user
517  # what happened by compiling again without the pipe.
518  $(info Running make again to see what failed)
519  $(info $(shell $(TCOMMAND)))
520  NEON_FLAG =
521  endif
522 
523  ifeq ($(NEON_FLAG),)
524  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ASM
525  endif
526 
527 # DETECT_FEATURES
528 endif
529 # IS_ARM32
530 endif
531 
532 ###########################################################
533 ##### Aach32 and Aarch64 #####
534 ###########################################################
535 
536 ifneq ($(IS_ARMV8),0)
537 ifeq ($(DETECT_FEATURES),1)
538 
539  TPROG = TestPrograms/test_arm_neon_header.cpp
540  TOPT = -DCRYPTOPP_ARM_NEON_HEADER=1
541  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
542  ifeq ($(strip $(HAVE_OPT)),0)
543  TEXTRA += -DCRYPTOPP_ARM_NEON_HEADER=1
544  endif
545 
546  TPROG = TestPrograms/test_arm_acle_header.cpp
547  TOPT = -DCRYPTOPP_ARM_ACLE_HEADER=1 -march=armv8-a
548  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
549  ifeq ($(strip $(HAVE_OPT)),0)
550  TEXTRA += -DCRYPTOPP_ARM_ACLE_HEADER=1
551  endif
552 
553  TPROG = TestPrograms/test_arm_asimd.cpp
554  TOPT = -march=armv8-a
555  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
556  ifeq ($(strip $(HAVE_OPT)),0)
557  ASIMD_FLAG = -march=armv8-a
558  ARIA_FLAG = -march=armv8-a
559  BLAKE2B_FLAG = -march=armv8-a
560  BLAKE2S_FLAG = -march=armv8-a
561  CHACHA_FLAG = -march=armv8-a
562  CHAM_FLAG = -march=armv8-a
563  LEA_FLAG = -march=armv8-a
564  NEON_FLAG = -march=armv8-a
565  SIMON128_FLAG = -march=armv8-a
566  SPECK128_FLAG = -march=armv8-a
567  SM4_FLAG = -march=armv8-a
568  else
569  # Make does not have useful debugging facilities. Show the user
570  # what happened by compiling again without the pipe.
571  $(info Running make again to see what failed)
572  $(info $(shell $(TCOMMAND)))
573  ASIMD_FLAG =
574  endif
575 
576  ifeq ($(ASIMD_FLAG),)
577  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ASM
578  endif
579 
580  ifneq ($(ASIMD_FLAG),)
581  TPROG = TestPrograms/test_arm_crc.cpp
582  TOPT = -march=armv8-a+crc
583  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
584  ifeq ($(strip $(HAVE_OPT)),0)
585  CRC_FLAG = -march=armv8-a+crc
586  else
587  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_CRC32
588  endif
589 
590  TPROG = TestPrograms/test_arm_aes.cpp
591  TOPT = -march=armv8-a+crypto
592  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
593  ifeq ($(strip $(HAVE_OPT)),0)
594  AES_FLAG = -march=armv8-a+crypto
595  else
596  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_AES
597  endif
598 
599  TPROG = TestPrograms/test_arm_pmull.cpp
600  TOPT = -march=armv8-a+crypto
601  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
602  ifeq ($(strip $(HAVE_OPT)),0)
603  GCM_FLAG = -march=armv8-a+crypto
604  GF2N_FLAG = -march=armv8-a+crypto
605  else
606  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_PMULL
607  endif
608 
609  TPROG = TestPrograms/test_arm_sha1.cpp
610  TOPT = -march=armv8-a+crypto
611  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
612  ifeq ($(strip $(HAVE_OPT)),0)
613  SHA_FLAG = -march=armv8-a+crypto
614  else
615  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA1
616  endif
617 
618  TPROG = TestPrograms/test_arm_sha256.cpp
619  TOPT = -march=armv8-a+crypto
620  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
621  ifeq ($(strip $(HAVE_OPT)),0)
622  SHA_FLAG = -march=armv8-a+crypto
623  else
624  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA2
625  endif
626 
627  TPROG = TestPrograms/test_arm_sm3.cpp
628  TOPT = -march=armv8.4-a+sm3
629  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
630  ifeq ($(strip $(HAVE_OPT)),0)
631  SM3_FLAG = -march=armv8.4-a+sm3
632  SM4_FLAG = -march=armv8.4-a+sm3
633  else
634  #CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_SM3
635  #CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_SM4
636  endif
637 
638  TPROG = TestPrograms/test_arm_sha3.cpp
639  TOPT = -march=armv8.4-a+sha3
640  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
641  ifeq ($(strip $(HAVE_OPT)),0)
642  SHA3_FLAG = -march=armv8.4-a+sha3
643  else
644  #CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA3
645  endif
646 
647  TPROG = TestPrograms/test_arm_sha512.cpp
648  TOPT = -march=armv8.4-a+sha512
649  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
650  ifeq ($(strip $(HAVE_OPT)),0)
651  SHA512_FLAG = -march=armv8.4-a+sha512
652  else
653  #CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA512
654  endif
655 
656  # ASIMD_FLAG
657  endif
658 
659 # DETECT_FEATURES
660 endif
661 # IS_ARMV8
662 endif
663 
664 ###########################################################
665 ##### PowerPC #####
666 ###########################################################
667 
668 # PowerPC and PowerPC64. Altivec is available with POWER4 with GCC and
669 # POWER6 with XLC. The tests below are crafted for IBM XLC and the LLVM
670 # front-end. XLC/LLVM only supplies POWER8 so we have to set the flags for
671 # XLC/LLVM to POWER8. I've got a feeling LLVM is going to cause trouble.
672 
673 ifneq ($(IS_PPC32)$(IS_PPC64),00)
674 ifeq ($(DETECT_FEATURES),1)
675 
676  # IBM XL C/C++ has the -qaltivec flag really screwed up. We can't seem
677  # to get it enabled without an -qarch= option. And -qarch= produces an
678  # error on later versions of the compiler. The only thing that seems
679  # to work consistently is -qarch=auto. -qarch=auto is equivalent to
680  # GCC's -march=native, which we don't really want.
681 
682  # XLC requires -qaltivec in addition to Arch or CPU option
683  ifeq ($(XLC_COMPILER),1)
684  # POWER9_FLAG = -qarch=pwr9 -qaltivec
685  POWER8_FLAG = -qarch=pwr8 -qaltivec
686  POWER7_VSX_FLAG = -qarch=pwr7 -qvsx -qaltivec
687  POWER7_PWR_FLAG = -qarch=pwr7 -qaltivec
688  ALTIVEC_FLAG = -qarch=auto -qaltivec
689  else
690  # POWER9_FLAG = -mcpu=power9
691  POWER8_FLAG = -mcpu=power8
692  POWER7_VSX_FLAG = -mcpu=power7 -mvsx
693  POWER7_PWR_FLAG = -mcpu=power7
694  ALTIVEC_FLAG = -maltivec
695  endif
696 
697  # GCC 10 is giving us trouble in CPU_ProbePower9() and
698  # CPU_ProbeDARN(). GCC is generating POWER9 instructions
699  # on POWER8 for ppc_power9.cpp. The compiler folks did
700  # not think through the consequences of requiring us to
701  # use -mcpu=power9 to unlock the ISA. Epic fail.
702  # https:#github.com/weidai11/cryptopp/issues/986
703  POWER9_FLAG =
704 
705  # XLC with LLVM front-ends failed to define XLC defines.
706  #ifeq ($(findstring -qxlcompatmacros,$(CXXFLAGS)),)
707  # TPROG = TestPrograms/test_ppc_altivec.cpp
708  # TOPT = -qxlcompatmacros
709  # HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
710  # ifeq ($(strip $(HAVE_OPT)),0)
711  # CRYPTOPP_CXXFLAGS += -qxlcompatmacros
712  # endif
713  #endif
714 
715  #####################################################################
716  # Looking for a POWER9 option
717 
718  #TPROG = TestPrograms/test_ppc_power9.cpp
719  #TOPT = $(POWER9_FLAG)
720  #HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
721  #ifeq ($(strip $(HAVE_OPT)),0)
722  # DARN_FLAG = $(POWER9_FLAG)
723  #else
724  # POWER9_FLAG =
725  #endif
726 
727  #####################################################################
728  # Looking for a POWER8 option
729 
730  TPROG = TestPrograms/test_ppc_power8.cpp
731  TOPT = $(POWER8_FLAG)
732  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
733  ifeq ($(strip $(HAVE_OPT)),0)
734  AES_FLAG = $(POWER8_FLAG)
735  BLAKE2B_FLAG = $(POWER8_FLAG)
736  CRC_FLAG = $(POWER8_FLAG)
737  GCM_FLAG = $(POWER8_FLAG)
738  GF2N_FLAG = $(POWER8_FLAG)
739  LEA_FLAG = $(POWER8_FLAG)
740  SHA_FLAG = $(POWER8_FLAG)
741  SHACAL2_FLAG = $(POWER8_FLAG)
742  else
743  POWER8_FLAG =
744  endif
745 
746  #####################################################################
747  # Looking for a POWER7 option
748 
749  # GCC needs -mvsx for Power7 to enable 64-bit vector elements.
750  # XLC provides 64-bit vector elements without an option.
751 
752  TPROG = TestPrograms/test_ppc_power7.cpp
753  TOPT = $(POWER7_VSX_FLAG)
754  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
755  ifeq ($(strip $(HAVE_OPT)),0)
756  POWER7_FLAG = $(POWER7_VSX_FLAG)
757  else
758  TPROG = TestPrograms/test_ppc_power7.cpp
759  TOPT = $(POWER7_PWR_FLAG)
760  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
761  ifeq ($(strip $(HAVE_OPT)),0)
762  POWER7_FLAG = $(POWER7_PWR_FLAG)
763  else
764  POWER7_FLAG =
765  endif
766  endif
767 
768  #####################################################################
769  # Looking for an Altivec option
770 
771  TPROG = TestPrograms/test_ppc_altivec.cpp
772  TOPT = $(ALTIVEC_FLAG)
773  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
774  ifeq ($(strip $(HAVE_OPT)),0)
775  ALTIVEC_FLAG := $(ALTIVEC_FLAG)
776  else
777  # Make does not have useful debugging facilities. Show the user
778  # what happened by compiling again without the pipe.
779  $(info Running make again to see what failed)
780  $(info $(shell $(TCOMMAND)))
781  ALTIVEC_FLAG =
782  endif
783 
784  ifneq ($(ALTIVEC_FLAG),)
785  BLAKE2S_FLAG = $(ALTIVEC_FLAG)
786  CHACHA_FLAG = $(ALTIVEC_FLAG)
787  SPECK128_FLAG = $(ALTIVEC_FLAG)
788  SIMON128_FLAG = $(ALTIVEC_FLAG)
789  endif
790 
791  #####################################################################
792  # Fixups for algorithms that can drop to a lower ISA, if needed
793 
794  # Drop to Altivec if higher Power is not available
795  ifneq ($(ALTIVEC_FLAG),)
796  ifeq ($(GCM_FLAG),)
797  GCM_FLAG = $(ALTIVEC_FLAG)
798  endif
799  endif
800 
801  #####################################################################
802  # Fixups for missing ISAs
803 
804  ifeq ($(ALTIVEC_FLAG),)
805  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_ALTIVEC
806  else ifeq ($(POWER7_FLAG),)
807  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_POWER7
808  else ifeq ($(POWER8_FLAG),)
809  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_POWER8
810  #else ifeq ($(POWER9_FLAG),)
811  # CRYPTOPP_CPPFLAGS += -DCRYPTOPP_DISABLE_POWER9
812  endif
813 
814 # DETECT_FEATURES
815 endif
816 
817 # IBM XL C++ compiler
818 ifeq ($(XLC_COMPILER),1)
819  ifeq ($(findstring -qmaxmem,$(CXXFLAGS)),)
820  CRYPTOPP_CXXFLAGS += -qmaxmem=-1
821  endif
822  # http://www-01.ibm.com/support/docview.wss?uid=swg21007500
823  ifeq ($(findstring -qrtti,$(CXXFLAGS)),)
824  CRYPTOPP_CXXFLAGS += -qrtti
825  endif
826 endif
827 
828 # IS_PPC32, IS_PPC64
829 endif
830 
831 ###########################################################
832 ##### Common #####
833 ###########################################################
834 
835 # Add -fPIC for targets *except* X86, X32, Cygwin or MinGW
836 ifeq ($(IS_X86)$(IS_CYGWIN)$(IS_MINGW),000)
837  ifeq ($(findstring -fpic,$(CXXFLAGS))$(findstring -fPIC,$(CXXFLAGS)),)
838  CRYPTOPP_CXXFLAGS += -fPIC
839  endif
840 endif
841 
842 # Use -pthread whenever it is available. See http://www.hpl.hp.com/techreports/2004/HPL-2004-209.pdf
843 # http://stackoverflow.com/questions/2127797/gcc-significance-of-pthread-flag-when-compiling
844 ifeq ($(DETECT_FEATURES),1)
845  ifeq ($(XLC_COMPILER),1)
846  ifeq ($(findstring -qthreaded,$(CXXFLAGS)),)
847  TPROG = TestPrograms/test_pthreads.cpp
848  TOPT = -qthreaded
849  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
850  ifeq ($(strip $(HAVE_OPT)),0)
851  CRYPTOPP_CXXFLAGS += -qthreaded
852  endif # CRYPTOPP_CXXFLAGS
853  endif # qthreaded
854  else
855  ifeq ($(findstring -pthread,$(CXXFLAGS)),)
856  TPROG = TestPrograms/test_pthreads.cpp
857  TOPT = -pthread
858  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
859  ifeq ($(strip $(HAVE_OPT)),0)
860  CRYPTOPP_CXXFLAGS += -pthread
861  endif # CRYPTOPP_CXXFLAGS
862  endif # pthread
863  endif # XLC/GCC and friends
864 endif # DETECT_FEATURES
865 
866 # Remove -fPIC if present. SunCC use -KPIC, and needs the larger GOT table
867 # https://docs.oracle.com/cd/E19205-01/819-5267/bkbaq/index.html
868 ifeq ($(SUN_COMPILER),1)
869  CRYPTOPP_CXXFLAGS := $(subst -fPIC,-KPIC,$(CRYPTOPP_CXXFLAGS))
870  CRYPTOPP_CXXFLAGS := $(subst -fpic,-KPIC,$(CRYPTOPP_CXXFLAGS))
871 endif
872 
873 # Remove -fPIC if present. IBM XL C++ uses -qpic
874 ifeq ($(XLC_COMPILER),1)
875  CRYPTOPP_CXXFLAGS := $(subst -fPIC,-qpic,$(CRYPTOPP_CXXFLAGS))
876  CRYPTOPP_CXXFLAGS := $(subst -fpic,-qpic,$(CRYPTOPP_CXXFLAGS))
877 endif
878 
879 # Disable IBM XL C++ "1500-036: (I) The NOSTRICT option (default at OPT(3))
880 # has the potential to alter the semantics of a program."
881 ifeq ($(XLC_COMPILER),1)
882  TPROG = TestPrograms/test_cxx.cpp
883  TOPT = -qsuppress=1500-036
884  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
885  ifeq ($(strip $(HAVE_OPT)),0)
886  CRYPTOPP_CXXFLAGS += -qsuppress=1500-036
887  endif # -qsuppress
888 endif # IBM XL C++ compiler
889 
890 # libc++ is LLVM's standard C++ library. If we add libc++
891 # here then all user programs must use it too. The open
892 # question is, which choice is easier on users?
893 ifneq ($(IS_DARWIN),0)
894  CXX ?= c++
895  # CRYPTOPP_CXXFLAGS += -stdlib=libc++
896  ifeq ($(findstring -fno-common,$(CXXFLAGS)),)
897  CRYPTOPP_CXXFLAGS += -fno-common
898  endif
899  IS_APPLE_LIBTOOL=$(shell libtool -V 2>&1 | $(GREP) -i -c 'Apple')
900  ifeq ($(IS_APPLE_LIBTOOL),1)
901  AR = libtool
902  else
903  AR = /usr/bin/libtool
904  endif
905  ARFLAGS = -static -o
906 endif
907 
908 # Add -xregs=no%appl SPARC. SunCC should not use certain registers in library code.
909 # https://docs.oracle.com/cd/E18659_01/html/821-1383/bkamt.html
910 ifneq ($(IS_SPARC32)$(IS_SPARC64),00)
911  ifeq ($(SUN_COMPILER),1)
912  ifeq ($(findstring -xregs=no%appl,$(CXXFLAGS)),)
913  CRYPTOPP_CXXFLAGS += -xregs=no%appl
914  endif # -xregs
915  endif # SunCC
916  ifeq ($(GCC_COMPILER),1)
917  ifeq ($(findstring -mno-app-regs,$(CXXFLAGS)),)
918  CRYPTOPP_CXXFLAGS += -mno-app-regs
919  endif # no-app-regs
920  endif # GCC
921 endif # Sparc
922 
923 # Add -pipe for everything except IBM XL C++, SunCC and ARM.
924 # Allow ARM-64 because they seems to have >1 GB of memory
925 ifeq ($(XLC_COMPILER)$(SUN_COMPILER)$(IS_ARM32),000)
926  ifeq ($(findstring -save-temps,$(CXXFLAGS)),)
927  CRYPTOPP_CXXFLAGS += -pipe
928  endif
929 endif
930 
931 # For SunOS, create a Mapfile that allows our object files
932 # to contain additional bits (like SSE4 and AES on old Xeon)
933 # http://www.oracle.com/technetwork/server-storage/solaris/hwcap-modification-139536.html
934 ifeq ($(IS_SUN)$(SUN_COMPILER),11)
935  ifneq ($(IS_X86)$(IS_X64),00)
936  ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CPPFLAGS)$(CXXFLAGS)),)
937  CRYPTOPP_LDFLAGS += -M cryptopp.mapfile
938  endif # No CRYPTOPP_DISABLE_ASM
939  endif # X86/X32/X64
940 endif # SunOS
941 
942 ifneq ($(IS_LINUX)$(IS_HURD),00)
943  ifeq ($(findstring -fopenmp,$(CXXFLAGS)),-fopenmp)
944  ifeq ($(findstring -lgomp,$(LDLIBS)),)
945  LDLIBS += -lgomp
946  endif # LDLIBS
947  endif # OpenMP
948 endif # IS_LINUX or IS_HURD
949 
950 # Add -errtags=yes to get the name for a warning suppression
951 ifneq ($(SUN_COMPILER),0) # override flags for CC Sun C++ compiler
952 # Add to all Solaris
953 CRYPTOPP_CXXFLAGS += -template=no%extdef
954 SUN_CC10_BUGGY := $(shell $(CXX) -V 2>&1 | $(GREP) -c -E "CC: Sun .* 5\.10 .* (2009|2010/0[1-4])")
955 ifneq ($(SUN_CC10_BUGGY),0)
956 # -DCRYPTOPP_INCLUDE_VECTOR_CC is needed for Sun Studio 12u1 Sun C++ 5.10 SunOS_i386 128229-02 2009/09/21
957 # and was fixed in May 2010. Remove it if you get "already had a body defined" errors in vector.cc
958 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_INCLUDE_VECTOR_CC
959 endif
960 AR = $(CXX)
961 ARFLAGS = -xar -o
962 RANLIB = true
963 endif
964 
965 # Native build testing. Issue 'make native'.
966 ifeq ($(findstring native,$(MAKECMDGOALS)),native)
967  NATIVE_OPT =
968 
969  # Try GCC and compatibles first
970  TPROG = TestPrograms/test_cxx.cpp
971  TOPT = -march=native
972  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
973  ifeq ($(strip $(HAVE_OPT)),0)
974  NATIVE_OPT = -march=native
975  endif # NATIVE_OPT
976 
977  # And tune
978  ifeq ($(NATIVE_OPT),)
979  TOPT = -mtune=native
980  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
981  ifeq ($(strip $(HAVE_OPT)),0)
982  NATIVE_OPT = -mtune=native
983  endif # NATIVE_OPT
984  endif
985 
986  # Try SunCC next
987  ifeq ($(NATIVE_OPT),)
988  TOPT = -native
989  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
990  ifeq ($(strip $(HAVE_OPT)),0)
991  NATIVE_OPT = -native
992  endif # NATIVE_OPT
993  endif
994 
995  ifneq ($(NATIVE_OPT),)
996  CRYPTOPP_CXXFLAGS += $(NATIVE_OPT)
997  endif
998 
999 endif # Native
1000 
1001 # Undefined Behavior Sanitizer (UBsan) testing. Issue 'make ubsan'.
1002 ifeq ($(findstring ubsan,$(MAKECMDGOALS)),ubsan)
1003  CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1004  CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1005  CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1006  ifeq ($(findstring -fsanitize=undefined,$(CXXFLAGS)),)
1007  CRYPTOPP_CXXFLAGS += -fsanitize=undefined
1008  endif # CRYPTOPP_CPPFLAGS
1009  ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CPPFLAGS)$(CXXFLAGS)),)
1010  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1011  endif # CRYPTOPP_CPPFLAGS
1012 endif # UBsan
1013 
1014 # Address Sanitizer (Asan) testing. Issue 'make asan'.
1015 ifeq ($(findstring asan,$(MAKECMDGOALS)),asan)
1016  CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1017  CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1018  CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1019  ifeq ($(findstring -fsanitize=address,$(CXXFLAGS)),)
1020  CRYPTOPP_CXXFLAGS += -fsanitize=address
1021  endif # CRYPTOPP_CXXFLAGS
1022  ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CPPFLAGS)$(CXXFLAGS)),)
1023  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1024  endif # CRYPTOPP_CPPFLAGS
1025  ifeq ($(findstring -fno-omit-frame-pointer,$(CXXFLAGS)),)
1026  CRYPTOPP_CXXFLAGS += -fno-omit-frame-pointer
1027  endif # CRYPTOPP_CXXFLAGS
1028 endif # Asan
1029 
1030 # LD gold linker testing. Triggered by 'LD=ld.gold'.
1031 ifeq ($(findstring ld.gold,$(LD)),ld.gold)
1032  ifeq ($(findstring -fuse-ld=gold,$(CXXFLAGS)),)
1033  LD_GOLD = $(shell command -v ld.gold)
1034  ELF_FORMAT := $(shell file $(LD_GOLD) 2>&1 | cut -d":" -f 2 | $(GREP) -i -c "elf")
1035  ifneq ($(ELF_FORMAT),0)
1036  CRYPTOPP_LDFLAGS += -fuse-ld=gold
1037  endif # ELF/ELF64
1038  endif # CXXFLAGS
1039 endif # Gold
1040 
1041 # lcov code coverage. Issue 'make coverage'.
1042 ifneq ($(filter lcov coverage,$(MAKECMDGOALS)),)
1043  CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1044  CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1045  CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1046  ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CPPFLAGS)$(CXXFLAGS)),)
1047  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1048  endif # CRYPTOPP_COVERAGE
1049  ifeq ($(findstring -coverage,$(CXXFLAGS)),)
1050  CRYPTOPP_CXXFLAGS += -coverage
1051  endif # -coverage
1052 endif # GCC code coverage
1053 
1054 # gcov code coverage for Travis. Issue 'make codecov'.
1055 ifneq ($(filter gcov codecov,$(MAKECMDGOALS)),)
1056  CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1057  CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1058  CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1059  ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CPPFLAGS)$(CXXFLAGS)),)
1060  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1061  endif # CRYPTOPP_COVERAGE
1062  ifeq ($(findstring -coverage,$(CXXFLAGS)),)
1063  CRYPTOPP_CXXFLAGS += -coverage
1064  endif # -coverage
1065 endif # GCC code coverage
1066 
1067 # Valgrind testing. Issue 'make valgrind'.
1068 ifneq ($(filter valgrind,$(MAKECMDGOALS)),)
1069  # Tune flags; see http://valgrind.org/docs/manual/quick-start.html
1070  CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1071  CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1072  CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1073  ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CPPFLAGS)$(CXXFLAGS)),)
1074  CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1075  endif # CRYPTOPP_CPPFLAGS
1076 endif # Valgrind
1077 
1078 # Debug testing on GNU systems. Triggered by -DDEBUG.
1079 # Newlib test due to http://sourceware.org/bugzilla/show_bug.cgi?id=20268
1080 ifneq ($(filter -DDEBUG -DDEBUG=1,$(CXXFLAGS)),)
1081  TPROG = TestPrograms/test_cxx.cpp
1082  TOPT =
1083  USING_GLIBCXX := $(shell $(CXX)$(CXXFLAGS) -E $(TPROG) -c 2>&1 | $(GREP) -i -c "__GLIBCXX__")
1084  ifneq ($(USING_GLIBCXX),0)
1085  ifeq ($(HAS_NEWLIB),0)
1086  ifeq ($(findstring -D_GLIBCXX_DEBUG,$(CPPFLAGS)$(CXXFLAGS)),)
1087  CRYPTOPP_CPPFLAGS += -D_GLIBCXX_DEBUG
1088  endif # CRYPTOPP_CPPFLAGS
1089  endif # HAS_NEWLIB
1090  endif # USING_GLIBCXX
1091 
1092  ifeq ($(XLC_COMPILER),1)
1093  TPROG = TestPrograms/test_cxx.cpp
1094  TOPT = -qheapdebug -qro
1095  HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
1096  ifeq ($(strip $(HAVE_OPT)),0)
1097  CRYPTOPP_CXXFLAGS += -qheapdebug -qro
1098  endif # CRYPTOPP_CXXFLAGS
1099  endif # XLC_COMPILER
1100 endif # Debug build
1101 
1102 # Dead code stripping. Issue 'make lean'.
1103 ifeq ($(findstring lean,$(MAKECMDGOALS)),lean)
1104  ifeq ($(findstring -ffunction-sections,$(CXXFLAGS)),)
1105  CRYPTOPP_CXXFLAGS += -ffunction-sections
1106  endif # CRYPTOPP_CXXFLAGS
1107  ifeq ($(findstring -fdata-sections,$(CXXFLAGS)),)
1108  CRYPTOPP_CXXFLAGS += -fdata-sections
1109  endif # CRYPTOPP_CXXFLAGS
1110  ifneq ($(IS_DARWIN),0)
1111  ifeq ($(findstring -Wl,-dead_strip,$(LDFLAGS)),)
1112  CRYPTOPP_LDFLAGS += -Wl,-dead_strip
1113  endif # CRYPTOPP_CXXFLAGS
1114  else # BSD, Linux and Unix
1115  ifeq ($(findstring -Wl,--gc-sections,$(LDFLAGS)),)
1116  CRYPTOPP_LDFLAGS += -Wl,--gc-sections
1117  endif # LDFLAGS
1118  endif # MAKECMDGOALS
1119 endif # Dead code stripping
1120 
1121 # For Shared Objects, Diff, Dist/Zip rules
1122 LIB_VER := $(shell $(GREP) "define CRYPTOPP_VERSION" config_ver.h | cut -d" " -f 3)
1123 LIB_MAJOR := $(shell echo $(LIB_VER) | cut -c 1)
1124 LIB_MINOR := $(shell echo $(LIB_VER) | cut -c 2)
1125 LIB_PATCH := $(shell echo $(LIB_VER) | cut -c 3)
1126 
1127 ifeq ($(strip $(LIB_PATCH)),)
1128  LIB_PATCH := 0
1129 endif
1130 
1131 ifeq ($(HAS_SOLIB_VERSION),1)
1132 # Different patchlevels and minors are compatible since 6.1
1133 SOLIB_COMPAT_SUFFIX=.$(LIB_MAJOR)
1134 # Linux uses -Wl,-soname
1135 ifneq ($(IS_LINUX)$(IS_HURD),00)
1136 # Linux uses full version suffix for shared library
1137 SOLIB_VERSION_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)
1138 SOLIB_FLAGS=-Wl,-soname,libcrypto++.so$(SOLIB_COMPAT_SUFFIX)
1139 endif
1140 # Solaris uses -Wl,-h
1141 ifeq ($(IS_SUN),1)
1142 # Solaris uses major version suffix for shared library, but we use major.minor
1143 # The minor version allows previous version to remain and not overwritten.
1144 # https://blogs.oracle.com/solaris/how-to-name-a-solaris-shared-object-v2
1145 SOLIB_VERSION_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR)
1146 SOLIB_FLAGS=-Wl,-h,libcrypto++.so$(SOLIB_COMPAT_SUFFIX)
1147 endif
1148 endif # HAS_SOLIB_VERSION
1149 
1150 ###########################################################
1151 ##### Temp file cleanup #####
1152 ###########################################################
1153 
1154 # After this point no more test programs should be run.
1155 # https://github.com/weidai11/cryptopp/issues/738
1156 ifeq ($(findstring /dev/null,$(TOUT)),)
1157  # $(info TOUT is not /dev/null, cleaning $(TOUT))
1158  ifeq ($(wildcard $(TOUT)),$(TOUT))
1159  UNUSED := $(shell $(RM) $(TOUT) 2>/dev/null)
1160  endif
1161  ifeq ($(wildcard $(TOUT).dSYM/),$(TOUT).dSYM/)
1162  UNUSED := $(shell $(RM) -r $(TOUT).dSYM/ 2>/dev/null)
1163  endif
1164 endif
1165 
1166 ###########################################################
1167 ##### Source and object files #####
1168 ###########################################################
1169 
1170 # List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
1171 SRCS := cryptlib.cpp cpu.cpp integer.cpp $(filter-out cryptlib.cpp cpu.cpp integer.cpp pch.cpp simple.cpp,$(sort $(wildcard *.cpp)))
1172 # For Makefile.am; resource.h is Windows
1173 INCL := $(filter-out resource.h,$(sort $(wildcard *.h)))
1174 
1175 ifneq ($(IS_MINGW),0)
1176 INCL += resource.h
1177 endif
1178 
1179 # Cryptogams source files. We couple to ARMv7 and NEON.
1180 # Limit to Linux. The source files target the GNU assembler.
1181 # Also see https://www.cryptopp.com/wiki/Cryptogams.
1182 ifeq ($(IS_ARM32)$(IS_LINUX),11)
1183  ifeq ($(filter -DCRYPTOPP_DISABLE_ASM -DCRYPTOPP_DISABLE_ARM_NEON,$(CPPFLAGS)$(CXXFLAGS)),)
1184  # Do not use -march=armv7 if the compiler is already targeting the ISA.
1185  # Also see https://github.com/weidai11/cryptopp/issues/1094
1186  ifneq ($($(CXX) ++ -dM -E - </dev/null 2>/dev/null| grep 'ARM_ARCH 7|_ARM_ARCH_7A__'),)
1187  CRYPTOGAMS_ARMV7_FLAG = -march=armv7-a
1188  endif
1189  ifeq ($(CLANG_COMPILER),1)
1190  CRYPTOGAMS_ARM_FLAG = $(CRYPTOGAMS_ARMV7_FLAG)
1191  CRYPTOGAMS_ARM_THUMB_FLAG = $(CRYPTOGAMS_ARMV7_FLAG) -mthumb
1192  else
1193  # -mfpu=auto due to https://github.com/weidai11/cryptopp/issues/1094
1194  CRYPTOGAMS_ARM_FLAG = $(CRYPTOGAMS_ARMV7_FLAG)
1195  CRYPTOGAMS_ARM_THUMB_FLAG = $(CRYPTOGAMS_ARMV7_FLAG)
1196  endif
1197  SRCS += aes_armv4.S sha1_armv4.S sha256_armv4.S sha512_armv4.S
1198  endif
1199 endif
1200 
1201 # Remove unneeded arch specific files to speed build time.
1202 ifeq ($(IS_PPC32)$(IS_PPC64),00)
1203  SRCS := $(filter-out ppc_%,$(SRCS))
1204 endif
1205 ifeq ($(IS_ARM32)$(IS_ARMV8),00)
1206  SRCS := $(filter-out arm_%,$(SRCS))
1207  SRCS := $(filter-out neon_%,$(SRCS))
1208 endif
1209 ifeq ($(IS_X86)$(IS_X32)$(IS_X64),000)
1210  SRCS := $(filter-out sse_%,$(SRCS))
1211 endif
1212 
1213 # List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
1214 OBJS := $(SRCS:.cpp=.o)
1215 OBJS := $(OBJS:.S=.o)
1216 
1217 # List test.cpp first to tame C++ static initialization problems.
1218 TESTSRCS := adhoc.cpp test.cpp bench1.cpp bench2.cpp bench3.cpp datatest.cpp dlltest.cpp fipsalgt.cpp validat0.cpp validat1.cpp validat2.cpp validat3.cpp validat4.cpp validat5.cpp validat6.cpp validat7.cpp validat8.cpp validat9.cpp validat10.cpp regtest1.cpp regtest2.cpp regtest3.cpp regtest4.cpp
1219 TESTINCL := bench.h factory.h validate.h
1220 
1221 # Test objects
1222 TESTOBJS := $(TESTSRCS:.cpp=.o)
1223 LIBOBJS := $(filter-out $(TESTOBJS),$(OBJS))
1224 
1225 # In Crypto++ 5.6.2 these were the source and object files for the FIPS DLL.
1226 # Since the library is on the Historical Validation List we add all files.
1227 # The 5.6.2 list is at https://github.com/weidai11/cryptopp/blob/789f81f048c9.
1228 DLLSRCS := $(SRCS)
1229 DLLOBJS := $(DLLSRCS:.cpp=.export.o)
1230 DLLOBJS := $(DLLOBJS:.S=.export.o)
1231 
1232 # Import lib testing
1233 LIBIMPORTOBJS := $(LIBOBJS:.o=.import.o)
1234 TESTIMPORTOBJS := $(TESTOBJS:.o=.import.o)
1235 DLLTESTOBJS := dlltest.dllonly.o
1236 
1237 # Clean recipe, Issue 998. Don't filter-out some artifacts from the list of objects
1238 # The *.S is a hack. It makes the ASM appear like C++ so the object files make the CLEAN_OBJS list
1239 CLEAN_SRCS := $(wildcard *.cpp) $(patsubst %.S,%.cpp,$(wildcard *.S))
1240 CLEAN_OBJS := $(CLEAN_SRCS:.cpp=.o) $(CLEAN_SRCS:.cpp=.import.o) $(CLEAN_SRCS:.cpp=.export.o)
1241 
1242 ###########################################################
1243 ##### Add our flags to user flags #####
1244 ###########################################################
1245 
1246 # This ensures we don't add flags when the user forbids
1247 # use of customary library flags, like -fPIC. Make will
1248 # ignore this assignment when CXXFLAGS is passed as an
1249 # argument to the make program: make CXXFLAGS="..."
1250 CPPFLAGS := $(strip $(CRYPTOPP_CPPFLAGS) $(CPPFLAGS))
1251 CXXFLAGS := $(strip $(CRYPTOPP_CXXFLAGS) $(CXXFLAGS))
1252 ASFLAGS := $(strip $(CRYPTOPP_ASFLAGS) $(ASFLAGS))
1253 LDFLAGS := $(strip $(CRYPTOPP_LDFLAGS) $(LDFLAGS))
1254 
1255 ###########################################################
1256 ##### Targets and Recipes #####
1257 ###########################################################
1258 
1259 # Default builds program with static library only
1260 .PHONY: default
1261 default: cryptest
1262 
1263 .PHONY: all static dynamic
1264 all: static dynamic cryptest
1265 
1266 ifneq ($(IS_DARWIN),0)
1267 static: libcrypto++.a
1268 shared dynamic dylib: libcrypto++.dylib
1269 else
1270 static: libcrypto++.a
1271 shared dynamic: libcrypto++.so$(SOLIB_VERSION_SUFFIX)
1272 endif
1273 
1274 # CXXFLAGS are tuned earlier.
1275 .PHONY: native no-asm asan ubsan
1276 native no-asm asan ubsan: cryptest
1277 
1278 # CXXFLAGS are tuned earlier. Applications must use linker flags
1279 # -Wl,--gc-sections (Linux and Unix) or -Wl,-dead_strip (OS X)
1280 .PHONY: lean
1281 lean: static dynamic cryptest
1282 
1283 # May want to export CXXFLAGS="-g3 -O1"
1284 .PHONY: lcov coverage
1285 lcov coverage: cryptest
1286  @-$(RM) -r ./TestCoverage/
1287  lcov --base-directory . --directory . --zerocounters -q
1288  ./cryptest v
1289  ./cryptest tv all
1290  ./cryptest b 0.25
1291  lcov --base-directory . --directory . -c -o cryptest.info
1292  lcov --remove cryptest.info "adhoc.*" -o cryptest.info
1293  lcov --remove cryptest.info "fips140.*" -o cryptest.info
1294  lcov --remove cryptest.info "*test.*" -o cryptest.info
1295  lcov --remove cryptest.info "/usr/*" -o cryptest.info
1296  genhtml -o ./TestCoverage/ -t "Crypto++ test coverage" --num-spaces 4 cryptest.info
1297 
1298 # Travis CI and CodeCov rule
1299 .PHONY: gcov codecov
1300 gcov codecov: cryptest
1301  @-$(RM) -r ./TestCoverage/
1302  ./cryptest v
1303  ./cryptest tv all
1304  gcov -r $(SRCS)
1305 
1306 # Should use CXXFLAGS="-g3 -O1"
1307 .PHONY: valgrind
1308 valgrind: cryptest
1309  valgrind --track-origins=yes --suppressions=cryptopp.supp ./cryptest v
1310 
1311 .PHONY: test check
1312 test check: cryptest
1313  ./cryptest v
1314 
1315 # Used to generate list of source files for Autotools, CMakeList, Android.mk, etc
1316 .PHONY: sources
1317 sources: adhoc.cpp
1318  $(info ***** Library sources *****)
1319  $(info $(filter-out $(TESTSRCS),$(SRCS)))
1320  $(info )
1321  $(info ***** Library headers *****)
1322  $(info $(filter-out $(TESTINCL),$(INCL)))
1323  $(info )
1324  $(info ***** Test sources *****)
1325  $(info $(TESTSRCS))
1326  $(info )
1327  $(info ***** Test headers *****)
1328  $(info $(TESTINCL))
1329 
1330 # Directory we want (can't specify on Doygen command line)
1331 DOCUMENT_DIRECTORY := ref$(LIB_VER)
1332 # Directory Doxygen uses (specified in Doygen config file)
1333 ifeq ($(wildcard Doxyfile),Doxyfile)
1334 DOXYGEN_DIRECTORY := $(strip $(shell $(GREP) "OUTPUT_DIRECTORY" Doxyfile | $(GREP) -v "\#" | cut -d "=" -f 2))
1335 endif
1336 # Default directory (in case its missing in the config file)
1337 ifeq ($(strip $(DOXYGEN_DIRECTORY)),)
1338 DOXYGEN_DIRECTORY := html-docs
1339 endif
1340 
1341 # Builds the documentation. Directory name is ref563, ref570, etc.
1342 .PHONY: docs html
1343 docs html:
1344  @-$(RM) -r $(DOXYGEN_DIRECTORY)/ $(DOCUMENT_DIRECTORY)/ html-docs/
1345  @-$(RM) CryptoPPRef.zip
1346  doxygen Doxyfile -d CRYPTOPP_DOXYGEN_PROCESSING
1347  $(MV) $(DOXYGEN_DIRECTORY)/ $(DOCUMENT_DIRECTORY)/
1348  zip -9 CryptoPPRef.zip -x ".*" -x "*/.*" -r $(DOCUMENT_DIRECTORY)/
1349 
1350 .PHONY: clean
1351 clean:
1352  -$(RM) adhoc.cpp.o adhoc.cpp.proto.o $(CLEAN_OBJS) rdrand-*.o
1353  @-$(RM) libcrypto++.a libcrypto++.dylib cryptopp.dll libcrypto++.dll.a libcrypto++.import.a
1354  @-$(RM) libcrypto++.so libcrypto++.so$(SOLIB_COMPAT_SUFFIX) libcrypto++.so$(SOLIB_VERSION_SUFFIX)
1355  @-$(RM) cryptest dlltest cryptest.import cryptest.dat ct et
1356  @-$(RM) *.la *.lo *.gcov *.gcno *.gcda *.stackdump core core-*
1357  @-$(RM) /tmp/adhoc
1358  @-$(RM) -r /tmp/cryptopp_test/
1359  @-$(RM) -r *.dSYM/ *.dylib.dSYM/
1360  @-$(RM) -r cov-int/
1361 
1362 .PHONY: autotools-clean
1363 autotools-clean:
1364  @-$(RM) -f configure.ac configure configure.in Makefile.am Makefile.in Makefile
1365  @-$(RM) -f config.guess config.status config.sub config.h.in compile depcomp
1366  @-$(RM) -f install-sh stamp-h1 ar-lib *.lo *.la *.m4 local.* lt*.sh missing
1367  @-$(RM) -f cryptest cryptestcwd libtool* libcrypto++.la libcrypto++.pc*
1368  @-$(RM) -rf build-aux/ m4/ auto*.cache/ .deps/ .libs/
1369 
1370 .PHONY: cmake-clean
1371 cmake-clean:
1372  @-$(RM) -f cryptopp-config.cmake CMakeLists.txt
1373  @-$(RM) -rf cmake_build/
1374 
1375 .PHONY: android-clean
1376 android-clean:
1377  @-$(RM) -f $(patsubst %_simd.cpp,%_simd.cpp.neon,$(wildcard *_simd.cpp))
1378  @-$(RM) -rf obj/
1379 
1380 .PHONY: distclean
1381 distclean: clean autotools-clean cmake-clean android-clean
1382  -$(RM) adhoc.cpp adhoc.cpp.copied GNUmakefile.deps benchmarks.html cryptest.txt
1383  -$(RM) cryptest_all.info cryptest_debug.info cryptest_noasm.info cryptest_base.info cryptest.info cryptest_release.info
1384  @-$(RM) cryptest-*.txt cryptopp.tgz libcrypto++.pc *.o *.bc *.ii *~
1385  @-$(RM) -r cryptlib.lib cryptest *.suo *.sdf *.pdb Win32/ x64/ ipch/
1386  @-$(RM) -r $(LIBOBJS:.o=.obj) $(TESTOBJS:.o=.obj)
1387  @-$(RM) -r $(LIBOBJS:.o=.lst) $(TESTOBJS:.o=.lst)
1388  @-$(RM) -r TestCoverage/ ref*/
1389  @-$(RM) cryptopp$(LIB_VER)\.* CryptoPPRef.zip
1390 
1391 # Install cryptest, libcrypto++.a, libcrypto++.so and libcrypto++.pc.
1392 # The library install was broken-out into its own recipe at GH #653.
1393 .PHONY: install
1394 install: cryptest install-lib
1395  @-$(MKDIR) $(DESTDIR)$(BINDIR)
1396  $(CP) cryptest $(DESTDIR)$(BINDIR)
1397  $(CHMOD) u=rwx,go=rx $(DESTDIR)$(BINDIR)/cryptest
1398  @-$(MKDIR) $(DESTDIR)$(DATADIR)/crypto++/TestData
1399  @-$(MKDIR) $(DESTDIR)$(DATADIR)/crypto++/TestVectors
1400  $(CP) TestData/*.dat $(DESTDIR)$(DATADIR)/crypto++/TestData
1401  $(CHMOD) u=rw,go=r $(DESTDIR)$(DATADIR)/crypto++/TestData/*.dat
1402  $(CP) TestVectors/*.txt $(DESTDIR)$(DATADIR)/crypto++/TestVectors
1403  $(CHMOD) u=rw,go=r $(DESTDIR)$(DATADIR)/crypto++/TestVectors/*.txt
1404 
1405 # A recipe to install only the library, and not cryptest. Also
1406 # see https://github.com/weidai11/cryptopp/issues/653. Some users
1407 # already have a libcrypto++.pc. Install the *.pc file if the file
1408 # is present. If you want one, then issue 'make libcrypto++.pc'.
1409 .PHONY: install-lib
1410 install-lib:
1411  @-$(MKDIR) $(DESTDIR)$(INCLUDEDIR)/crypto++
1412  $(CP) *.h $(DESTDIR)$(INCLUDEDIR)/crypto++
1413  $(CHMOD) u=rw,go=r $(DESTDIR)$(INCLUDEDIR)/crypto++/*.h
1414 ifneq ($(wildcard libcrypto++.a),)
1415  @-$(MKDIR) $(DESTDIR)$(LIBDIR)
1416  $(CP) libcrypto++.a $(DESTDIR)$(LIBDIR)
1417  $(CHMOD) u=rw,go=r $(DESTDIR)$(LIBDIR)/libcrypto++.a
1418 endif
1419 ifneq ($(wildcard libcryptopp.dylib),)
1420  @-$(MKDIR) $(DESTDIR)$(LIBDIR)
1421  $(CP) libcryptopp.dylib $(DESTDIR)$(LIBDIR)
1422  $(CHMOD) u=rwx,go=rx $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
1423  -install_name_tool -id $(DESTDIR)$(LIBDIR)/libcryptopp.dylib $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
1424 endif
1425 ifneq ($(wildcard libcrypto++.so$(SOLIB_VERSION_SUFFIX)),)
1426  @-$(MKDIR) $(DESTDIR)$(LIBDIR)
1427  $(CP) libcrypto++.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)
1428  $(CHMOD) u=rwx,go=rx $(DESTDIR)$(LIBDIR)/libcrypto++.so$(SOLIB_VERSION_SUFFIX)
1429 ifeq ($(HAS_SOLIB_VERSION),1)
1430  -$(LN) libcrypto++.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcrypto++.so
1431  -$(LN) libcrypto++.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcrypto++.so$(SOLIB_COMPAT_SUFFIX)
1432  $(LDCONF) $(DESTDIR)$(LIBDIR)
1433 endif
1434 endif
1435 ifneq ($(wildcard libcrypto++.pc),)
1436  @-$(MKDIR) $(DESTDIR)$(LIBDIR)/pkgconfig
1437  $(CP) libcrypto++.pc $(DESTDIR)$(LIBDIR)/pkgconfig
1438  $(CHMOD) u=rw,go=r $(DESTDIR)$(LIBDIR)/pkgconfig/libcrypto++.pc
1439 endif
1440 
1441 .PHONY: remove uninstall
1442 remove uninstall:
1443  -$(RM) -r $(DESTDIR)$(INCLUDEDIR)/crypto++
1444  -$(RM) $(DESTDIR)$(LIBDIR)/libcrypto++.a
1445  -$(RM) $(DESTDIR)$(BINDIR)/cryptest
1446 ifneq ($(wildcard $(DESTDIR)$(LIBDIR)/libcryptopp.dylib),)
1447  -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
1448 endif
1449 ifneq ($(wildcard $(DESTDIR)$(LIBDIR)/libcrypto++.so),)
1450  -$(RM) $(DESTDIR)$(LIBDIR)/libcrypto++.so
1451 endif
1452  @-$(RM) $(DESTDIR)$(LIBDIR)/libcrypto++.so$(SOLIB_VERSION_SUFFIX)
1453  @-$(RM) $(DESTDIR)$(LIBDIR)/libcrypto++.so$(SOLIB_COMPAT_SUFFIX)
1454  @-$(RM) $(DESTDIR)$(LIBDIR)/pkgconfig/libcrypto++.pc
1455  @-$(RM) -r $(DESTDIR)$(DATADIR)/crypto++
1456 
1457 libcrypto++.a: $(LIBOBJS) | osx_warning
1458  $(AR) $(ARFLAGS) $@ $(LIBOBJS)
1459 ifeq ($(IS_SUN),0)
1460  $(RANLIB) $@
1461 endif
1462 
1463 ifeq ($(HAS_SOLIB_VERSION),1)
1464 .PHONY: libcrypto++.so
1465 libcryptopp.so: libcrypto++.so$(SOLIB_VERSION_SUFFIX) | so_warning
1466 endif
1467 
1468 libcrypto++.so$(SOLIB_VERSION_SUFFIX): $(LIBOBJS)
1469 ifeq ($(XLC_COMPILER),1)
1470  $(CXX) -qmkshrobj $(SOLIB_FLAGS) -o $@ $(CXXFLAGS) $(LDFLAGS) $(LIBOBJS) $(LDLIBS)
1471 else
1472  $(CXX) -shared $(SOLIB_FLAGS) -o $@ $(CXXFLAGS) $(LDFLAGS) $(LIBOBJS) $(LDLIBS)
1473 endif
1474 ifeq ($(HAS_SOLIB_VERSION),1)
1475  -$(LN) libcrypto++.so$(SOLIB_VERSION_SUFFIX) libcrypto++.so
1476  -$(LN) libcrypto++.so$(SOLIB_VERSION_SUFFIX) libcrypto++.so$(SOLIB_COMPAT_SUFFIX)
1477 endif
1478 
1479 libcryptopp.dylib: $(LIBOBJS) | osx_warning
1480  $(CXX) -dynamiclib -o $@ $(CXXFLAGS) -install_name "$@" -current_version "$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)" -compatibility_version "$(LIB_MAJOR).$(LIB_MINOR)" -headerpad_max_install_names $(LDFLAGS) $(LIBOBJS)
1481 
1482 cryptest: $(LINK_LIBRARY) $(TESTOBJS) | osx_warning
1483  $(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) $(LINK_LIBRARY_PATH)$(LINK_LIBRARY) $(LDFLAGS) $(LDLIBS)
1484 
1485 # Makes it faster to test changes
1486 nolib: $(OBJS)
1487  $(CXX) -o ct $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS)
1488 
1489 dll: cryptest.import.exe dlltest.exe
1490 
1491 cryptopp.dll: $(DLLOBJS)
1492  $(CXX) -shared -o $@ $(CXXFLAGS) $(DLLOBJS) $(LDFLAGS) $(LDLIBS) -Wl,--out-implib=libcryptopp.dll.a
1493 
1494 libcryptopp.import.a: $(LIBIMPORTOBJS)
1495  $(AR) $(ARFLAGS) $@ $(LIBIMPORTOBJS)
1496 ifeq ($(IS_SUN),0)
1497  $(RANLIB) $@
1498 endif
1499 
1500 cryptest.import.exe: cryptopp.dll libcryptopp.import.a $(TESTIMPORTOBJS)
1501  $(CXX) -o $@ $(CXXFLAGS) $(TESTIMPORTOBJS) -L. -lcryptopp.dll -lcryptopp.import $(LDFLAGS) $(LDLIBS)
1502 
1503 dlltest.exe: cryptopp.dll $(DLLTESTOBJS)
1504  $(CXX) -o $@ $(CXXFLAGS) $(DLLTESTOBJS) -L. -lcryptopp.dll $(LDFLAGS) $(LDLIBS)
1505 
1506 # Some users already have a libcryptopp.pc. We install it if the file
1507 # is present. If you want one, then issue 'make libcryptopp.pc'. Be sure
1508 # to use/verify PREFIX and LIBDIR below after writing the file.
1509 cryptopp.pc libcrypto++.pc:
1510  @echo '# Crypto++ package configuration file' > libcrypto++.pc
1511  @echo '' >> libcrypto++.pc
1512  @echo 'prefix=$(PC_PREFIX)' >> libcrypto++.pc
1513  @echo 'libdir=$(PC_LIBDIR)' >> libcrypto++.pc
1514  @echo 'includedir=$(PC_INCLUDEDIR)' >> libcrypto++.pc
1515  @echo 'datadir=$(PC_DATADIR)' >> libcrypto++.pc
1516  @echo '' >> libcrypto++.pc
1517  @echo 'Name: Crypto++' >> libcrypto++.pc
1518  @echo 'Description: Crypto++ cryptographic library' >> libcrypto++.pc
1519  @echo 'Version: 8.7' >> libcrypto++.pc
1520  @echo 'URL: https://cryptopp.com/' >> libcrypto++.pc
1521  @echo '' >> libcrypto++.pc
1522  @echo 'Cflags: -I$${includedir}' >> libcrypto++.pc
1523  @echo 'Libs: -L$${libdir} -lcryptopp' >> libcrypto++.pc
1524 
1525 # This recipe prepares the distro files
1526 TEXT_FILES := *.h *.cpp *.S GNUmakefile GNUmakefile-cross License.txt Readme.txt Install.txt Filelist.txt Doxyfile cryptest* cryptlib* dlltest* cryptdll* *.sln *.vcxproj *.filters cryptopp.rc TestVectors/*.txt TestData/*.dat TestPrograms/*.cpp
1527 EXEC_FILES := TestScripts/*.sh TestScripts/*.cmd
1528 ifneq ($(wildcard *.sh),)
1529  EXEC_FILES += $(wildcard *.sh)
1530 endif
1531 EXEC_DIRS := TestData/ TestVectors/ TestScripts/ TestPrograms/
1532 
1533 ifeq ($(wildcard Filelist.txt),Filelist.txt)
1534 DIST_FILES := $(shell cat Filelist.txt)
1535 endif
1536 
1537 .PHONY: trim
1538 trim:
1539 ifneq ($(IS_DARWIN),0)
1540  $(SED) -i '' -e's/[[:space:]]*$$//' *.supp *.txt .*.yml *.h *.cpp *.asm *.S
1541  $(SED) -i '' -e's/[[:space:]]*$$//' *.sln *.vcxproj *.filters GNUmakefile GNUmakefile-cross
1542  $(SED) -i '' -e's/[[:space:]]*$$//' TestData/*.dat TestVectors/*.txt TestPrograms/*.cpp TestScripts/*.*
1543  make convert
1544 else
1545  $(SED) -i -e's/[[:space:]]*$$//' *.supp *.txt .*.yml *.h *.cpp *.asm *.S
1546  $(SED) -i -e's/[[:space:]]*$$//' *.sln *.vcxproj *.filters GNUmakefile GNUmakefile-cross
1547  $(SED) -i -e's/[[:space:]]*$$//' TestData/*.dat TestVectors/*.txt TestPrograms/*.cpp TestScripts/*.*
1548  make convert
1549 endif
1550 
1551 .PHONY: convert
1552 convert:
1553  @-$(CHMOD) u=rwx,go=rx $(EXEC_DIRS)
1554  @-$(CHMOD) u=rw,go=r $(TEXT_FILES) *.supp .*.yml *.asm *.zip TestVectors/*.txt TestData/*.dat TestPrograms/*.cpp
1555  @-$(CHMOD) u=rwx,go=rx $(EXEC_FILES)
1556  -unix2dos --keepdate --quiet $(TEXT_FILES) .*.yml *.asm TestScripts/*.cmd TestScripts/*.txt TestScripts/*.cpp
1557  -dos2unix --keepdate --quiet GNUmakefile GNUmakefile-cross *.sh *.S *.supp *.mapfile TestScripts/*.sh
1558 ifneq ($(IS_DARWIN),0)
1559  @-xattr -c *
1560 endif
1561 
1562 # Build the ZIP file with source files. No documentation.
1563 .PHONY: zip dist
1564 zip dist: | distclean convert
1565  zip -q -9 cryptopp$(LIB_VER).zip $(DIST_FILES)
1566 
1567 # Build the ISO to transfer the ZIP to old distros via CDROM
1568 .PHONY: iso
1569 iso: | zip
1570 ifneq ($(IS_DARWIN),0)
1571  $(MKDIR) $(PWD)/cryptopp$(LIB_VER)
1572  $(CP) cryptopp$(LIB_VER).zip $(PWD)/cryptopp$(LIB_VER)
1573  hdiutil makehybrid -iso -joliet -o cryptopp$(LIB_VER).iso $(PWD)/cryptopp$(LIB_VER)
1574  @-$(RM) -r $(PWD)/cryptopp$(LIB_VER)
1575 else ifneq ($(IS_LINUX)$(IS_HURD),00)
1576  $(MKDIR) $(PWD)/cryptopp$(LIB_VER)
1577  $(CP) cryptopp$(LIB_VER).zip $(PWD)/cryptopp$(LIB_VER)
1578  genisoimage -q -o cryptopp$(LIB_VER).iso $(PWD)/cryptopp$(LIB_VER)
1579  @-$(RM) -r $(PWD)/cryptopp$(LIB_VER)
1580 endif
1581 
1582 # CRYPTOPP_CPU_FREQ in GHz
1583 CRYPTOPP_CPU_FREQ ?= 0.0
1584 .PHONY: bench benchmark benchmarks
1585 bench benchmark benchmarks: cryptest
1586  @-$(RM) -f benchmarks.html
1587  ./cryptest b 2 $(CRYPTOPP_CPU_FREQ)
1588 
1589 adhoc.cpp: adhoc.cpp.proto
1590 ifeq ($(wildcard adhoc.cpp),)
1591  cp adhoc.cpp.proto adhoc.cpp
1592 else
1593  touch adhoc.cpp
1594 endif
1595 
1596 # Include dependencies, if present. You must issue `make deps` to create them.
1597 ifeq ($(wildcard GNUmakefile.deps),GNUmakefile.deps)
1598 -include GNUmakefile.deps
1599 endif # Dependencies
1600 
1601 # A few recipes trigger warnings for -std=c++11 and -stdlib=c++
1602 NOSTD_CXXFLAGS=$(filter-out -stdlib=%,$(filter-out -std=%,$(CXXFLAGS)))
1603 
1604 # Cryptogams ARM asm implementation. AES needs -mthumb for Clang
1605 aes_armv4.o : aes_armv4.S
1606  $(CXX) $(strip $(CPPFLAGS) $(ASFLAGS) $(NOSTD_CXXFLAGS) $(CRYPTOGAMS_ARM_THUMB_FLAG) -c) $<
1607 
1608 # SSSE3 or NEON available
1609 aria_simd.o : aria_simd.cpp
1610  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(ARIA_FLAG) -c) $<
1611 
1612 # SSE, NEON or POWER7 available
1613 blake2s_simd.o : blake2s_simd.cpp
1614  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(BLAKE2S_FLAG) -c) $<
1615 
1616 # SSE, NEON or POWER8 available
1617 blake2b_simd.o : blake2b_simd.cpp
1618  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(BLAKE2B_FLAG) -c) $<
1619 
1620 # SSE2 or NEON available
1621 chacha_simd.o : chacha_simd.cpp
1622  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CHACHA_FLAG) -c) $<
1623 
1624 # AVX2 available
1625 chacha_avx.o : chacha_avx.cpp
1626  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CHACHA_AVX2_FLAG) -c) $<
1627 
1628 # SSSE3 available
1629 cham_simd.o : cham_simd.cpp
1630  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CHAM_FLAG) -c) $<
1631 
1632 # SSE4.2 or ARMv8a available
1633 crc_simd.o : crc_simd.cpp
1634  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CRC_FLAG) -c) $<
1635 
1636 # Power9 available
1637 darn.o : darn.cpp
1638  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(DARN_FLAG) -c) $<
1639 
1640 # SSE2 on i686
1641 donna_sse.o : donna_sse.cpp
1642  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SSE2_FLAG) -c) $<
1643 
1644 # Carryless multiply
1645 gcm_simd.o : gcm_simd.cpp
1646  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(GCM_FLAG) -c) $<
1647 
1648 # Carryless multiply
1649 gf2n_simd.o : gf2n_simd.cpp
1650  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(GF2N_FLAG) -c) $<
1651 
1652 # SSSE3 available
1653 keccak_simd.o : keccak_simd.cpp
1654  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(KECCAK_FLAG) -c) $<
1655 
1656 # SSSE3 available
1657 lea_simd.o : lea_simd.cpp
1658  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LEA_FLAG) -c) $<
1659 
1660 # SSSE3 available
1661 lsh256_sse.o : lsh256_sse.cpp
1662  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LSH256_FLAG) -c) $<
1663 
1664 # AVX2 available
1665 lsh256_avx.o : lsh256_avx.cpp
1666  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LSH256_AVX2_FLAG) -c) $<
1667 
1668 # SSSE3 available
1669 lsh512_sse.o : lsh512_sse.cpp
1670  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LSH512_FLAG) -c) $<
1671 
1672 # AVX2 available
1673 lsh512_avx.o : lsh512_avx.cpp
1674  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LSH512_AVX2_FLAG) -c) $<
1675 
1676 # NEON available
1677 neon_simd.o : neon_simd.cpp
1678  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(NEON_FLAG) -c) $<
1679 
1680 # AltiVec available
1681 ppc_simd.o : ppc_simd.cpp
1682  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(ALTIVEC_FLAG) -c) $<
1683 
1684 # Power7 available
1685 ppc_power7.o : ppc_power7.cpp
1686  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(POWER7_FLAG) -c) $<
1687 
1688 # Power8 available
1689 ppc_power8.o : ppc_power8.cpp
1690  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(POWER8_FLAG) -c) $<
1691 
1692 # Power9 available
1693 ppc_power9.o : ppc_power9.cpp
1694  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(POWER9_FLAG) -c) $<
1695 
1696 # AESNI or ARMv7a/ARMv8a available
1697 rijndael_simd.o : rijndael_simd.cpp
1698  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(AES_FLAG) -c) $<
1699 
1700 # SSE4.2/SHA-NI or ARMv8a available
1701 sha_simd.o : sha_simd.cpp
1702  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SHA_FLAG) -c) $<
1703 
1704 # Cryptogams SHA1 asm implementation.
1705 sha1_armv4.o : sha1_armv4.S
1706  $(CXX) $(strip $(CPPFLAGS) $(ASFLAGS) $(NOSTD_CXXFLAGS) $(CRYPTOGAMS_ARM_FLAG) -c) $<
1707 
1708 # Cryptogams SHA256 asm implementation.
1709 sha256_armv4.o : sha256_armv4.S
1710  $(CXX) $(strip $(CPPFLAGS) $(ASFLAGS) $(NOSTD_CXXFLAGS) $(CRYPTOGAMS_ARM_FLAG) -c) $<
1711 
1712 # Cryptogams SHA512 asm implementation.
1713 sha512_armv4.o : sha512_armv4.S
1714  $(CXX) $(strip $(CPPFLAGS) $(ASFLAGS) $(NOSTD_CXXFLAGS) $(CRYPTOGAMS_ARM_FLAG) -c) $<
1715 
1716 sha3_simd.o : sha3_simd.cpp
1717  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SHA3_FLAG) -c) $<
1718 
1719 # SSE4.2/SHA-NI or ARMv8a available
1720 shacal2_simd.o : shacal2_simd.cpp
1721  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SHA_FLAG) -c) $<
1722 
1723 # SSSE3, NEON or POWER8 available
1724 simon128_simd.o : simon128_simd.cpp
1725  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SIMON128_FLAG) -c) $<
1726 
1727 # SSSE3, NEON or POWER8 available
1728 speck128_simd.o : speck128_simd.cpp
1729  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SPECK128_FLAG) -c) $<
1730 
1731 # ARMv8.4 available
1732 sm3_simd.o : sm3_simd.cpp
1733  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SM3_FLAG) -c) $<
1734 
1735 # AESNI available
1736 sm4_simd.o : sm4_simd.cpp
1737  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SM4_FLAG) -c) $<
1738 
1739 # IBM XLC -O3 optimization bug
1740 ifeq ($(XLC_COMPILER),1)
1741 sm3.o : sm3.cpp
1742  $(CXX) $(strip $(CPPFLAGS) $(subst -O3,-O2,$(CXXFLAGS)) -c) $<
1743 donna_32.o : donna_32.cpp
1744  $(CXX) $(strip $(CPPFLAGS) $(subst -O3,-O2,$(CXXFLAGS)) -c) $<
1745 donna_64.o : donna_64.cpp
1746  $(CXX) $(strip $(CPPFLAGS) $(subst -O3,-O2,$(CXXFLAGS)) -c) $<
1747 endif
1748 
1749 # SSE2 on i686
1750 sse_simd.o : sse_simd.cpp
1751  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SSE2_FLAG) -c) $<
1752 
1753 # Don't build Rijndael with UBsan. Too much noise due to unaligned data accesses.
1754 ifneq ($(findstring -fsanitize=undefined,$(CXXFLAGS)),)
1755 rijndael.o : rijndael.cpp
1756  $(CXX) $(strip $(subst -fsanitize=undefined,,$(CXXFLAGS)) -c) $<
1757 endif
1758 
1759 # Only use CRYPTOPP_DATA_DIR if its not set in CXXFLAGS
1760 ifeq ($(findstring -DCRYPTOPP_DATA_DIR, $(CPPFLAGS)$(CXXFLAGS)),)
1761 ifneq ($(strip $(CRYPTOPP_DATA_DIR)),)
1762 validat%.o : validat%.cpp
1763  $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" $(CXXFLAGS) -c) $<
1764 bench%.o : bench%.cpp
1765  $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" $(CXXFLAGS) -c) $<
1766 datatest.o : datatest.cpp
1767  $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" $(CXXFLAGS) -c) $<
1768 test.o : test.cpp
1769  $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" $(CXXFLAGS) -c) $<
1770 endif
1771 endif
1772 
1773 validat1.o : validat1.cpp
1774  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(ALTIVEC_FLAG) -c) $<
1775 
1776 %.dllonly.o : %.cpp
1777  $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DLL_ONLY $(CXXFLAGS) -c) $< -o $@
1778 
1779 %.import.o : %.cpp
1780  $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_IMPORTS $(CXXFLAGS) -c) $< -o $@
1781 
1782 %.export.o : %.cpp
1783  $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_EXPORTS $(CXXFLAGS) -c) $< -o $@
1784 
1785 %.bc : %.cpp
1786  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) -c) $<
1787 
1788 %.o : %.cpp
1789  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) -c) $<
1790 
1791 .PHONY: so_warning
1792 so_warning:
1793 ifeq ($(HAS_SOLIB_VERSION),1)
1794  $(info )
1795  $(info WARNING: Only the symlinks to the shared-object library have been updated.)
1796  $(info WARNING: If the library is installed in a system directory you will need)
1797  $(info WARNING: to run 'ldconfig' to update the shared-object library cache.)
1798  $(info )
1799 endif
1800 
1801 .PHONY: osx_warning
1802 osx_warning:
1803 ifeq ($(IS_DARWIN)$(CLANG_COMPILER),11)
1804  ifeq ($(findstring -stdlib=libc++,$(CRYPTOPP_CXXFLAGS)$(CXXFLAGS)),)
1805  $(info )
1806  $(info INFO: Crypto++ was built without LLVM's libc++. If you are using the library)
1807  $(info INFO: with modern Xcode, then you should add -stdlib=libc++ to CXXFLAGS. It is)
1808  $(info INFO: already present in the makefile, and you only need to uncomment it.)
1809  $(info )
1810  endif
1811 endif
1812 
1813 .PHONY: dep deps depend
1814 dep deps depend GNUmakefile.deps:
1815  $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS)) -MM *.cpp > GNUmakefile.deps