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 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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) -Isrc -DSDL_INTERFACE \
  29. -DUSING_OPENGL -DZLIB_SUPPORT -DUSING_EMITTER \
  30. -DUSING_OPENAL -DUSING_MTK_TGA -DUSING_PTHREADS \
  31. -DUSING_HEL -DHAVE_SDL_TTF
  32. BASE_LIBS=$(shell sdl-config --libs) -lz -lstdc++ \
  33. -lpthread -lSDL_ttf
  34. # -DDEBUG_GL
  35. DEBUG_DEFS=-DDEBUG -DEXPERIMENTAL
  36. DEBUG_OBJ=
  37. ifeq ($(UNAME),Darwin)
  38. AUDIO_LIBS += -lalut
  39. AUDIO_LIBS += -framework OpenAL
  40. AUDIO_LIBS += -L/usr/local/lib
  41. AUDIO_DEFS += -I/usr/local/include
  42. BASE_LIBS += -L/opt/local/lib
  43. BASE_DEFS += -I/opt/local/include
  44. BASE_LIBS += -framework OpenGL
  45. BASE_LIBS += -framework GLUT
  46. else
  47. AUDIO_LIBS += -lopenal
  48. BASE_LIBS += -L/usr/local/lib
  49. BASE_DEFS += -I/usr/local/include
  50. endif
  51. BASE_LIBS += $(AUDIO_LIBS)
  52. BASE_DEFS += $(AUDIO_DEFS)
  53. # libferit, File transfer via HTTP/FTP/etc support
  54. LIBFERIT_LIB=/usr/local/lib/libferit.so
  55. LIBFERIT=$(shell if test -e $(LIBFERIT_LIB) > /dev/null; then echo yes; fi)
  56. ifeq ($(LIBFERIT), yes)
  57. BASE_DEFS += -DHAVE_LIBFERIT
  58. BASE_LIBS += -lferit
  59. endif
  60. ###############################################################
  61. TREE_DIR=OpenRaider
  62. BUILD_DEBUG_DIR=bin/debug
  63. BUILD_RELEASE_DIR=bin/release
  64. BUILD_PROF_DIR=bin/prof
  65. BUILD_TEST_DIR=bin/test
  66. BUILD_MEM_DIR=bin/mem
  67. BUILD_INSTALL_DIR=bin/$(BUILD_SELECT)
  68. DEB_DIR=/tmp/$(NAME).deb
  69. # Edited for Debian GNU/Linux.
  70. DESTDIR =
  71. INSTALL_BIN=$(DESTDIR)/usr/games
  72. INSTALL_LIB=$(DESTDIR)/usr/lib
  73. INSTALL_DOC=$(DESTDIR)/usr/share/doc/$(NAME)
  74. INSTALL_SHARE=$(DESTDIR)/usr/share/$(NAME)
  75. INSTALL_INCLUDE=$(DESTDIR)/usr/include
  76. ###############################################################
  77. CC=gcc
  78. BASE_CFLAGS=-Wall $(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. ifneq ($(UNAME),Darwin)
  84. LD_FLAGS+=-lGL -lGLU
  85. endif
  86. RELEASE_CFLAGS=$(BASE_CFLAGS) -ffast-math -funroll-loops \
  87. -fomit-frame-pointer -O2
  88. DEBUG_CFLAGS=$(BASE_CFLAGS) -g -O0 $(DEBUG_DEFS)
  89. ################################################################
  90. DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
  91. DO_SHLIB_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
  92. TARGETS=$(BUILDDIR)/$(NAME)
  93. ################################################################
  94. auto: $(BUILD_SELECT)
  95. run: $(BUILD_SELECT)
  96. bin/$(BUILD_SELECT)/OpenRaider
  97. targets: $(TARGETS)
  98. bundle: release
  99. mac_dist/bundle.sh
  100. mac_dist/plist.sh $(NAME) $(VERSION) $(BUILD_ID) > bin/OpenRaider.app/Contents/Info.plist
  101. mac_dist/frameworks.sh
  102. bundle-image: bundle
  103. mac_dist/image.sh
  104. bundle-archive: bundle
  105. mac_dist/archive.sh
  106. all: debug release prof
  107. debug:
  108. @-mkdir -p $(BUILD_DEBUG_DIR)
  109. $(MAKE) targets BUILDDIR=$(BUILD_DEBUG_DIR) \
  110. CFLAGS="$(DEBUG_CFLAGS)" \
  111. LD_FLAGS="$(LD_FLAGS)"
  112. prof:
  113. @-mkdir -p $(BUILD_PROF_DIR)
  114. $(MAKE) targets BUILDDIR=$(BUILD_PROF_DIR) \
  115. CFLAGS="$(DEBUG_CFLAGS) -pg" \
  116. LD_FLAGS="$(LD_FLAGS) -pg"
  117. release:
  118. @-mkdir -p $(BUILD_RELEASE_DIR)
  119. $(MAKE) targets BUILDDIR=$(BUILD_RELEASE_DIR) \
  120. CFLAGS="$(RELEASE_CFLAGS)" \
  121. LD_FLAGS="$(LD_FLAGS)"
  122. #####################################
  123. ded:
  124. @-mkdir -p $(BUILD_DEBUG_DIR)/ded
  125. $(MAKE) targets BUILDDIR=$(BUILD_DEBUG_DIR)/ded \
  126. CFLAGS="$(DEBUG_CFLAGS) -DDEDICATED_SERVER" \
  127. LD_FLAGS="$(LD_FLAGS)"
  128. # -DDEBUG_MEMEORY_VERBOSE
  129. # -DDEBUG_MEMEORY
  130. memory:
  131. @-mkdir -p $(BUILD_MEM_DIR)
  132. $(MAKE) targets BUILDDIR=$(BUILD_MEM_DIR) \
  133. DEBUG_OBJ="$(BUILD_MEM_DIR)/memory_test.o" \
  134. CFLAGS="$(DEBUG_CFLAGS) -DDEBUG_MEMEORY" \
  135. LD_FLAGS="$(LD_FLAGS)"
  136. depend:
  137. @-echo "Making deps..."
  138. @-echo "# Autogenerated dependency file" > depend
  139. @-find ./src -name "*.cpp" -exec ./deps.sh $(BASE_DEFS) {} \; >> depend
  140. @-echo "[DONE]"
  141. ################################################################
  142. # Later hel will become a seperate library once it matures
  143. HEL_OBJ = \
  144. $(BUILDDIR)/Mass.o \
  145. $(BUILDDIR)/Simulation.o \
  146. $(BUILDDIR)/Vector3d.o \
  147. $(BUILDDIR)/Matrix.o \
  148. $(BUILDDIR)/ViewVolume.o \
  149. $(BUILDDIR)/CollisionObject.o \
  150. $(BUILDDIR)/BoundingVolume.o \
  151. $(BUILDDIR)/Quaternion.o \
  152. $(BUILDDIR)/math.o \
  153. $(BUILDDIR)/Entity.o
  154. #$(BUILDDIR)/Spring.o
  155. OBJS = \
  156. $(DEBUG_OBJ) \
  157. $(HEL_OBJ) \
  158. $(BUILDDIR)/mtk_tga.o \
  159. $(BUILDDIR)/System.o \
  160. $(BUILDDIR)/SDLSystem.o \
  161. $(BUILDDIR)/OpenRaider.o \
  162. $(BUILDDIR)/World.o \
  163. $(BUILDDIR)/TombRaider.o \
  164. $(BUILDDIR)/GLString.o \
  165. $(BUILDDIR)/Camera.o \
  166. $(BUILDDIR)/OpenGLMesh.o \
  167. $(BUILDDIR)/Render.o \
  168. $(BUILDDIR)/Sound.o \
  169. $(BUILDDIR)/Network.o \
  170. $(BUILDDIR)/Texture.o \
  171. $(BUILDDIR)/Emitter.o \
  172. $(BUILDDIR)/Particle.o \
  173. $(BUILDDIR)/SkeletalModel.o \
  174. $(BUILDDIR)/Light.o
  175. $(BUILDDIR)/$(NAME) : $(OBJS)
  176. $(CC) $(CFLAGS) $(LD_FLAGS) -o $@ $(OBJS)
  177. #################################################################
  178. clean: clean-small clean-dep
  179. clean-small: clean-build clean-test clean-obj
  180. @-rm -rf bin/OpenRaider.app
  181. @-rm -rf bin/OpenRaider.dmg
  182. @-rm -rf bin/OpenRaider.zip
  183. clean-dep:
  184. @-echo "Cleaning dependencies"
  185. @-rm -f depend
  186. @-echo "[DONE]"
  187. clean-test:
  188. @-echo "Cleaning test builds"
  189. @-rm -f $(BUILD_TEST_DIR)/*.o
  190. @-rm -f $(BUILD_TEST_DIR)/*.test
  191. @-rm -rf $(BUILD_TEST_DIR)/*.build
  192. @-echo "[DONE]"
  193. clean-obj:
  194. @-echo "Cleaning objects"
  195. @-rm -f $(BUILD_PROF_DIR)/*.o
  196. @-rm -f $(BUILD_DEBUG_DIR)/*.o
  197. @-rm -f $(BUILD_RELEASE_DIR)/*.o
  198. @-rm -f $(BUILD_TEST_DIR)/*.o
  199. @-rm -f $(BUILD_MEM_DIR)/*.o
  200. @-echo "[DONE]"
  201. clean-build:
  202. @-echo "Cleaning builds"
  203. @-rm -f $(BUILD_PROF_DIR)/$(NAME)
  204. @-rm -f $(BUILD_DEBUG_DIR)/$(NAME)
  205. @-rm -f $(BUILD_RELEASE_DIR)/$(NAME)
  206. @-rm -f $(BUILD_MEM_DIR)/$(NAME)
  207. @-echo "[DONE]"
  208. #################################################################
  209. -include depend
  210. #################################################################
  211. ifneq ($(UNAME),Darwin)
  212. install:
  213. mkdir -p $(INSTALL_SHARE)/data
  214. cp setup.sh $(INSTALL_SHARE)
  215. cp data/* $(INSTALL_SHARE)/data
  216. mkdir -p $(INSTALL_DOC)
  217. cp README.md README.old ChangeLog
  218. mkdir -p $(INSTALL_BIN)
  219. cp bin/$(BUILD_SELECT)/OpenRaider $(INSTALL_BIN)
  220. bin-tarball: clean-build clean-test clean-obj $(BUILD_SELECT)
  221. @-cd .. && tar zcvf $(NAME_TAR)-$(VERSION_DEB)-$(ARCH).tar.gz \
  222. $(TREE_DIR)/Makefile $(TREE_DIR)/data \
  223. $(TREE_DIR)/bin/$(BUILD_SELECT)/OpenRaider \
  224. $(TREE_DIR)/README.md $(TREE_DIR)/ChangeLog
  225. endif
  226. #################################################################
  227. # Unit Test builds
  228. #################################################################
  229. TEST_FLAGS=-Wall -g -O0 -DDEBUG -lstdc++
  230. TEST_MAP_TR5=~/projects/Data/models/tombraider/tr5/demo.trc
  231. TEST_MAP_TR4=~/projects/Data/models/tombraider/tr4/angkor1.tr4
  232. TEST_MAP_TR3=~/projects/Data/models/tombraider/tr3/scotland.tr2
  233. TEST_MAP_TR2=~/projects/Data/models/tombraider/tr2/unwater.tr2
  234. TEST_MAP_TR1=~/projects/Data/models/tombraider/tr1/level1.phd
  235. TombRaider.reg_test:
  236. $(MAKE) TombRaider.test
  237. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR1) > /tmp/log.tr1
  238. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR2) > /tmp/log.tr2
  239. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR3) > /tmp/log.tr3
  240. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR4) > /tmp/log.tr4
  241. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR5) > /tmp/log.tr5
  242. TombRaider.test:
  243. @-mkdir -p $(BUILD_TEST_DIR)
  244. $(MAKE) targets NAME=TombRaider.test BUILDDIR=$(BUILD_TEST_DIR) \
  245. OBJS="$(BUILD_TEST_DIR)/TombRaider.o $(BUILD_TEST_DIR)/mtk_tga.o $(BUILD_TEST_DIR)/memeory_test.o" \
  246. CFLAGS="$(BASE_CFLAGS) -g -D__TOMBRAIDER_TEST__ -D__TEST_TR5_DUMP_TGA -D__TEST_32BIT_TEXTILES -DDEBUG_MEMEORY" \
  247. LD_FLAGS="-lz -lstdc++"
  248. #################################################################
  249. ifeq ($(UNAME),Darwin)
  250. GLString.test:
  251. mkdir -p $(BUILD_TEST_DIR)
  252. $(CC) -Wall -Isrc -D__TEST__ -DHAVE_MTK -DHAVE_SDL -DUSING_MTK_TGA \
  253. $(shell sdl-config --cflags) $(shell sdl-config --libs) \
  254. -I/opt/local/include -I/usr/local/include \
  255. -framework OpenGL \
  256. -framework GLUT \
  257. -lm -lstdc++ \
  258. src/Texture.cpp src/mtk_tga.cpp \
  259. src/GLString.cpp -o $(BUILD_TEST_DIR)/GLString.test
  260. else
  261. GLString.test:
  262. mkdir -p $(BUILD_TEST_DIR)
  263. $(CC) -Wall -Isrc -D__TEST__ -DHAVE_MTK -DHAVE_SDL -DUSING_MTK_TGA \
  264. $(shell sdl-config --cflags) $(shell sdl-config --libs) \
  265. -lGL -lGLU -lm \
  266. src/Texture.cpp src/mtk_tga.cpp \
  267. src/GLString.cpp -o $(BUILD_TEST_DIR)/GLString.test
  268. endif
  269. #################################################################
  270. # CollisionObject and HeightCollisionObject seem to be missing?
  271. # -- xythobuz, 2014-01-04
  272. SIMULATION_CFLAGS=-Wall -O0 -g -Isrc $(shell sdl-config --cflags) \
  273. -I/opt/local/include \
  274. -DUSING_OPENGL -DUSING_HEL -DUSING_MTK_TGA \
  275. -DUNIT_TEST_SIMULATION
  276. SIMULATION_OBJS=$(BUILD_TEST_DIR)/mtk_tga.o $(BUILD_TEST_DIR)/Texture.o \
  277. $(BUILD_TEST_DIR)/Mass.o \
  278. $(BUILD_TEST_DIR)/CollisionObject.o \
  279. $(BUILD_TEST_DIR)/Simulation.o \
  280. $(BUILD_TEST_DIR)/Vector3d.o \
  281. $(BUILD_TEST_DIR)/Matrix.o \
  282. $(BUILD_TEST_DIR)/ViewVolume.o \
  283. $(BUILD_TEST_DIR)/BoundingVolume.o \
  284. $(BUILD_TEST_DIR)/Quaternion.o \
  285. $(BUILD_TEST_DIR)/math.o
  286. Simulation.test:
  287. mkdir -p $(BUILD_TEST_DIR)
  288. $(MAKE) targets NAME=Simulation.test BUILDDIR=$(BUILD_TEST_DIR) \
  289. OBJS="$(SIMULATION_OBJS)" \
  290. CFLAGS="$(SIMULATION_CFLAGS)" \
  291. LD_FLAGS="-lm -lstdc++ -lSDL_ttf -lSDL -lGL -lGLU $(shell sdl-config --libs)"
  292. #################################################################
  293. # Spring files seem to be missing?
  294. # -- xythobuz, 2014-01-04
  295. HEL_PARTICLE_CFLAGS=-Wall -O0 -g -Isrc $(shell sdl-config --cflags) \
  296. -I/opt/local/include \
  297. -DUSING_OPENGL -DUSING_HEL -DUSING_MTK_TGA \
  298. -DUNIT_TEST_SPRING -DHAVE_SDL_TTF
  299. HEL_PARTICLE_OBJS=$(BUILD_TEST_DIR)/mtk_tga.o $(BUILD_TEST_DIR)/Texture.o \
  300. $(BUILD_TEST_DIR)/Mass.o \
  301. $(BUILD_TEST_DIR)/Spring.o \
  302. $(BUILD_TEST_DIR)/CollisionObject.o \
  303. $(BUILD_TEST_DIR)/Simulation.o \
  304. $(BUILD_TEST_DIR)/Vector3d.o \
  305. $(BUILD_TEST_DIR)/Matrix.o \
  306. $(BUILD_TEST_DIR)/ViewVolume.o \
  307. $(BUILD_TEST_DIR)/BoundingVolume.o \
  308. $(BUILD_TEST_DIR)/Quaternion.o \
  309. $(BUILD_TEST_DIR)/math.o
  310. Spring.test:
  311. mkdir -p $(BUILD_TEST_DIR)
  312. $(MAKE) targets NAME=Spring.test BUILDDIR=$(BUILD_TEST_DIR) \
  313. OBJS="$(HEL_PARTICLE_OBJS)" \
  314. CFLAGS="$(HEL_PARTICLE_CFLAGS)" \
  315. LD_FLAGS="-lm -lstdc++ -lSDL_ttf-lGL -lGLU $(shell sdl-config --libs)"
  316. #################################################################
  317. Hel.test: Quaternion.test Matrix.test Math.test
  318. Matrix.test:
  319. @-echo "Building Matrix unit test"
  320. mkdir -p $(BUILD_TEST_DIR)
  321. $(CC) -Wall -g -DMATRIX_UNIT_TEST -lm -lstdc++ -Isrc \
  322. src/hel/Matrix.cpp src/hel/Quaternion.cpp src/hel/Vector3d.cpp \
  323. -o $(BUILD_TEST_DIR)/Matrix.test
  324. @-echo "================================================="
  325. @-echo "Running Matrix unit test"
  326. $(BUILD_TEST_DIR)/Matrix.test
  327. Quaternion.test:
  328. @-echo "Building Quaternion unit test"
  329. mkdir -p $(BUILD_TEST_DIR)
  330. $(CC) -Wall -g -DUNIT_TEST_QUATERNION -lm -lstdc++ -Isrc \
  331. src/hel/Quaternion.cpp -o $(BUILD_TEST_DIR)/Quaternion.test
  332. @-echo "================================================="
  333. @-echo "Running Quaternion unit test"
  334. $(BUILD_TEST_DIR)/Quaternion.test
  335. Math.test:
  336. @-echo "Building Math unit test"
  337. mkdir -p $(BUILD_TEST_DIR)
  338. $(CC) -Wall -g -DMATH_UNIT_TEST -lm -lstdc++ -Isrc \
  339. src/hel/math.cpp src/hel/Vector3d.cpp -o $(BUILD_TEST_DIR)/Math.test
  340. @-echo "================================================="
  341. @-echo "Running hel unit test"
  342. $(BUILD_TEST_DIR)/Math.test
  343. #################################################################
  344. Memory.test:
  345. mkdir -p $(BUILD_TEST_DIR)
  346. $(CC) -Wall -g -D__TEST__ -lstdc++ \
  347. -DDEBUG_MEMEORY -DDEBUG_MEMEORY_ERROR \
  348. src/memeory_test.cpp -o $(BUILD_TEST_DIR)/memory_test.test
  349. #################################################################
  350. Network.test:
  351. mkdir -p $(BUILD_TEST_DIR)
  352. $(CC) $(TEST_FLAGS) -DUNIT_TEST_NETWORK \
  353. src/Network.cpp -o $(BUILD_TEST_DIR)/Network.test
  354. #################################################################
  355. Sound.test:
  356. mkdir -p $(BUILD_TEST_DIR)
  357. $(CC) $(TEST_FLAGS) -DUNIT_TEST_SOUND \
  358. -DUSING_OPENAL $(AUDIO_LIBS) \
  359. src/Sound.cpp -o $(BUILD_TEST_DIR)/Sound.test
  360. ifeq ($(UNAME),Darwin)
  361. install_name_tool -change libalut.0.1.0.dylib /opt/local/lib/libalut.0.1.0.dylib $(BUILD_TEST_DIR)/Sound.test
  362. endif
  363. #################################################################