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

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