1 CXXFLAGS ?= -DNDEBUG -g2 -Os -fPIC -pipe
3 # The following options reduce code size, but breaks link or makes link very slow on some systems
4 # CXXFLAGS += -ffunction-sections -fdata-sections
5 # LDFLAGS += -Wl,--gc-sections
17 CLANG_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c
"clang")
23 # Can be used by Android and Embeeded cross-compiles. Disable by
default because
24 # Android and embedded users typically don
't run this configuration.
25 HAS_SOLIB_VERSION ?= 0
27 # Default prefix for make install
32 # http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
34 DATADIR := $(PREFIX)/share
37 LIBDIR := $(PREFIX)/lib
40 BINDIR := $(PREFIX)/bin
43 INCLUDEDIR := $(PREFIX)/include
46 # We honor ARFLAGS, but the "v" option used by default causes a noisy make
51 # Sadly, we can't actually use GCC_PRAGMA_AWARE because of GCC bug 53431.
52 # Its a shame because GCC has so much to offer by the way of analysis.
54 ifneq ($(CLANG_COMPILER),0)
58 # iOS cross-compile configuration.
63 CXXFLAGS += $(IOS_FLAGS) -arch $(IOS_ARCH)
64 CXXFLAGS += -isysroot $(IOS_SYSROOT) -stdlib=libc++
71 # Android cross-compile configuration.
72 # See http://www.cryptopp.com/wiki/Android_(Command_Line).
73 ifeq ($(IS_ANDROID),1)
74 # CPP, CXX, AR, RANLIB, LD, etc are set in 'setenv-android.sh'
75 CXXFLAGS += $(AOSP_FLAGS) -DANDROID --sysroot=$(AOSP_SYSROOT)
76 CXXFLAGS += -Wa,--noexecstack -I$(AOSP_STL_INC)
78 # c++config.h shows up in odd places at times.
79 ifneq ($(AOSP_BITS_INC),)
80 CXXFLAGS += -I$(AOSP_BITS_INC)
83 LDLIBS += $(AOSP_STL_LIB)
86 # ARM embedded cross-compile configuration.
89 ifeq ($(IS_ARM_EMBEDDED),1)
90 # CPP, CXX, AR, RANLIB, LD, etc are set in
'setenv-embedded.sh'
91 CXXFLAGS += $(ARM_EMBEDDED_FLAGS) --sysroot=$(ARM_EMBEDDED_SYSROOT)
94 # Dead code stripping. Issue
'make lean'.
95 ifeq ($(findstring lean,$(MAKECMDGOALS)),lean)
96 ifeq ($(findstring -ffunction-sections,$(CXXFLAGS)),)
97 CXXFLAGS += -ffunction-sections
99 ifeq ($(findstring -fdata-sections,$(CXXFLAGS)),)
100 CXXFLAGS += -fdata-sections
103 ifeq ($(findstring -Wl,-dead_strip,$(LDFLAGS)),)
104 LDFLAGS += -Wl,-dead_strip
106 else # BSD, Linux and Unix
107 ifeq ($(findstring -Wl,--gc-sections,$(LDFLAGS)),)
108 LDFLAGS += -Wl,--gc-sections
111 endif # Dead code stripping
113 # List cryptlib.cpp first and cpu.cpp second in an attempt to tame C++ static initialization problems.
114 # The issue spills into POD data types of cpu.cpp due to the storage class of the bools, so cpu.cpp
115 # is the second candidate for explicit initialization order.
116 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))
117 OBJS := $(SRCS:.cpp=.o)
119 # test.o needs to be after bench.o
for cygwin 1.1.4 (possible ld bug?)
120 TESTSRCS := bench1.cpp bench2.cpp test.cpp validat1.cpp validat2.cpp validat3.cpp adhoc.cpp datatest.cpp regtest.cpp fipsalgt.cpp dlltest.cpp
121 TESTOBJS := $(TESTSRCS:.cpp=.o)
122 LIBOBJS := $(filter-out $(TESTOBJS),$(OBJS))
124 # For Shared Objects, Diff, Dist/Zip rules
125 LIB_VER := $(shell $(EGREP)
"define CRYPTOPP_VERSION" config.h | cut -d
" " -f 3)
126 LIB_MAJOR := $(shell echo $(LIB_VER) | cut -c 1)
127 LIB_MINOR := $(shell echo $(LIB_VER) | cut -c 2)
128 LIB_PATCH := $(shell echo $(LIB_VER) | cut -c 3)
130 ifeq ($(strip $(LIB_PATCH)),)
134 ifeq ($(HAS_SOLIB_VERSION),1)
135 # Full version suffix for shared library
136 SOLIB_VERSION_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)
137 # Different patchlevels are compatible, minor versions are not
138 SOLIB_COMPAT_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR)
139 SOLIB_FLAGS=-Wl,-soname,libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
140 endif # HAS_SOLIB_VERSION
146 static: libcryptopp.a
147 shared dynamic dylib: libcryptopp.dylib
149 static: libcryptopp.a
150 shared dynamic: libcryptopp.so$(SOLIB_VERSION_SUFFIX)
156 # CXXFLAGS are tuned earlier. Applications must use linker flags
157 # -Wl,--gc-sections (Linux and Unix) or -Wl,-dead_strip (OS X)
159 lean:
static dynamic cryptest.exe
163 -$(RM) cryptest.exe libcryptopp.a libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.dylib
164 ifeq ($(HAS_SOLIB_VERSION),1)
165 -$(RM) libcryptopp.so libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
167 -$(RM) adhoc.cpp.o adhoc.cpp.proto.o $(LIBOBJS) $(TESTOBJS)
168 ifneq ($(wildcard *.exe.dSYM),)
169 -$(RM) -r *.exe.dSYM/
171 ifneq ($(wildcard *.dylib.dSYM),)
172 -$(RM) -r *.dylib.dSYM/
177 -$(RM) adhoc.cpp adhoc.cpp.copied GNUmakefile.deps cryptopp.tgz *.o *.ii *.s
181 $(MKDIR) -p $(DESTDIR)$(INCLUDEDIR)/cryptopp
182 $(CP) *.h $(DESTDIR)$(INCLUDEDIR)/cryptopp
183 -$(CHMOD) 755 $(DESTDIR)$(INCLUDEDIR)/cryptopp
184 -$(CHMOD) 644 $(DESTDIR)$(INCLUDEDIR)/cryptopp