Open Source Tomb Raider Engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Makefile 12KB

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