移植cryptopp 5.6.2版本到ARM中需要进行的GNUmakefile 修改:

来源:互联网 发布:spice仿真软件下载 编辑:程序博客网 时间:2024/06/01 15:41

修改ARM平台下的cryptopp 5.6.2版本 GNUmakefile 

使用arm-linux-g++进行编译, install后将库和头文件放入arm开发环境对应的目录中
增加-fPIC编译参数,使其能够进行动态编译并非固定内存地址寻址.

CXXFLAGS = -DNDEBUG -g -O2# -O3 fails to link on Cygwin GCC version 4.5.3# -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-sectionsARFLAGS = -cr# ar needs the dash on OpenBSDRANLIB = ranlibCP = cpMKDIR = mkdirEGREP = egrepUNAME = $(shell uname)ISX86 = $(shell uname -m | $(EGREP) -c "i.86|x86|i86|amd64")IS_SUN_CC = $(shell arm-linux-g++ -V 2>&1 | $(EGREP) -c "CC: Sun")IS_LINUX = $(shell arm-linux-g++ -dumpmachine 2>&1 | $(EGREP) -c "linux")IS_MINGW = $(shell arm-linux-g++ -dumpmachine 2>&1 | $(EGREP) -c "mingw")CLANG_COMPILER = $(shell arm-linux-g++ --version 2>&1 | $(EGREP) -i -c "clang version")# Default prefix for make installifeq ($(PREFIX),)PREFIX = /opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/sys-rootendififeq ($(CXX),gcc)# for some reason CXX is gcc on cygwin 1.1.4CXX = arm-linux-g++endififeq ($(ISX86),1)GCC42_OR_LATER = $(shell arm-linux-g++ -v 2>&1 | $(EGREP) -c "^gcc version (4.[2-9]|[5-9])")INTEL_COMPILER = $(shell arm-linux-g++ --version 2>&1 | $(EGREP) -c "\(ICC\)")ICC111_OR_LATER = $(shell arm-linux-g++ --version 2>&1 | $(EGREP) -c "\(ICC\) ([2-9][0-9]|1[2-9]|11\.[1-9])")GAS210_OR_LATER = $(shell arm-linux-g++ -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.[1-9][0-9]|[3-9])")GAS217_OR_LATER = $(shell arm-linux-g++ -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])")GAS219_OR_LATER = $(shell arm-linux-g++ -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.19|2\.[2-9]|[3-9])")ifneq ($(GCC42_OR_LATER),0)ifeq ($(UNAME),Darwin)CXXFLAGS += -arch x86_64 -arch i386else#CXXFLAGS += -march=nativeendifendififneq ($(INTEL_COMPILER),0)CXXFLAGS += -wd68 -wd186 -wd279 -wd327ifeq ($(ICC111_OR_LATER),0)# "internal error: backend signals" occurs on some x86 inline assembly with ICC 9 and some x64 inline assembly with ICC 11.0# if you want to use Crypto++'s assembly code with ICC, try enabling it on individual filesCXXFLAGS += -DCRYPTOPP_DISABLE_ASMendifendififeq ($(GAS210_OR_LATER),0)# .intel_syntax wasn't supported until GNU assembler 2.10CXXFLAGS += -DCRYPTOPP_DISABLE_ASMelseifeq ($(GAS217_OR_LATER),0)CXXFLAGS += -DCRYPTOPP_DISABLE_SSSE3elseifeq ($(GAS219_OR_LATER),0)CXXFLAGS += -DCRYPTOPP_DISABLE_AESNIendifendififeq ($(UNAME),SunOS)CXXFLAGS += -Wa,--divide# allow use of "/" operatorendifendifendif# ISX86ifeq ($(UNAME),)# for DJGPP, where uname doesn't existCXXFLAGS += -mbnu210elseCXXFLAGS += -pipeendififeq ($(IS_MINGW),1)LDLIBS += -lws2_32endififeq ($(IS_LINUX),1)LDFLAGS += -pthreadifneq ($(shell uname -i | $(EGREP) -c "(_64|d64)"),0)M32OR64 = -m64endifendififeq ($(UNAME),Darwin)AR = libtoolARFLAGS = -static -oCXX = c++IS_GCC2 = $(shell arm-linux-g++ -v 2>&1 | $(EGREP) -c gcc-932)ifeq ($(IS_GCC2),1)CXXFLAGS += -fno-coalesce-templates -fno-coalesce-static-vtablesLDLIBS += -lstdc++LDFLAGS += -flat_namespace -undefined suppress -mendifendififeq ($(UNAME),SunOS)LDLIBS += -lnsl -lsocketM32OR64 = -m$(shell isainfo -b)endififneq ($(CLANG_COMPILER),0)CXXFLAGS += -Wno-tautological-compareendififneq ($(IS_SUN_CC),0)# override flags for CC Sun C++ compilerCXXFLAGS = -DNDEBUG -O -g0 -native -template=no%extdef $(M32OR64)LDFLAGS =AR = $(CXX)ARFLAGS = -xar -oRANLIB = trueSUN_CC10_BUGGY = $(shell arm-linux-g++ -V 2>&1 | $(EGREP) -c "CC: Sun .* 5\.10 .* (2009|2010/0[1-4])")ifneq ($(SUN_CC10_BUGGY),0)# -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# remove it if you get "already had a body defined" errors in vector.ccCXXFLAGS += -DCRYPTOPP_INCLUDE_VECTOR_CCendifendifSRCS = $(wildcard *.cpp)ifeq ($(SRCS),)# workaround wildcard function bug in GNU Make 3.77SRCS = $(shell echo *.cpp)endifOBJS = $(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.oLIBOBJS = $(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.cppDLLOBJS = $(DLLSRCS:.cpp=.export.o)LIBIMPORTOBJS = $(LIBOBJS:.o=.import.o)TESTIMPORTOBJS = $(TESTOBJS:.o=.import.o)DLLTESTOBJS = dlltest.dllonly.oall: cryptest.exestatic: libcryptopp.adynamic: libcryptopp.sotest: cryptest.exe./cryptest.exe vclean:-$(RM) cryptest.exe libcryptopp.a libcryptopp.so $(LIBOBJS) $(TESTOBJS) cryptopp.dll libcryptopp.dll.a libcryptopp.import.a cryptest.import.exe dlltest.exe $(DLLOBJS) $(LIBIMPORTOBJS) $(TESTI MPORTOBJS) $(DLLTESTOBJS)install:$(MKDIR) -p $(PREFIX)/include/cryptopp $(PREFIX)/lib $(PREFIX)/bin-$(CP) *.h $(PREFIX)/include/cryptopp-$(CP) *.a $(PREFIX)/lib-$(CP) *.so $(PREFIX)/lib-$(CP) *.exe $(PREFIX)/binremove:-$(RM) -rf $(PREFIX)/include/cryptopp-$(RM) $(PREFIX)/lib/libcryptopp.a-$(RM) $(PREFIX)/lib/libcryptopp.so-$(RM) $(PREFIX)/bin/cryptest.exelibcryptopp.a: $(LIBOBJS)$(AR) $(ARFLAGS) $@ $(LIBOBJS)$(RANLIB) $@libcryptopp.so: $(LIBOBJS)arm-linux-g++ -shared -o $@ $(LIBOBJS)cryptest.exe: libcryptopp.a $(TESTOBJS)arm-linux-g++ -o $@ $(CXXFLAGS) $(TESTOBJS) ./libcryptopp.a $(LDFLAGS) $(LDLIBS)nolib: $(OBJS)# makes it faster to test changesarm-linux-g++ -o ct $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS)dll: cryptest.import.exe dlltest.execryptopp.dll: $(DLLOBJS)arm-linux-g++ -shared -o $@ $(CXXFLAGS) $(DLLOBJS) $(LDFLAGS) $(LDLIBS) -Wl,--out-implib=libcryptopp.dll.alibcryptopp.import.a: $(LIBIMPORTOBJS)$(AR) $(ARFLAGS) $@ $(LIBIMPORTOBJS)$(RANLIB) $@cryptest.import.exe: cryptopp.dll libcryptopp.import.a $(TESTIMPORTOBJS)arm-linux-g++ -o $@ $(CXXFLAGS) $(TESTIMPORTOBJS) -L. -lcryptopp.dll -lcryptopp.import $(LDFLAGS) $(LDLIBS)dlltest.exe: cryptopp.dll $(DLLTESTOBJS)arm-linux-g++ -o $@ $(CXXFLAGS) $(DLLTESTOBJS) -L. -lcryptopp.dll $(LDFLAGS) $(LDLIBS)adhoc.cpp: adhoc.cpp.protoifeq ($(wildcard adhoc.cpp),)cp adhoc.cpp.proto adhoc.cppelsetouch adhoc.cppendif%.dllonly.o : %.cpparm-linux-g++ $(CXXFLAGS) -DCRYPTOPP_DLL_ONLY -c $< -o $@%.import.o : %.cpparm-linux-g++ $(CXXFLAGS) -DCRYPTOPP_IMPORTS -c $< -o $@%.export.o : %.cpparm-linux-g++ $(CXXFLAGS) -DCRYPTOPP_EXPORTS -c $< -o $@%.o : %.cpparm-linux-g++ $(CXXFLAGS) -c $<


0 0