Counter Strike : Global Offensive Source Code
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.

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