1 ###########################################################
2 ##### System Attributes and Programs #####
3 ###########################################################
6 ARFLAGS ?= -cr # ar needs the dash on OpenBSD
15 LDCONF ?= /sbin/ldconfig -n
16 UNAME := $(shell uname)
18 IS_X86 := $(shell uname -m | $(EGREP) -v "x86_64" | $(EGREP) -i -c "i.86|x86|i86")
20 IS_X64 := $(shell uname -m | $(EGREP) -i -c "(_64|d64)")
21 IS_PPC := $(shell uname -m | $(EGREP) -i -c "ppc|power")
22 IS_ARM32 := $(shell uname -m | $(EGREP) -i -c "arm")
23 IS_ARM64 := $(shell uname -m | $(EGREP) -i -c "aarch64")
25 IS_SUN := $(shell uname | $(EGREP) -i -c "SunOS")
26 IS_LINUX := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "Linux")
27 IS_MINGW := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "MinGW")
28 IS_CYGWIN := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "Cygwin")
29 IS_DARWIN := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "Darwin")
30 IS_NETBSD := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "NetBSD")
32 SUN_COMPILER := $(shell $(CXX) -V 2>&1 | $(EGREP) -i -c "CC: (Sun|Studio)")
33 GCC_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -v "clang" | $(EGREP) -i -c "(gcc|g\+\+)")
34 CLANG_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "clang")
35 INTEL_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "\(icc\)")
36 MACPORTS_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "macports")
38 # Sun Studio 12.0 provides SunCC 0x0510; and Sun Studio 12.3 provides SunCC 0x0512
39 SUNCC_510_OR_LATER := $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: (Sun|Studio) .* (5\.1[0-9]|5\.[2-9]|6\.)")
40 SUNCC_511_OR_LATER := $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: (Sun|Studio) .* (5\.1[1-9]|5\.[2-9]|6\.)")
41 SUNCC_512_OR_LATER := $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: (Sun|Studio) .* (5\.1[2-9]|5\.[2-9]|6\.)")
42 SUNCC_513_OR_LATER := $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: (Sun|Studio) .* (5\.1[3-9]|5\.[2-9]|6\.)")
44 HAS_SOLIB_VERSION := $(IS_LINUX)
48 IS_X86 := $(shell isainfo -k 2>/dev/null | grep -i -c "i386")
49 IS_X64 := $(shell isainfo -k 2>/dev/null | grep -i -c "amd64")
52 ###########################################################
53 ##### General Variables #####
54 ###########################################################
56 # Base CXXFLAGS used if the user did not specify them
57 ifeq ($(SUN_COMPILER),1)
58 ifeq ($(SUNCC_512_OR_LATER),1)
59 CXXFLAGS ?= -DNDEBUG -g3 -xO2
61 CXXFLAGS ?= -DNDEBUG -g -xO2
64 CXXFLAGS ?= -DNDEBUG -g2 -O2
67 # Default prefix for make install
72 # http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
74 DATADIR := $(PREFIX)/share
77 LIBDIR := $(PREFIX)/lib
80 BINDIR := $(PREFIX)/bin
83 INCLUDEDIR := $(PREFIX)/include
86 # Fix CXX on Cygwin 1.1.4
91 # We honor ARFLAGS, but the "v" option used by default causes a noisy make
96 ###########################################################
97 ##### X86/X32/X64 Options #####
98 ###########################################################
100 ifneq ($(IS_X86)$(IS_X32)$(IS_X64),000)
102 # Fixup. Clang integrated assembler will be used (-Wa,-q)
103 ifneq ($(MACPORTS_COMPILER),1)
104 IS_GAS := $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler")
107 ifneq ($(GCC_COMPILER),0)
108 IS_GCC_29 := $(shell $(CXX) -v 2>&1 | $(EGREP) -i -c gcc-9[0-9][0-9])
109 GCC42_OR_LATER := $(shell $(CXX) -v 2>&1 | $(EGREP) -i -c "gcc version (4\.[2-9]|[5-9]\.)")
110 GCC46_OR_LATER := $(shell $(CXX) -v 2>&1 | $(EGREP) -i -c "gcc version (4\.[6-9]|[5-9]\.)")
114 GAS210_OR_LATER := $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.[1-9][0-9]|[3-9])")
115 GAS217_OR_LATER := $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.1[7-9]|2\.[2-9]|[3-9])")
116 GAS219_OR_LATER := $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.19|2\.[2-9]|[3-9])")
119 ICC111_OR_LATER := $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\) ([2-9][0-9]|1[2-9]|11\.[1-9])")
121 # Add -fPIC for targets *except* X86, X32, Cygwin or MinGW
122 ifeq ($(IS_X86)$(IS_X32)$(IS_CYGWIN)$(IS_MINGW)$(SUN_COMPILER),00000)
123 ifeq ($(findstring -fPIC,$(CXXFLAGS)),)
128 # Guard use of -march=native
129 ifeq ($(GCC42_OR_LATER)$(IS_NETBSD),10)
130 CXXFLAGS += -march=native
131 else ifneq ($(CLANG_COMPILER)$(INTEL_COMPILER),00)
132 CXXFLAGS += -march=native
134 # GCC 3.3 and "unknown option -march="
135 # Ubuntu GCC 4.1 compiler crash with -march=native
136 # NetBSD GCC 4.8 compiler and "bad value (native) for -march= switch"
137 # Sun compiler is handled below
138 ifeq ($(SUN_COMPILER)$(IS_X64),01)
140 else ifeq ($(SUN_COMPILER)$(IS_X86),01)
145 # Aligned access required for -O3 and above due to vectorization
146 UNALIGNED_ACCESS := $(shell $(EGREP) -c "^[[:space:]]*//[[:space:]]*\#[[:space:]]*define[[:space:]]*CRYPTOPP_NO_UNALIGNED_DATA_ACCESS" config.h)
147 ifneq ($(UNALIGNED_ACCESS),0)
148 ifeq ($(findstring -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS,$(CXXFLAGS)),)
149 ifeq ($(findstring -O3,$(CXXFLAGS)),-O3)
150 CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
152 ifeq ($(findstring -O5,$(CXXFLAGS)),-O5)
153 CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
155 ifeq ($(findstring -Ofast,$(CXXFLAGS)),-Ofast)
156 CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
158 endif # CRYPTOPP_NO_UNALIGNED_DATA_ACCESS
159 endif # UNALIGNED_ACCESS
161 ifneq ($(INTEL_COMPILER),0)
162 CXXFLAGS += -wd68 -wd186 -wd279 -wd327 -wd161 -wd3180
163 ifeq ($(ICC111_OR_LATER),0)
164 # "internal error: backend signals" occurs on some x86 inline assembly with ICC 9 and some x64 inline assembly with ICC 11.0
165 # if you want to use Crypto++'s assembly code with ICC, try enabling it on individual files
166 CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
170 # .intel_syntax wasn't supported until GNU assembler 2.10
171 ifeq ($(GCC_COMPILER)$(MACPORTS_COMPILER)$(GAS210_OR_LATER),100)
172 CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
174 ifeq ($(GCC_COMPILER)$(MACPORTS_COMPILER)$(GAS217_OR_LATER),100)
175 CXXFLAGS += -DCRYPTOPP_DISABLE_SSSE3
177 ifeq ($(GCC_COMPILER)$(MACPORTS_COMPILER)$(GAS219_OR_LATER),100)
178 CXXFLAGS += -DCRYPTOPP_DISABLE_AESNI
183 # Tell MacPorts GCC to use Clang integrated assembler
184 # http://github.com/weidai11/cryptopp/issues/190
185 ifeq ($(GCC_COMPILER)$(MACPORTS_COMPILER),11)
186 ifneq ($(findstring -Wa,-q,$(CXXFLAGS)),-Wa,-q)
189 ifneq ($(findstring -Wa,-q,$(CXXFLAGS)),-DCRYPTOPP_CLANG_INTEGRATED_ASSEMBLER)
190 CXXFLAGS += -DCRYPTOPP_CLANG_INTEGRATED_ASSEMBLER=1
194 # GCC on Solaris needs -m64. Otherwise, i386 is default
195 # http://github.com/weidai11/cryptopp/issues/230
196 ifeq ($(IS_SUN)$(GCC_COMPILER)$(IS_X64),111)
200 # Allow use of "/" operator for GNU Assembler.
201 # http://sourceware.org/bugzilla/show_bug.cgi?id=4572
202 ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),)
203 ifeq ($(IS_SUN)$(GCC_COMPILER),11)
204 CXXFLAGS += -Wa,--divide
208 ifeq ($(UNAME),) # for DJGPP, where uname doesn't exist
210 else ifneq ($(findstring -save-temps,$(CXXFLAGS)),-save-temps)
211 ifeq ($(SUN_COMPILER),0)
218 ###########################################################
219 ##### Not X86/X32/X64 #####
220 ###########################################################
223 ifeq ($(findstring -fPIC,$(CXXFLAGS)),)
227 # Add -pipe for everything except ARM (allow ARM-64 because they seems to have > 1 GB of memory)
229 ifeq ($(findstring -save-temps,$(CXXFLAGS)),)
234 # Aligned access required for -O3 and above due to vectorization
235 UNALIGNED_ACCESS := $(shell $(EGREP) -c "^[[:space:]]*//[[:space:]]*\#[[:space:]]*define[[:space:]]*CRYPTOPP_NO_UNALIGNED_DATA_ACCESS" config.h)
236 ifneq ($(UNALIGNED_ACCESS),0)
237 ifeq ($(findstring -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS,$(CXXFLAGS)),)
238 ifeq ($(findstring -O3,$(CXXFLAGS)),-O3)
239 CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
241 ifeq ($(findstring -O5,$(CXXFLAGS)),-O5)
242 CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
244 ifeq ($(findstring -Ofast,$(CXXFLAGS)),-Ofast)
245 CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
247 endif # CRYPTOPP_NO_UNALIGNED_DATA_ACCESS
248 endif # UNALIGNED_ACCESS
252 ###########################################################
254 ###########################################################
256 ifneq ($(IS_MINGW),0)
261 LDLIBS += -lnsl -lsocket
266 ifeq ($(findstring -fopenmp,$(CXXFLAGS)),-fopenmp)
267 ifeq ($(findstring -lgomp,$(LDLIBS)),)
273 ifneq ($(IS_DARWIN),0)
277 ifeq ($(IS_GCC_29),1)
278 CXXFLAGS += -fno-coalesce-templates -fno-coalesce-static-vtables
280 LDFLAGS += -flat_namespace -undefined suppress -m
284 # Add -errtags=yes to get the name for a warning suppression
285 ifneq ($(SUN_COMPILER),0) # override flags for CC Sun C++ compiler
286 IS_64 := $(shell isainfo -b 2>/dev/null | grep -i -c "64")
289 else ifeq ($(IS_64),0)
292 ifneq ($(SUNCC_513_OR_LATER),0)
300 CXXFLAGS += -template=no%extdef
301 SUN_CC10_BUGGY := $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: Sun .* 5\.10 .* (2009|2010/0[1-4])")
302 ifneq ($(SUN_CC10_BUGGY),0)
303 # -DCRYPTOPP_INCLUDE_VECTOR_CC is needed for Sun Studio 12u1 Sun C++ 5.10 SunOS_i386 128229-02 2009/09/21 and was fixed in May 2010
304 # remove it if you get "already had a body defined" errors in vector.cc
305 CXXFLAGS += -DCRYPTOPP_INCLUDE_VECTOR_CC
307 #ifneq ($SUNCC_512_OR_LATER),0)
308 #CXXFLAGS += -xarch=aes -D__AES__=1 -xarch=no%sse4_1 -xarch=no%sse4_2
315 # Undefined Behavior Sanitizer (UBsan) testing. There's no sense in
316 # allowing unaligned data access. There will too many findings.
317 ifeq ($(findstring ubsan,$(MAKECMDGOALS)),ubsan)
318 ifeq ($(findstring -fsanitize=undefined,$(CXXFLAGS)),)
319 CXXFLAGS += -fsanitize=undefined
321 ifeq ($(findstring -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS,$(CXXFLAGS)),)
322 CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
326 # Address Sanitizer (Asan) testing. Issue 'make asan'.
327 ifeq ($(findstring asan,$(MAKECMDGOALS)),asan)
328 ifeq ($(findstring -fsanitize=address,$(CXXFLAGS)),)
329 CXXFLAGS += -fsanitize=address
331 ifeq ($(findstring -fno-omit-frame-pointer,$(CXXFLAGS)),)
332 CXXFLAGS += -fno-omit-frame-pointer
336 # LD gold linker testing. Triggered by 'LD=ld.gold'.
337 ifeq ($(findstring ld.gold,$(LD)),ld.gold)
338 ifeq ($(findstring -fuse-ld=gold,$(CXXFLAGS)),)
339 ELF_FORMAT := $(shell file `which ld.gold` 2>&1 | cut -d":" -f 2 | $(EGREP) -i -c "elf")
340 ifneq ($(ELF_FORMAT),0)
341 LDFLAGS += -fuse-ld=gold
346 # Aligned access testing. Issue 'make aligned'.
347 ifneq ($(filter align aligned,$(MAKECMDGOALS)),)
348 ifeq ($(findstring -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS,$(CXXFLAGS)),)
349 CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
351 endif # Aligned access
353 # GCC code coverage. Issue 'make coverage'.
354 ifneq ($(filter coverage,$(MAKECMDGOALS)),)
355 ifeq ($(findstring -coverage,$(CXXFLAGS)),)
356 CXXFLAGS += -coverage
358 endif # GCC code coverage
360 # Debug testing on GNU systems. Triggered by -DDEBUG.
361 # Newlib test due to http://sourceware.org/bugzilla/show_bug.cgi?id=20268
362 ifneq ($(filter -DDEBUG -DDEBUG=1,$(CXXFLAGS)),)
363 USING_GLIBCXX := $(shell $(CXX) -x c++ $(CXXFLAGS) -E adhoc.cpp.proto 2>&1 | $(EGREP) -i -c "__GLIBCXX__")
364 ifneq ($(USING_GLIBCXX),0)
365 HAS_NEWLIB := $(shell $(CXX) -x c++ $(CXXFLAGS) -E adhoc.cpp.proto 2>&1 | $(EGREP) -i -c "__NEWLIB__")
366 ifeq ($(HAS_NEWLIB),0)
367 ifeq ($(findstring -D_GLIBCXX_DEBUG,$(CXXFLAGS)),)
368 CXXFLAGS += -D_GLIBCXX_DEBUG
371 endif # USING_GLIBCXX
372 endif # GNU Debug build
374 # Dead code stripping. Issue 'make lean'.
375 ifeq ($(findstring lean,$(MAKECMDGOALS)),lean)
376 ifeq ($(findstring -ffunction-sections,$(CXXFLAGS)),)
377 CXXFLAGS += -ffunction-sections
379 ifeq ($(findstring -fdata-sections,$(CXXFLAGS)),)
380 CXXFLAGS += -fdata-sections
382 ifneq ($(IS_DARWIN),0)
383 ifeq ($(findstring -Wl,-dead_strip,$(LDFLAGS)),)
384 LDFLAGS += -Wl,-dead_strip
386 else # BSD, Linux and Unix
387 ifeq ($(findstring -Wl,--gc-sections,$(LDFLAGS)),)
388 LDFLAGS += -Wl,--gc-sections
391 endif # Dead code stripping
393 # For Shared Objects, Diff, Dist/Zip rules
394 LIB_VER := $(shell $(EGREP) "define CRYPTOPP_VERSION" config.h | cut -d" " -f 3)
395 LIB_MAJOR := $(shell echo $(LIB_VER) | cut -c 1)
396 LIB_MINOR := $(shell echo $(LIB_VER) | cut -c 2)
397 LIB_PATCH := $(shell echo $(LIB_VER) | cut -c 3)
399 ifeq ($(strip $(LIB_PATCH)),)
403 ifeq ($(HAS_SOLIB_VERSION),1)
404 # Full version suffix for shared library
405 SOLIB_VERSION_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)
406 # Different patchlevels are compatible, minor versions are not
407 SOLIB_COMPAT_SUFFIX=.6
408 SOLIB_FLAGS=-Wl,-soname,libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
409 endif # HAS_SOLIB_VERSION
411 ###########################################################
412 ##### Source and object files #####
413 ###########################################################
415 # List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
416 SRCS := cryptlib.cpp cpu.cpp integer.cpp $(filter-out cryptlib.cpp cpu.cpp integer.cpp pch.cpp simple.cpp winpipes.cpp cryptlib_bds.cpp,$(wildcard *.cpp))
418 # Need CPU for X86/X64/X32 and ARM
419 ifeq ($(IS_X86)$(IS_X64)$(IS_ARM32)$(IS_ARM64),0000)
420 SRCS := $(filter-out cpu.cpp, $(SRCS))
422 # Need RDRAND for X86/X64/X32
423 ifeq ($(IS_X86)$(IS_X64),00)
424 SRCS := $(filter-out rdrand.cpp, $(SRCS))
427 ifneq ($(IS_MINGW),0)
431 # List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
432 OBJS := $(SRCS:.cpp=.o)
434 # List test.cpp first to tame C++ static initialization problems.
435 TESTSRCS := test.cpp bench1.cpp bench2.cpp validat1.cpp validat2.cpp validat3.cpp adhoc.cpp datatest.cpp regtest.cpp fipsalgt.cpp dlltest.cpp
436 TESTOBJS := $(TESTSRCS:.cpp=.o)
437 LIBOBJS := $(filter-out $(TESTOBJS),$(OBJS))
439 # List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
440 DLLSRCS := cryptlib.cpp cpu.cpp integer.cpp shacal2.cpp md5.cpp shark.cpp zinflate.cpp gf2n.cpp salsa.cpp xtr.cpp oaep.cpp polynomi.cpp rc2.cpp default.cpp wait.cpp wake.cpp twofish.cpp iterhash.cpp adler32.cpp elgamal.cpp marss.cpp blowfish.cpp ecp.cpp filters.cpp strciphr.cpp camellia.cpp ida.cpp zlib.cpp des.cpp crc.cpp algparam.cpp dessp.cpp tea.cpp eax.cpp network.cpp emsa2.cpp pkcspad.cpp squaretb.cpp idea.cpp authenc.cpp hmac.cpp zdeflate.cpp xtrcrypt.cpp queue.cpp mars.cpp rc5.cpp blake2.cpp hrtimer.cpp eprecomp.cpp hex.cpp dsa.cpp sha.cpp fips140.cpp gzip.cpp seal.cpp files.cpp base32.cpp vmac.cpp tigertab.cpp sharkbox.cpp safer.cpp randpool.cpp esign.cpp arc4.cpp osrng.cpp skipjack.cpp seed.cpp sha3.cpp sosemanuk.cpp bfinit.cpp rabin.cpp 3way.cpp rw.cpp rdrand.cpp rsa.cpp rdtables.cpp gost.cpp socketft.cpp tftables.cpp nbtheory.cpp panama.cpp modes.cpp rijndael.cpp casts.cpp chacha.cpp gfpcrypt.cpp poly1305.cpp dll.cpp ec2n.cpp blumshub.cpp algebra.cpp basecode.cpp base64.cpp cbcmac.cpp rc6.cpp dh2.cpp gf256.cpp mqueue.cpp misc.cpp pssr.cpp channels.cpp tiger.cpp cast.cpp rng.cpp square.cpp asn.cpp whrlpool.cpp md4.cpp dh.cpp ccm.cpp md2.cpp mqv.cpp gf2_32.cpp ttmac.cpp luc.cpp trdlocal.cpp pubkey.cpp gcm.cpp ripemd.cpp eccrypto.cpp serpent.cpp cmac.cpp
441 DLLOBJS := $(DLLSRCS:.cpp=.export.o)
444 LIBIMPORTOBJS := $(LIBOBJS:.o=.import.o)
445 TESTIMPORTOBJS := $(TESTOBJS:.o=.import.o)
446 DLLTESTOBJS := dlltest.dllonly.o
448 ###########################################################
449 ##### Targets and Recipes #####
450 ###########################################################
455 ifneq ($(IS_DARWIN),0)
456 static: libcryptopp.a
457 shared dynamic dylib: libcryptopp.dylib
459 static: libcryptopp.a
460 shared dynamic: libcryptopp.so$(SOLIB_VERSION_SUFFIX)
464 deps GNUmakefile.deps:
465 $(CXX) $(CXXFLAGS) -MM *.cpp > GNUmakefile.deps
467 # CXXFLAGS are tuned earlier.
468 .PHONY: asan ubsan align aligned
469 asan ubsan align aligned: libcryptopp.a cryptest.exe
471 # CXXFLAGS are tuned earlier. Applications must use linker flags
472 # -Wl,--gc-sections (Linux and Unix) or -Wl,-dead_strip (OS X)
474 lean: static dynamic cryptest.exe
476 # May want to export CXXFLAGS="-g3 -O1"
478 coverage: libcryptopp.a cryptest.exe
479 lcov --base-directory . --directory . --zerocounters -q
481 ./cryptest.exe tv all
482 lcov --base-directory . --directory . -c -o cryptest.info
483 lcov --remove cryptest.info "*test.*" "bench*.cpp" "validat*.*" "/usr/*" -o cryptest.info
484 rm -rf ./TestCoverage/
485 genhtml -o ./TestCoverage/ -t "cryptest.exe test coverage" --num-spaces 4 cryptest.info
488 test check: cryptest.exe
491 # Used to generate list of source files for Autotools, CMakeList, Android.mk, etc
494 $(info Library sources: $(filter-out fipstest.cpp $(TESTSRCS),$(SRCS)))
496 $(info Test sources: $(TESTSRCS))
498 # Directory we want (can't specify on Doygen command line)
499 DOCUMENT_DIRECTORY := ref$(LIB_VER)
500 # Directory Doxygen uses (specified in Doygen config file)
501 ifeq ($(wildcard Doxyfile),Doxyfile)
502 DOXYGEN_DIRECTORY := $(strip $(shell $(EGREP) "OUTPUT_DIRECTORY" Doxyfile | grep -v "\#" | cut -d "=" -f 2))
504 # Default directory (in case its missing in the config file)
505 ifeq ($(strip $(DOXYGEN_DIRECTORY)),)
506 DOXYGEN_DIRECTORY := html-docs
509 # Builds the documentation. Directory name is ref563, ref570, etc.
512 -$(RM) -r $(DOXYGEN_DIRECTORY)/ $(DOCUMENT_DIRECTORY)/ html-docs/
513 doxygen Doxyfile -d CRYPTOPP_DOXYGEN_PROCESSING
514 $(MV) $(DOXYGEN_DIRECTORY)/ $(DOCUMENT_DIRECTORY)/
515 -$(RM) CryptoPPRef.zip
516 zip -9 CryptoPPRef.zip -x ".*" -x "*/.*" -r $(DOCUMENT_DIRECTORY)/
520 -$(RM) libcryptopp.a libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.dylib cryptopp.dll libcryptopp.dll.a libcryptopp.import.a
521 ifeq ($(HAS_SOLIB_VERSION),1)
522 -$(RM) libcryptopp.so libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
524 -$(RM) adhoc.cpp.o adhoc.cpp.proto.o $(LIBOBJS) $(TESTOBJS) $(DLLOBJS) $(LIBIMPORTOBJS) $(TESTIMPORTOBJS) $(DLLTESTOBJS)
525 -$(RM) cryptest.exe dlltest.exe cryptest.import.exe cryptest.info ct rdrand-???.o
526 -$(RM) *.gcno *.gcda *.stackdump core-*
527 -$(RM) /tmp/adhoc.exe
528 ifneq ($(wildcard /tmp/cryptopp_test/),)
529 -$(RM) -r /tmp/cryptopp_test/
531 ifneq ($(wildcard *.exe.dSYM),)
532 -$(RM) -r *.exe.dSYM/
534 ifneq ($(wildcard *.dylib.dSYM),)
535 -$(RM) -r *.dylib.dSYM/
537 ifneq ($(wildcard cov-int/),)
543 -$(RM) adhoc.cpp adhoc.cpp.copied GNUmakefile.deps benchmarks.html cryptest.txt cryptest-*.txt
544 -$(RM) CMakeCache.txt Makefile CTestTestfile.cmake cmake_install.cmake cryptopp-config-version.cmake
545 -$(RM) cryptopp.tgz *.o *.bc *.ii *.s *~
546 ifneq ($(wildcard CMakeFiles/),)
547 -$(RM) -r CMakeFiles/
549 ifneq ($(wildcard $(DOCUMENT_DIRECTORY)/),)
550 -$(RM) -r $(DOCUMENT_DIRECTORY)/
552 ifneq ($(wildcard TestCoverage/),)
553 -$(RM) -r TestCoverage/
555 ifneq ($(wildcard cryptopp$(LIB_VER)\.*),)
556 -$(RM) cryptopp$(LIB_VER)\.*
558 ifneq ($(wildcard $(DOC_DIRECTORY)),)
559 -$(RM) -r $(DOC_DIRECTORY)
561 ifneq ($(wildcard CryptoPPRef.zip),)
562 -$(RM) CryptoPPRef.zip
567 $(MKDIR) -p $(DESTDIR)$(INCLUDEDIR)/cryptopp
568 $(CP) *.h $(DESTDIR)$(INCLUDEDIR)/cryptopp
569 -$(CHMOD) 0755 $(DESTDIR)$(INCLUDEDIR)/cryptopp
570 -$(CHMOD) 0644 $(DESTDIR)$(INCLUDEDIR)/cryptopp/*.h
571 ifneq ($(wildcard libcryptopp.a),)
572 $(MKDIR) -p $(DESTDIR)$(LIBDIR)
573 $(CP) libcryptopp.a $(DESTDIR)$(LIBDIR)
574 -$(CHMOD) 0644 $(DESTDIR)$(LIBDIR)/libcryptopp.a
576 ifneq ($(wildcard cryptest.exe),)
577 $(MKDIR) -p $(DESTDIR)$(BINDIR)
578 $(CP) cryptest.exe $(DESTDIR)$(BINDIR)
579 -$(CHMOD) 0755 $(DESTDIR)$(BINDIR)/cryptest.exe
580 $(MKDIR) -p $(DESTDIR)$(DATADIR)/cryptopp
581 $(CP) -r TestData $(DESTDIR)$(DATADIR)/cryptopp
582 $(CP) -r TestVectors $(DESTDIR)$(DATADIR)/cryptopp
583 -$(CHMOD) 0755 $(DESTDIR)$(DATADIR)/cryptopp
584 -$(CHMOD) 0755 $(DESTDIR)$(DATADIR)/cryptopp/TestData
585 -$(CHMOD) 0755 $(DESTDIR)$(DATADIR)/cryptopp/TestVectors
586 -$(CHMOD) 0644 $(DESTDIR)$(DATADIR)/cryptopp/TestData/*.dat
587 -$(CHMOD) 0644 $(DESTDIR)$(DATADIR)/cryptopp/TestVectors/*.txt
589 ifneq ($(wildcard libcryptopp.dylib),)
590 $(MKDIR) -p $(DESTDIR)$(LIBDIR)
591 $(CP) libcryptopp.dylib $(DESTDIR)$(LIBDIR)
592 -install_name_tool -id $(DESTDIR)$(LIBDIR)/libcryptopp.dylib $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
593 -$(CHMOD) 0755 $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
595 ifneq ($(wildcard libcryptopp.so$(SOLIB_VERSION_SUFFIX)),)
596 $(MKDIR) -p $(DESTDIR)$(LIBDIR)
597 $(CP) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)
598 -$(CHMOD) 0755 $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
599 ifeq ($(HAS_SOLIB_VERSION),1)
600 -$(LN) -sf libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so
601 $(LDCONF) $(DESTDIR)$(LIBDIR)
605 .PHONY: remove uninstall
607 -$(RM) -r $(DESTDIR)$(INCLUDEDIR)/cryptopp
608 -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.a
609 -$(RM) $(DESTDIR)$(BINDIR)/cryptest.exe
610 -$(RM) -r $(DESTDIR)$(DATADIR)/cryptopp
611 ifneq ($(IS_DARWIN),0)
612 -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
614 -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
615 ifeq ($(HAS_SOLIB_VERSION),1)
616 -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
617 -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so
618 $(LDCONF) $(DESTDIR)$(LIBDIR)
622 libcryptopp.a: $(LIBOBJS)
623 $(AR) $(ARFLAGS) $@ $(LIBOBJS)
628 ifeq ($(HAS_SOLIB_VERSION),1)
629 .PHONY: libcryptopp.so
630 libcryptopp.so: libcryptopp.so$(SOLIB_VERSION_SUFFIX) | so_warning
633 libcryptopp.so$(SOLIB_VERSION_SUFFIX): $(LIBOBJS)
634 $(CXX) -shared $(SOLIB_FLAGS) -o $@ $(CXXFLAGS) $(LDFLAGS) $(LIBOBJS) $(LDLIBS)
635 ifeq ($(HAS_SOLIB_VERSION),1)
636 -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.so
637 -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
640 libcryptopp.dylib: $(LIBOBJS)
641 $(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)
643 cryptest.exe: libcryptopp.a $(TESTOBJS)
644 $(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) ./libcryptopp.a $(LDFLAGS) $(LDLIBS)
646 # Makes it faster to test changes
648 $(CXX) -o ct $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS)
650 dll: cryptest.import.exe dlltest.exe
652 cryptopp.dll: $(DLLOBJS)
653 $(CXX) -shared -o $@ $(CXXFLAGS) $(DLLOBJS) $(LDFLAGS) $(LDLIBS) -Wl,--out-implib=libcryptopp.dll.a
655 libcryptopp.import.a: $(LIBIMPORTOBJS)
656 $(AR) $(ARFLAGS) $@ $(LIBIMPORTOBJS)
661 cryptest.import.exe: cryptopp.dll libcryptopp.import.a $(TESTIMPORTOBJS)
662 $(CXX) -o $@ $(CXXFLAGS) $(TESTIMPORTOBJS) -L. -lcryptopp.dll -lcryptopp.import $(LDFLAGS) $(LDLIBS)
664 dlltest.exe: cryptopp.dll $(DLLTESTOBJS)
665 $(CXX) -o $@ $(CXXFLAGS) $(DLLTESTOBJS) -L. -lcryptopp.dll $(LDFLAGS) $(LDLIBS)
667 # This recipe prepares the distro files
668 TEXT_FILES := *.h *.cpp adhoc.cpp.proto License.txt Readme.txt Install.txt Filelist.txt CMakeLists.txt config.compat Doxyfile cryptest* cryptlib* dlltest* cryptdll* *.sln *.vcxproj *.filters cryptopp.rc TestVectors/*.txt TestData/*.dat TestScripts/*.sh TestScripts/*.pl TestScripts/*.cmd
669 EXEC_FILES := GNUmakefile GNUmakefile-cross TestData/ TestVectors/ TestScripts/
671 ifeq ($(wildcard Filelist.txt),Filelist.txt)
672 DIST_FILES := $(shell cat Filelist.txt)
677 ifneq ($(IS_DARWIN),0)
678 sed -i '' -e's/[[:space:]]*$$//' *.compat *.sh *.h *.cpp *.sln *.vcxproj GNUmakefile GNUmakefile-cross
681 sed -i -e's/[[:space:]]*$$//' *.compat *.sh *.h *.cpp *.sln *.vcxproj GNUmakefile GNUmakefile-cross
687 -$(CHMOD) 0700 TestVectors/ TestData/ TestScripts/
688 -$(CHMOD) 0600 $(TEXT_FILES) *.asm *.S *.zip *.cmake TestVectors/*.txt TestData/*.dat
689 -$(CHMOD) 0700 $(EXEC_FILES) *.sh *.cmd TestScripts/*.sh TestScripts/*.pl TestScripts/*.cmd
690 -$(CHMOD) 0700 *.cmd *.sh GNUmakefile GNUmakefile-cross TestScripts/*.sh TestScripts/*.pl
691 -unix2dos --keepdate --quiet $(TEXT_FILES) *.asm *.cmd *.cmake TestScripts/*.pl TestScripts/*.cmd
692 -dos2unix --keepdate --quiet GNUmakefile GNUmakefile-cross *.S *.sh TestScripts/*.sh
693 ifneq ($(IS_DARWIN),0)
697 # Build the ZIP file with source files. No documentation.
699 zip dist: | distclean convert
700 zip -q -9 cryptopp$(LIB_VER).zip $(DIST_FILES)
702 # Build the ISO to transfer the ZIP to old distros via CDROM
705 ifneq ($(IS_DARWIN),0)
706 $(MKDIR) -p $(PWD)/cryptopp$(LIB_VER)
707 $(CP) cryptopp$(LIB_VER).zip $(PWD)/cryptopp$(LIB_VER)
708 hdiutil makehybrid -iso -joliet -o cryptopp$(LIB_VER).iso $(PWD)/cryptopp$(LIB_VER)
709 -$(RM) -r $(PWD)/cryptopp$(LIB_VER)
710 else ifneq ($(IS_LINUX),0)
711 $(MKDIR) -p $(PWD)/cryptopp$(LIB_VER)
712 $(CP) cryptopp$(LIB_VER).zip $(PWD)/cryptopp$(LIB_VER)
713 genisoimage -q -o cryptopp$(LIB_VER).iso $(PWD)/cryptopp$(LIB_VER)
714 -$(RM) -r $(PWD)/cryptopp$(LIB_VER)
717 # CRYPTOPP_CPU_SPEED in GHz
718 CRYPTOPP_CPU_SPEED ?= 2.4
719 .PHONY: bench benchmark benchmarks
720 bench benchmark benchmarks: cryptest.exe
721 rm -f benchmarks.html
722 echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">" >> benchmarks.html
723 echo "<HTML>" >> benchmarks.html
724 echo "<HEAD>" >> benchmarks.html
725 echo "<TITLE>Speed Comparison of Popular Crypto Algorithms</TITLE>" >> benchmarks.html
726 echo "</HEAD>" >> benchmarks.html
727 echo "<BODY>" >> benchmarks.html
728 echo "<H1><a href=\"http://www.cryptopp.com\">Crypto++</a>" $(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH) "Benchmarks</H1>" >> benchmarks.html
729 echo "<P>Here are speed benchmarks for some commonly used cryptographic algorithms.</P>" >> benchmarks.html
730 ./cryptest.exe b 3 $(CRYPTOPP_CPU_SPEED) >> benchmarks.html
731 echo "</BODY>" >> benchmarks.html
732 echo "</HTML>" >> benchmarks.html
734 adhoc.cpp: adhoc.cpp.proto
735 ifeq ($(wildcard adhoc.cpp),)
736 cp adhoc.cpp.proto adhoc.cpp
741 # Include dependencies, if present. You must issue `make deps` to create them.
742 ifeq ($(wildcard GNUmakefile.deps),GNUmakefile.deps)
743 -include GNUmakefile.deps
746 # MacPorts/GCC issue with init_priority. Apple/GCC and Fink/GCC are fine; limit to MacPorts.
747 # Also see http://lists.macosforge.org/pipermail/macports-users/2015-September/039223.html
748 ifeq ($(GCC_COMPILER)$(MACPORTS_COMPILER),11)
749 ifeq ($(findstring -DMACPORTS_GCC_COMPILER,$(CXXFLAGS)),)
751 $(CXX) $(CXXFLAGS) -DMACPORTS_GCC_COMPILER=1 -c cryptlib.cpp
753 $(CXX) $(CXXFLAGS) -DMACPORTS_GCC_COMPILER=1 -c cpu.cpp
757 # Only use CRYPTOPP_DATA_DIR if its not set in CXXFLAGS
758 ifeq ($(findstring -DCRYPTOPP_DATA_DIR,$(CXXFLAGS)),)
759 ifneq ($(strip $(CRYPTOPP_DATA_DIR)),)
760 validat%.o : validat%.cpp
761 $(CXX) $(CXXFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" -c $<
762 bench%.o : bench%.cpp
763 $(CXX) $(CXXFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" -c $<
764 datatest.o : datatest.cpp
765 $(CXX) $(CXXFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" -c $<
767 $(CXX) $(CXXFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" -c $<
772 $(CXX) $(CXXFLAGS) -DCRYPTOPP_DLL_ONLY -c $< -o $@
775 $(CXX) $(CXXFLAGS) -DCRYPTOPP_IMPORTS -c $< -o $@
778 $(CXX) $(CXXFLAGS) -DCRYPTOPP_EXPORTS -c $< -o $@
781 $(CXX) $(CXXFLAGS) -c $<
784 $(CXX) $(CXXFLAGS) -c $<
788 ifeq ($(HAS_SOLIB_VERSION),1)
789 $(info WARNING: Only the symlinks to the shared-object library have been updated.)
790 $(info WARNING: If the library is installed in a system directory you will need)
791 $(info WARNING: to run 'ldconfig' to update the shared-object library cache.)