Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

572 lines
20 KiB

  1. SHELL=/bin/bash
  2. # Base CXXFLAGS used if the user did not specify them
  3. CXXFLAGS ?= -DNDEBUG -g2 -O2
  4. # -fPIC is supported, please report failures with steps to reproduce
  5. # If PIC is required but results in a crash, then use -DCRYPTOPP_DISABLE_ASM
  6. CXXFLAGS += -fPIC
  7. # Add the following options reduce code size, but breaks link
  8. # or makes link very slow on some systems
  9. CXXFLAGS += -ffunction-sections -fdata-sections
  10. # VALVE: when steamclient.so is launched from Python the stack is not 16-byte aligned and gcc assumes
  11. # that it will be, causing crashes when writing to SSE local variables.
  12. CXXFLAGS += -mstackrealign
  13. # LDFLAGS += -Wl,--gc-sections
  14. AR ?= ar
  15. ARFLAGS ?= -cr # ar needs the dash on OpenBSD
  16. RANLIB ?= ranlib
  17. CP ?= cp
  18. CHMOD ?= chmod
  19. MKDIR ?= mkdir
  20. EGREP ?= egrep
  21. UNAME := $(shell uname)
  22. BUILDVERSION="Building libcryptopp.a"
  23. IS_X86 := $(shell uname -m | $(EGREP) -i -c "i.86|x86|i86|amd64")
  24. IS_X86_64 := $(shell uname -m | $(EGREP) -i -c "(_64|d64)")
  25. IS_AARCH64 := $(shell uname -m | $(EGREP) -i -c "aarch64")
  26. IS_SUN := $(shell uname | $(EGREP) -i -c "SunOS")
  27. IS_LINUX := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "Linux")
  28. IS_MINGW := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "MinGW")
  29. IS_CYGWIN := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "Cygwin")
  30. IS_DARWIN := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "Darwin")
  31. SUN_COMPILER := $(shell $(CXX) -V 2>&1 | $(EGREP) -i -c "CC: Sun")
  32. GCC_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "(gcc|g\+\+)")
  33. CLANG_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "clang")
  34. INTEL_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\)")
  35. MACPORTS_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "macports")
  36. # Default prefix for make install
  37. ifeq ($(PREFIX),)
  38. PREFIX = /usr
  39. endif
  40. # VALVE: Add support for debug builds if we need them
  41. ifeq ($(MAKE_DEBUG),1)
  42. OPTIMIZER_FLAGS=-g -ggdb
  43. else
  44. OPTIMIZER_FLAGS=-O2
  45. endif
  46. ifeq ($(CXX),gcc) # for some reason CXX is gcc on cygwin 1.1.4
  47. CXX := g++
  48. endif
  49. # We honor ARFLAGS, but the "v" often option used by default causes a noisy make
  50. ifeq ($(ARFLAGS),rv)
  51. ARFLAGS = r
  52. endif
  53. # VALVE: Some defaults to match the rest of the steam build
  54. CXXFLAGS += $(OPTIMIZER_FLAGS) -fvisibility=hidden -w
  55. # If we're building this for STEAMCMD, then we use the Valve compile tools
  56. ifeq ($(STEAMCMD),1)
  57. BUILDVERSION="Building libcryptopp.a for SteamCMD"
  58. CXX = /valve/bin/g++
  59. BINDIR =linux32
  60. else
  61. # Otherwise we're building for STEAM, so use the native compile tools
  62. BUILDVERSION="Building libcryptopp.a for Steam"
  63. ifeq ($(ISX64),1)
  64. CXX = g++-4.8 -m64
  65. BINDIR =ubuntu12_64
  66. else
  67. CXX = g++-4.8 -m32
  68. BINDIR =ubuntu12_32
  69. endif
  70. endif
  71. ifeq ($(IS_X86),1)
  72. IS_GCC_29 := $(shell $(CXX) -v 2>&1 | $(EGREP) -i -c gcc-9[0-9][0-9])
  73. GCC42_OR_LATER := $(shell $(CXX) -v 2>&1 | $(EGREP) -i -c "gcc version (4\.[2-9]|[5-9]\.)")
  74. GCC46_OR_LATER := $(shell $(CXX) -v 2>&1 | $(EGREP) -i -c "gcc version (4\.[6-9]|[5-9]\.)")
  75. GCC48_OR_LATER := $(shell $(CXX) -v 2>&1 | $(EGREP) -i -c "gcc version (4\.[8-9]|[5-9]\.)")
  76. GCC49_OR_LATER := $(shell $(CXX) -v 2>&1 | $(EGREP) -i -c "gcc version (4\.9|[5-9]\.)")
  77. ICC111_OR_LATER := $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\) ([2-9][0-9]|1[2-9]|11\.[1-9])")
  78. 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])")
  79. 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])")
  80. 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])")
  81. # Add -fPIC for x86_64, but not X32, Cygwin or MinGW
  82. ifneq ($(IS_X86_64),0)
  83. IS_X32 := $(shell $(CXX) -dM -E - < /dev/null 2>&1 | $(EGREP) -c "ILP32")
  84. ifeq ($(IS_X32)$(IS_CYGWIN)$(IS_MINGW),000)
  85. ifeq ($(findstring -fPIC,$(CXXFLAGS)),)
  86. CXXFLAGS += -fPIC
  87. endif
  88. endif
  89. endif
  90. # Guard use of -march=native
  91. ifeq ($(GCC_COMPILER),0)
  92. CXXFLAGS += -march=native
  93. else ifneq ($(GCC42_OR_LATER),0)
  94. ifeq ($(UNAME),Darwin)
  95. CXXFLAGS += -arch x86_64 -arch i386
  96. else
  97. ifeq ($(ISX64),1)
  98. CXXFLAGS += -march=x86-64
  99. else
  100. CXXFLAGS += -march=pentium4
  101. endif
  102. endif
  103. endif
  104. # Aligned access required at -O3 for GCC due to vectorization (circa 08/2008). Expect other compilers to do the same.
  105. UNALIGNED_ACCESS := $(shell $(EGREP) -c "^[[:space:]]*//[[:space:]]*\#[[:space:]]*define[[:space:]]*CRYPTOPP_NO_UNALIGNED_DATA_ACCESS" config.h)
  106. ifeq ($(findstring -O3,$(CXXFLAGS)),-O3)
  107. ifneq ($(UNALIGNED_ACCESS),0)
  108. ifeq ($(GCC46_OR_LATER),1)
  109. ifeq ($(findstring -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS,$(CXXFLAGS)),)
  110. CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
  111. endif # CRYPTOPP_NO_UNALIGNED_DATA_ACCESS
  112. endif # GCC 4.6
  113. endif # UNALIGNED_ACCESS
  114. endif # Vectorization
  115. ifneq ($(INTEL_COMPILER),0)
  116. CXXFLAGS += -wd68 -wd186 -wd279 -wd327 -wd161 -wd3180
  117. ifeq ($(ICC111_OR_LATER),0)
  118. # "internal error: backend signals" occurs on some x86 inline assembly with ICC 9 and some x64 inline assembly with ICC 11.0
  119. # if you want to use Crypto++'s assembly code with ICC, try enabling it on individual files
  120. CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
  121. endif
  122. endif
  123. ifeq ($(GCC_COMPILER)$(GAS210_OR_LATER),10) # .intel_syntax wasn't supported until GNU assembler 2.10
  124. CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
  125. else
  126. ifeq ($(GCC_COMPILER)$(GAS217_OR_LATER),10)
  127. CXXFLAGS += -DCRYPTOPP_DISABLE_SSSE3
  128. else
  129. ifeq ($(GCC_COMPILER)$(GAS219_OR_LATER),10)
  130. CXXFLAGS += -DCRYPTOPP_DISABLE_AESNI
  131. endif
  132. endif
  133. ifneq ($(IS_SUN),0)
  134. CXXFLAGS += -Wa,--divide # allow use of "/" operator
  135. endif
  136. endif
  137. endif # IS_X86
  138. ifeq ($(UNAME),) # for DJGPP, where uname doesn't exist
  139. CXXFLAGS += -mbnu210
  140. else ifneq ($(findstring -save-temps,$(CXXFLAGS)),-save-temps)
  141. CXXFLAGS += -pipe
  142. endif
  143. ifneq ($(IS_MINGW),0)
  144. LDLIBS += -lws2_32
  145. endif
  146. ifeq ($(IS_LINUX),1)
  147. LDFLAGS += -pthread
  148. ifeq ($(findstring -fopenmp,$(CXXFLAGS)),-fopenmp)
  149. ifeq ($(findstring -lgomp,$(LDLIBS)),)
  150. LDLIBS += -lgomp
  151. endif # LDLIBS
  152. endif # OpenMP
  153. ifneq ($(IS_X86_64),0)
  154. M32OR64 = -m64
  155. endif
  156. endif # IS_LINUX
  157. # And add it for ARM64, too
  158. ifneq ($(IS_AARCH64),0)
  159. ifeq ($(findstring -fPIC,$(CXXFLAGS)),)
  160. CXXFLAGS += -fPIC
  161. endif
  162. endif
  163. ifneq ($(IS_DARWIN),0)
  164. AR = libtool
  165. ARFLAGS = -static -o
  166. # VALVE: Mac build compatibility
  167. CXX = clang++
  168. CXXFLAGS = -std=c++11 -stdlib=libc++ -DNDEBUG -g2 -O2 -fPIC -ffunction-sections -fdata-sections -mstackrealign -fvisibility=hidden -w -march=core2 -pipe -arch x86_64 -arch i386 -mmacosx-version-min=10.7 -DCRYPTOPP_DISABLE_ASM
  169. BINDIR = osx32
  170. ifeq ($(IS_GCC_29),1)
  171. CXXFLAGS += -fno-coalesce-templates -fno-coalesce-static-vtables
  172. LDLIBS += -lstdc++
  173. LDFLAGS += -flat_namespace -undefined suppress -m
  174. endif
  175. endif
  176. ifneq ($(IS_SUN),0)
  177. LDLIBS += -lnsl -lsocket
  178. M32OR64 = -m$(shell isainfo -b)
  179. endif
  180. ifneq ($(SUN_COMPILER),0) # override flags for CC Sun C++ compiler
  181. CXXFLAGS ?= -DNDEBUG -O -g0 -native -template=no%extdef $(M32OR64)
  182. LDFLAGS =
  183. AR = $(CXX)
  184. ARFLAGS = -xar -o
  185. RANLIB = true
  186. SUN_CC10_BUGGY := $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: Sun .* 5\.10 .* (2009|2010/0[1-4])")
  187. ifneq ($(SUN_CC10_BUGGY),0)
  188. # -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
  189. # remove it if you get "already had a body defined" errors in vector.cc
  190. CXXFLAGS += -DCRYPTOPP_INCLUDE_VECTOR_CC
  191. endif
  192. endif
  193. # Undefined Behavior Sanitizer (UBsan) testing. There's no sense in
  194. # allowing unaligned data access. There will too many findings.
  195. ifeq ($(findstring ubsan,$(MAKECMDGOALS)),ubsan)
  196. ifeq ($(findstring -fsanitize=undefined,$(CXXFLAGS)),)
  197. CXXFLAGS += -fsanitize=undefined
  198. endif # CXXFLAGS
  199. ifeq ($(findstring -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS,$(CXXFLAGS)),)
  200. CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
  201. endif # CXXFLAGS
  202. endif # UBsan
  203. # Address Sanitizer (Asan) testing
  204. ifeq ($(findstring asan,$(MAKECMDGOALS)),asan)
  205. ifeq ($(findstring -fsanitize=address,$(CXXFLAGS)),)
  206. CXXFLAGS += -fsanitize=address
  207. endif # CXXFLAGS
  208. endif # Asan
  209. # LD gold linker testing
  210. ifeq ($(findstring ld.gold,$(LD)),ld.gold)
  211. ifeq ($(findstring -Wl,-fuse-ld=gold,$(CXXFLAGS)),)
  212. ELF_FORMAT := $(shell file `which ld.gold` 2>&1 | cut -d":" -f 2 | $(EGREP) -i -c "elf")
  213. ifneq ($(ELF_FORMAT),0)
  214. GOLD_OPTION = -Wl,-fuse-ld=gold
  215. endif # ELF/ELF64
  216. endif # CXXFLAGS
  217. endif # Gold
  218. # Aligned access testing
  219. ifneq ($(filter align aligned,$(MAKECMDGOALS)),)
  220. ifeq ($(findstring -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS,$(CXXFLAGS)),)
  221. CXXFLAGS += -DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS
  222. endif # # CXXFLAGS
  223. endif # Aligned access
  224. # Debug testing on GNU systems
  225. ifneq ($(filter -DDEBUG -DDEBUG=1,$(CXXFLAGS)),)
  226. USING_GLIBCXX := $(shell $(CXX) -x c++ $(CXXFLAGS) -E adhoc.cpp.proto 2>&1 | $(EGREP) -i -c "__GLIBCXX__")
  227. ifneq ($(USING_GLIBCXX),0)
  228. ifeq ($(findstring -D_GLIBCXX_DEBUG,$(CXXFLAGS)),)
  229. CXXFLAGS += -D_GLIBCXX_DEBUG
  230. endif # CXXFLAGS
  231. ifeq ($(findstring -D_GLIBCXX_CONCEPT_CHECKS,$(CXXFLAGS)),)
  232. CXXFLAGS += -D_GLIBCXX_CONCEPT_CHECKS
  233. endif # CXXFLAGS
  234. endif # USING_GLIBCXX
  235. endif # GNU Debug build
  236. # List cryptlib.cpp first and cpu.o second in an attempt to tame C++ static initialization problems. The issue
  237. # spills into POD data types, so cpu.cpp is the second candidate for explicit initialization order.
  238. SRCS := cryptlib.cpp cpu.cpp $(filter-out cryptlib.cpp cpu.cpp pch.cpp simple.cpp winpipes.cpp cryptlib_bds.cpp,$(wildcard *.cpp))
  239. # No need for CPU or RDRAND on non-X86 systems. X32 is represented with X64.
  240. ifeq ($(IS_X86)$(IS_X86_64),00)
  241. SRCS := $(filter-out cpu.cpp rdrand.cpp, $(SRCS))
  242. endif
  243. # VALVE - cut out RDRAND, its hard to compile on Mac and we don't ever use it.
  244. ifneq ($(IS_DARWIN),0)
  245. SRCS := $(filter-out rdrand.cpp, $(SRCS))
  246. endif
  247. ifneq ($(IS_MINGW),0)
  248. SRCS += winpipes.cpp
  249. endif
  250. # List of objects with crytlib.o and cpu.o at the first and second index position
  251. OBJS := $(SRCS:.cpp=.o)
  252. # test.o needs to be after bench.o for cygwin 1.1.4 (possible ld bug?)
  253. TESTOBJS := bench.o bench2.o test.o validat1.o validat2.o validat3.o adhoc.o datatest.o regtest.o fipsalgt.o dlltest.o
  254. LIBOBJS := $(filter-out $(TESTOBJS),$(OBJS))
  255. # List cryptlib.cpp first in an attempt to tame C++ static initialization problems
  256. DLLSRCS := cryptlib.cpp algebra.cpp algparam.cpp asn.cpp basecode.cpp cbcmac.cpp channels.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
  257. DLLOBJS := $(DLLSRCS:.cpp=.export.o)
  258. # Import lib testing
  259. LIBIMPORTOBJS := $(LIBOBJS:.o=.import.o)
  260. TESTIMPORTOBJS := $(TESTOBJS:.o=.import.o)
  261. DLLTESTOBJS := dlltest.dllonly.o
  262. # For Shared Objects, Diff, Dist/Zip rules
  263. LIB_VER := $(shell $(EGREP) "define CRYPTOPP_VERSION" config.h | cut -d" " -f 3)
  264. LIB_MAJOR := $(shell echo $(LIB_VER) | cut -c 1)
  265. LIB_MINOR := $(shell echo $(LIB_VER) | cut -c 2)
  266. LIB_PATCH := $(shell echo $(LIB_VER) | cut -c 3)
  267. ifeq ($(strip $(LIB_PATCH)),)
  268. LIB_PATCH := 0
  269. endif
  270. #VALVE: We only really need to build libcryptopp.a on Linux and Mac
  271. all: start_status libcryptopp.a end_status
  272. ifneq ($(IS_DARWIN),0)
  273. static: libcryptopp.a
  274. shared dynamic dylib: libcryptopp.dylib
  275. else
  276. static: libcryptopp.a
  277. shared dynamic: libcryptopp.so
  278. endif
  279. .PHONY: deps
  280. deps GNUmakefile.deps:
  281. $(CXX) $(CXXFLAGS) -MM *.cpp > GNUmakefile.deps
  282. .PHONY: asan ubsan align aligned
  283. asan ubsan align aligned: libcryptopp.a cryptest.exe
  284. .PHONY: test check
  285. test check: cryptest.exe
  286. ./cryptest.exe v
  287. # Directory we want (can't specify on Doygen command line)
  288. DOCUMENT_DIRECTORY := ref$(LIB_VER)
  289. # Directory Doxygen uses (specified in Doygen config file)
  290. ifeq ($(wildcard Doxyfile),Doxyfile)
  291. DOXYGEN_DIRECTORY := $(strip $(shell $(EGREP) "OUTPUT_DIRECTORY" Doxyfile | grep -v "\#" | cut -d "=" -f 2))
  292. endif
  293. # Default directory (missing in config file)
  294. ifeq ($(strip $(DOXYGEN_DIRECTORY)),)
  295. DOXYGEN_DIRECTORY := html-docs
  296. endif
  297. .PHONY: docs html
  298. docs html:
  299. -$(RM) -r $(DOXYGEN_DIRECTORY)/ $(DOCUMENT_DIRECTORY)/ html-docs/
  300. doxygen Doxyfile -d CRYPTOPP_DOXYGEN_PROCESSING
  301. mv $(DOXYGEN_DIRECTORY)/ $(DOCUMENT_DIRECTORY)/
  302. -$(RM) CryptoPPRef.zip
  303. zip -9 CryptoPPRef.zip -x ".*" -x "*/.*" -r $(DOCUMENT_DIRECTORY)/
  304. .PHONY: clean
  305. clean:
  306. -$(RM) libcryptopp.a libcryptopp.so libcryptopp.dylib cryptopp.dll libcryptopp.dll.a libcryptopp.import.a
  307. -$(RM) adhoc.cpp.o adhoc.cpp.proto.o $(LIBOBJS) $(TESTOBJS) $(DLLOBJS) $(LIBIMPORTOBJS) $(TESTIMPORTOBJS) $(DLLTESTOBJS) *.stackdump core-*
  308. -$(RM) cryptest.exe dlltest.exe cryptest.import.exe ct rdrand-???.o
  309. ifneq ($(wildcard *.exe.dSYM),)
  310. -$(RM) -r *.exe.dSYM/
  311. endif
  312. ifneq ($(wildcard $(DOCUMENT_DIRECTORY)/),)
  313. -$(RM) -r $(DOCUMENT_DIRECTORY)/
  314. endif
  315. ifneq ($(wildcard cov-int/),)
  316. -$(RM) -r cov-int/
  317. endif
  318. .PHONY: distclean
  319. distclean: clean
  320. -$(RM) adhoc.cpp adhoc.cpp.copied GNUmakefile.deps benchmarks.html cryptest.txt cryptest-*.txt *.o *.ii *.s
  321. ifneq ($(wildcard cryptopp$(LIB_VER)\.*),)
  322. -$(RM) cryptopp$(LIB_VER)\.*
  323. endif
  324. ifneq ($(wildcard $(DOC_DIRECTORY)),)
  325. -$(RM) -r $(DOC_DIRECTORY)
  326. endif
  327. ifneq ($(wildcard CryptoPPRef.zip),)
  328. -$(RM) CryptoPPRef.zip
  329. endif
  330. .PHONY: install
  331. install:
  332. $(MKDIR) -p $(PREFIX)/include/cryptopp $(PREFIX)/lib $(PREFIX)/bin
  333. -$(CP) *.h $(PREFIX)/include/cryptopp
  334. -$(CHMOD) 755 $(PREFIX)/include/cryptopp
  335. -$(CHMOD) 644 $(PREFIX)/include/cryptopp/*.h
  336. -$(CP) libcryptopp.a $(PREFIX)/lib
  337. -$(CHMOD) 644 $(PREFIX)/lib/libcryptopp.a
  338. -$(CP) cryptest.exe $(PREFIX)/bin
  339. -$(CHMOD) 755 $(PREFIX)/bin/cryptest.exe
  340. ifneq ($(IS_DARWIN),0)
  341. -$(CP) libcryptopp.dylib $(PREFIX)/lib
  342. -$(CHMOD) 755 $(PREFIX)/lib/libcryptopp.dylib
  343. else
  344. -$(CP) libcryptopp.so $(PREFIX)/lib
  345. -$(CHMOD) 755 $(PREFIX)/lib/libcryptopp.so
  346. endif
  347. .PHONY: remove uninstall
  348. remove uninstall:
  349. -$(RM) -r $(PREFIX)/include/cryptopp
  350. -$(RM) $(PREFIX)/lib/libcryptopp.a
  351. -$(RM) $(PREFIX)/bin/cryptest.exe
  352. ifneq ($(IS_DARWIN),0)
  353. -$(RM) $(PREFIX)/lib/libcryptopp.dylib
  354. else
  355. -$(RM) $(PREFIX)/lib/libcryptopp.so
  356. endif
  357. libcryptopp.a: public_service | $(LIBOBJS)
  358. $(AR) $(ARFLAGS) $@ $(LIBOBJS)
  359. $(RANLIB) $@
  360. #VALVE: Copy the file into the right spot.
  361. p4 edit ../../lib/$(BINDIR)/release/libcryptopp.a
  362. $(CP) libcryptopp.a ../../lib/$(BINDIR)/release
  363. libcryptopp.so: public_service | $(LIBOBJS)
  364. $(CXX) -shared -o $@ $(CXXFLAGS) $(GOLD_OPTION) $(LIBOBJS) $(LDLIBS)
  365. libcryptopp.dylib: $(LIBOBJS)
  366. $(CXX) -dynamiclib -o $@ $(CXXFLAGS) -install_name "$@" -current_version "$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)" -compatibility_version "$(LIB_MAJOR).$(LIB_MINOR)" $(LIBOBJS)
  367. cryptest.exe: public_service | libcryptopp.a $(TESTOBJS)
  368. $(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) ./libcryptopp.a $(LDFLAGS) $(GOLD_OPTION) $(LDLIBS)
  369. nolib: $(OBJS) # makes it faster to test changes
  370. $(CXX) -o ct $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS)
  371. dll: cryptest.import.exe dlltest.exe
  372. cryptopp.dll: $(DLLOBJS)
  373. $(CXX) -shared -o $@ $(CXXFLAGS) $(DLLOBJS) $(LDFLAGS) $(LDLIBS) -Wl,--out-implib=libcryptopp.dll.a
  374. libcryptopp.import.a: $(LIBIMPORTOBJS)
  375. $(AR) $(ARFLAGS) $@ $(LIBIMPORTOBJS)
  376. $(RANLIB) $@
  377. cryptest.import.exe: cryptopp.dll libcryptopp.import.a $(TESTIMPORTOBJS)
  378. $(CXX) -o $@ $(CXXFLAGS) $(TESTIMPORTOBJS) -L. -lcryptopp.dll -lcryptopp.import $(LDFLAGS) $(LDLIBS)
  379. dlltest.exe: cryptopp.dll $(DLLTESTOBJS)
  380. $(CXX) -o $@ $(CXXFLAGS) $(DLLTESTOBJS) -L. -lcryptopp.dll $(LDFLAGS) $(LDLIBS)
  381. # This recipe requires a previous "svn co -r 541 http://svn.code.sf.net/p/cryptopp/code/trunk/c5"
  382. .PHONY: diff
  383. diff:
  384. -$(RM) cryptopp$(LIB_VER).diff
  385. -svn diff -r 541 > cryptopp$(LIB_VER).diff
  386. # This recipe prepares the distro files
  387. TEXT_FILES := *.h *.cpp adhoc.cpp.proto License.txt Readme.txt Install.txt Filelist.txt config.recommend Doxyfile cryptest* cryptlib* dlltest* cryptdll* *.sln *.vcproj *.dsw *.dsp cryptopp.rc TestVectors/*.txt TestData/*.dat
  388. EXEC_FILES := GNUmakefile GNUmakefile-cross cryptest.sh rdrand-nasm.sh TestData/ TestVectors/
  389. ifeq ($(wildcard Filelist.txt),Filelist.txt)
  390. DIST_FILES := $(shell cat Filelist.txt)
  391. endif
  392. .PHONY: convert
  393. convert:
  394. chmod 0700 TestVectors/ TestData/
  395. chmod 0600 $(TEXT_FILES) *.zip
  396. chmod 0700 $(EXEC_FILES)
  397. chmod u+x *.cmd *.sh
  398. unix2dos --keepdate --quiet $(TEXT_FILES) *.asm *.cmd
  399. dos2unix --keepdate --quiet GNUmakefile GNUmakefile-cross *.S *.sh
  400. ifneq ($(IS_DARWIN),0)
  401. xattr -c *
  402. endif
  403. .PHONY: zip dist
  404. zip dist: | distclean convert diff
  405. zip -q -9 cryptopp$(LIB_VER).zip $(DIST_FILES)
  406. .PHONY: bench benchmark benchmarks
  407. bench benchmark benchmarks: cryptest.exe
  408. rm -f benchmarks.html
  409. echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">" >> benchmarks.html
  410. echo "<HTML>" >> benchmarks.html
  411. echo "<HEAD>" >> benchmarks.html
  412. echo "<TITLE>Speed Comparison of Popular Crypto Algorithms</TITLE>" >> benchmarks.html
  413. echo "</HEAD>" >> benchmarks.html
  414. echo "<BODY>" >> benchmarks.html
  415. echo "<H1><a href=\"http://www.cryptopp.com\">Crypto++</a>" $(LIB_MAJOR).$(LIB_MINOR).$(LIB_REVISION) "Benchmarks</H1>" >> benchmarks.html
  416. echo "<P>Here are speed benchmarks for some commonly used cryptographic algorithms.</P>" >> benchmarks.html
  417. ./cryptest.exe b 3 2.4 >> benchmarks.html
  418. echo "</BODY>" >> benchmarks.html
  419. echo "</HTML>" >> benchmarks.html
  420. adhoc.cpp: adhoc.cpp.proto
  421. ifeq ($(wildcard adhoc.cpp),)
  422. cp adhoc.cpp.proto adhoc.cpp
  423. else
  424. touch adhoc.cpp
  425. endif
  426. # Include dependencies, if present. You must issue `make deps` to create them.
  427. ifeq ($(wildcard GNUmakefile.deps),GNUmakefile.deps)
  428. -include GNUmakefile.deps
  429. endif # Dependencies
  430. # MacPorts/GCC issue with init_priority. Apple/GCC and Fink/GCC are fine; limit to MacPorts.
  431. # Also see http://lists.macosforge.org/pipermail/macports-users/2015-September/039223.html
  432. ifeq ($(GCC_COMPILER)$(MACPORTS_COMPILER),11)
  433. ifeq ($(findstring -DMACPORTS_GCC_COMPILER,$(CXXFLAGS)),)
  434. cryptlib.o:
  435. $(CXX) $(CXXFLAGS) -DMACPORTS_GCC_COMPILER=1 -c cryptlib.cpp
  436. cpu.o:
  437. $(CXX) $(CXXFLAGS) -DMACPORTS_GCC_COMPILER=1 -c cpu.cpp
  438. endif
  439. endif
  440. %.dllonly.o : %.cpp
  441. $(CXX) $(CXXFLAGS) -DCRYPTOPP_DLL_ONLY -c $< -o $@
  442. %.import.o : %.cpp
  443. $(CXX) $(CXXFLAGS) -DCRYPTOPP_IMPORTS -c $< -o $@
  444. %.export.o : %.cpp
  445. $(CXX) $(CXXFLAGS) -DCRYPTOPP_EXPORTS -c $< -o $@
  446. %.o : %.cpp
  447. $(CXX) $(CXXFLAGS) -c $<
  448. # Verify the options.
  449. start_status:
  450. @echo $(BUILDVERSION);
  451. @if [ "$(MAKE_DEBUG)" == "1" ]; then\
  452. echo ""; \
  453. echo ""; \
  454. echo "NOTE: Relevant environment variables detected.";\
  455. if [ "$(MAKE_DEBUG)" == "1" ]; then\
  456. echo " MAKE_DEBUG was found so optimizations will be reduced.";\
  457. echo "";\
  458. echo "";\
  459. fi;\
  460. fi
  461. end_status:
  462. @if [ "$(MAKE_DEBUG)" == "1" ]; then\
  463. echo ""; \
  464. echo ""; \
  465. echo "NOTE: MAKE_DEBUG was found so a debug build was made.";\
  466. echo ""; \
  467. echo ""; \
  468. fi
  469. # Warn of potential configurations issues. They will go away after 5.6.3.
  470. UNALIGNED_ACCESS := $(shell $(EGREP) -c "^[[:space:]]*//[[:space:]]*\#[[:space:]]*define[[:space:]]*CRYPTOPP_NO_UNALIGNED_DATA_ACCESS" config.h)
  471. NO_INIT_PRIORITY := $(shell $(EGREP) -c "^[[:space:]]*//[[:space:]]*\#[[:space:]]*define[[:space:]]*CRYPTOPP_INIT_PRIORITY" config.h)
  472. COMPATIBILITY_562 := $(shell $(EGREP) -c "^[[:space:]]*\#[[:space:]]*define[[:space:]]*CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562" config.h)
  473. .PHONY: public_service
  474. public_service:
  475. ifneq ($(UNALIGNED_ACCESS),0)
  476. $(info WARNING: CRYPTOPP_NO_UNALIGNED_DATA_ACCESS is not defined in config.h.)
  477. endif
  478. ifneq ($(NO_INIT_PRIORITY),0)
  479. $(info WARNING: CRYPTOPP_INIT_PRIORITY is not defined in config.h.)
  480. endif
  481. ifneq ($(COMPATIBILITY_562),0)
  482. $(info WARNING: CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 is defined in config.h.)
  483. endif
  484. ifneq ($(UNALIGNED_ACCESS)$(NO_INIT_PRIORITY)$(COMPATIBILITY_562),000)
  485. $(info WARNING: You should make these changes in config.h, and not CXXFLAGS.)
  486. $(info WARNING: You can 'mv config.recommend config.h', but it breaks versioning.)
  487. $(info WARNING: See http://cryptopp.com/wiki/config.h for more details.)
  488. $(info )
  489. endif