ext-cryptopp/GNUmakefile

169 lines
5.2 KiB
Makefile
Raw Normal View History

CXXFLAGS = -DNDEBUG -g -O2
#CXXFLAGS = -g
# -fPIC is supported. Please report any breakage of -fPIC as a bug.
# CXXFLAGS += -fPIC
# the following options reduce code size, but breaks link or makes link very slow on some systems
# CXXFLAGS += -ffunction-sections -fdata-sections
# LDFLAGS += -Wl,--gc-sections
2002-10-04 17:31:41 +00:00
ARFLAGS = -cr # ar needs the dash on OpenBSD
RANLIB = ranlib
2006-12-09 17:09:01 +00:00
CP = cp
MKDIR = mkdir
EGREP = egrep
2002-10-04 17:31:41 +00:00
UNAME = $(shell uname)
2009-03-14 22:21:14 +00:00
ISX86 = $(shell uname -m | $(EGREP) -c "i.86|x86|i86|amd64")
ISMINGW = $(shell uname | $(EGREP) -c "MINGW32")
2006-12-09 17:09:01 +00:00
# Default prefix for make install
ifeq ($(PREFIX),)
PREFIX = /usr
endif
2003-10-22 21:08:07 +00:00
ifeq ($(CXX),gcc) # for some reason CXX is gcc on cygwin 1.1.4
CXX = g++
endif
ifeq ($(ISX86),1)
GCC42_OR_LATER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(GCC\) (4.[2-9]|[5-9])")
2007-04-16 02:51:59 +00:00
INTEL_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\)")
2009-03-14 22:21:14 +00:00
GAS210_OR_LATER = $(shell echo "" | $(AS) -v 2>&1 | $(EGREP) -c "GNU assembler version (2\.[1-9][0-9]|[3-9])")
GAS217_OR_LATER = $(shell echo "" | $(AS) -v 2>&1 | $(EGREP) -c "GNU assembler version (2\.1[7-9]|2\.[2-9]|[3-9])")
2003-10-22 21:08:07 +00:00
ifneq ($(GCC42_OR_LATER),0)
ifneq ($(UNAME),Darwin)
CXXFLAGS += -march=native -mtune=native
endif
endif
2002-10-04 17:31:41 +00:00
2009-03-04 09:27:52 +00:00
ifneq ($(INTEL_COMPILER),0)
# "internal error: backend signals" occurs on some x86 inline assembly with ICC 9 and some x64 inline assembly with ICC 11
# if you want to use Crypto++'s assembly code with ICC, try enabling it on individual files
CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
endif
ifeq ($(GAS210_OR_LATER),0) # .intel_syntax wasn't supported until GNU assembler 2.10
CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
2007-05-05 01:21:44 +00:00
else
2009-03-14 22:21:14 +00:00
ifeq ($(GAS217_OR_LATER),0)
CXXFLAGS += -DCRYPTOPP_DISABLE_SSSE3
endif
2007-05-05 01:21:44 +00:00
ifeq ($(UNAME),SunOS)
CXXFLAGS += -Wa,--divide # allow use of "/" operator
endif
endif
2009-03-14 22:21:14 +00:00
endif # ISX86
2003-10-14 09:41:35 +00:00
ifeq ($(ISMINGW),1)
LDLIBS += -lws2_32
endif
2002-10-04 17:31:41 +00:00
ifeq ($(UNAME),) # for DJGPP, where uname doesn't exist
CXXFLAGS += -mbnu210
else
CXXFLAGS += -pipe
endif
2006-12-09 17:09:01 +00:00
ifeq ($(UNAME),Linux)
LDFLAGS += -pthread
endif
2002-10-04 21:45:04 +00:00
ifeq ($(UNAME),Darwin)
2003-03-20 01:24:12 +00:00
AR = libtool
ARFLAGS = -static -o
2004-06-19 11:42:41 +00:00
CXX = c++
IS_GCC2 = $(shell $(CXX) -v 2>&1 | $(EGREP) -c gcc-932)
2003-03-20 01:24:12 +00:00
ifeq ($(IS_GCC2),1)
CXXFLAGS += -fno-coalesce-templates -fno-coalesce-static-vtables
2002-10-04 21:45:04 +00:00
LDLIBS += -lstdc++
LDFLAGS += -flat_namespace -undefined suppress -m
2002-10-04 17:31:41 +00:00
endif
2003-03-20 01:24:12 +00:00
endif
2002-10-04 17:31:41 +00:00
ifeq ($(UNAME),SunOS)
2002-10-04 21:45:04 +00:00
LDLIBS += -lnsl -lsocket
2007-04-16 05:40:37 +00:00
ifeq ($(CXX),CC) # override flags for CC (Solaris native C++ compiler)
CXXFLAGS = -DNDEBUG -O -g0 -native -template=no%extdef -m$(shell isainfo -b)
2007-04-16 05:40:37 +00:00
LDFLAGS =
ifeq ($(ISX86),1)
# SSE2 intrinsics should work in Sun Studio 12, but we're not using SSE2 intrinsics anymore
2007-04-16 05:40:37 +00:00
# CXXFLAGS += -xarch=sse2 -D__SSE2__
endif
endif
2002-10-04 17:31:41 +00:00
endif
SRCS = $(wildcard *.cpp)
ifeq ($(SRCS),) # workaround wildcard function bug in GNU Make 3.77
SRCS = $(shell echo *.cpp)
2002-10-04 17:31:41 +00:00
endif
OBJS = $(SRCS:.cpp=.o)
# test.o needs to be after bench.o for cygwin 1.1.4 (possible ld bug?)
TESTOBJS = bench.o bench2.o test.o validat1.o validat2.o validat3.o adhoc.o datatest.o regtest.o fipsalgt.o dlltest.o
2002-10-04 17:31:41 +00:00
LIBOBJS = $(filter-out $(TESTOBJS),$(OBJS))
DLLSRCS = algebra.cpp algparam.cpp asn.cpp basecode.cpp cbcmac.cpp channels.cpp cryptlib.cpp des.cpp dessp.cpp dh.cpp dll.cpp dsa.cpp ec2n.cpp eccrypto.cpp ecp.cpp eprecomp.cpp files.cpp filters.cpp fips140.cpp fipstest.cpp gf2n.cpp gfpcrypt.cpp hex.cpp hmac.cpp integer.cpp iterhash.cpp misc.cpp modes.cpp modexppc.cpp mqueue.cpp nbtheory.cpp oaep.cpp osrng.cpp pch.cpp pkcspad.cpp pubkey.cpp queue.cpp randpool.cpp rdtables.cpp rijndael.cpp rng.cpp rsa.cpp sha.cpp simple.cpp skipjack.cpp strciphr.cpp trdlocal.cpp
DLLOBJS = $(DLLSRCS:.cpp=.export.o)
2003-07-11 19:16:35 +00:00
LIBIMPORTOBJS = $(LIBOBJS:.o=.import.o)
TESTIMPORTOBJS = $(TESTOBJS:.o=.import.o)
DLLTESTOBJS = dlltest.dllonly.o
2002-10-04 17:31:41 +00:00
all: cryptest.exe
2008-02-02 08:38:21 +00:00
test: cryptest.exe
./cryptest.exe v
2002-10-04 17:31:41 +00:00
clean:
$(RM) cryptest.exe libcryptopp.a $(LIBOBJS) $(TESTOBJS) cryptopp.dll libcryptopp.dll.a libcryptopp.import.a cryptest.import.exe dlltest.exe $(DLLOBJS) $(LIBIMPORTOBJS) $(TESTIMPORTOBJS) $(DLLTESTOBJS)
2002-10-04 17:31:41 +00:00
2006-12-09 17:09:01 +00:00
install:
$(MKDIR) -p $(PREFIX)/include/cryptopp $(PREFIX)/lib $(PREFIX)/bin
$(CP) *.h $(PREFIX)/include/cryptopp
$(CP) *.a $(PREFIX)/lib
$(CP) *.exe $(PREFIX)/bin
2002-10-04 17:31:41 +00:00
libcryptopp.a: $(LIBOBJS)
$(AR) $(ARFLAGS) $@ $(LIBOBJS)
$(RANLIB) $@
cryptest.exe: libcryptopp.a $(TESTOBJS)
$(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) -L. -lcryptopp $(LDFLAGS) $(LDLIBS)
nolib: $(OBJS) # makes it faster to test changes
$(CXX) -o ct $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS)
dll: cryptest.import.exe dlltest.exe
cryptopp.dll: $(DLLOBJS)
$(CXX) -shared -o $@ $(CXXFLAGS) $(DLLOBJS) $(LDFLAGS) $(LDLIBS) -Wl,--out-implib=libcryptopp.dll.a
libcryptopp.import.a: $(LIBIMPORTOBJS)
$(AR) $(ARFLAGS) $@ $(LIBIMPORTOBJS)
$(RANLIB) $@
cryptest.import.exe: cryptopp.dll libcryptopp.import.a $(TESTIMPORTOBJS)
$(CXX) -o $@ $(CXXFLAGS) $(TESTIMPORTOBJS) -L. -lcryptopp.dll -lcryptopp.import $(LDFLAGS) $(LDLIBS)
dlltest.exe: cryptopp.dll $(DLLTESTOBJS)
$(CXX) -o $@ $(CXXFLAGS) $(DLLTESTOBJS) -L. -lcryptopp.dll $(LDFLAGS) $(LDLIBS)
2002-12-06 22:02:46 +00:00
adhoc.cpp: adhoc.cpp.proto
ifeq ($(wildcard adhoc.cpp),)
cp adhoc.cpp.proto adhoc.cpp
else
touch adhoc.cpp
endif
%.dllonly.o : %.cpp
$(CXX) $(CXXFLAGS) -DCRYPTOPP_DLL_ONLY -c $< -o $@
%.import.o : %.cpp
$(CXX) $(CXXFLAGS) -DCRYPTOPP_IMPORTS -c $< -o $@
%.export.o : %.cpp
$(CXX) $(CXXFLAGS) -DCRYPTOPP_EXPORTS -c $< -o $@
2002-10-04 17:31:41 +00:00
%.o : %.cpp
2002-10-04 17:31:41 +00:00
$(CXX) $(CXXFLAGS) -c $<