Makefile 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. # (C)2004-2010 SourceMod Development Team
  2. # Makefile written by David "BAILOPAN" Anderson
  3. ###########################################
  4. ### EDIT THESE PATHS FOR YOUR OWN SETUP ###
  5. ###########################################
  6. SMSDK = ../..
  7. HL2SDK_ORIG = ../../../hl2sdk
  8. HL2SDK_OB = ../../../hl2sdk-ob
  9. HL2SDK_CSS = ../../../hl2sdk-css
  10. HL2SDK_OB_VALVE = ../../../hl2sdk-ob-valve
  11. HL2SDK_L4D = ../../../hl2sdk-l4d
  12. HL2SDK_L4D2 = ../../../hl2sdk-l4d2
  13. HL2SDK_CSGO = ../../../hl2sdk-csgo
  14. MMSOURCE19 = ../../../mmsource-1.9
  15. #####################################
  16. ### EDIT BELOW FOR OTHER PROJECTS ###
  17. #####################################
  18. PROJECT = sample
  19. #Uncomment for Metamod: Source enabled extension
  20. #USEMETA = true
  21. OBJECTS = smsdk_ext.cpp extension.cpp
  22. ##############################################
  23. ### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
  24. ##############################################
  25. C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing
  26. C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
  27. C_GCC4_FLAGS = -fvisibility=hidden
  28. CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
  29. CPP = gcc
  30. CPP_OSX = clang
  31. ##########################
  32. ### SDK CONFIGURATIONS ###
  33. ##########################
  34. override ENGSET = false
  35. # Check for valid list of engines
  36. ifneq (,$(filter original orangebox orangeboxvalve css left4dead left4dead2 csgo,$(ENGINE)))
  37. override ENGSET = true
  38. endif
  39. ifeq "$(ENGINE)" "original"
  40. HL2SDK = $(HL2SDK_ORIG)
  41. CFLAGS += -DSOURCE_ENGINE=1
  42. endif
  43. ifeq "$(ENGINE)" "orangebox"
  44. HL2SDK = $(HL2SDK_OB)
  45. CFLAGS += -DSOURCE_ENGINE=3
  46. endif
  47. ifeq "$(ENGINE)" "css"
  48. HL2SDK = $(HL2SDK_CSS)
  49. CFLAGS += -DSOURCE_ENGINE=6
  50. endif
  51. ifeq "$(ENGINE)" "orangeboxvalve"
  52. HL2SDK = $(HL2SDK_OB_VALVE)
  53. CFLAGS += -DSOURCE_ENGINE=7
  54. endif
  55. ifeq "$(ENGINE)" "left4dead"
  56. HL2SDK = $(HL2SDK_L4D)
  57. CFLAGS += -DSOURCE_ENGINE=8
  58. endif
  59. ifeq "$(ENGINE)" "left4dead2"
  60. HL2SDK = $(HL2SDK_L4D2)
  61. CFLAGS += -DSOURCE_ENGINE=9
  62. endif
  63. ifeq "$(ENGINE)" "csgo"
  64. HL2SDK = $(HL2SDK_CSGO)
  65. CFLAGS += -DSOURCE_ENGINE=12
  66. endif
  67. HL2PUB = $(HL2SDK)/public
  68. ifeq "$(ENGINE)" "original"
  69. INCLUDE += -I$(HL2SDK)/public/dlls
  70. METAMOD = $(MMSOURCE19)/core-legacy
  71. else
  72. INCLUDE += -I$(HL2SDK)/public/game/server
  73. METAMOD = $(MMSOURCE19)/core
  74. endif
  75. OS := $(shell uname -s)
  76. ifeq "$(OS)" "Darwin"
  77. LIB_EXT = dylib
  78. HL2LIB = $(HL2SDK)/lib/mac
  79. else
  80. LIB_EXT = so
  81. ifeq "$(ENGINE)" "original"
  82. HL2LIB = $(HL2SDK)/linux_sdk
  83. else
  84. HL2LIB = $(HL2SDK)/lib/linux
  85. endif
  86. endif
  87. # if ENGINE is original or OB
  88. ifneq (,$(filter original orangebox,$(ENGINE)))
  89. LIB_SUFFIX = _i486.$(LIB_EXT)
  90. else
  91. LIB_PREFIX = lib
  92. LIB_SUFFIX = .$(LIB_EXT)
  93. endif
  94. INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn
  95. ifeq "$(USEMETA)" "true"
  96. LINK_HL2 = $(HL2LIB)/tier1_i486.a $(LIB_PREFIX)vstdlib$(LIB_SUFFIX) $(LIB_PREFIX)tier0$(LIB_SUFFIX)
  97. ifeq "$(ENGINE)" "csgo"
  98. LINK_HL2 += $(HL2LIB)/interfaces_i486.a
  99. endif
  100. LINK += $(LINK_HL2)
  101. INCLUDE += -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I$(METAMOD) \
  102. -I$(METAMOD)/sourcehook
  103. CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_BLOODYGOODTIME=4 -DSE_EYE=5 \
  104. -DSE_CSS=6 -DSE_ORANGEBOXVALVE=7 -DSE_LEFT4DEAD=8 -DSE_LEFT4DEAD2=9 -DSE_ALIENSWARM=10 \
  105. -DSE_PORTAL2=11 -DSE_CSGO=12
  106. endif
  107. LINK += -m32 -lm -ldl
  108. CFLAGS += -DPOSIX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \
  109. -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -DCOMPILER_GCC -Wall -Werror \
  110. -Wno-overloaded-virtual -Wno-switch -Wno-unused -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32
  111. CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti
  112. ################################################
  113. ### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
  114. ################################################
  115. BINARY = $(PROJECT).ext.$(LIB_EXT)
  116. ifeq "$(DEBUG)" "true"
  117. BIN_DIR = Debug
  118. CFLAGS += $(C_DEBUG_FLAGS)
  119. else
  120. BIN_DIR = Release
  121. CFLAGS += $(C_OPT_FLAGS)
  122. endif
  123. ifeq "$(USEMETA)" "true"
  124. BIN_DIR := $(BIN_DIR).$(ENGINE)
  125. endif
  126. ifeq "$(OS)" "Darwin"
  127. CPP = $(CPP_OSX)
  128. LIB_EXT = dylib
  129. CFLAGS += -DOSX -D_OSX
  130. LINK += -dynamiclib -lstdc++ -mmacosx-version-min=10.5
  131. else
  132. LIB_EXT = so
  133. CFLAGS += -D_LINUX
  134. LINK += -shared
  135. endif
  136. IS_CLANG := $(shell $(CPP) --version | head -1 | grep clang > /dev/null && echo "1" || echo "0")
  137. ifeq "$(IS_CLANG)" "1"
  138. CPP_MAJOR := $(shell $(CPP) --version | grep clang | sed "s/.*version \([0-9]\)*\.[0-9]*.*/\1/")
  139. CPP_MINOR := $(shell $(CPP) --version | grep clang | sed "s/.*version [0-9]*\.\([0-9]\)*.*/\1/")
  140. else
  141. CPP_MAJOR := $(shell $(CPP) -dumpversion >&1 | cut -b1)
  142. CPP_MINOR := $(shell $(CPP) -dumpversion >&1 | cut -b3)
  143. endif
  144. # If not clang
  145. ifeq "$(IS_CLANG)" "0"
  146. CFLAGS += -mfpmath=sse
  147. endif
  148. # Clang || GCC >= 4
  149. ifeq "$(shell expr $(IS_CLANG) \| $(CPP_MAJOR) \>= 4)" "1"
  150. CFLAGS += $(C_GCC4_FLAGS)
  151. CPPFLAGS += $(CPP_GCC4_FLAGS)
  152. endif
  153. # Clang >= 3 || GCC >= 4.7
  154. ifeq "$(shell expr $(IS_CLANG) \& $(CPP_MAJOR) \>= 3 \| $(CPP_MAJOR) \>= 4 \& $(CPP_MINOR) \>= 7)" "1"
  155. CFLAGS += -Wno-delete-non-virtual-dtor
  156. endif
  157. # OS is Linux and not using clang
  158. ifeq "$(shell expr $(OS) \= Linux \& $(IS_CLANG) \= 0)" "1"
  159. LINK += -static-libgcc
  160. endif
  161. OBJ_BIN := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
  162. # This will break if we include other Makefiles, but is fine for now. It allows
  163. # us to make a copy of this file that uses altered paths (ie. Makefile.mine)
  164. # or other changes without mucking up the original.
  165. MAKEFILE_NAME := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
  166. $(BIN_DIR)/%.o: %.cpp
  167. $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
  168. all: check
  169. mkdir -p $(BIN_DIR)
  170. ln -sf ../smsdk_ext.cpp
  171. if [ "$(USEMETA)" = "true" ]; then \
  172. ln -sf $(HL2LIB)/$(LIB_PREFIX)vstdlib$(LIB_SUFFIX); \
  173. ln -sf $(HL2LIB)/$(LIB_PREFIX)tier0$(LIB_SUFFIX); \
  174. fi
  175. $(MAKE) -f $(MAKEFILE_NAME) extension
  176. check:
  177. if [ "$(USEMETA)" = "true" ] && [ "$(ENGSET)" = "false" ]; then \
  178. echo "You must supply one of the following values for ENGINE:"; \
  179. echo "csgo, left4dead2, left4dead, css, orangeboxvalve, orangebox, or original"; \
  180. exit 1; \
  181. fi
  182. extension: check $(OBJ_BIN)
  183. $(CPP) $(INCLUDE) $(OBJ_BIN) $(LINK) -o $(BIN_DIR)/$(BINARY)
  184. debug:
  185. $(MAKE) -f $(MAKEFILE_NAME) all DEBUG=true
  186. default: all
  187. clean: check
  188. rm -rf $(BIN_DIR)/*.o
  189. rm -rf $(BIN_DIR)/$(BINARY)