Open Source Tomb Raider Engine
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Makefile 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. ###############################################################
  2. # Mongoose <stu7440@westga.edu>
  3. ###############################################################
  4. # + Cleaner clean
  5. # + Add new include tree
  6. # + Add new flags
  7. # + Install/Uninstall
  8. # + Debian and Redhat packaging
  9. # + Lots of misc new features
  10. ###############################################################
  11. BUILD_SELECT=debug
  12. NAME=OpenRaider
  13. NAME_TAR=openraider
  14. MAJOR_VERSION=0
  15. MINOR_VERSION=1
  16. MICRO_VERSION=2
  17. BUILD_ID=$(shell date "+%Y%m%d")
  18. PRE=
  19. VERSION=$(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)$(PRE)
  20. VERSION_DEB=$(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION).$(BUILD_ID)
  21. BUILD_HOST=$(shell uname -s -n -r -m)
  22. ARCH=$(shell uname -m -s | sed -e "s/ /-/g")
  23. UNAME=$(shell uname -s)
  24. ###############################################################
  25. # -DMULTITEXTURE Add OpenGL multitexturing
  26. # -DUNICODE_SUPPORT Add unicode/internation keyboard support
  27. # -DUSING_EMITTER_IN_GAME Run particle test in game
  28. BASE_DEFS=$(shell sdl-config --cflags) -Iinclude -DSDL_INTERFACE \
  29. -DUSING_OPENGL -DZLIB_SUPPORT -DUSING_EMITTER \
  30. -DUSING_OPENAL -DUSING_TGA -DUSING_PTHREADS \
  31. BASE_LIBS=$(shell sdl-config --libs) -lz -lstdc++ \
  32. -lpthread -lSDL_ttf
  33. # -DDEBUG_GL
  34. DEBUG_DEFS=-DDEBUG -DEXPERIMENTAL
  35. DEBUG_OBJ=
  36. ifeq ($(UNAME),Darwin)
  37. AUDIO_LIBS += -lalut
  38. AUDIO_LIBS += -framework OpenAL
  39. AUDIO_LIBS += -L/usr/local/lib
  40. AUDIO_DEFS += -I/usr/local/include
  41. GL_LIBS += -framework OpenGL
  42. GL_LIBS += -L/opt/local/lib
  43. GL_DEFS += -I/opt/local/include
  44. else
  45. AUDIO_LIBS += -lopenal
  46. GL_LIBS += -lGL -lGLU
  47. GL_LIBS += -L/usr/local/lib
  48. GL_DEFS += -I/usr/local/include
  49. endif
  50. BASE_LIBS += $(AUDIO_LIBS)
  51. BASE_LIBS += $(GL_LIBS)
  52. BASE_DEFS += $(AUDIO_DEFS)
  53. BASE_DEFS += $(GL_DEFS)
  54. # libferit, File transfer via HTTP/FTP/etc support
  55. LIBFERIT_LIB=/usr/local/lib/libferit.so
  56. LIBFERIT=$(shell if test -e $(LIBFERIT_LIB) > /dev/null; then echo yes; fi)
  57. ifeq ($(LIBFERIT), yes)
  58. BASE_DEFS += -DHAVE_LIBFERIT
  59. BASE_LIBS += -lferit
  60. endif
  61. ###############################################################
  62. TREE_DIR=OpenRaider
  63. BUILD_DEBUG_DIR=bin/debug
  64. BUILD_RELEASE_DIR=bin/release
  65. BUILD_PROF_DIR=bin/prof
  66. BUILD_TEST_DIR=bin/test
  67. BUILD_MEM_DIR=bin/mem
  68. BUILD_INSTALL_DIR=bin/$(BUILD_SELECT)
  69. DEB_DIR=/tmp/$(NAME).deb
  70. # Edited for Debian GNU/Linux.
  71. DESTDIR =
  72. INSTALL_BIN=$(DESTDIR)/usr/games
  73. INSTALL_LIB=$(DESTDIR)/usr/lib
  74. INSTALL_DOC=$(DESTDIR)/usr/share/doc/$(NAME)
  75. INSTALL_SHARE=$(DESTDIR)/usr/share/$(NAME)
  76. INSTALL_INCLUDE=$(DESTDIR)/usr/include
  77. ###############################################################
  78. CC=gcc
  79. WARNINGS=-Weverything -Wno-padded -Wno-packed -Wno-documentation
  80. WARNINGS+=-Wno-documentation-unknown-command -Wno-format-nonliteral
  81. WARNINGS+=-Wno-covered-switch-default -Wno-global-constructors
  82. WARNINGS+=-Wno-exit-time-destructors -Wno-c++98-compat-pedantic
  83. WARNINGS+=-Wno-disabled-macro-expansion -Wno-missing-variable-declarations
  84. WARNINGS+=-Wno-missing-prototypes
  85. WARNINGS+=-Wno-conversion -Wno-sign-conversion -Wno-shorten-64-to-32
  86. FLAGS_ALL=-std=c++11
  87. BASE_CFLAGS=$(FLAGS_ALL) $(BASE_DEFS) \
  88. -DVERSION=\"\\\"$(NAME)-$(VERSION)-$(BUILD_ID)\\\"\" \
  89. -DBUILD_HOST=\"\\\"$(BUILD_HOST)\\\"\"
  90. LD_FLAGS=-L/usr/X11/lib -lXmu -lXt -lSM -lICE -lXext -lX11 -lXi \
  91. -lm $(BASE_LIBS)
  92. RELEASE_CFLAGS=$(BASE_CFLAGS) -ffast-math -funroll-loops \
  93. -fomit-frame-pointer -O2 -Wall
  94. DEBUG_CFLAGS=$(BASE_CFLAGS) -g -O0 $(DEBUG_DEFS) $(WARNINGS)
  95. ################################################################
  96. DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
  97. DO_SHLIB_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
  98. TARGETS=$(BUILDDIR)/$(NAME)
  99. ################################################################
  100. auto: $(BUILD_SELECT)
  101. run: $(BUILD_SELECT)
  102. bin/$(BUILD_SELECT)/OpenRaider
  103. targets: $(TARGETS)
  104. bundle: release
  105. mac_dist/bundle.sh
  106. mac_dist/plist.sh $(NAME) $(VERSION) $(BUILD_ID) > bin/OpenRaider.app/Contents/Info.plist
  107. mac_dist/frameworks.sh
  108. bundle-image: bundle
  109. mac_dist/image.sh
  110. bundle-archive: bundle
  111. mac_dist/archive.sh
  112. all: debug release prof
  113. debug:
  114. @-mkdir -p $(BUILD_DEBUG_DIR)
  115. $(MAKE) targets BUILDDIR=$(BUILD_DEBUG_DIR) \
  116. CFLAGS="$(DEBUG_CFLAGS)" \
  117. LD_FLAGS="$(LD_FLAGS)"
  118. prof:
  119. @-mkdir -p $(BUILD_PROF_DIR)
  120. $(MAKE) targets BUILDDIR=$(BUILD_PROF_DIR) \
  121. CFLAGS="$(DEBUG_CFLAGS) -pg" \
  122. LD_FLAGS="$(LD_FLAGS) -pg"
  123. release:
  124. @-mkdir -p $(BUILD_RELEASE_DIR)
  125. $(MAKE) targets BUILDDIR=$(BUILD_RELEASE_DIR) \
  126. CFLAGS="$(RELEASE_CFLAGS)" \
  127. LD_FLAGS="$(LD_FLAGS)"
  128. #####################################
  129. ded:
  130. @-mkdir -p $(BUILD_DEBUG_DIR)/ded
  131. $(MAKE) targets BUILDDIR=$(BUILD_DEBUG_DIR)/ded \
  132. CFLAGS="$(DEBUG_CFLAGS) -DDEDICATED_SERVER" \
  133. LD_FLAGS="$(LD_FLAGS)"
  134. # -DDEBUG_MEMORY_VERBOSE
  135. # -DDEBUG_MEMORY
  136. memory:
  137. @-mkdir -p $(BUILD_MEM_DIR)
  138. $(MAKE) targets BUILDDIR=$(BUILD_MEM_DIR) \
  139. DEBUG_OBJ="$(BUILD_MEM_DIR)/memory_test.o" \
  140. CFLAGS="$(DEBUG_CFLAGS) -DDEBUG_MEMORY" \
  141. LD_FLAGS="$(LD_FLAGS)"
  142. depend:
  143. @-echo "Making deps..."
  144. @-echo "# Autogenerated dependency file" > depend
  145. @-find ./src -name "*.cpp" -exec ./deps.sh $(BASE_DEFS) {} \; >> depend
  146. @-echo "[DONE]"
  147. ################################################################
  148. OBJS = \
  149. $(DEBUG_OBJ) \
  150. $(BUILDDIR)/Camera.o \
  151. $(BUILDDIR)/Emitter.o \
  152. $(BUILDDIR)/GLString.o \
  153. $(BUILDDIR)/MatMath.o \
  154. $(BUILDDIR)/Matrix.o \
  155. $(BUILDDIR)/Network.o \
  156. $(BUILDDIR)/OpenGLMesh.o \
  157. $(BUILDDIR)/OpenRaider.o \
  158. $(BUILDDIR)/Particle.o \
  159. $(BUILDDIR)/Quaternion.o \
  160. $(BUILDDIR)/Render.o \
  161. $(BUILDDIR)/SDLSystem.o \
  162. $(BUILDDIR)/SkeletalModel.o \
  163. $(BUILDDIR)/Sound.o \
  164. $(BUILDDIR)/System.o \
  165. $(BUILDDIR)/Texture.o \
  166. $(BUILDDIR)/tga.o \
  167. $(BUILDDIR)/TombRaider.o \
  168. $(BUILDDIR)/Vector3d.o \
  169. $(BUILDDIR)/ViewVolume.o \
  170. $(BUILDDIR)/World.o
  171. $(BUILDDIR)/$(NAME) : $(OBJS)
  172. $(CC) $(CFLAGS) $(LD_FLAGS) -o $@ $(OBJS)
  173. #################################################################
  174. clean: clean-small clean-dep clean-doc
  175. clean-small: clean-build clean-test clean-obj
  176. @-rm -rf bin/OpenRaider.app
  177. @-rm -rf bin/OpenRaider.dmg
  178. @-rm -rf bin/OpenRaider.zip
  179. clean-dep:
  180. @-echo "Cleaning dependencies"
  181. @-rm -f depend
  182. @-echo "[DONE]"
  183. clean-test:
  184. @-echo "Cleaning test builds"
  185. @-rm -f $(BUILD_TEST_DIR)/*.o
  186. @-rm -rf $(BUILD_TEST_DIR)/*.dSYM
  187. @-rm -f $(BUILD_TEST_DIR)/*.test
  188. @-rm -rf $(BUILD_TEST_DIR)/*.build
  189. @-echo "[DONE]"
  190. clean-obj:
  191. @-echo "Cleaning objects"
  192. @-rm -f $(BUILD_PROF_DIR)/*.o
  193. @-rm -f $(BUILD_DEBUG_DIR)/*.o
  194. @-rm -f $(BUILD_RELEASE_DIR)/*.o
  195. @-rm -f $(BUILD_TEST_DIR)/*.o
  196. @-rm -f $(BUILD_MEM_DIR)/*.o
  197. @-echo "[DONE]"
  198. clean-build:
  199. @-echo "Cleaning builds"
  200. @-rm -f $(BUILD_PROF_DIR)/$(NAME)
  201. @-rm -f $(BUILD_DEBUG_DIR)/$(NAME)
  202. @-rm -f $(BUILD_RELEASE_DIR)/$(NAME)
  203. @-rm -f $(BUILD_MEM_DIR)/$(NAME)
  204. @-echo "[DONE]"
  205. clean-doc:
  206. @-echo "Cleaning docs"
  207. @-rm -rf doc
  208. @-echo "[DONE]"
  209. #################################################################
  210. -include depend
  211. #################################################################
  212. ifneq ($(UNAME),Darwin)
  213. install:
  214. mkdir -p $(INSTALL_SHARE)/data
  215. cp setup.sh $(INSTALL_SHARE)
  216. cp data/* $(INSTALL_SHARE)/data
  217. mkdir -p $(INSTALL_DOC)
  218. cp README.md README.old ChangeLog
  219. mkdir -p $(INSTALL_BIN)
  220. cp bin/$(BUILD_SELECT)/OpenRaider $(INSTALL_BIN)
  221. bin-tarball: clean-build clean-test clean-obj $(BUILD_SELECT)
  222. @-cd .. && tar zcvf $(NAME_TAR)-$(VERSION_DEB)-$(ARCH).tar.gz \
  223. $(TREE_DIR)/Makefile $(TREE_DIR)/data \
  224. $(TREE_DIR)/bin/$(BUILD_SELECT)/OpenRaider \
  225. $(TREE_DIR)/README.md $(TREE_DIR)/ChangeLog
  226. endif
  227. #################################################################
  228. # Unit Test builds
  229. #################################################################
  230. TEST_FLAGS=$(FLAGS_ALL) -g -O0 -DDEBUG -lstdc++ -Iinclude
  231. TEST_MAP_TR5=~/.OpenRaider/paks/tr5/demo.trc
  232. TEST_MAP_TR4=~/.OpenRaider/paks/tr4/angkor1.tr4
  233. TEST_MAP_TR3=~/.OpenRaider/paks/tr3/scotland.tr2
  234. TEST_MAP_TR2=~/.OpenRaider/paks/tr2/unwater.tr2
  235. TEST_MAP_TR1=~/.OpenRaider/paks/tr1/level1.phd
  236. test.build: Matrix.test Math.test Memory.test Network.test Sound.test tga.test GLString.test TombRaider.test
  237. test: test.build
  238. @-echo "================================================="
  239. @-echo "Running Memory unit test"
  240. $(BUILD_TEST_DIR)/memory_test.test
  241. @-echo "================================================="
  242. @-echo "Running Matrix unit test"
  243. $(BUILD_TEST_DIR)/Matrix.test
  244. @-echo "================================================="
  245. @-echo "Running Math unit test"
  246. $(BUILD_TEST_DIR)/Math.test
  247. @-echo "================================================="
  248. @-echo "Running Sound unit test"
  249. $(BUILD_TEST_DIR)/Sound.test
  250. @-echo "================================================="
  251. @-echo "Running TGA unit test"
  252. $(BUILD_TEST_DIR)/tga.test
  253. @-echo "================================================="
  254. @-echo "Running GLString unit test"
  255. $(BUILD_TEST_DIR)/GLString.test
  256. @-echo "================================================="
  257. @-echo "Running TombRaider unit test"
  258. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR1)
  259. TombRaider.reg_test:
  260. $(MAKE) TombRaider.test
  261. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR1) > /tmp/log.tr1
  262. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR2) > /tmp/log.tr2
  263. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR3) > /tmp/log.tr3
  264. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR4) > /tmp/log.tr4
  265. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR5) > /tmp/log.tr5
  266. TR_FLAGS = -D__TEST_TR5_DUMP_TGA -D__TEST_32BIT_TEXTILES -DDEBUG_MEMORY
  267. TombRaider.test:
  268. @-mkdir -p $(BUILD_TEST_DIR)
  269. $(CC) $(FLAGS_ALL) $(WARNINGS) -Iinclude $(TR_FLAGS) -o $(BUILD_TEST_DIR)/TombRaiderTest.o -c test/TombRaider.cpp
  270. $(MAKE) targets NAME=TombRaider.test BUILDDIR=$(BUILD_TEST_DIR) \
  271. OBJS="$(BUILD_TEST_DIR)/TombRaiderTest.o $(BUILD_TEST_DIR)/TombRaider.o $(BUILD_TEST_DIR)/tga.o $(BUILD_TEST_DIR)/memory_test.o" \
  272. CFLAGS="$(BASE_CFLAGS) -g $(TR_FLAGS)" \
  273. LD_FLAGS="-lz -lstdc++"
  274. #################################################################
  275. GLString.test:
  276. mkdir -p $(BUILD_TEST_DIR)
  277. $(CC) $(FLAGS_ALL) $(WARNINGS) -Iinclude \
  278. $(shell sdl-config --cflags) $(shell sdl-config --libs) \
  279. $(GL_LIBS) $(GL_DEFS) -lSDL_ttf -lm -lstdc++ \
  280. src/Texture.cpp src/GLString.cpp \
  281. test/GLString.cpp -o $(BUILD_TEST_DIR)/GLString.test
  282. #################################################################
  283. Matrix.test:
  284. @-echo "Building Matrix unit test"
  285. mkdir -p $(BUILD_TEST_DIR)
  286. $(CC) $(FLAGS_ALL) $(WARNINGS) -g -lm -lstdc++ -Iinclude \
  287. src/Matrix.cpp src/Quaternion.cpp src/Vector3d.cpp \
  288. test/Matrix.cpp -o $(BUILD_TEST_DIR)/Matrix.test
  289. Math.test:
  290. @-echo "Building Math unit test"
  291. mkdir -p $(BUILD_TEST_DIR)
  292. $(CC) $(FLAGS_ALL) $(WARNINGS) -g -lm -lstdc++ -Iinclude \
  293. src/MatMath.cpp src/Vector3d.cpp test/MatMath.cpp -o $(BUILD_TEST_DIR)/Math.test
  294. #################################################################
  295. Memory.test:
  296. mkdir -p $(BUILD_TEST_DIR)
  297. $(CC) $(FLAGS_ALL) $(WARNINGS) -g -lstdc++ -Iinclude \
  298. -DDEBUG_MEMORY -DDEBUG_MEMORY_ERROR \
  299. src/memory_test.cpp test/memory_test.cpp -o $(BUILD_TEST_DIR)/memory_test.test
  300. #################################################################
  301. Network.test:
  302. mkdir -p $(BUILD_TEST_DIR)
  303. $(CC) $(TEST_FLAGS) $(WARNINGS) \
  304. src/Network.cpp test/Network.cpp -o $(BUILD_TEST_DIR)/Network.test
  305. #################################################################
  306. Sound.test:
  307. mkdir -p $(BUILD_TEST_DIR)
  308. $(CC) $(TEST_FLAGS) $(WARNINGS) \
  309. -DUSING_OPENAL $(AUDIO_LIBS) $(AUDIO_DEFS) \
  310. src/Sound.cpp test/Sound.cpp -o $(BUILD_TEST_DIR)/Sound.test
  311. #################################################################
  312. tga.test:
  313. mkdir -p $(BUILD_TEST_DIR)
  314. $(CC) $(TEST_FLAGS) $(WARNINGS) \
  315. src/tga.cpp test/tga.cpp -o $(BUILD_TEST_DIR)/tga.test
  316. #################################################################