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.

256 lines
7.9 KiB

  1. SHELL=/bin/bash
  2. CXXFLAGS = -DNDEBUG -g -O2
  3. #CXXFLAGS = -g
  4. # -fPIC is supported. Please report any breakage of -fPIC as a bug.
  5. CXXFLAGS += -fPIC
  6. # the following options reduce code size, but breaks link or makes link very slow on some systems
  7. CXXFLAGS += -ffunction-sections -fdata-sections
  8. # LDFLAGS += -Wl,--gc-sections
  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. BUILDVERSION="Building libcryptopp.a"
  17. # Default prefix for make install
  18. ifeq ($(PREFIX),)
  19. PREFIX = /usr
  20. endif
  21. # VALVE: Add support for debug builds if we need them
  22. ifeq ($(MAKE_DEBUG),1)
  23. OPTIMIZER_FLAGS=-g -ggdb
  24. else
  25. OPTIMIZER_FLAGS=-O2
  26. endif
  27. ifeq ($(CXX),gcc) # for some reason CXX is gcc on cygwin 1.1.4
  28. CXX = g++
  29. endif
  30. # VALVE: Some defaults to match the rest of the steam build
  31. CXXFLAGS += $(OPTIMIZER_FLAGS) -fvisibility=hidden -w
  32. # If we're building this for STEAMCMD, then we use the Valve compile tools
  33. ifeq ($(STEAMCMD),1)
  34. BUILDVERSION="Building libcryptopp.a for SteamCMD"
  35. CXX = /valve/bin/g++
  36. BINDIR =linux32
  37. else
  38. # Otherwise we're building for STEAM, so use the native compile tools
  39. BUILDVERSION="Building libcryptopp.a for Steam"
  40. CXX = /usr/bin/g++
  41. BINDIR =ubuntu12_32
  42. endif
  43. # on linux x86_64, use valve's compiler (and make sure not to specify -m32 in CXXFLAGS above"
  44. #CXX = /valve/gcc-4.5.1-glibc-2.9/x86_64-valve-linux-gnu/bin/x86_64-valve-linux-gnu-g++
  45. #BINDIR = linux64
  46. ifeq ($(ISX86),1)
  47. GCC42_OR_LATER = $(shell $(CXX) -v 2>&1 | $(EGREP) -c "^gcc version (4.[2-9]|[5-9])")
  48. INTEL_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\)")
  49. ICC111_OR_LATER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\) ([2-9][0-9]|1[2-9]|11\.[1-9])")
  50. IS_SUN_CC = $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: Sun")
  51. GAS210_OR_LATER = $(shell echo "" | $(AS) -v 2>&1 | $(EGREP) -c "GNU assembler version (2\.[1-9][0-9]|[3-9])")
  52. GAS217_OR_LATER = $(shell echo "" | $(AS) -v 2>&1 | $(EGREP) -c "GNU assembler version (2\.1[7-9]|2\.[2-9]|[3-9])")
  53. GAS219_OR_LATER = $(shell echo "" | $(AS) -v 2>&1 | $(EGREP) -c "GNU assembler version (2\.19|2\.[2-9]|[3-9])")
  54. ISMINGW = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "mingw")
  55. ifneq ($(GCC42_OR_LATER),0)
  56. ifeq ($(UNAME),Darwin)
  57. CXXFLAGS += -arch x86_64 -arch i386
  58. else
  59. CXXFLAGS += -march=pentium4
  60. endif
  61. endif
  62. ifneq ($(INTEL_COMPILER),0)
  63. CXXFLAGS += -wd68 -wd186 -wd279 -wd327
  64. ifeq ($(ICC111_OR_LATER),0)
  65. # "internal error: backend signals" occurs on some x86 inline assembly with ICC 9 and some x64 inline assembly with ICC 11.0
  66. # if you want to use Crypto++'s assembly code with ICC, try enabling it on individual files
  67. CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
  68. endif
  69. endif
  70. ifeq ($(GAS210_OR_LATER),0) # .intel_syntax wasn't supported until GNU assembler 2.10
  71. CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
  72. else
  73. ifeq ($(GAS217_OR_LATER),0)
  74. CXXFLAGS += -DCRYPTOPP_DISABLE_SSSE3
  75. else
  76. ifeq ($(GAS219_OR_LATER),0)
  77. CXXFLAGS += -DCRYPTOPP_DISABLE_AESNI
  78. endif
  79. endif
  80. ifeq ($(UNAME),SunOS)
  81. CXXFLAGS += -Wa,--divide # allow use of "/" operator
  82. endif
  83. endif
  84. ifeq ($(ISMINGW),1)
  85. LDLIBS += -lws2_32
  86. endif
  87. endif # ISX86
  88. ifeq ($(UNAME),) # for DJGPP, where uname doesn't exist
  89. CXXFLAGS += -mbnu210
  90. else
  91. CXXFLAGS += -pipe
  92. endif
  93. ifeq ($(UNAME),Linux)
  94. LDFLAGS += -pthread
  95. ifneq ($(shell uname -i | $(EGREP) -c "(_64|d64)"),0)
  96. M32OR64 = -m64
  97. endif
  98. endif
  99. ifeq ($(UNAME),Darwin)
  100. AR = libtool
  101. ARFLAGS = -static -o
  102. # VALVE: Mac build compatibility
  103. CXX = clang++
  104. #CXX = g++-4.2
  105. CXXFLAGS += -arch x86_64 -arch i386
  106. CXXFLAGS += -mmacosx-version-min=10.7
  107. CXXFLAGS += -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
  108. BINDIR = common/osx32
  109. CXXFLAGS += -std=c++11 -stdlib=libc++
  110. #CXXFLAGS += -fno-coalesce-templates -fno-coalesce-static-vtables
  111. #LDLIBS += -lstdc++
  112. LDFLAGS += -stdlib=libc++
  113. endif
  114. ifeq ($(UNAME),SunOS)
  115. LDLIBS += -lnsl -lsocket
  116. M32OR64 = -m$(shell isainfo -b)
  117. endif
  118. ifneq ($(IS_SUN_CC),0) # override flags for CC Sun C++ compiler
  119. CXXFLAGS = -DNDEBUG -O -g0 -native -template=no%extdef $(M32OR64)
  120. LDFLAGS =
  121. AR = $(CXX)
  122. ARFLAGS = -xar -o
  123. RANLIB = true
  124. SUN_CC10_BUGGY = $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: Sun .* 5\.10 .* (2009|2010/0[1-4])")
  125. ifneq ($(SUN_CC10_BUGGY),0)
  126. # -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
  127. # remove it if you get "already had a body defined" errors in vector.cc
  128. CXXFLAGS += -DCRYPTOPP_INCLUDE_VECTOR_CC
  129. endif
  130. endif
  131. SRCS = $(wildcard *.cpp)
  132. ifeq ($(SRCS),) # workaround wildcard function bug in GNU Make 3.77
  133. SRCS = $(shell echo *.cpp)
  134. endif
  135. OBJS = $(SRCS:.cpp=.o)
  136. # test.o needs to be after bench.o for cygwin 1.1.4 (possible ld bug?)
  137. TESTOBJS = bench.o bench2.o test.o validat1.o validat2.o validat3.o adhoc.o datatest.o regtest.o fipsalgt.o dlltest.o
  138. LIBOBJS = $(filter-out $(TESTOBJS),$(OBJS))
  139. 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
  140. DLLOBJS = $(DLLSRCS:.cpp=.export.o)
  141. LIBIMPORTOBJS = $(LIBOBJS:.o=.import.o)
  142. TESTIMPORTOBJS = $(TESTOBJS:.o=.import.o)
  143. DLLTESTOBJS = dlltest.dllonly.o
  144. #VALVE: We only really need to build libcryptopp.a on Linux and Mac
  145. all: start_status libcryptopp.a end_status
  146. test: cryptest.exe
  147. ./cryptest.exe v
  148. clean:
  149. $(RM) cryptest.exe libcryptopp.a $(LIBOBJS) $(TESTOBJS) cryptopp.dll libcryptopp.dll.a libcryptopp.import.a cryptest.import.exe dlltest.exe $(DLLOBJS) $(LIBIMPORTOBJS) $(TESTIMPORTOBJS) $(DLLTESTOBJS)
  150. install:
  151. $(MKDIR) -p $(PREFIX)/include/cryptopp $(PREFIX)/lib $(PREFIX)/bin
  152. $(CP) *.h $(PREFIX)/include/cryptopp
  153. $(CP) *.a $(PREFIX)/lib
  154. $(CP) *.so $(PREFIX)/lib
  155. $(CP) *.exe $(PREFIX)/bin
  156. libcryptopp.a: $(LIBOBJS)
  157. $(AR) $(ARFLAGS) $@ $(LIBOBJS)
  158. $(RANLIB) $@
  159. #VALVE: Copy the file into the right spot. This doesn't handle perforce, you need to do that yourself.
  160. $(CP) libcryptopp.a ../../lib/$(BINDIR)/release
  161. libcryptopp.so: $(LIBOBJS)
  162. $(CXX) -shared -o $@ $(LIBOBJS)
  163. cryptest.exe: libcryptopp.a $(TESTOBJS)
  164. $(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) -L. -lcryptopp $(LDFLAGS) $(LDLIBS)
  165. nolib: $(OBJS) # makes it faster to test changes
  166. $(CXX) -o ct $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS)
  167. dll: cryptest.import.exe dlltest.exe
  168. cryptopp.dll: $(DLLOBJS)
  169. $(CXX) -shared -o $@ $(CXXFLAGS) $(DLLOBJS) $(LDFLAGS) $(LDLIBS) -Wl,--out-implib=libcryptopp.dll.a
  170. libcryptopp.import.a: $(LIBIMPORTOBJS)
  171. $(AR) $(ARFLAGS) $@ $(LIBIMPORTOBJS)
  172. $(RANLIB) $@
  173. cryptest.import.exe: cryptopp.dll libcryptopp.import.a $(TESTIMPORTOBJS)
  174. $(CXX) -o $@ $(CXXFLAGS) $(TESTIMPORTOBJS) -L. -lcryptopp.dll -lcryptopp.import $(LDFLAGS) $(LDLIBS)
  175. dlltest.exe: cryptopp.dll $(DLLTESTOBJS)
  176. $(CXX) -o $@ $(CXXFLAGS) $(DLLTESTOBJS) -L. -lcryptopp.dll $(LDFLAGS) $(LDLIBS)
  177. adhoc.cpp: adhoc.cpp.proto
  178. ifeq ($(wildcard adhoc.cpp),)
  179. cp adhoc.cpp.proto adhoc.cpp
  180. else
  181. touch adhoc.cpp
  182. endif
  183. %.dllonly.o : %.cpp
  184. $(CXX) $(CXXFLAGS) -DCRYPTOPP_DLL_ONLY -c $< -o $@
  185. %.import.o : %.cpp
  186. $(CXX) $(CXXFLAGS) -DCRYPTOPP_IMPORTS -c $< -o $@
  187. %.export.o : %.cpp
  188. $(CXX) $(CXXFLAGS) -DCRYPTOPP_EXPORTS -c $< -o $@
  189. %.o : %.cpp
  190. $(CXX) $(CXXFLAGS) -c $<
  191. # Verify the options.
  192. start_status:
  193. @echo $(BUILDVERSION);
  194. @if [ "$(MAKE_DEBUG)" == "1" ]; then\
  195. echo ""; \
  196. echo ""; \
  197. echo "NOTE: Relevant environment variables detected.";\
  198. if [ "$(MAKE_DEBUG)" == "1" ]; then\
  199. echo " MAKE_DEBUG was found so optimizations will be reduced.";\
  200. echo "";\
  201. echo "";\
  202. fi;\
  203. fi
  204. end_status:
  205. @if [ "$(MAKE_DEBUG)" == "1" ]; then\
  206. echo ""; \
  207. echo ""; \
  208. echo "NOTE: MAKE_DEBUG was found so a debug build was made.";\
  209. echo ""; \
  210. echo ""; \
  211. fi