Advertisement
Guest User

Untitled

a guest
Mar 5th, 2015
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 6.88 KB | None | 0 0
  1. CXXFLAGS = -DNDEBUG -g -O2
  2. # -O3 fails to link on Cygwin GCC version 4.5.3
  3. # -fPIC is supported. Please report any breakage of -fPIC as a bug.
  4. # CXXFLAGS += -fPIC
  5. # the following options reduce code size, but breaks link or makes link very slow on some systems
  6. # CXXFLAGS += -ffunction-sections -fdata-sections
  7. # LDFLAGS += -Wl,--gc-sections
  8. CXX = g++48
  9. ARFLAGS = -cr   # ar needs the dash on OpenBSD
  10. RANLIB = ranlib
  11. CP = cp
  12. MKDIR = mkdir
  13. EGREP = egrep
  14. UNAME = $(shell uname)
  15. ISX86 = $(shell uname -m | $(EGREP) -c "i.86|x86|i86|amd64")
  16. IS_SUN_CC = $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: Sun")
  17. IS_LINUX = $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -c "linux")
  18. IS_MINGW = $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -c "mingw")
  19. CLANG_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "clang version")
  20.  
  21. # Default prefix for make install
  22. ifeq ($(PREFIX),)
  23. PREFIX = /usr
  24. endif
  25.  
  26. ifeq ($(CXX),gcc)   # for some reason CXX is gcc on cygwin 1.1.4
  27. CXX = g++48
  28. endif
  29.  
  30. ifeq ($(ISX86),1)
  31.  
  32. GCC42_OR_LATER = $(shell $(CXX) -v 2>&1 | $(EGREP) -c "^gcc version (4.[2-9]|[5-9])")
  33. INTEL_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\)")
  34. ICC111_OR_LATER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\) ([2-9][0-9]|1[2-9]|11\.[1-9])")
  35. 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])")
  36. 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])")
  37. 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])")
  38.  
  39. ifneq ($(GCC42_OR_LATER),0)
  40. ifeq ($(UNAME),Darwin)
  41. CXXFLAGS += -arch x86_64 -arch i386
  42. else
  43. CXXFLAGS += -march=native
  44. endif
  45. endif
  46.  
  47. ifneq ($(INTEL_COMPILER),0)
  48. CXXFLAGS += -wd68 -wd186 -wd279 -wd327
  49. ifeq ($(ICC111_OR_LATER),0)
  50. # "internal error: backend signals" occurs on some x86 inline assembly with ICC 9 and some x64 inline assembly with ICC 11.0
  51. # if you want to use Crypto++'s assembly code with ICC, try enabling it on individual files
  52. CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
  53. endif
  54. endif
  55.  
  56. ifeq ($(GAS210_OR_LATER),0) # .intel_syntax wasn't supported until GNU assembler 2.10
  57. CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
  58. else
  59. ifeq ($(GAS217_OR_LATER),0)
  60. CXXFLAGS += -DCRYPTOPP_DISABLE_SSSE3
  61. else
  62. ifeq ($(GAS219_OR_LATER),0)
  63. CXXFLAGS += -DCRYPTOPP_DISABLE_AESNI
  64. endif
  65. endif
  66. ifeq ($(UNAME),SunOS)
  67. CXXFLAGS += -Wa,--divide    # allow use of "/" operator
  68. endif
  69. endif
  70.  
  71. endif   # ISX86
  72.  
  73. ifeq ($(UNAME),)    # for DJGPP, where uname doesn't exist
  74. CXXFLAGS += -mbnu210
  75. else
  76. CXXFLAGS += -pipe
  77. endif
  78.  
  79. ifeq ($(IS_MINGW),1)
  80. LDLIBS += -lws2_32
  81. endif
  82.  
  83. ifeq ($(IS_LINUX),1)
  84. LDFLAGS += -pthread
  85. ifneq ($(shell uname -i | $(EGREP) -c "(_64|d64)"),0)
  86. M32OR64 = -m64
  87. endif
  88. endif
  89.  
  90. ifeq ($(UNAME),Darwin)
  91. AR = libtool
  92. ARFLAGS = -static -o
  93. CXX = c++
  94. IS_GCC2 = $(shell $(CXX) -v 2>&1 | $(EGREP) -c gcc-932)
  95. ifeq ($(IS_GCC2),1)
  96. CXXFLAGS += -fno-coalesce-templates -fno-coalesce-static-vtables
  97. LDLIBS += -lstdc++
  98. LDFLAGS += -flat_namespace -undefined suppress -m
  99. endif
  100. endif
  101.  
  102. ifeq ($(UNAME),SunOS)
  103. LDLIBS += -lnsl -lsocket
  104. M32OR64 = -m$(shell isainfo -b)
  105. endif
  106.  
  107. ifneq ($(CLANG_COMPILER),0)
  108. CXXFLAGS += -Wno-tautological-compare
  109. endif
  110.  
  111. ifneq ($(IS_SUN_CC),0)  # override flags for CC Sun C++ compiler
  112. CXXFLAGS = -DNDEBUG -O -g0 -native -template=no%extdef $(M32OR64)
  113. LDFLAGS =
  114. AR = $(CXX)
  115. ARFLAGS = -xar -o
  116. RANLIB = true
  117. SUN_CC10_BUGGY = $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: Sun .* 5\.10 .* (2009|2010/0[1-4])")
  118. ifneq ($(SUN_CC10_BUGGY),0)
  119. # -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
  120. # remove it if you get "already had a body defined" errors in vector.cc
  121. CXXFLAGS += -DCRYPTOPP_INCLUDE_VECTOR_CC
  122. endif
  123. endif
  124.  
  125. SRCS = $(wildcard *.cpp)
  126. ifeq ($(SRCS),)             # workaround wildcard function bug in GNU Make 3.77
  127. SRCS = $(shell echo *.cpp)
  128. endif
  129.  
  130. OBJS = $(SRCS:.cpp=.o)
  131. # test.o needs to be after bench.o for cygwin 1.1.4 (possible ld bug?)
  132. TESTOBJS = bench.o bench2.o test.o validat1.o validat2.o validat3.o adhoc.o datatest.o regtest.o fipsalgt.o dlltest.o
  133. LIBOBJS = $(filter-out $(TESTOBJS),$(OBJS))
  134.  
  135. 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
  136. DLLOBJS = $(DLLSRCS:.cpp=.export.o)
  137. LIBIMPORTOBJS = $(LIBOBJS:.o=.import.o)
  138. TESTIMPORTOBJS = $(TESTOBJS:.o=.import.o)
  139. DLLTESTOBJS = dlltest.dllonly.o
  140.  
  141. all: cryptest.exe
  142. static: libcryptopp.a
  143. dynamic: libcryptopp.so
  144.  
  145. test: cryptest.exe
  146.     ./cryptest.exe v
  147.  
  148. clean:
  149.     -$(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)
  150.  
  151. install:
  152.     $(MKDIR) -p $(PREFIX)/include/cryptopp $(PREFIX)/lib $(PREFIX)/bin
  153.     -$(CP) *.h $(PREFIX)/include/cryptopp
  154.     -$(CP) *.a $(PREFIX)/lib
  155.     -$(CP) *.so $(PREFIX)/lib
  156.     -$(CP) *.exe $(PREFIX)/bin
  157.  
  158. remove:
  159.     -$(RM) -rf $(PREFIX)/include/cryptopp
  160.     -$(RM) $(PREFIX)/lib/libcryptopp.a
  161.     -$(RM) $(PREFIX)/lib/libcryptopp.so
  162.     -$(RM) $(PREFIX)/bin/cryptest.exe
  163.  
  164. libcryptopp.a: $(LIBOBJS)
  165.     $(AR) $(ARFLAGS) $@ $(LIBOBJS)
  166.     $(RANLIB) $@
  167.  
  168. libcryptopp.so: $(LIBOBJS)
  169.     $(CXX) -shared -o $@ $(LIBOBJS)
  170.  
  171. cryptest.exe: libcryptopp.a $(TESTOBJS)
  172.     $(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) ./libcryptopp.a $(LDFLAGS) $(LDLIBS)
  173.  
  174. nolib: $(OBJS)      # makes it faster to test changes
  175.     $(CXX) -o ct $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS)
  176.  
  177. dll: cryptest.import.exe dlltest.exe
  178.  
  179. cryptopp.dll: $(DLLOBJS)
  180.     $(CXX) -shared -o $@ $(CXXFLAGS) $(DLLOBJS) $(LDFLAGS) $(LDLIBS) -Wl,--out-implib=libcryptopp.dll.a
  181.  
  182. libcryptopp.import.a: $(LIBIMPORTOBJS)
  183.     $(AR) $(ARFLAGS) $@ $(LIBIMPORTOBJS)
  184.     $(RANLIB) $@
  185.  
  186. cryptest.import.exe: cryptopp.dll libcryptopp.import.a $(TESTIMPORTOBJS)
  187.     $(CXX) -o $@ $(CXXFLAGS) $(TESTIMPORTOBJS) -L. -lcryptopp.dll -lcryptopp.import $(LDFLAGS) $(LDLIBS)
  188.  
  189. dlltest.exe: cryptopp.dll $(DLLTESTOBJS)
  190.     $(CXX) -o $@ $(CXXFLAGS) $(DLLTESTOBJS) -L. -lcryptopp.dll $(LDFLAGS) $(LDLIBS)
  191.  
  192. adhoc.cpp: adhoc.cpp.proto
  193. ifeq ($(wildcard adhoc.cpp),)
  194.     cp adhoc.cpp.proto adhoc.cpp
  195. else
  196.     touch adhoc.cpp
  197. endif
  198.  
  199. %.dllonly.o : %.cpp
  200.     $(CXX) $(CXXFLAGS) -DCRYPTOPP_DLL_ONLY -c $< -o $@
  201.  
  202. %.import.o : %.cpp
  203.     $(CXX) $(CXXFLAGS) -DCRYPTOPP_IMPORTS -c $< -o $@
  204.  
  205. %.export.o : %.cpp
  206.     $(CXX) $(CXXFLAGS) -DCRYPTOPP_EXPORTS -c $< -o $@
  207.  
  208. %.o : %.cpp
  209.     $(CXX) $(CXXFLAGS) -c $<
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement