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.exe recipe. Change to
17# ./libcryptopp.so or ./libcryptopp.dylib to suit your
18# taste. https://github.com/weidai11/cryptopp/issues/866
19LINK_LIBRARY ?= libcryptopp.a
20LINK_LIBRARY_PATH ?= ./
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/cryptopp/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/cryptopp/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# Use -pthread whenever it is available. See http://www.hpl.hp.com/techreports/2004/HPL-2004-209.pdf
850# http://stackoverflow.com/questions/2127797/gcc-significance-of-pthread-flag-when-compiling
851ifeq ($(DETECT_FEATURES),1)
852 ifeq ($(XLC_COMPILER),1)
853 ifeq ($(findstring -qthreaded,$(CXXFLAGS)),)
854 TPROG = TestPrograms/test_pthreads.cpp
855 TOPT = -qthreaded
856 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
857 ifeq ($(strip $(HAVE_OPT)),0)
858 CRYPTOPP_CXXFLAGS += -qthreaded
859 endif # CRYPTOPP_CXXFLAGS
860 endif # qthreaded
861 else
862 ifeq ($(findstring -pthread,$(CXXFLAGS)),)
863 TPROG = TestPrograms/test_pthreads.cpp
864 TOPT = -pthread
865 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
866 ifeq ($(strip $(HAVE_OPT)),0)
867 CRYPTOPP_CXXFLAGS += -pthread
868 endif # CRYPTOPP_CXXFLAGS
869 endif # pthread
870 endif # XLC/GCC and friends
871endif # DETECT_FEATURES
872
873# Remove -fPIC if present. SunCC use -KPIC, and needs the larger GOT table
874# https://docs.oracle.com/cd/E19205-01/819-5267/bkbaq/index.html
875ifeq ($(SUN_COMPILER),1)
876 CRYPTOPP_CXXFLAGS := $(subst -fPIC,-KPIC,$(CRYPTOPP_CXXFLAGS))
877 CRYPTOPP_CXXFLAGS := $(subst -fpic,-KPIC,$(CRYPTOPP_CXXFLAGS))
878endif
879
880# Remove -fPIC if present. IBM XL C++ uses -qpic
881ifeq ($(XLC_COMPILER),1)
882 CRYPTOPP_CXXFLAGS := $(subst -fPIC,-qpic,$(CRYPTOPP_CXXFLAGS))
883 CRYPTOPP_CXXFLAGS := $(subst -fpic,-qpic,$(CRYPTOPP_CXXFLAGS))
884endif
885
886# Disable IBM XL C++ "1500-036: (I) The NOSTRICT option (default at OPT(3))
887# has the potential to alter the semantics of a program."
888ifeq ($(XLC_COMPILER),1)
889 TPROG = TestPrograms/test_cxx.cpp
890 TOPT = -qsuppress=1500-036
891 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
892 ifeq ($(strip $(HAVE_OPT)),0)
893 CRYPTOPP_CXXFLAGS += -qsuppress=1500-036
894 endif # -qsuppress
895endif # IBM XL C++ compiler
896
897# libc++ is LLVM's standard C++ library. If we add libc++
898# here then all user programs must use it too. The open
899# question is, which choice is easier on users?
900ifneq ($(IS_DARWIN),0)
901 CXX ?= c++
902 # CRYPTOPP_CXXFLAGS += -stdlib=libc++
903 ifeq ($(findstring -fno-common,$(CXXFLAGS)),)
904 CRYPTOPP_CXXFLAGS += -fno-common
905 endif
906 IS_APPLE_LIBTOOL=$(shell libtool -V 2>&1 | $(GREP) -i -c 'Apple')
907 ifeq ($(IS_APPLE_LIBTOOL),1)
908 AR = libtool
909 else
910 AR = /usr/bin/libtool
911 endif
912 ARFLAGS = -static -o
913endif
914
915# Add -xregs=no%appl SPARC. SunCC should not use certain registers in library code.
916# https://docs.oracle.com/cd/E18659_01/html/821-1383/bkamt.html
917ifneq ($(IS_SPARC32)$(IS_SPARC64),00)
918 ifeq ($(SUN_COMPILER),1)
919 ifeq ($(findstring -xregs=no%appl,$(CXXFLAGS)),)
920 CRYPTOPP_CXXFLAGS += -xregs=no%appl
921 endif # -xregs
922 endif # SunCC
923 ifeq ($(GCC_COMPILER),1)
924 ifeq ($(findstring -mno-app-regs,$(CXXFLAGS)),)
925 CRYPTOPP_CXXFLAGS += -mno-app-regs
926 endif # no-app-regs
927 endif # GCC
928endif # Sparc
929
930# Add -pipe for everything except IBM XL C++, SunCC and ARM.
931# Allow ARM-64 because they seems to have >1 GB of memory
932ifeq ($(XLC_COMPILER)$(SUN_COMPILER)$(IS_ARM32),000)
933 ifeq ($(findstring -save-temps,$(CXXFLAGS)),)
934 CRYPTOPP_CXXFLAGS += -pipe
935 endif
936endif
937
938# For SunOS, create a Mapfile that allows our object files
939# to contain additional bits (like SSE4 and AES on old Xeon)
940# http://www.oracle.com/technetwork/server-storage/solaris/hwcap-modification-139536.html
941ifeq ($(IS_SUN)$(SUN_COMPILER),11)
942 ifneq ($(IS_X86)$(IS_X64),00)
943 ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
944 CRYPTOPP_LDFLAGS += -M cryptopp.mapfile
945 endif # No CRYPTOPP_DISABLE_ASM
946 endif # X86/X32/X64
947endif # SunOS
948
949ifneq ($(IS_LINUX)$(IS_HURD),00)
950 ifeq ($(findstring -fopenmp,$(CXXFLAGS)),-fopenmp)
951 ifeq ($(findstring -lgomp,$(LDLIBS)),)
952 LDLIBS += -lgomp
953 endif # LDLIBS
954 endif # OpenMP
955endif # IS_LINUX or IS_HURD
956
957# Add -errtags=yes to get the name for a warning suppression
958ifneq ($(SUN_COMPILER),0) # override flags for CC Sun C++ compiler
959# Add to all Solaris
960CRYPTOPP_CXXFLAGS += -template=no%extdef
961SUN_CC10_BUGGY := $(shell $(CXX) -V 2>&1 | $(GREP) -c -E "CC: Sun .* 5\.10 .* (2009|2010/0[1-4])")
962ifneq ($(SUN_CC10_BUGGY),0)
963# -DCRYPTOPP_INCLUDE_VECTOR_CC is needed for Sun Studio 12u1 Sun C++ 5.10 SunOS_i386 128229-02 2009/09/21
964# and was fixed in May 2010. Remove it if you get "already had a body defined" errors in vector.cc
965CRYPTOPP_CPPFLAGS += -DCRYPTOPP_INCLUDE_VECTOR_CC
966endif
967AR = $(CXX)
968ARFLAGS = -xar -o
969RANLIB = true
970endif
971
972# Native build testing. Issue 'make native'.
973ifeq ($(findstring native,$(MAKECMDGOALS)),native)
974 NATIVE_OPT =
975
976 # Try GCC and compatibles first
977 TPROG = TestPrograms/test_cxx.cpp
978 TOPT = -march=native
979 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
980 ifeq ($(strip $(HAVE_OPT)),0)
981 NATIVE_OPT = -march=native
982 endif # NATIVE_OPT
983
984 # And tune
985 ifeq ($(NATIVE_OPT),)
986 TOPT = -mtune=native
987 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
988 ifeq ($(strip $(HAVE_OPT)),0)
989 NATIVE_OPT = -mtune=native
990 endif # NATIVE_OPT
991 endif
992
993 # Try SunCC next
994 ifeq ($(NATIVE_OPT),)
995 TOPT = -native
996 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
997 ifeq ($(strip $(HAVE_OPT)),0)
998 NATIVE_OPT = -native
999 endif # NATIVE_OPT
1000 endif
1001
1002 ifneq ($(NATIVE_OPT),)
1003 CRYPTOPP_CXXFLAGS += $(NATIVE_OPT)
1004 endif
1005
1006endif # Native
1007
1008# Undefined Behavior Sanitizer (UBsan) testing. Issue 'make ubsan'.
1009ifeq ($(findstring ubsan,$(MAKECMDGOALS)),ubsan)
1010 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1011 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1012 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1013 ifeq ($(findstring -fsanitize=undefined,$(CXXFLAGS)),)
1014 CRYPTOPP_CXXFLAGS += -fsanitize=undefined
1015 endif # CRYPTOPP_CPPFLAGS
1016 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
1017 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1018 endif # CRYPTOPP_CPPFLAGS
1019endif # UBsan
1020
1021# Address Sanitizer (Asan) testing. Issue 'make asan'.
1022ifeq ($(findstring asan,$(MAKECMDGOALS)),asan)
1023 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1024 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1025 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1026 ifeq ($(findstring -fsanitize=address,$(CXXFLAGS)),)
1027 CRYPTOPP_CXXFLAGS += -fsanitize=address
1028 endif # CRYPTOPP_CXXFLAGS
1029 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
1030 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1031 endif # CRYPTOPP_CPPFLAGS
1032 ifeq ($(findstring -fno-omit-frame-pointer,$(CXXFLAGS)),)
1033 CRYPTOPP_CXXFLAGS += -fno-omit-frame-pointer
1034 endif # CRYPTOPP_CXXFLAGS
1035endif # Asan
1036
1037# LD gold linker testing. Triggered by 'LD=ld.gold'.
1038ifeq ($(findstring ld.gold,$(LD)),ld.gold)
1039 ifeq ($(findstring -fuse-ld=gold,$(CXXFLAGS)),)
1040 LD_GOLD = $(shell command -v ld.gold)
1041 ELF_FORMAT := $(shell file $(LD_GOLD) 2>&1 | cut -d":" -f 2 | $(GREP) -i -c "elf")
1042 ifneq ($(ELF_FORMAT),0)
1043 CRYPTOPP_LDFLAGS += -fuse-ld=gold
1044 endif # ELF/ELF64
1045 endif # CXXFLAGS
1046endif # Gold
1047
1048# lcov code coverage. Issue 'make coverage'.
1049ifneq ($(filter lcov coverage,$(MAKECMDGOALS)),)
1050 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1051 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1052 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1053 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
1054 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1055 endif # CRYPTOPP_COVERAGE
1056 ifeq ($(findstring -coverage,$(CXXFLAGS)),)
1057 CRYPTOPP_CXXFLAGS += -coverage
1058 endif # -coverage
1059endif # GCC code coverage
1060
1061# gcov code coverage for Travis. Issue 'make codecov'.
1062ifneq ($(filter gcov codecov,$(MAKECMDGOALS)),)
1063 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1064 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1065 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1066 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
1067 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1068 endif # CRYPTOPP_COVERAGE
1069 ifeq ($(findstring -coverage,$(CXXFLAGS)),)
1070 CRYPTOPP_CXXFLAGS += -coverage
1071 endif # -coverage
1072endif # GCC code coverage
1073
1074# Valgrind testing. Issue 'make valgrind'.
1075ifneq ($(filter valgrind,$(MAKECMDGOALS)),)
1076 # Tune flags; see http://valgrind.org/docs/manual/quick-start.html
1077 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-g%=-g3)
1078 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-O%=-O1)
1079 CRYPTOPP_CXXFLAGS := $(CRYPTOPP_CXXFLAGS:-xO%=-xO1)
1080 ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
1081 CRYPTOPP_CPPFLAGS += -DCRYPTOPP_COVERAGE
1082 endif # CRYPTOPP_CPPFLAGS
1083endif # Valgrind
1084
1085# Debug testing on GNU systems. Triggered by -DDEBUG.
1086# Newlib test due to http://sourceware.org/bugzilla/show_bug.cgi?id=20268
1087ifneq ($(filter -DDEBUG -DDEBUG=1,$(CPPFLAGS)$(CXXFLAGS)),)
1088 TPROG = TestPrograms/test_cxx.cpp
1089 TOPT =
1090 USING_GLIBCXX := $(shell $(CXX) $(CPPFLAGS) $(CXXFLAGS) -E $(TPROG) -c 2>&1 | $(GREP) -i -c "__GLIBCXX__")
1091 ifneq ($(USING_GLIBCXX),0)
1092 ifeq ($(HAS_NEWLIB),0)
1093 ifeq ($(findstring -D_GLIBCXX_DEBUG,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
1094 CRYPTOPP_CPPFLAGS += -D_GLIBCXX_DEBUG
1095 endif # CRYPTOPP_CPPFLAGS
1096 endif # HAS_NEWLIB
1097 endif # USING_GLIBCXX
1098
1099 ifeq ($(XLC_COMPILER),1)
1100 TPROG = TestPrograms/test_cxx.cpp
1101 TOPT = -qheapdebug -qro
1102 HAVE_OPT = $(shell $(TCOMMAND) 2>&1 | wc -w)
1103 ifeq ($(strip $(HAVE_OPT)),0)
1104 CRYPTOPP_CXXFLAGS += -qheapdebug -qro
1105 endif # CRYPTOPP_CXXFLAGS
1106 endif # XLC_COMPILER
1107endif # Debug build
1108
1109# Dead code stripping. Issue 'make lean'.
1110ifeq ($(findstring lean,$(MAKECMDGOALS)),lean)
1111 ifeq ($(findstring -ffunction-sections,$(CXXFLAGS)),)
1112 CRYPTOPP_CXXFLAGS += -ffunction-sections
1113 endif # CRYPTOPP_CXXFLAGS
1114 ifeq ($(findstring -fdata-sections,$(CXXFLAGS)),)
1115 CRYPTOPP_CXXFLAGS += -fdata-sections
1116 endif # CRYPTOPP_CXXFLAGS
1117 ifneq ($(IS_DARWIN),0)
1118 ifeq ($(findstring -Wl,-dead_strip,$(LDFLAGS)),)
1119 CRYPTOPP_LDFLAGS += -Wl,-dead_strip
1120 endif # CRYPTOPP_CXXFLAGS
1121 else # BSD, Linux and Unix
1122 ifeq ($(findstring -Wl,--gc-sections,$(LDFLAGS)),)
1123 CRYPTOPP_LDFLAGS += -Wl,--gc-sections
1124 endif # LDFLAGS
1125 endif # MAKECMDGOALS
1126endif # Dead code stripping
1127
1128# For Shared Objects, Diff, Dist/Zip rules
1129LIB_VER := $(shell $(GREP) "define CRYPTOPP_VERSION" config_ver.h | cut -d" " -f 3)
1130LIB_MAJOR := $(shell echo $(LIB_VER) | cut -c 1)
1131LIB_MINOR := $(shell echo $(LIB_VER) | cut -c 2)
1132LIB_PATCH := $(shell echo $(LIB_VER) | cut -c 3)
1133
1134ifeq ($(strip $(LIB_PATCH)),)
1135 LIB_PATCH := 0
1136endif
1137
1138ifeq ($(HAS_SOLIB_VERSION),1)
1139# Different patchlevels and minors are compatible since 6.1
1140SOLIB_COMPAT_SUFFIX=.$(LIB_MAJOR)
1141# Linux uses -Wl,-soname
1142ifneq ($(IS_LINUX)$(IS_HURD),00)
1143# Linux uses full version suffix for shared library
1144SOLIB_VERSION_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)
1145SOLIB_FLAGS=-Wl,-soname,libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
1146endif
1147# Solaris uses -Wl,-h
1148ifeq ($(IS_SUN),1)
1149# Solaris uses major version suffix for shared library, but we use major.minor
1150# The minor version allows previous version to remain and not overwritten.
1151# https://blogs.oracle.com/solaris/how-to-name-a-solaris-shared-object-v2
1152SOLIB_VERSION_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR)
1153SOLIB_FLAGS=-Wl,-h,libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
1154endif
1155endif # HAS_SOLIB_VERSION
1156
1157###########################################################
1158##### Temp file cleanup #####
1159###########################################################
1160
1161# After this point no more test programs should be run.
1162# https://github.com/weidai11/cryptopp/issues/738
1163ifeq ($(findstring /dev/null,$(TOUT)),)
1164 # $(info TOUT is not /dev/null, cleaning $(TOUT))
1165 ifeq ($(wildcard $(TOUT)),$(TOUT))
1166 UNUSED := $(shell $(RM) $(TOUT) 2>/dev/null)
1167 endif
1168 ifeq ($(wildcard $(TOUT).dSYM/),$(TOUT).dSYM/)
1169 UNUSED := $(shell $(RM) -r $(TOUT).dSYM/ 2>/dev/null)
1170 endif
1171endif
1172
1173###########################################################
1174##### Source and object files #####
1175###########################################################
1176
1177# List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
1178SRCS := cryptlib.cpp cpu.cpp integer.cpp $(filter-out cryptlib.cpp cpu.cpp integer.cpp pch.cpp simple.cpp,$(sort $(wildcard *.cpp)))
1179# For Makefile.am; resource.h is Windows
1180INCL := $(filter-out resource.h,$(sort $(wildcard *.h)))
1181
1182ifneq ($(IS_MINGW),0)
1183INCL += resource.h
1184endif
1185
1186# Cryptogams source files. We couple to ARMv7 and NEON due to SHA using NEON.
1187# Limit to Linux. The source files target the GNU assembler.
1188# Also see https://www.cryptopp.com/wiki/Cryptogams.
1189ifeq ($(IS_ARM32)$(IS_LINUX),11)
1190 ifeq ($(filter -DCRYPTOPP_DISABLE_ASM -DCRYPTOPP_DISABLE_ARM_NEON,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
1191 # Do not use -march=armv7 if the compiler is already targeting the ISA.
1192 # Also see https://github.com/weidai11/cryptopp/issues/1094
1193 ifeq ($(shell $(CXX) -dM -E TestPrograms/test_cxx.cpp 2>/dev/null | grep -E '__ARM_ARCH 7|__ARM_ARCH_7A__'),)
1194 CRYPTOGAMS_ARMV7_FLAG = -march=armv7-a
1195 endif
1196 ifeq ($(CLANG_COMPILER),1)
1197 CRYPTOGAMS_ARM_FLAG = $(CRYPTOGAMS_ARMV7_FLAG)
1198 CRYPTOGAMS_ARM_THUMB_FLAG = $(CRYPTOGAMS_ARMV7_FLAG) -mthumb
1199 else
1200 # -mfpu=auto due to https://github.com/weidai11/cryptopp/issues/1094
1201 CRYPTOGAMS_ARM_FLAG = $(CRYPTOGAMS_ARMV7_FLAG)
1202 CRYPTOGAMS_ARM_THUMB_FLAG = $(CRYPTOGAMS_ARMV7_FLAG)
1203 endif
1204 SRCS += aes_armv4.S sha1_armv4.S sha256_armv4.S sha512_armv4.S
1205 endif
1206endif
1207
1208# Remove unneeded arch specific files to speed build time.
1209ifeq ($(IS_PPC32)$(IS_PPC64),00)
1210 SRCS := $(filter-out %_ppc.cpp,$(SRCS))
1211endif
1212ifeq ($(IS_ARM32)$(IS_ARMV8),00)
1213 SRCS := $(filter-out arm_%,$(SRCS))
1214 SRCS := $(filter-out neon_%,$(SRCS))
1215 SRCS := $(filter-out %_armv4.S,$(SRCS))
1216endif
1217ifeq ($(IS_X86)$(IS_X64),00)
1218 SRCS := $(filter-out sse_%,$(SRCS))
1219 SRCS := $(filter-out %_sse.cpp,$(SRCS))
1220 SRCS := $(filter-out %_avx.cpp,$(SRCS))
1221endif
1222
1223# If ASM is disabled we can remove the SIMD files, too.
1224ifneq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CRYPTOPP_CPPFLAGS)$(CPPFLAGS)$(CXXFLAGS)),)
1225 SRCS := $(filter-out arm_%,$(SRCS))
1226 SRCS := $(filter-out ppc_%,$(SRCS))
1227 SRCS := $(filter-out neon_%,$(SRCS))
1228 SRCS := $(filter-out sse_%,$(SRCS))
1229 SRCS := $(filter-out %_sse.cpp,$(SRCS))
1230 SRCS := $(filter-out %_avx.cpp,$(SRCS))
1231 SRCS := $(filter-out %_ppc.cpp,$(SRCS))
1232 SRCS := $(filter-out %_simd.cpp,$(SRCS))
1233 SRCS := $(filter-out %_armv4.S,$(SRCS))
1234endif
1235
1236# List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
1237OBJS := $(SRCS:.cpp=.o)
1238OBJS := $(OBJS:.S=.o)
1239
1240# List test.cpp first to tame C++ static initialization problems.
1241TESTSRCS := 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
1242TESTINCL := bench.h factory.h validate.h
1243
1244# Test objects
1245TESTOBJS := $(TESTSRCS:.cpp=.o)
1246LIBOBJS := $(filter-out $(TESTOBJS),$(OBJS))
1247
1248# In Crypto++ 5.6.2 these were the source and object files for the FIPS DLL.
1249# Since the library is on the Historical Validation List we add all files.
1250# The 5.6.2 list is at https://github.com/weidai11/cryptopp/blob/789f81f048c9.
1251DLLSRCS := $(SRCS)
1252DLLOBJS := $(DLLSRCS:.cpp=.export.o)
1253DLLOBJS := $(DLLOBJS:.S=.export.o)
1254
1255# Import lib testing
1256LIBIMPORTOBJS := $(LIBOBJS:.o=.import.o)
1257TESTIMPORTOBJS := $(TESTOBJS:.o=.import.o)
1258DLLTESTOBJS := dlltest.dllonly.o
1259
1260# Clean recipe, Issue 998. Don't filter-out some artifacts from the list of objects
1261# The *.S is a hack. It makes the ASM appear like C++ so the object files make the CLEAN_OBJS list
1262CLEAN_SRCS := $(wildcard *.cpp) $(patsubst %.S,%.cpp,$(wildcard *.S))
1263CLEAN_OBJS := $(CLEAN_SRCS:.cpp=.o) $(CLEAN_SRCS:.cpp=.import.o) $(CLEAN_SRCS:.cpp=.export.o)
1264
1265###########################################################
1266##### Add our flags to user flags #####
1267###########################################################
1268
1269# This ensures we don't add flags when the user forbids
1270# use of customary library flags, like -fPIC. Make will
1271# ignore this assignment when CXXFLAGS is passed as an
1272# argument to the make program: make CXXFLAGS="..."
1273CPPFLAGS := $(strip $(CRYPTOPP_CPPFLAGS) $(CPPFLAGS))
1274CXXFLAGS := $(strip $(CRYPTOPP_CXXFLAGS) $(CXXFLAGS))
1275ASFLAGS := $(strip $(CRYPTOPP_ASFLAGS) $(ASFLAGS))
1276LDFLAGS := $(strip $(CRYPTOPP_LDFLAGS) $(LDFLAGS))
1277
1278###########################################################
1279##### Targets and Recipes #####
1280###########################################################
1281
1282# Default builds program with static library only
1283.PHONY: default
1284default: cryptest.exe
1285
1286.PHONY: all static dynamic
1287all: static dynamic cryptest.exe
1288
1289ifneq ($(IS_DARWIN),0)
1290static: libcryptopp.a
1291shared dynamic dylib: libcryptopp.dylib
1292else
1293static: libcryptopp.a
1294shared dynamic: libcryptopp.so$(SOLIB_VERSION_SUFFIX)
1295endif
1296
1297# CXXFLAGS are tuned earlier.
1298.PHONY: native no-asm asan ubsan
1299native no-asm asan ubsan: cryptest.exe
1300
1301# CXXFLAGS are tuned earlier. Applications must use linker flags
1302# -Wl,--gc-sections (Linux and Unix) or -Wl,-dead_strip (OS X)
1303.PHONY: lean
1304lean: static dynamic cryptest.exe
1305
1306# May want to export CXXFLAGS="-g3 -O1"
1307.PHONY: lcov coverage
1308lcov coverage: cryptest.exe
1309 @-$(RM) -r ./TestCoverage/
1310 lcov --base-directory . --directory . --zerocounters -q
1311 ./cryptest.exe v
1312 ./cryptest.exe tv all
1313 ./cryptest.exe b 0.25
1314 lcov --base-directory . --directory . -c -o cryptest.info
1315 lcov --remove cryptest.info "adhoc.*" -o cryptest.info
1316 lcov --remove cryptest.info "fips140.*" -o cryptest.info
1317 lcov --remove cryptest.info "*test.*" -o cryptest.info
1318 lcov --remove cryptest.info "/usr/*" -o cryptest.info
1319 genhtml -o ./TestCoverage/ -t "Crypto++ test coverage" --num-spaces 4 cryptest.info
1320
1321# Travis CI and CodeCov rule
1322.PHONY: gcov codecov
1323gcov codecov: cryptest.exe
1324 @-$(RM) -r ./TestCoverage/
1325 ./cryptest.exe v
1326 ./cryptest.exe tv all
1327 gcov -r $(SRCS)
1328
1329# Should use CXXFLAGS="-g3 -O1"
1330.PHONY: valgrind
1331valgrind: cryptest.exe
1332 valgrind --track-origins=yes --suppressions=cryptopp.supp ./cryptest.exe v
1333
1334.PHONY: test check
1335test check: cryptest.exe
1336 ./cryptest.exe v
1337
1338# Used to generate list of source files for Autotools, CMakeList, Android.mk, etc
1339.PHONY: sources
1340sources: adhoc.cpp
1341 $(info ***** Library sources *****)
1342 $(info $(filter-out $(TESTSRCS),$(SRCS)))
1343 $(info )
1344 $(info ***** Library headers *****)
1345 $(info $(filter-out $(TESTINCL),$(INCL)))
1346 $(info )
1347 $(info ***** Test sources *****)
1348 $(info $(TESTSRCS))
1349 $(info )
1350 $(info ***** Test headers *****)
1351 $(info $(TESTINCL))
1352
1353# Directory we want (can't specify on Doygen command line)
1354DOCUMENT_DIRECTORY := ref$(LIB_VER)
1355# Directory Doxygen uses (specified in Doygen config file)
1356ifeq ($(wildcard Doxyfile),Doxyfile)
1357DOXYGEN_DIRECTORY := $(strip $(shell $(GREP) "OUTPUT_DIRECTORY" Doxyfile | $(GREP) -v "\#" | cut -d "=" -f 2))
1358endif
1359# Default directory (in case its missing in the config file)
1360ifeq ($(strip $(DOXYGEN_DIRECTORY)),)
1361DOXYGEN_DIRECTORY := html-docs
1362endif
1363
1364# Builds the documentation. Directory name is ref563, ref570, etc.
1365.PHONY: docs html
1366docs html:
1367 @-$(RM) -r $(DOXYGEN_DIRECTORY)/ $(DOCUMENT_DIRECTORY)/ html-docs/
1368 @-$(RM) CryptoPPRef.zip
1369 doxygen Doxyfile -d CRYPTOPP_DOXYGEN_PROCESSING
1370 $(MV) $(DOXYGEN_DIRECTORY)/ $(DOCUMENT_DIRECTORY)/
1371 zip -9 CryptoPPRef.zip -x ".*" -x "*/.*" -r $(DOCUMENT_DIRECTORY)/
1372
1373.PHONY: clean
1374clean:
1375 -$(RM) adhoc.cpp.o adhoc.cpp.proto.o $(CLEAN_OBJS) rdrand-*.o
1376 @-$(RM) libcryptopp.a libcryptopp.dylib cryptopp.dll libcryptopp.dll.a libcryptopp.import.a
1377 @-$(RM) libcryptopp.so libcryptopp.so$(SOLIB_COMPAT_SUFFIX) libcryptopp.so$(SOLIB_VERSION_SUFFIX)
1378 @-$(RM) cryptest.exe dlltest.exe cryptest.import.exe cryptest.dat ct et
1379 @-$(RM) *.la *.lo *.gcov *.gcno *.gcda *.stackdump core core-*
1380 @-$(RM) /tmp/adhoc.exe
1381 @-$(RM) -r /tmp/cryptopp_test/
1382 @-$(RM) -r *.exe.dSYM/ *.dylib.dSYM/
1383 @-$(RM) -r cov-int/
1384
1385.PHONY: autotools-clean
1386autotools-clean:
1387 @-$(RM) -f bootstrap.sh configure.ac configure configure.in Makefile.am Makefile.in Makefile
1388 @-$(RM) -f config.guess config.status config.sub config.h.in compile depcomp
1389 @-$(RM) -f install-sh stamp-h1 ar-lib *.lo *.la *.m4 local.* lt*.sh missing
1390 @-$(RM) -f cryptest cryptestcwd libtool* libcryptopp.la libcryptopp.pc*
1391 @-$(RM) -rf build-aux/ m4/ auto*.cache/ .deps/ .libs/
1392
1393.PHONY: cmake-clean
1394cmake-clean:
1395 @-$(RM) -f cryptopp-config.cmake CMakeLists.txt
1396 @-$(RM) -rf cmake_build/
1397
1398.PHONY: android-clean
1399android-clean:
1400 @-$(RM) -f $(patsubst %_simd.cpp,%_simd.cpp.neon,$(wildcard *_simd.cpp))
1401 @-$(RM) -rf obj/
1402
1403.PHONY: distclean
1404distclean: clean autotools-clean cmake-clean android-clean
1405 -$(RM) adhoc.cpp adhoc.cpp.copied GNUmakefile.deps benchmarks.html cryptest.txt
1406 -$(RM) cryptest_all.info cryptest_debug.info cryptest_noasm.info cryptest_base.info cryptest.info cryptest_release.info
1407 @-$(RM) cryptest-*.txt cryptopp.tgz libcryptopp.pc *.o *.bc *.ii *~
1408 @-$(RM) -r cryptlib.lib cryptest.exe *.suo *.sdf *.pdb Win32/ x64/ ipch/
1409 @-$(RM) -r $(LIBOBJS:.o=.obj) $(TESTOBJS:.o=.obj)
1410 @-$(RM) -r $(LIBOBJS:.o=.lst) $(TESTOBJS:.o=.lst)
1411 @-$(RM) -r TestCoverage/ ref*/
1412 @-$(RM) cryptopp$(LIB_VER)\.* CryptoPPRef.zip
1413
1414# Install cryptest.exe, libcryptopp.a, libcryptopp.so and libcryptopp.pc.
1415# The library install was broken-out into its own recipe at GH #653.
1416.PHONY: install
1417install: cryptest.exe install-lib
1418 @-$(MKDIR) $(DESTDIR)$(BINDIR)
1419 $(CP) cryptest.exe $(DESTDIR)$(BINDIR)
1420 $(CHMOD) u=rwx,go=rx $(DESTDIR)$(BINDIR)/cryptest.exe
1421 @-$(MKDIR) $(DESTDIR)$(DATADIR)/cryptopp/TestData
1422 @-$(MKDIR) $(DESTDIR)$(DATADIR)/cryptopp/TestVectors
1423 $(CP) TestData/*.dat $(DESTDIR)$(DATADIR)/cryptopp/TestData
1424 $(CHMOD) u=rw,go=r $(DESTDIR)$(DATADIR)/cryptopp/TestData/*.dat
1425 $(CP) TestVectors/*.txt $(DESTDIR)$(DATADIR)/cryptopp/TestVectors
1426 $(CHMOD) u=rw,go=r $(DESTDIR)$(DATADIR)/cryptopp/TestVectors/*.txt
1427
1428# A recipe to install only the library, and not cryptest.exe. Also
1429# see https://github.com/weidai11/cryptopp/issues/653. Some users
1430# already have a libcryptopp.pc. Install the *.pc file if the file
1431# is present. If you want one, then issue 'make libcryptopp.pc'.
1432.PHONY: install-lib
1433install-lib:
1434 @-$(MKDIR) $(DESTDIR)$(INCLUDEDIR)/cryptopp
1435 $(CP) *.h $(DESTDIR)$(INCLUDEDIR)/cryptopp
1436 $(CHMOD) u=rw,go=r $(DESTDIR)$(INCLUDEDIR)/cryptopp/*.h
1437ifneq ($(wildcard libcryptopp.a),)
1438 @-$(MKDIR) $(DESTDIR)$(LIBDIR)
1439 $(CP) libcryptopp.a $(DESTDIR)$(LIBDIR)
1440 $(CHMOD) u=rw,go=r $(DESTDIR)$(LIBDIR)/libcryptopp.a
1441endif
1442ifneq ($(wildcard libcryptopp.dylib),)
1443 @-$(MKDIR) $(DESTDIR)$(LIBDIR)
1444 $(CP) libcryptopp.dylib $(DESTDIR)$(LIBDIR)
1445 $(CHMOD) u=rwx,go=rx $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
1446 -install_name_tool -id $(DESTDIR)$(LIBDIR)/libcryptopp.dylib $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
1447endif
1448ifneq ($(wildcard libcryptopp.so$(SOLIB_VERSION_SUFFIX)),)
1449 @-$(MKDIR) $(DESTDIR)$(LIBDIR)
1450 $(CP) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)
1451 $(CHMOD) u=rwx,go=rx $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
1452ifeq ($(HAS_SOLIB_VERSION),1)
1453 -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so
1454 -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
1455 $(LDCONF) $(DESTDIR)$(LIBDIR)
1456endif
1457endif
1458ifneq ($(wildcard libcryptopp.pc),)
1459 @-$(MKDIR) $(DESTDIR)$(LIBDIR)/pkgconfig
1460 $(CP) libcryptopp.pc $(DESTDIR)$(LIBDIR)/pkgconfig
1461 $(CHMOD) u=rw,go=r $(DESTDIR)$(LIBDIR)/pkgconfig/libcryptopp.pc
1462endif
1463
1464.PHONY: remove uninstall
1465remove uninstall:
1466 -$(RM) -r $(DESTDIR)$(INCLUDEDIR)/cryptopp
1467 -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.a
1468 -$(RM) $(DESTDIR)$(BINDIR)/cryptest.exe
1469ifneq ($(wildcard $(DESTDIR)$(LIBDIR)/libcryptopp.dylib),)
1470 -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
1471endif
1472ifneq ($(wildcard $(DESTDIR)$(LIBDIR)/libcryptopp.so),)
1473 -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so
1474endif
1475 @-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
1476 @-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
1477 @-$(RM) $(DESTDIR)$(LIBDIR)/pkgconfig/libcryptopp.pc
1478 @-$(RM) -r $(DESTDIR)$(DATADIR)/cryptopp
1479
1480libcryptopp.a: $(LIBOBJS) | osx_warning
1481 $(AR) $(ARFLAGS) $@ $(LIBOBJS)
1482ifeq ($(IS_SUN),0)
1483 $(RANLIB) $@
1484endif
1485
1486ifeq ($(HAS_SOLIB_VERSION),1)
1487.PHONY: libcryptopp.so
1488libcryptopp.so: libcryptopp.so$(SOLIB_VERSION_SUFFIX) | so_warning
1489endif
1490
1491libcryptopp.so$(SOLIB_VERSION_SUFFIX): $(LIBOBJS)
1492ifeq ($(XLC_COMPILER),1)
1493 $(CXX) -qmkshrobj $(SOLIB_FLAGS) -o $@ $(CXXFLAGS) $(LDFLAGS) $(LIBOBJS) $(LDLIBS)
1494else
1495 $(CXX) -shared $(SOLIB_FLAGS) -o $@ $(CXXFLAGS) $(LDFLAGS) $(LIBOBJS) $(LDLIBS)
1496endif
1497ifeq ($(HAS_SOLIB_VERSION),1)
1498 -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.so
1499 -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
1500endif
1501
1502libcryptopp.dylib: $(LIBOBJS) | osx_warning
1503 $(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)
1504
1505cryptest.exe: $(LINK_LIBRARY) $(TESTOBJS) | osx_warning
1506 $(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) $(LINK_LIBRARY_PATH)$(LINK_LIBRARY) $(LDFLAGS) $(LDLIBS)
1507
1508# Makes it faster to test changes
1509nolib: $(OBJS)
1510 $(CXX) -o ct $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS)
1511
1512dll: cryptest.import.exe dlltest.exe
1513
1514cryptopp.dll: $(DLLOBJS)
1515 $(CXX) -shared -o $@ $(CXXFLAGS) $(DLLOBJS) $(LDFLAGS) $(LDLIBS) -Wl,--out-implib=libcryptopp.dll.a
1516
1517libcryptopp.import.a: $(LIBIMPORTOBJS)
1518 $(AR) $(ARFLAGS) $@ $(LIBIMPORTOBJS)
1519ifeq ($(IS_SUN),0)
1520 $(RANLIB) $@
1521endif
1522
1523cryptest.import.exe: cryptopp.dll libcryptopp.import.a $(TESTIMPORTOBJS)
1524 $(CXX) -o $@ $(CXXFLAGS) $(TESTIMPORTOBJS) -L. -lcryptopp.dll -lcryptopp.import $(LDFLAGS) $(LDLIBS)
1525
1526dlltest.exe: cryptopp.dll $(DLLTESTOBJS)
1527 $(CXX) -o $@ $(CXXFLAGS) $(DLLTESTOBJS) -L. -lcryptopp.dll $(LDFLAGS) $(LDLIBS)
1528
1529# Some users already have a libcryptopp.pc. We install it if the file
1530# is present. If you want one, then issue 'make libcryptopp.pc'. Be sure
1531# to use/verify PREFIX and LIBDIR below after writing the file.
1532cryptopp.pc libcryptopp.pc:
1533 @echo '# Crypto++ package configuration file' > libcryptopp.pc
1534 @echo '' >> libcryptopp.pc
1535 @echo 'prefix=$(PC_PREFIX)' >> libcryptopp.pc
1536 @echo 'libdir=$(PC_LIBDIR)' >> libcryptopp.pc
1537 @echo 'includedir=$(PC_INCLUDEDIR)' >> libcryptopp.pc
1538 @echo 'datadir=$(PC_DATADIR)' >> libcryptopp.pc
1539 @echo '' >> libcryptopp.pc
1540 @echo 'Name: Crypto++' >> libcryptopp.pc
1541 @echo 'Description: Crypto++ cryptographic library' >> libcryptopp.pc
1542 @echo 'Version: 8.7' >> libcryptopp.pc
1543 @echo 'URL: https://cryptopp.com/' >> libcryptopp.pc
1544 @echo '' >> libcryptopp.pc
1545 @echo 'Cflags: -I$${includedir}' >> libcryptopp.pc
1546 @echo 'Libs: -L$${libdir} -lcryptopp' >> libcryptopp.pc
1547
1548# This recipe prepares the distro files
1549TEXT_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
1550EXEC_FILES := TestScripts/*.sh TestScripts/*.cmd
1551ifneq ($(wildcard *.sh),)
1552 EXEC_FILES += $(wildcard *.sh)
1553endif
1554EXEC_DIRS := TestData/ TestVectors/ TestScripts/ TestPrograms/
1555
1556ifeq ($(wildcard Filelist.txt),Filelist.txt)
1557DIST_FILES := $(shell cat Filelist.txt)
1558endif
1559
1560.PHONY: trim
1561trim:
1562ifneq ($(IS_DARWIN),0)
1563 $(SED) -i '' -e's/[[:space:]]*$$//' *.supp *.txt .*.yml *.h *.cpp *.asm *.S
1564 $(SED) -i '' -e's/[[:space:]]*$$//' *.sln *.vcxproj *.filters GNUmakefile GNUmakefile-cross
1565 $(SED) -i '' -e's/[[:space:]]*$$//' TestData/*.dat TestVectors/*.txt TestPrograms/*.cpp TestScripts/*.*
1566 make convert
1567else
1568 $(SED) -i -e's/[[:space:]]*$$//' *.supp *.txt .*.yml *.h *.cpp *.asm *.S
1569 $(SED) -i -e's/[[:space:]]*$$//' *.sln *.vcxproj *.filters GNUmakefile GNUmakefile-cross
1570 $(SED) -i -e's/[[:space:]]*$$//' TestData/*.dat TestVectors/*.txt TestPrograms/*.cpp TestScripts/*.*
1571 make convert
1572endif
1573
1574.PHONY: convert
1575convert:
1576 @-$(CHMOD) u=rwx,go=rx $(EXEC_DIRS)
1577 @-$(CHMOD) u=rw,go=r $(TEXT_FILES) *.supp .*.yml *.asm *.zip TestVectors/*.txt TestData/*.dat TestPrograms/*.cpp
1578 @-$(CHMOD) u=rwx,go=rx $(EXEC_FILES)
1579 -unix2dos --keepdate --quiet $(TEXT_FILES) .*.yml *.asm TestScripts/*.cmd TestScripts/*.txt TestScripts/*.cpp
1580 -dos2unix --keepdate --quiet GNUmakefile GNUmakefile-cross *.sh *.S *.supp *.mapfile TestScripts/*.sh
1581ifneq ($(IS_DARWIN),0)
1582 @-xattr -c *
1583endif
1584
1585# Build the ZIP file with source files. No documentation.
1586.PHONY: zip dist
1587zip dist: | distclean convert
1588 zip -q -9 cryptopp$(LIB_VER).zip $(DIST_FILES)
1589
1590# Build the ISO to transfer the ZIP to old distros via CDROM
1591.PHONY: iso
1592iso: | zip
1593ifneq ($(IS_DARWIN),0)
1594 $(MKDIR) $(PWD)/cryptopp$(LIB_VER)
1595 $(CP) cryptopp$(LIB_VER).zip $(PWD)/cryptopp$(LIB_VER)
1596 hdiutil makehybrid -iso -joliet -o cryptopp$(LIB_VER).iso $(PWD)/cryptopp$(LIB_VER)
1597 @-$(RM) -r $(PWD)/cryptopp$(LIB_VER)
1598else ifneq ($(IS_LINUX)$(IS_HURD),00)
1599 $(MKDIR) $(PWD)/cryptopp$(LIB_VER)
1600 $(CP) cryptopp$(LIB_VER).zip $(PWD)/cryptopp$(LIB_VER)
1601 genisoimage -q -o cryptopp$(LIB_VER).iso $(PWD)/cryptopp$(LIB_VER)
1602 @-$(RM) -r $(PWD)/cryptopp$(LIB_VER)
1603endif
1604
1605# CRYPTOPP_CPU_FREQ in GHz
1606CRYPTOPP_CPU_FREQ ?= 0.0
1607.PHONY: bench benchmark benchmarks
1608bench benchmark benchmarks: cryptest.exe
1609 @-$(RM) -f benchmarks.html
1610 ./cryptest.exe b 2 $(CRYPTOPP_CPU_FREQ)
1611
1612adhoc.cpp: adhoc.cpp.proto
1613ifeq ($(wildcard adhoc.cpp),)
1614 cp adhoc.cpp.proto adhoc.cpp
1615else
1616 touch adhoc.cpp
1617endif
1618
1619# Include dependencies, if present. You must issue `make deps` to create them.
1620ifeq ($(wildcard GNUmakefile.deps),GNUmakefile.deps)
1621-include GNUmakefile.deps
1622endif # Dependencies
1623
1624# A few recipes trigger warnings for -std=c++11 and -stdlib=c++
1625NOSTD_CXXFLAGS=$(filter-out -stdlib=%,$(filter-out -std=%,$(CXXFLAGS)))
1626
1627# Cryptogams ARM asm implementation. AES needs -mthumb for Clang
1628aes_armv4.o : aes_armv4.S
1629 $(CXX) $(strip $(CPPFLAGS) $(ASFLAGS) $(NOSTD_CXXFLAGS) $(CRYPTOGAMS_ARM_THUMB_FLAG) -c) $<
1630
1631# SSSE3 or NEON available
1632aria_simd.o : aria_simd.cpp
1633 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(ARIA_FLAG) -c) $<
1634
1635# SSE, NEON or POWER7 available
1636blake2s_simd.o : blake2s_simd.cpp
1637 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(BLAKE2S_FLAG) -c) $<
1638
1639# SSE, NEON or POWER8 available
1640blake2b_simd.o : blake2b_simd.cpp
1641 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(BLAKE2B_FLAG) -c) $<
1642
1643# SSE2 or NEON available
1644chacha_simd.o : chacha_simd.cpp
1645 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CHACHA_FLAG) -c) $<
1646
1647# AVX2 available
1648chacha_avx.o : chacha_avx.cpp
1649 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CHACHA_AVX2_FLAG) -c) $<
1650
1651# SSSE3 available
1652cham_simd.o : cham_simd.cpp
1653 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CHAM_FLAG) -c) $<
1654
1655# SSE4.2 or ARMv8a available
1656crc_simd.o : crc_simd.cpp
1657 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CRC_FLAG) -c) $<
1658
1659# Power9 available
1660darn.o : darn.cpp
1661 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(DARN_FLAG) -c) $<
1662
1663# SSE2 on i686
1664donna_sse.o : donna_sse.cpp
1665 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SSE2_FLAG) -c) $<
1666
1667# Carryless multiply
1668gcm_simd.o : gcm_simd.cpp
1669 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(GCM_FLAG) -c) $<
1670
1671# Carryless multiply
1672gf2n_simd.o : gf2n_simd.cpp
1673 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(GF2N_FLAG) -c) $<
1674
1675# SSSE3 available
1676keccak_simd.o : keccak_simd.cpp
1677 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(KECCAK_FLAG) -c) $<
1678
1679# SSSE3 available
1680lea_simd.o : lea_simd.cpp
1681 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LEA_FLAG) -c) $<
1682
1683# SSSE3 available
1684lsh256_sse.o : lsh256_sse.cpp
1685 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LSH256_FLAG) -c) $<
1686
1687# AVX2 available
1688lsh256_avx.o : lsh256_avx.cpp
1689 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LSH256_AVX2_FLAG) -c) $<
1690
1691# SSSE3 available
1692lsh512_sse.o : lsh512_sse.cpp
1693 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LSH512_FLAG) -c) $<
1694
1695# AVX2 available
1696lsh512_avx.o : lsh512_avx.cpp
1697 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LSH512_AVX2_FLAG) -c) $<
1698
1699# NEON available
1700neon_simd.o : neon_simd.cpp
1701 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(NEON_FLAG) -c) $<
1702
1703# AltiVec available
1704ppc_simd.o : ppc_simd.cpp
1705 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(ALTIVEC_FLAG) -c) $<
1706
1707# AESNI or ARMv7a/ARMv8a available
1708rijndael_simd.o : rijndael_simd.cpp
1709 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(AES_FLAG) -c) $<
1710
1711# SSE4.2/SHA-NI or ARMv8a available
1712sha_simd.o : sha_simd.cpp
1713 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SHA_FLAG) -c) $<
1714
1715# Cryptogams SHA1/SHA256/SHA512 asm implementation.
1716sha%_armv4.o : sha%_armv4.S
1717 $(CXX) $(strip $(CPPFLAGS) $(ASFLAGS) $(NOSTD_CXXFLAGS) $(CRYPTOGAMS_ARM_FLAG) -c) $<
1718
1719sha3_simd.o : sha3_simd.cpp
1720 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SHA3_FLAG) -c) $<
1721
1722# SSE4.2/SHA-NI or ARMv8a available
1723shacal2_simd.o : shacal2_simd.cpp
1724 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SHA_FLAG) -c) $<
1725
1726# SSSE3, NEON or POWER8 available
1727simon128_simd.o : simon128_simd.cpp
1728 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SIMON128_FLAG) -c) $<
1729
1730# SSSE3, NEON or POWER8 available
1731speck128_simd.o : speck128_simd.cpp
1732 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SPECK128_FLAG) -c) $<
1733
1734# ARMv8.4 available
1735sm3_simd.o : sm3_simd.cpp
1736 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SM3_FLAG) -c) $<
1737
1738# AESNI available
1739sm4_simd.o : sm4_simd.cpp
1740 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SM4_FLAG) -c) $<
1741
1742# IBM XLC -O3 optimization bug
1743ifeq ($(XLC_COMPILER),1)
1744sm3.o : sm3.cpp
1745 $(CXX) $(strip $(CPPFLAGS) $(subst -O3,-O2,$(CXXFLAGS)) -c) $<
1746donna_32.o : donna_32.cpp
1747 $(CXX) $(strip $(CPPFLAGS) $(subst -O3,-O2,$(CXXFLAGS)) -c) $<
1748donna_64.o : donna_64.cpp
1749 $(CXX) $(strip $(CPPFLAGS) $(subst -O3,-O2,$(CXXFLAGS)) -c) $<
1750endif
1751
1752# SSE2 on i686
1753sse_simd.o : sse_simd.cpp
1754 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SSE2_FLAG) -c) $<
1755
1756# Don't build Rijndael with UBsan. Too much noise due to unaligned data accesses.
1757ifneq ($(findstring -fsanitize=undefined,$(CXXFLAGS)),)
1758rijndael.o : rijndael.cpp
1759 $(CXX) $(strip $(subst -fsanitize=undefined,,$(CXXFLAGS)) -c) $<
1760endif
1761
1762# Only use CRYPTOPP_DATA_DIR if its not set in CXXFLAGS
1763ifeq ($(findstring -DCRYPTOPP_DATA_DIR, $(CPPFLAGS)$(CXXFLAGS)),)
1764ifneq ($(strip $(CRYPTOPP_DATA_DIR)),)
1765validat%.o : validat%.cpp
1766 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" $(CXXFLAGS) -c) $<
1767bench%.o : bench%.cpp
1768 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" $(CXXFLAGS) -c) $<
1769datatest.o : datatest.cpp
1770 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" $(CXXFLAGS) -c) $<
1771test.o : test.cpp
1772 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" $(CXXFLAGS) -c) $<
1773endif
1774endif
1775
1776validat1.o : validat1.cpp
1777 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(ALTIVEC_FLAG) -c) $<
1778
1779%.dllonly.o : %.cpp
1780 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_DLL_ONLY $(CXXFLAGS) -c) $< -o $@
1781
1782%.import.o : %.cpp
1783 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_IMPORTS $(CXXFLAGS) -c) $< -o $@
1784
1785%.export.o : %.cpp
1786 $(CXX) $(strip $(CPPFLAGS) -DCRYPTOPP_EXPORTS $(CXXFLAGS) -c) $< -o $@
1787
1788%.bc : %.cpp
1789 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) -c) $<
1790
1791%.o : %.cpp
1792 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) -c) $<
1793
1794.PHONY: so_warning
1795so_warning:
1796ifeq ($(HAS_SOLIB_VERSION),1)
1797 $(info )
1798 $(info WARNING: Only the symlinks to the shared-object library have been updated.)
1799 $(info WARNING: If the library is installed in a system directory you will need)
1800 $(info WARNING: to run 'ldconfig' to update the shared-object library cache.)
1801 $(info )
1802endif
1803
1804.PHONY: osx_warning
1805osx_warning:
1806ifeq ($(IS_DARWIN)$(CLANG_COMPILER),11)
1807 ifeq ($(findstring -stdlib=libc++,$(CRYPTOPP_CXXFLAGS)$(CXXFLAGS)),)
1808 $(info )
1809 $(info INFO: Crypto++ was built without LLVM's libc++. If you are using the library)
1810 $(info INFO: with modern Xcode, then you should add -stdlib=libc++ to CXXFLAGS. It is)
1811 $(info INFO: already present in the makefile, and you only need to uncomment it.)
1812 $(info )
1813 endif
1814endif
1815
1816.PHONY: dep deps depend
1817dep deps depend GNUmakefile.deps:
1818 $(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS)) -MM *.cpp > GNUmakefile.deps