Open Source Tomb Raider Engine
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Makefile 12KB

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