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