2015-11-05 06:59:46 +00:00
|
|
|
CXXFLAGS ?= -DNDEBUG -g2 -Os -fPIC -pipe
|
2015-06-08 11:50:22 +00:00
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
# The following options reduce code size, but breaks link or makes link very slow on some systems
|
2015-07-31 18:24:49 +00:00
|
|
|
# CXXFLAGS += -ffunction-sections -fdata-sections
|
|
|
|
# LDFLAGS += -Wl,--gc-sections
|
|
|
|
|
2015-12-31 06:43:42 +00:00
|
|
|
AR ?= ar
|
|
|
|
ARFLAGS ?= cr
|
2015-11-05 06:59:46 +00:00
|
|
|
RANLIB ?= ranlib
|
2015-12-31 06:43:42 +00:00
|
|
|
CP ?= cp
|
|
|
|
MV ?= mv
|
|
|
|
CHMOD ?= chmod
|
|
|
|
MKDIR ?= mkdir
|
|
|
|
EGREP ?= egrep
|
2015-12-26 18:57:04 +00:00
|
|
|
LN ?= ln -sf
|
|
|
|
LDCONF ?= /sbin/ldconfig -n
|
2015-07-31 18:24:49 +00:00
|
|
|
|
|
|
|
CLANG_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "clang")
|
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
IS_IOS ?= 0
|
|
|
|
IS_ANDROID ?= 0
|
|
|
|
IS_ARM_EMBEDDED ?= 0
|
2015-11-05 06:59:46 +00:00
|
|
|
|
|
|
|
# Default prefix for make install
|
|
|
|
ifeq ($(PREFIX),)
|
|
|
|
PREFIX = /usr/local
|
|
|
|
endif
|
2015-07-31 18:24:49 +00:00
|
|
|
|
2015-12-31 06:43:42 +00:00
|
|
|
# http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
|
|
|
|
ifeq ($(DATADIR),)
|
|
|
|
DATADIR := $(PREFIX)/share
|
|
|
|
endif
|
|
|
|
ifeq ($(LIBDIR),)
|
|
|
|
LIBDIR := $(PREFIX)/lib
|
|
|
|
endif
|
|
|
|
ifeq ($(BINDIR),)
|
|
|
|
BINDIR := $(PREFIX)/bin
|
|
|
|
endif
|
|
|
|
ifeq ($(INCLUDEDIR),)
|
|
|
|
INCLUDEDIR := $(PREFIX)/include
|
|
|
|
endif
|
|
|
|
|
|
|
|
# We honor ARFLAGS, but the "v" option used by default causes a noisy make
|
|
|
|
ifeq ($(ARFLAGS),rv)
|
|
|
|
ARFLAGS = r
|
|
|
|
endif
|
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
# Sadly, we can't actually use GCC_PRAGMA_AWARE because of GCC bug 53431.
|
|
|
|
# Its a shame because GCC has so much to offer by the way of analysis.
|
|
|
|
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431
|
|
|
|
ifneq ($(CLANG_COMPILER),0)
|
2015-12-08 19:55:58 +00:00
|
|
|
CXXFLAGS += -Wall -Wno-delete-non-virtual-dtor
|
2015-11-05 06:59:46 +00:00
|
|
|
endif
|
2015-07-31 18:24:49 +00:00
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
# iOS cross-compile configuration.
|
2015-06-08 11:50:22 +00:00
|
|
|
# See http://www.cryptopp.com/wiki/iOS_(Command_Line).
|
|
|
|
ifeq ($(IS_IOS),1)
|
2015-11-05 06:59:46 +00:00
|
|
|
CXX = clang++
|
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
CXXFLAGS += $(IOS_FLAGS) -arch $(IOS_ARCH)
|
|
|
|
CXXFLAGS += -isysroot $(IOS_SYSROOT) -stdlib=libc++
|
2015-06-08 11:50:22 +00:00
|
|
|
|
|
|
|
AR = libtool
|
|
|
|
ARFLAGS = -static -o
|
2015-12-08 19:55:58 +00:00
|
|
|
RANLIB = ranlib
|
2015-06-08 11:50:22 +00:00
|
|
|
endif
|
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
# Android cross-compile configuration.
|
2015-06-08 11:50:22 +00:00
|
|
|
# See http://www.cryptopp.com/wiki/Android_(Command_Line).
|
|
|
|
ifeq ($(IS_ANDROID),1)
|
|
|
|
# CPP, CXX, AR, RANLIB, LD, etc are set in 'setenv-android.sh'
|
2015-12-08 19:55:58 +00:00
|
|
|
CXXFLAGS += $(AOSP_FLAGS) -DANDROID --sysroot=$(AOSP_SYSROOT)
|
|
|
|
CXXFLAGS += -Wa,--noexecstack -I$(AOSP_STL_INC)
|
|
|
|
|
|
|
|
# c++config.h shows up in odd places at times.
|
|
|
|
ifneq ($(AOSP_BITS_INC),)
|
|
|
|
CXXFLAGS += -I$(AOSP_BITS_INC)
|
|
|
|
endif
|
|
|
|
|
|
|
|
LDLIBS += $(AOSP_STL_LIB)
|
2015-12-27 18:13:16 +00:00
|
|
|
HAS_SOLIB_VERSION := 1
|
2015-06-08 11:50:22 +00:00
|
|
|
endif
|
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
# ARM embedded cross-compile configuration.
|
2015-06-08 11:50:22 +00:00
|
|
|
# See http://www.cryptopp.com/wiki/ARM_Embedded_(Command_Line)
|
|
|
|
# and http://www.cryptopp.com/wiki/ARM_Embedded_(Bare Metal).
|
|
|
|
ifeq ($(IS_ARM_EMBEDDED),1)
|
|
|
|
# CPP, CXX, AR, RANLIB, LD, etc are set in 'setenv-embedded.sh'
|
2015-12-08 19:55:58 +00:00
|
|
|
CXXFLAGS += $(ARM_EMBEDDED_FLAGS) --sysroot=$(ARM_EMBEDDED_SYSROOT)
|
2015-12-27 18:13:16 +00:00
|
|
|
HAS_SOLIB_VERSION := 1
|
2015-06-08 11:50:22 +00:00
|
|
|
endif
|
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
# List cryptlib.cpp first and cpu.cpp second in an attempt to tame C++ static initialization problems.
|
|
|
|
# The issue spills into POD data types of cpu.cpp due to the storage class of the bools, so cpu.cpp
|
|
|
|
# is the second candidate for explicit initialization order.
|
2015-11-18 20:35:35 +00:00
|
|
|
SRCS := cryptlib.cpp cpu.cpp $(filter-out cryptlib.cpp cpu.cpp pch.cpp simple.cpp winpipes.cpp cryptlib_bds.cpp,$(wildcard *.cpp))
|
2015-11-05 06:59:46 +00:00
|
|
|
OBJS := $(SRCS:.cpp=.o)
|
2015-07-31 18:24:49 +00:00
|
|
|
|
2015-06-08 11:50:22 +00:00
|
|
|
# test.o needs to be after bench.o for cygwin 1.1.4 (possible ld bug?)
|
2015-12-08 19:55:58 +00:00
|
|
|
TESTSRCS := bench.cpp bench2.cpp test.cpp validat1.cpp validat2.cpp validat3.cpp adhoc.cpp datatest.cpp regtest.cpp fipsalgt.cpp dlltest.cpp
|
|
|
|
TESTOBJS := $(TESTSRCS:.cpp=.o)
|
2015-11-05 06:59:46 +00:00
|
|
|
LIBOBJS := $(filter-out $(TESTOBJS),$(OBJS))
|
2015-06-08 11:50:22 +00:00
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
# For Shared Objects, Diff, Dist/Zip rules
|
|
|
|
LIB_VER := $(shell $(EGREP) "define CRYPTOPP_VERSION" config.h | cut -d" " -f 3)
|
|
|
|
LIB_MAJOR := $(shell echo $(LIB_VER) | cut -c 1)
|
|
|
|
LIB_MINOR := $(shell echo $(LIB_VER) | cut -c 2)
|
|
|
|
LIB_PATCH := $(shell echo $(LIB_VER) | cut -c 3)
|
2015-06-08 11:50:22 +00:00
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
ifeq ($(strip $(LIB_PATCH)),)
|
|
|
|
LIB_PATCH := 0
|
|
|
|
endif
|
2015-07-31 18:24:49 +00:00
|
|
|
|
2015-12-26 18:57:04 +00:00
|
|
|
ifeq ($(HAS_SOLIB_VERSION),1)
|
|
|
|
# Full version suffix for shared library
|
|
|
|
SOLIB_VERSION_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)
|
|
|
|
# Different patchlevels are compatible, minor versions are not
|
|
|
|
SOLIB_COMPAT_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR)
|
|
|
|
SOLIB_FLAGS=-Wl,-soname,libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
|
|
|
|
endif # HAS_SOLIB_VERSION
|
|
|
|
|
2015-12-29 00:30:01 +00:00
|
|
|
.PHONY: all
|
2015-11-05 06:59:46 +00:00
|
|
|
all: cryptest.exe
|
2015-07-31 18:24:49 +00:00
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
ifneq ($(IS_IOS),0)
|
2015-11-05 06:59:46 +00:00
|
|
|
static: libcryptopp.a
|
|
|
|
shared dynamic dylib: libcryptopp.dylib
|
|
|
|
else
|
2015-06-08 11:50:22 +00:00
|
|
|
static: libcryptopp.a
|
2015-12-26 18:57:04 +00:00
|
|
|
shared dynamic: libcryptopp.so$(SOLIB_VERSION_SUFFIX)
|
2015-11-05 06:59:46 +00:00
|
|
|
endif
|
2015-06-08 11:50:22 +00:00
|
|
|
|
|
|
|
test: cryptest.exe
|
|
|
|
./cryptest.exe v
|
|
|
|
|
2015-07-31 18:24:49 +00:00
|
|
|
.PHONY: clean
|
2015-06-08 11:50:22 +00:00
|
|
|
clean:
|
2015-12-26 18:57:04 +00:00
|
|
|
-$(RM) cryptest.exe libcryptopp.a libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.dylib
|
|
|
|
ifeq ($(HAS_SOLIB_VERSION),1)
|
|
|
|
-$(RM) libcryptopp.so libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
|
|
|
|
endif
|
2015-12-08 19:55:58 +00:00
|
|
|
-$(RM) adhoc.cpp.o adhoc.cpp.proto.o $(LIBOBJS) $(TESTOBJS)
|
2015-11-05 06:59:46 +00:00
|
|
|
ifneq ($(wildcard *.dSYM),)
|
2015-12-08 19:55:58 +00:00
|
|
|
-$(RM) -r cryptest.exe.dSYM
|
2015-11-05 06:59:46 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
.PHONY: distclean
|
|
|
|
distclean: clean
|
2015-12-08 19:55:58 +00:00
|
|
|
-$(RM) adhoc.cpp adhoc.cpp.copied GNUmakefile.deps *.o *.ii *.s
|
2015-06-08 11:50:22 +00:00
|
|
|
|
2015-07-31 18:24:49 +00:00
|
|
|
.PHONY: install
|
2015-06-08 11:50:22 +00:00
|
|
|
install:
|
2015-12-31 06:43:42 +00:00
|
|
|
$(MKDIR) -p $(DESTDIR)$(INCLUDEDIR)/cryptopp
|
|
|
|
$(CP) *.h $(DESTDIR)$(INCLUDEDIR)/cryptopp
|
|
|
|
-$(CHMOD) 755 $(DESTDIR)$(INCLUDEDIR)/cryptopp
|
|
|
|
-$(CHMOD) 644 $(DESTDIR)$(INCLUDEDIR)/cryptopp/*.h
|
2015-12-27 18:13:16 +00:00
|
|
|
ifneq ($(wildcard cryptest.exe),)
|
2015-12-31 06:43:42 +00:00
|
|
|
$(MKDIR) -p $(DESTDIR)$(BINDIR)
|
|
|
|
$(CP) cryptest.exe $(DESTDIR)$(BINDIR)
|
|
|
|
-$(CHMOD) 755 $(DESTDIR)$(BINDIR)/cryptest.exe
|
2015-12-09 05:41:15 +00:00
|
|
|
endif
|
2015-12-27 18:13:16 +00:00
|
|
|
ifneq ($(wildcard libcryptopp.a),)
|
2015-12-31 06:43:42 +00:00
|
|
|
$(MKDIR) -p $(DESTDIR)$(LIBDIR)
|
|
|
|
$(CP) libcryptopp.a $(DESTDIR)$(LIBDIR)
|
|
|
|
-$(CHMOD) 644 $(DESTDIR)$(LIBDIR)/libcryptopp.a
|
2015-12-27 18:13:16 +00:00
|
|
|
endif
|
|
|
|
ifneq ($(wildcard libcryptopp.dylib),)
|
2015-12-31 06:43:42 +00:00
|
|
|
$(MKDIR) -p $(DESTDIR)$(LIBDIR)
|
|
|
|
$(CP) libcryptopp.dylib $(DESTDIR)$(LIBDIR)
|
|
|
|
-$(CHMOD) 755 $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
|
2015-12-27 18:13:16 +00:00
|
|
|
endif
|
|
|
|
ifneq ($(wildcard libcryptopp.so$(SOLIB_VERSION_SUFFIX)),)
|
2015-12-31 06:43:42 +00:00
|
|
|
$(CP) libcryptopp.so $(DESTDIR)$(LIBDIR)
|
|
|
|
-$(CHMOD) 755 $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
|
2015-12-26 18:57:04 +00:00
|
|
|
ifeq ($(HAS_SOLIB_VERSION),1)
|
2015-12-31 06:43:42 +00:00
|
|
|
-$(LN) -sf libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so
|
|
|
|
$(LDCONF) $(DESTDIR)$(LIBDIR)
|
2015-12-26 18:57:04 +00:00
|
|
|
endif
|
2015-11-05 06:59:46 +00:00
|
|
|
endif
|
2015-06-08 11:50:22 +00:00
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
.PHONY: remove uninstall
|
|
|
|
remove uninstall:
|
2015-12-31 06:43:42 +00:00
|
|
|
-$(RM) -r $(DESTDIR)$(INCLUDEDIR)/cryptopp
|
|
|
|
-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.a
|
|
|
|
-$(RM) $(DESTDIR)$(BINDIR)/cryptest.exe
|
2015-12-08 19:55:58 +00:00
|
|
|
ifneq ($(IS_IOS),0)
|
2015-12-31 06:43:42 +00:00
|
|
|
-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
|
2015-11-05 06:59:46 +00:00
|
|
|
else
|
2015-12-31 06:43:42 +00:00
|
|
|
-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
|
2015-12-26 18:57:04 +00:00
|
|
|
ifeq ($(HAS_SOLIB_VERSION),1)
|
2015-12-31 06:43:42 +00:00
|
|
|
-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
|
|
|
|
-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so
|
|
|
|
$(LDCONF) $(DESTDIR)$(LIBDIR)
|
2015-12-26 18:57:04 +00:00
|
|
|
endif
|
2015-11-05 06:59:46 +00:00
|
|
|
endif
|
2015-06-08 11:50:22 +00:00
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
libcryptopp.a: $(LIBOBJS)
|
2015-06-08 11:50:22 +00:00
|
|
|
$(AR) $(ARFLAGS) $@ $(LIBOBJS)
|
|
|
|
$(RANLIB) $@
|
|
|
|
|
2015-12-26 18:57:04 +00:00
|
|
|
.PHONY: libcryptopp.so
|
2015-12-27 18:13:16 +00:00
|
|
|
libcryptopp.so: libcryptopp.so$(SOLIB_VERSION_SUFFIX)
|
2015-12-26 18:57:04 +00:00
|
|
|
|
2015-12-27 18:13:16 +00:00
|
|
|
libcryptopp.so$(SOLIB_VERSION_SUFFIX): $(LIBOBJS)
|
2015-12-26 18:57:04 +00:00
|
|
|
$(CXX) -shared $(SOLIB_FLAGS) -o $@ $(CXXFLAGS) -Wl,--exclude-libs,ALL $(LIBOBJS) $(LDLIBS)
|
|
|
|
ifeq ($(HAS_SOLIB_VERSION),1)
|
|
|
|
-$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.so
|
|
|
|
-$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
|
|
|
|
endif
|
2015-06-08 11:50:22 +00:00
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
libcryptopp.dylib: $(LIBOBJS)
|
2015-12-31 06:43:42 +00:00
|
|
|
$(CXX) -dynamiclib -o $@ $(CXXFLAGS) -install_name "$@" -current_version "$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)" -compatibility_version "$(LIB_MAJOR).$(LIB_MINOR)" -headerpad_max_install_names $(LIBOBJS)
|
2015-12-08 19:55:58 +00:00
|
|
|
|
|
|
|
cryptest.exe: libcryptopp.a $(TESTOBJS)
|
2015-06-08 11:50:22 +00:00
|
|
|
$(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) ./libcryptopp.a $(LDFLAGS) $(LDLIBS)
|
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
# Used to generate list of source files for Autotools, CMakeList and Android.mk
|
|
|
|
.PHONY: sources
|
|
|
|
sources:
|
|
|
|
$(info Library sources: $(filter-out fipstest.cpp $(TESTSRCS),$(SRCS)))
|
|
|
|
$(info )
|
|
|
|
$(info Test sources: $(TESTSRCS))
|
|
|
|
|
2015-06-08 11:50:22 +00:00
|
|
|
adhoc.cpp: adhoc.cpp.proto
|
|
|
|
ifeq ($(wildcard adhoc.cpp),)
|
|
|
|
cp adhoc.cpp.proto adhoc.cpp
|
|
|
|
else
|
|
|
|
touch adhoc.cpp
|
|
|
|
endif
|
|
|
|
|
2015-11-18 20:35:35 +00:00
|
|
|
# Include dependencies, if present. You must issue `make deps` to create them.
|
|
|
|
ifeq ($(wildcard GNUmakefile.deps),GNUmakefile.deps)
|
|
|
|
-include GNUmakefile.deps
|
|
|
|
endif # Dependencies
|
|
|
|
|
2015-06-08 11:50:22 +00:00
|
|
|
%.o : %.cpp
|
|
|
|
$(CXX) $(CXXFLAGS) -c $<
|
2015-07-20 10:55:42 +00:00
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
GNUmakefile.deps:
|
2015-07-20 10:55:42 +00:00
|
|
|
$(CXX) $(CXXFLAGS) -MM *.cpp > GNUmakefile.deps
|