Open Source Tomb Raider Engine
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Makefile 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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 -lSDL2_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. BASE_LIBS += -L/usr/X11/lib -lXmu -lXt -lSM -lICE -lXext -lX11 -lXi
  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
  71. WARNINGS+=-Wno-global-constructors -Wno-exit-time-destructors
  72. WARNINGS+=-Wno-documentation-unknown-command -Wno-c++98-compat-pedantic
  73. WARNINGS+=-Wno-missing-prototypes -Wno-missing-variable-declarations
  74. WARNINGS+=-Wno-disabled-macro-expansion
  75. WARNINGS+=-Wno-shorten-64-to-32 -Wno-sign-conversion
  76. FLAGS_ALL=-std=c++11
  77. BASE_CFLAGS=$(FLAGS_ALL) $(BASE_DEFS) \
  78. -DVERSION=\"\\\"$(NAME)-$(VERSION)-$(BUILD_ID)\\\"\" \
  79. -DBUILD_HOST=\"\\\"$(BUILD_HOST)\\\"\"
  80. LD_FLAGS=-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. docLocal:
  181. sed -i '' 's/HAVE_DOT = YES/HAVE_DOT = NO/g' Doxyfile
  182. doxygen
  183. cp -R doc/html/* ../apache/
  184. rm -rf doc
  185. sed -i '' 's/HAVE_DOT = NO/HAVE_DOT = YES/g' Doxyfile
  186. #################################################################
  187. clean: clean-small clean-dep clean-doc
  188. clean-small: clean-build clean-test clean-obj
  189. @-rm -rf bin/OpenRaider.app
  190. @-rm -rf bin/OpenRaider.dmg
  191. @-rm -rf bin/OpenRaider.zip
  192. clean-dep:
  193. @-echo "Cleaning dependencies"
  194. @-rm -f depend
  195. @-echo "[DONE]"
  196. clean-test:
  197. @-echo "Cleaning test builds"
  198. @-rm -f $(BUILD_TEST_DIR)/*.o
  199. @-rm -rf $(BUILD_TEST_DIR)/*.dSYM
  200. @-rm -f $(BUILD_TEST_DIR)/*.test
  201. @-rm -rf $(BUILD_TEST_DIR)/*.build
  202. @-echo "[DONE]"
  203. clean-obj:
  204. @-echo "Cleaning objects"
  205. @-rm -f $(BUILD_PROF_DIR)/*.o
  206. @-rm -f $(BUILD_DEBUG_DIR)/*.o
  207. @-rm -f $(BUILD_RELEASE_DIR)/*.o
  208. @-rm -f $(BUILD_TEST_DIR)/*.o
  209. @-rm -f $(BUILD_MEM_DIR)/*.o
  210. @-echo "[DONE]"
  211. clean-build:
  212. @-echo "Cleaning builds"
  213. @-rm -f $(BUILD_PROF_DIR)/$(NAME)
  214. @-rm -f $(BUILD_DEBUG_DIR)/$(NAME)
  215. @-rm -f $(BUILD_RELEASE_DIR)/$(NAME)
  216. @-rm -f $(BUILD_MEM_DIR)/$(NAME)
  217. @-echo "[DONE]"
  218. clean-doc:
  219. @-echo "Cleaning docs"
  220. @-rm -rf doc
  221. @-echo "[DONE]"
  222. #################################################################
  223. -include depend
  224. #################################################################
  225. ifneq ($(UNAME),Darwin)
  226. install:
  227. mkdir -p $(INSTALL_SHARE)/data
  228. cp setup.sh $(INSTALL_SHARE)
  229. cp data/* $(INSTALL_SHARE)/data
  230. mkdir -p $(INSTALL_DOC)
  231. cp README.md README.old ChangeLog
  232. mkdir -p $(INSTALL_BIN)
  233. cp bin/$(BUILD_SELECT)/OpenRaider $(INSTALL_BIN)
  234. bin-tarball: clean-build clean-test clean-obj $(BUILD_SELECT)
  235. @-cd .. && tar zcvf $(NAME_TAR)-$(VERSION_DEB)-$(ARCH).tar.gz \
  236. $(TREE_DIR)/Makefile $(TREE_DIR)/data \
  237. $(TREE_DIR)/bin/$(BUILD_SELECT)/OpenRaider \
  238. $(TREE_DIR)/README.md $(TREE_DIR)/ChangeLog
  239. endif
  240. #################################################################
  241. # Unit Test builds
  242. #################################################################
  243. TEST_FLAGS=$(FLAGS_ALL) -g -O0 -DDEBUG -DUNIT_TEST -lstdc++ -Iinclude
  244. TEST_MAP_TR5=~/.OpenRaider/paks/tr5/demo.trc
  245. TEST_MAP_TR4=~/.OpenRaider/paks/tr4/angkor1.tr4
  246. TEST_MAP_TR3=~/.OpenRaider/paks/tr3/scotland.tr2
  247. TEST_MAP_TR2=~/.OpenRaider/paks/tr2/unwater.tr2
  248. TEST_MAP_TR1=~/.OpenRaider/paks/tr1/level1.phd
  249. test.build: Matrix.test Math.test Memory.test Network.test Sound.test tga.test GLString.test TombRaider.test
  250. test: test.build
  251. @-echo "================================================="
  252. @-echo "Running Memory unit test"
  253. $(BUILD_TEST_DIR)/memory_test.test
  254. @-echo "================================================="
  255. @-echo "Running Matrix unit test"
  256. $(BUILD_TEST_DIR)/Matrix.test
  257. @-echo "================================================="
  258. @-echo "Running Math unit test"
  259. $(BUILD_TEST_DIR)/Math.test
  260. @-echo "================================================="
  261. @-echo "Running Sound unit test"
  262. $(BUILD_TEST_DIR)/Sound.test
  263. @-echo "================================================="
  264. @-echo "Running TGA unit test"
  265. $(BUILD_TEST_DIR)/tga.test
  266. @-echo "================================================="
  267. @-echo "Running GLString unit test"
  268. $(BUILD_TEST_DIR)/GLString.test
  269. @-echo "================================================="
  270. @-echo "Running TombRaider unit test"
  271. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR1)
  272. TombRaider.reg_test:
  273. $(MAKE) TombRaider.test
  274. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR1) > /tmp/log.tr1
  275. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR2) > /tmp/log.tr2
  276. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR3) > /tmp/log.tr3
  277. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR4) > /tmp/log.tr4
  278. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR5) > /tmp/log.tr5
  279. TR_FLAGS = -D__TEST_TR5_DUMP_TGA -D__TEST_32BIT_TEXTILES -DDEBUG_MEMORY
  280. TombRaider.test:
  281. @-mkdir -p $(BUILD_TEST_DIR)
  282. $(CC) $(FLAGS_ALL) $(WARNINGS) -Iinclude $(TR_FLAGS) -o $(BUILD_TEST_DIR)/TombRaiderTest.o -c test/TombRaider.cpp
  283. $(MAKE) targets NAME=TombRaider.test BUILDDIR=$(BUILD_TEST_DIR) \
  284. OBJS="$(BUILD_TEST_DIR)/TombRaiderTest.o $(BUILD_TEST_DIR)/TombRaider.o $(BUILD_TEST_DIR)/tga.o $(BUILD_TEST_DIR)/memory_test.o" \
  285. CFLAGS="$(BASE_CFLAGS) -g $(TR_FLAGS)" \
  286. LD_FLAGS="-lz -lstdc++"
  287. #################################################################
  288. GLString.test:
  289. mkdir -p $(BUILD_TEST_DIR)
  290. $(CC) $(FLAGS_ALL) $(WARNINGS) -Iinclude \
  291. $(shell sdl2-config --libs) \
  292. $(GL_LIBS) $(GL_DEFS) -lSDL2_ttf -lm -lstdc++ \
  293. src/Texture.cpp src/tga.cpp src/GLString.cpp \
  294. test/GLString.cpp -o $(BUILD_TEST_DIR)/GLString.test
  295. #################################################################
  296. Matrix.test:
  297. @-echo "Building Matrix unit test"
  298. mkdir -p $(BUILD_TEST_DIR)
  299. $(CC) $(FLAGS_ALL) $(WARNINGS) -g -lm -lstdc++ -Iinclude \
  300. src/Matrix.cpp src/Quaternion.cpp src/Vector3d.cpp src/MatMath.cpp \
  301. test/Matrix.cpp -o $(BUILD_TEST_DIR)/Matrix.test
  302. Math.test:
  303. @-echo "Building Math unit test"
  304. mkdir -p $(BUILD_TEST_DIR)
  305. $(CC) $(FLAGS_ALL) $(WARNINGS) -g -lm -lstdc++ -Iinclude \
  306. src/MatMath.cpp src/Vector3d.cpp test/MatMath.cpp -o $(BUILD_TEST_DIR)/Math.test
  307. #################################################################
  308. Memory.test:
  309. mkdir -p $(BUILD_TEST_DIR)
  310. $(CC) $(FLAGS_ALL) $(WARNINGS) -g -lstdc++ -Iinclude \
  311. -DDEBUG_MEMORY -DDEBUG_MEMORY_ERROR \
  312. src/memory_test.cpp test/memory_test.cpp -o $(BUILD_TEST_DIR)/memory_test.test
  313. #################################################################
  314. Network.test:
  315. mkdir -p $(BUILD_TEST_DIR)
  316. $(CC) $(TEST_FLAGS) $(WARNINGS) src/MatMath.cpp src/Vector3d.cpp \
  317. src/Network.cpp test/Network.cpp -o $(BUILD_TEST_DIR)/Network.test
  318. #################################################################
  319. Sound.test:
  320. mkdir -p $(BUILD_TEST_DIR)
  321. $(CC) $(TEST_FLAGS) $(WARNINGS) \
  322. $(AUDIO_LIBS) $(AUDIO_DEFS) \
  323. src/Sound.cpp test/Sound.cpp -o $(BUILD_TEST_DIR)/Sound.test
  324. #################################################################
  325. tga.test:
  326. mkdir -p $(BUILD_TEST_DIR)
  327. $(CC) $(TEST_FLAGS) $(WARNINGS) \
  328. src/tga.cpp test/tga.cpp -o $(BUILD_TEST_DIR)/tga.test
  329. #################################################################