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