source: git/src-cryptopp/GNUmakefile

Last change on this file was e230cb0, checked in by David Stainton <dstainton415@…>, at 2016-10-12T13:27:29Z

Add cryptopp from tag CRYPTOPP_5_6_5

  • Property mode set to 100755
File size: 28.3 KB
Line 
1###########################################################
2#####        System Attributes and Programs           #####
3###########################################################
4
5AR ?= ar
6ARFLAGS ?= -cr # ar needs the dash on OpenBSD
7RANLIB ?= ranlib
8
9CP ?= cp
10MV ?= mv
11EGREP ?= egrep
12CHMOD ?= chmod
13MKDIR ?= mkdir
14LN ?= ln -sf
15LDCONF ?= /sbin/ldconfig -n
16UNAME := $(shell uname)
17
18IS_X86 := $(shell uname -m | $(EGREP) -v "x86_64" | $(EGREP) -i -c "i.86|x86|i86")
19IS_X32 ?= 0
20IS_X64 := $(shell uname -m | $(EGREP) -i -c "(_64|d64)")
21IS_PPC := $(shell uname -m | $(EGREP) -i -c "ppc|power")
22IS_ARM32 := $(shell uname -m | $(EGREP) -i -c "arm")
23IS_ARM64 := $(shell uname -m | $(EGREP) -i -c "aarch64")
24
25IS_SUN := $(shell uname | $(EGREP) -i -c "SunOS")
26IS_LINUX := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "Linux")
27IS_MINGW := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "MinGW")
28IS_CYGWIN := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "Cygwin")
29IS_DARWIN := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "Darwin")
30IS_NETBSD := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "NetBSD")
31
32SUN_COMPILER := $(shell $(CXX) -V 2>&1 | $(EGREP) -i -c "CC: (Sun|Studio)")
33GCC_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -v "clang" | $(EGREP) -i -c "(gcc|g\+\+)")
34CLANG_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "clang")
35INTEL_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "\(icc\)")
36MACPORTS_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "macports")
37
38# Sun Studio 12.0 provides SunCC 0x0510; and Sun Studio 12.3 provides SunCC 0x0512
39SUNCC_510_OR_LATER := $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: (Sun|Studio) .* (5\.1[0-9]|5\.[2-9]|6\.)")
40SUNCC_511_OR_LATER := $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: (Sun|Studio) .* (5\.1[1-9]|5\.[2-9]|6\.)")
41SUNCC_512_OR_LATER := $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: (Sun|Studio) .* (5\.1[2-9]|5\.[2-9]|6\.)")
42SUNCC_513_OR_LATER := $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: (Sun|Studio) .* (5\.1[3-9]|5\.[2-9]|6\.)")
43
44HAS_SOLIB_VERSION := $(IS_LINUX)
45
46# Fixup SunOS
47ifeq ($(IS_SUN),1)
48IS_X86 := $(shell isainfo -k 2>/dev/null | grep -i -c "i386")
49IS_X64 := $(shell isainfo -k 2>/dev/null | grep -i -c "amd64")
50endif
51
52###########################################################
53#####                General Variables                #####
54###########################################################
55
56# Base CXXFLAGS used if the user did not specify them
57ifeq ($(SUN_COMPILER),1)
58  ifeq ($(SUNCC_512_OR_LATER),1)
59    CXXFLAGS ?= -DNDEBUG -g3 -xO2
60  else
61    CXXFLAGS ?= -DNDEBUG -g -xO2
62  endif
63else
64  CXXFLAGS ?= -DNDEBUG -g2 -O2
65endif
66
67# Default prefix for make install
68ifeq ($(PREFIX),)
69PREFIX = /usr/local
70endif
71
72# http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
73ifeq ($(DATADIR),)
74DATADIR := $(PREFIX)/share
75endif
76ifeq ($(LIBDIR),)
77LIBDIR := $(PREFIX)/lib
78endif
79ifeq ($(BINDIR),)
80BINDIR := $(PREFIX)/bin
81endif
82ifeq ($(INCLUDEDIR),)
83INCLUDEDIR := $(PREFIX)/include
84endif
85
86# Fix CXX on Cygwin 1.1.4
87ifeq ($(CXX),gcc)
88CXX := g++
89endif
90
91# We honor ARFLAGS, but the "v" option used by default causes a noisy make
92ifeq ($(ARFLAGS),rv)
93ARFLAGS = r
94endif
95
96###########################################################
97#####               X86/X32/X64 Options               #####
98###########################################################
99
100ifneq ($(IS_X86)$(IS_X32)$(IS_X64),000)
101
102# Fixup. Clang integrated assembler will be used (-Wa,-q)
103ifneq ($(MACPORTS_COMPILER),1)
104  IS_GAS := $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler")
105endif
106
107ifneq ($(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]\.)")
111endif
112
113ifneq ($(IS_GAS),0)
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])")
117endif
118
119ICC111_OR_LATER := $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\) ([2-9][0-9]|1[2-9]|11\.[1-9])")
120
121# Add -fPIC for targets *except* X86, X32, Cygwin or MinGW
122ifeq ($(IS_X86)$(IS_X32)$(IS_CYGWIN)$(IS_MINGW)$(SUN_COMPILER),00000)
123 ifeq ($(findstring -fPIC,$(CXXFLAGS)),)
124   CXXFLAGS += -fPIC
125 endif
126endif
127
128# Guard use of -march=native
129ifeq ($(GCC42_OR_LATER)$(IS_NETBSD),10)
130   CXXFLAGS += -march=native
131else ifneq ($(CLANG_COMPILER)$(INTEL_COMPILER),00)
132   CXXFLAGS += -march=native
133else
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)
139    CXXFLAGS += -m64
140  else ifeq ($(SUN_COMPILER)$(IS_X86),01)
141    CXXFLAGS += -m32
142  endif # X86/X32/X64
143endif
144
145# Aligned access required for -O3 and above due to vectorization
146UNALIGNED_ACCESS := $(shell $(EGREP) -c "^[[:space:]]*//[[:space:]]*\#[[:space:]]*define[[:space:]]*CRYPTOPP_NO_UNALIGNED_DATA_ACCESS" config.h)
147ifneq ($(UNALIGNED_ACCESS),0)
148ifeq ($(findstring -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS,$(CXXFLAGS)),)
149ifeq ($(findstring -O3,$(CXXFLAGS)),-O3)
150CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
151endif # -O3
152ifeq ($(findstring -O5,$(CXXFLAGS)),-O5)
153CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
154endif # -O5
155ifeq ($(findstring -Ofast,$(CXXFLAGS)),-Ofast)
156CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
157endif # -Ofast
158endif # CRYPTOPP_NO_UNALIGNED_DATA_ACCESS
159endif # UNALIGNED_ACCESS
160
161ifneq ($(INTEL_COMPILER),0)
162CXXFLAGS += -wd68 -wd186 -wd279 -wd327 -wd161 -wd3180
163ifeq ($(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
166CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
167endif
168endif
169
170# .intel_syntax wasn't supported until GNU assembler 2.10
171ifeq ($(GCC_COMPILER)$(MACPORTS_COMPILER)$(GAS210_OR_LATER),100)
172CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
173else
174ifeq ($(GCC_COMPILER)$(MACPORTS_COMPILER)$(GAS217_OR_LATER),100)
175CXXFLAGS += -DCRYPTOPP_DISABLE_SSSE3
176else
177ifeq ($(GCC_COMPILER)$(MACPORTS_COMPILER)$(GAS219_OR_LATER),100)
178CXXFLAGS += -DCRYPTOPP_DISABLE_AESNI
179endif
180endif
181endif
182
183# Tell MacPorts GCC to use Clang integrated assembler
184#   http://github.com/weidai11/cryptopp/issues/190
185ifeq ($(GCC_COMPILER)$(MACPORTS_COMPILER),11)
186ifneq ($(findstring -Wa,-q,$(CXXFLAGS)),-Wa,-q)
187CXXFLAGS += -Wa,-q
188endif
189ifneq ($(findstring -Wa,-q,$(CXXFLAGS)),-DCRYPTOPP_CLANG_INTEGRATED_ASSEMBLER)
190CXXFLAGS += -DCRYPTOPP_CLANG_INTEGRATED_ASSEMBLER=1
191endif
192endif
193
194# GCC on Solaris needs -m64. Otherwise, i386 is default
195#   http://github.com/weidai11/cryptopp/issues/230
196ifeq ($(IS_SUN)$(GCC_COMPILER)$(IS_X64),111)
197CXXFLAGS += -m64
198endif
199
200# Allow use of "/" operator for GNU Assembler.
201#   http://sourceware.org/bugzilla/show_bug.cgi?id=4572
202ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),)
203ifeq ($(IS_SUN)$(GCC_COMPILER),11)
204CXXFLAGS += -Wa,--divide
205endif
206endif
207
208ifeq ($(UNAME),)        # for DJGPP, where uname doesn't exist
209CXXFLAGS += -mbnu210
210else ifneq ($(findstring -save-temps,$(CXXFLAGS)),-save-temps)
211ifeq ($(SUN_COMPILER),0)
212CXXFLAGS += -pipe
213endif
214endif
215
216else
217
218###########################################################
219#####                 Not X86/X32/X64                 #####
220###########################################################
221
222# Add PIC
223ifeq ($(findstring -fPIC,$(CXXFLAGS)),)
224  CXXFLAGS += -fPIC
225endif
226
227# Add -pipe for everything except ARM (allow ARM-64 because they seems to have > 1 GB of memory)
228ifeq ($(IS_ARM32),0)
229ifeq ($(findstring -save-temps,$(CXXFLAGS)),)
230CXXFLAGS += -pipe
231endif
232endif
233
234# Aligned access required for -O3 and above due to vectorization
235UNALIGNED_ACCESS := $(shell $(EGREP) -c "^[[:space:]]*//[[:space:]]*\#[[:space:]]*define[[:space:]]*CRYPTOPP_NO_UNALIGNED_DATA_ACCESS" config.h)
236ifneq ($(UNALIGNED_ACCESS),0)
237ifeq ($(findstring -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS,$(CXXFLAGS)),)
238ifeq ($(findstring -O3,$(CXXFLAGS)),-O3)
239CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
240endif # -O3
241ifeq ($(findstring -O5,$(CXXFLAGS)),-O5)
242CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
243endif # -O5
244ifeq ($(findstring -Ofast,$(CXXFLAGS)),-Ofast)
245CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
246endif # -Ofast
247endif # CRYPTOPP_NO_UNALIGNED_DATA_ACCESS
248endif # UNALIGNED_ACCESS
249
250endif   # IS_X86
251
252###########################################################
253#####                      Common                     #####
254###########################################################
255
256ifneq ($(IS_MINGW),0)
257LDLIBS += -lws2_32
258endif
259
260ifneq ($(IS_SUN),0)
261LDLIBS += -lnsl -lsocket
262endif
263
264ifeq ($(IS_LINUX),1)
265LDFLAGS += -pthread
266ifeq ($(findstring -fopenmp,$(CXXFLAGS)),-fopenmp)
267ifeq ($(findstring -lgomp,$(LDLIBS)),)
268LDLIBS += -lgomp
269endif # LDLIBS
270endif # OpenMP
271endif # IS_LINUX
272
273ifneq ($(IS_DARWIN),0)
274AR = libtool
275ARFLAGS = -static -o
276CXX ?= c++
277ifeq ($(IS_GCC_29),1)
278CXXFLAGS += -fno-coalesce-templates -fno-coalesce-static-vtables
279LDLIBS += -lstdc++
280LDFLAGS += -flat_namespace -undefined suppress -m
281endif
282endif
283
284# Add -errtags=yes to get the name for a warning suppression
285ifneq ($(SUN_COMPILER),0)       # override flags for CC Sun C++ compiler
286IS_64 := $(shell isainfo -b 2>/dev/null | grep -i -c "64")
287ifeq ($(IS_64),1)
288CXXFLAGS += -m64
289else ifeq ($(IS_64),0)
290CXXFLAGS += -m32
291endif
292ifneq ($(SUNCC_513_OR_LATER),0)
293CXXFLAGS += -native
294endif
295# Add for non-i386
296ifneq ($(IS_X86),1)
297CXXFLAGS += -KPIC
298endif
299# Add to all Solaris
300CXXFLAGS += -template=no%extdef
301SUN_CC10_BUGGY := $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: Sun .* 5\.10 .* (2009|2010/0[1-4])")
302ifneq ($(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
305CXXFLAGS += -DCRYPTOPP_INCLUDE_VECTOR_CC
306endif
307#ifneq ($SUNCC_512_OR_LATER),0)
308#CXXFLAGS += -xarch=aes -D__AES__=1 -xarch=no%sse4_1 -xarch=no%sse4_2
309#endif
310AR = $(CXX)
311ARFLAGS = -xar -o
312RANLIB = true
313endif
314
315# Undefined Behavior Sanitizer (UBsan) testing. There's no sense in
316#   allowing unaligned data access. There will too many findings.
317ifeq ($(findstring ubsan,$(MAKECMDGOALS)),ubsan)
318ifeq ($(findstring -fsanitize=undefined,$(CXXFLAGS)),)
319CXXFLAGS += -fsanitize=undefined
320endif # CXXFLAGS
321ifeq ($(findstring -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS,$(CXXFLAGS)),)
322CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
323endif # CXXFLAGS
324endif # UBsan
325
326# Address Sanitizer (Asan) testing. Issue 'make asan'.
327ifeq ($(findstring asan,$(MAKECMDGOALS)),asan)
328ifeq ($(findstring -fsanitize=address,$(CXXFLAGS)),)
329CXXFLAGS += -fsanitize=address
330endif # CXXFLAGS
331ifeq ($(findstring -fno-omit-frame-pointer,$(CXXFLAGS)),)
332CXXFLAGS += -fno-omit-frame-pointer
333endif # CXXFLAGS
334endif # Asan
335
336# LD gold linker testing. Triggered by 'LD=ld.gold'.
337ifeq ($(findstring ld.gold,$(LD)),ld.gold)
338ifeq ($(findstring -fuse-ld=gold,$(CXXFLAGS)),)
339ELF_FORMAT := $(shell file `which ld.gold` 2>&1 | cut -d":" -f 2 | $(EGREP) -i -c "elf")
340ifneq ($(ELF_FORMAT),0)
341LDFLAGS += -fuse-ld=gold
342endif # ELF/ELF64
343endif # CXXFLAGS
344endif # Gold
345
346# Aligned access testing. Issue 'make aligned'.
347ifneq ($(filter align aligned,$(MAKECMDGOALS)),)
348ifeq ($(findstring -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS,$(CXXFLAGS)),)
349CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
350endif # CXXFLAGS
351endif # Aligned access
352
353# GCC code coverage. Issue 'make coverage'.
354ifneq ($(filter coverage,$(MAKECMDGOALS)),)
355ifeq ($(findstring -coverage,$(CXXFLAGS)),)
356CXXFLAGS += -coverage
357endif # -coverage
358endif # GCC code coverage
359
360# Debug testing on GNU systems. Triggered by -DDEBUG.
361#   Newlib test due to http://sourceware.org/bugzilla/show_bug.cgi?id=20268
362ifneq ($(filter -DDEBUG -DDEBUG=1,$(CXXFLAGS)),)
363USING_GLIBCXX := $(shell $(CXX) -x c++ $(CXXFLAGS) -E adhoc.cpp.proto 2>&1 | $(EGREP) -i -c "__GLIBCXX__")
364ifneq ($(USING_GLIBCXX),0)
365HAS_NEWLIB := $(shell $(CXX) -x c++ $(CXXFLAGS) -E adhoc.cpp.proto 2>&1 | $(EGREP) -i -c "__NEWLIB__")
366ifeq ($(HAS_NEWLIB),0)
367ifeq ($(findstring -D_GLIBCXX_DEBUG,$(CXXFLAGS)),)
368CXXFLAGS += -D_GLIBCXX_DEBUG
369endif # CXXFLAGS
370endif # NAS_NEWLIB
371endif # USING_GLIBCXX
372endif # GNU Debug build
373
374# Dead code stripping. Issue 'make lean'.
375ifeq ($(findstring lean,$(MAKECMDGOALS)),lean)
376ifeq ($(findstring -ffunction-sections,$(CXXFLAGS)),)
377CXXFLAGS += -ffunction-sections
378endif # CXXFLAGS
379ifeq ($(findstring -fdata-sections,$(CXXFLAGS)),)
380CXXFLAGS += -fdata-sections
381endif # CXXFLAGS
382ifneq ($(IS_DARWIN),0)
383ifeq ($(findstring -Wl,-dead_strip,$(LDFLAGS)),)
384LDFLAGS += -Wl,-dead_strip
385endif # CXXFLAGS
386else # BSD, Linux and Unix
387ifeq ($(findstring -Wl,--gc-sections,$(LDFLAGS)),)
388LDFLAGS += -Wl,--gc-sections
389endif # LDFLAGS
390endif # MAKECMDGOALS
391endif # Dead code stripping
392
393# For Shared Objects, Diff, Dist/Zip rules
394LIB_VER := $(shell $(EGREP) "define CRYPTOPP_VERSION" config.h | cut -d" " -f 3)
395LIB_MAJOR := $(shell echo $(LIB_VER) | cut -c 1)
396LIB_MINOR := $(shell echo $(LIB_VER) | cut -c 2)
397LIB_PATCH := $(shell echo $(LIB_VER) | cut -c 3)
398
399ifeq ($(strip $(LIB_PATCH)),)
400LIB_PATCH := 0
401endif
402
403ifeq ($(HAS_SOLIB_VERSION),1)
404# Full version suffix for shared library
405SOLIB_VERSION_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)
406# Different patchlevels are compatible, minor versions are not
407SOLIB_COMPAT_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR)
408SOLIB_FLAGS=-Wl,-soname,libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
409endif # HAS_SOLIB_VERSION
410
411###########################################################
412#####              Source and object files            #####
413###########################################################
414
415# List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
416SRCS := 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))
417
418# Need CPU for X86/X64/X32 and ARM
419ifeq ($(IS_X86)$(IS_X64)$(IS_ARM32)$(IS_ARM64),0000)
420  SRCS := $(filter-out cpu.cpp, $(SRCS))
421endif
422# Need RDRAND for X86/X64/X32
423ifeq ($(IS_X86)$(IS_X64),00)
424  SRCS := $(filter-out rdrand.cpp, $(SRCS))
425endif
426
427ifneq ($(IS_MINGW),0)
428SRCS += winpipes.cpp
429endif
430
431# List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
432OBJS := $(SRCS:.cpp=.o)
433
434# List test.cpp first to tame C++ static initialization problems.
435TESTSRCS := test.cpp bench1.cpp bench2.cpp validat1.cpp validat2.cpp validat3.cpp adhoc.cpp datatest.cpp regtest.cpp fipsalgt.cpp dlltest.cpp
436TESTOBJS := $(TESTSRCS:.cpp=.o)
437LIBOBJS := $(filter-out $(TESTOBJS),$(OBJS))
438
439# List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
440DLLSRCS := 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
441DLLOBJS := $(DLLSRCS:.cpp=.export.o)
442
443# Import lib testing
444LIBIMPORTOBJS := $(LIBOBJS:.o=.import.o)
445TESTIMPORTOBJS := $(TESTOBJS:.o=.import.o)
446DLLTESTOBJS := dlltest.dllonly.o
447
448###########################################################
449#####                Targets and Recipes              #####
450###########################################################
451
452.PHONY: all
453all: cryptest.exe
454
455ifneq ($(IS_DARWIN),0)
456static: libcryptopp.a
457shared dynamic dylib: libcryptopp.dylib
458else
459static: libcryptopp.a
460shared dynamic: libcryptopp.so$(SOLIB_VERSION_SUFFIX)
461endif
462
463.PHONY: deps
464deps GNUmakefile.deps:
465        $(CXX) $(CXXFLAGS) -MM *.cpp > GNUmakefile.deps
466
467# CXXFLAGS are tuned earlier.
468.PHONY: asan ubsan align aligned
469asan ubsan align aligned: libcryptopp.a cryptest.exe
470
471# CXXFLAGS are tuned earlier. Applications must use linker flags
472#  -Wl,--gc-sections (Linux and Unix) or -Wl,-dead_strip (OS X)
473.PHONY: lean
474lean: static dynamic cryptest.exe
475
476# May want to export CXXFLAGS="-g3 -O1"
477.PHONY: coverage
478coverage: libcryptopp.a cryptest.exe
479        lcov --base-directory . --directory . --zerocounters -q
480        ./cryptest.exe v
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
486
487.PHONY: test check
488test check: cryptest.exe
489        ./cryptest.exe v
490
491# Used to generate list of source files for Autotools, CMakeList, Android.mk, etc
492.PHONY: sources
493sources:
494        $(info Library sources: $(filter-out fipstest.cpp $(TESTSRCS),$(SRCS)))
495        $(info )
496        $(info Test sources: $(TESTSRCS))
497
498# Directory we want (can't specify on Doygen command line)
499DOCUMENT_DIRECTORY := ref$(LIB_VER)
500# Directory Doxygen uses (specified in Doygen config file)
501ifeq ($(wildcard Doxyfile),Doxyfile)
502DOXYGEN_DIRECTORY := $(strip $(shell $(EGREP) "OUTPUT_DIRECTORY" Doxyfile | grep -v "\#" | cut -d "=" -f 2))
503endif
504# Default directory (in case its missing in the config file)
505ifeq ($(strip $(DOXYGEN_DIRECTORY)),)
506DOXYGEN_DIRECTORY := html-docs
507endif
508
509# Builds the documentation. Directory name is ref563, ref570, etc.
510.PHONY: docs html
511docs html:
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)/
517
518.PHONY: clean
519clean:
520        -$(RM) libcryptopp.a libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.dylib cryptopp.dll libcryptopp.dll.a libcryptopp.import.a
521ifeq ($(HAS_SOLIB_VERSION),1)
522        -$(RM) libcryptopp.so libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
523endif
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
528ifneq ($(wildcard /tmp/cryptopp_test/),)
529        -$(RM) -r /tmp/cryptopp_test/
530endif
531ifneq ($(wildcard *.exe.dSYM),)
532        -$(RM) -r *.exe.dSYM/
533endif
534ifneq ($(wildcard *.dylib.dSYM),)
535        -$(RM) -r *.dylib.dSYM/
536endif
537ifneq ($(wildcard cov-int/),)
538        -$(RM) -r cov-int/
539endif
540
541.PHONY: distclean
542distclean: clean
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 *~
546ifneq ($(wildcard CMakeFiles/),)
547        -$(RM) -r CMakeFiles/
548endif
549ifneq ($(wildcard $(DOCUMENT_DIRECTORY)/),)
550        -$(RM) -r $(DOCUMENT_DIRECTORY)/
551endif
552ifneq ($(wildcard TestCoverage/),)
553        -$(RM) -r TestCoverage/
554endif
555ifneq ($(wildcard cryptopp$(LIB_VER)\.*),)
556        -$(RM) cryptopp$(LIB_VER)\.*
557endif
558ifneq ($(wildcard $(DOC_DIRECTORY)),)
559        -$(RM) -r $(DOC_DIRECTORY)
560endif
561ifneq ($(wildcard CryptoPPRef.zip),)
562        -$(RM) CryptoPPRef.zip
563endif
564
565.PHONY: install
566install:
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
571ifneq ($(wildcard libcryptopp.a),)
572        $(MKDIR) -p $(DESTDIR)$(LIBDIR)
573        $(CP) libcryptopp.a $(DESTDIR)$(LIBDIR)
574        -$(CHMOD) 0644 $(DESTDIR)$(LIBDIR)/libcryptopp.a
575endif
576ifneq ($(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
588endif
589ifneq ($(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
594endif
595ifneq ($(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)
599ifeq ($(HAS_SOLIB_VERSION),1)
600        -$(LN) -sf libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so
601        $(LDCONF) $(DESTDIR)$(LIBDIR)
602endif
603endif
604
605.PHONY: remove uninstall
606remove 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
611ifneq ($(IS_DARWIN),0)
612        -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
613else
614        -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
615ifeq ($(HAS_SOLIB_VERSION),1)
616        -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
617        -$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so
618        $(LDCONF) $(DESTDIR)$(LIBDIR)
619endif
620endif
621
622libcryptopp.a: $(LIBOBJS)
623        $(AR) $(ARFLAGS) $@ $(LIBOBJS)
624ifeq ($(IS_SUN),0)
625        $(RANLIB) $@
626endif
627
628ifeq ($(HAS_SOLIB_VERSION),1)
629.PHONY: libcryptopp.so
630libcryptopp.so: libcryptopp.so$(SOLIB_VERSION_SUFFIX) | so_warning
631endif
632
633libcryptopp.so$(SOLIB_VERSION_SUFFIX): $(LIBOBJS)
634        $(CXX) -shared $(SOLIB_FLAGS) -o $@ $(CXXFLAGS) $(LDFLAGS) $(LIBOBJS) $(LDLIBS)
635ifeq ($(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)
638endif
639
640libcryptopp.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)
642
643cryptest.exe: libcryptopp.a $(TESTOBJS)
644        $(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) ./libcryptopp.a $(LDFLAGS) $(LDLIBS)
645
646# Makes it faster to test changes
647nolib: $(OBJS)
648        $(CXX) -o ct $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS)
649
650dll: cryptest.import.exe dlltest.exe
651
652cryptopp.dll: $(DLLOBJS)
653        $(CXX) -shared -o $@ $(CXXFLAGS) $(DLLOBJS) $(LDFLAGS) $(LDLIBS) -Wl,--out-implib=libcryptopp.dll.a
654
655libcryptopp.import.a: $(LIBIMPORTOBJS)
656        $(AR) $(ARFLAGS) $@ $(LIBIMPORTOBJS)
657ifeq ($(IS_SUN),0)
658        $(RANLIB) $@
659endif
660
661cryptest.import.exe: cryptopp.dll libcryptopp.import.a $(TESTIMPORTOBJS)
662        $(CXX) -o $@ $(CXXFLAGS) $(TESTIMPORTOBJS) -L. -lcryptopp.dll -lcryptopp.import $(LDFLAGS) $(LDLIBS)
663
664dlltest.exe: cryptopp.dll $(DLLTESTOBJS)
665        $(CXX) -o $@ $(CXXFLAGS) $(DLLTESTOBJS) -L. -lcryptopp.dll $(LDFLAGS) $(LDLIBS)
666
667# This recipe prepares the distro files
668TEXT_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
669EXEC_FILES := GNUmakefile GNUmakefile-cross TestData/ TestVectors/ TestScripts/
670
671ifeq ($(wildcard Filelist.txt),Filelist.txt)
672DIST_FILES := $(shell cat Filelist.txt)
673endif
674
675.PHONY: trim
676trim:
677ifneq ($(IS_DARWIN),0)
678        sed -i '' -e's/[[:space:]]*$$//' *.compat *.sh *.h *.cpp *.sln *.vcxproj GNUmakefile GNUmakefile-cross
679        make convert
680else
681        sed -i -e's/[[:space:]]*$$//' *.compat *.sh *.h *.cpp *.sln *.vcxproj GNUmakefile GNUmakefile-cross
682        make convert
683endif
684
685.PHONY: convert
686convert:
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
693ifneq ($(IS_DARWIN),0)
694        -xattr -c *
695endif
696
697# Build the ZIP file with source files. No documentation.
698.PHONY: zip dist
699zip dist: | distclean convert
700        zip -q -9 cryptopp$(LIB_VER).zip $(DIST_FILES)
701
702# Build the ISO to transfer the ZIP to old distros via CDROM
703.PHONY: iso
704iso: | zip
705ifneq ($(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)
710else 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)
715endif
716
717# CRYPTOPP_CPU_SPEED in GHz
718CRYPTOPP_CPU_SPEED ?= 2.4
719.PHONY: bench benchmark benchmarks
720bench 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
733
734adhoc.cpp: adhoc.cpp.proto
735ifeq ($(wildcard adhoc.cpp),)
736        cp adhoc.cpp.proto adhoc.cpp
737else
738        touch adhoc.cpp
739endif
740
741# Include dependencies, if present. You must issue `make deps` to create them.
742ifeq ($(wildcard GNUmakefile.deps),GNUmakefile.deps)
743-include GNUmakefile.deps
744endif # Dependencies
745
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
748ifeq ($(GCC_COMPILER)$(MACPORTS_COMPILER),11)
749ifeq ($(findstring -DMACPORTS_GCC_COMPILER,$(CXXFLAGS)),)
750cryptlib.o:
751        $(CXX) $(CXXFLAGS) -DMACPORTS_GCC_COMPILER=1 -c cryptlib.cpp
752cpu.o:
753        $(CXX) $(CXXFLAGS) -DMACPORTS_GCC_COMPILER=1 -c cpu.cpp
754endif
755endif
756
757# Only use CRYPTOPP_DATA_DIR if its not set in CXXFLAGS
758ifeq ($(findstring -DCRYPTOPP_DATA_DIR,$(CXXFLAGS)),)
759ifneq ($(strip $(CRYPTOPP_DATA_DIR)),)
760validat%.o : validat%.cpp
761        $(CXX) $(CXXFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" -c $<
762bench%.o : bench%.cpp
763        $(CXX) $(CXXFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" -c $<
764datatest.o : datatest.cpp
765        $(CXX) $(CXXFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" -c $<
766test.o : test.cpp
767        $(CXX) $(CXXFLAGS) -DCRYPTOPP_DATA_DIR=\"$(CRYPTOPP_DATA_DIR)\" -c $<
768endif
769endif
770
771%.dllonly.o : %.cpp
772        $(CXX) $(CXXFLAGS) -DCRYPTOPP_DLL_ONLY -c $< -o $@
773
774%.import.o : %.cpp
775        $(CXX) $(CXXFLAGS) -DCRYPTOPP_IMPORTS -c $< -o $@
776
777%.export.o : %.cpp
778        $(CXX) $(CXXFLAGS) -DCRYPTOPP_EXPORTS -c $< -o $@
779
780%.bc : %.cpp
781        $(CXX) $(CXXFLAGS) -c $<
782
783%.o : %.cpp
784        $(CXX) $(CXXFLAGS) -c $<
785
786.PHONY: so_warning
787so_warning:
788ifeq ($(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.)
792        $(info )
793endif
Note: See TracBrowser for help on using the repository browser.