Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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. GL_LIBS += -framework OpenGL
  43. GL_LIBS += -L/opt/local/lib
  44. GL_DEFS += -I/opt/local/include
  45. else
  46. AUDIO_LIBS += -lopenal
  47. GL_LIBS += -lGL -lGLU
  48. GL_LIBS += -L/usr/local/lib
  49. GL_DEFS += -I/usr/local/include
  50. endif
  51. BASE_LIBS += $(AUDIO_LIBS)
  52. BASE_LIBS += $(GL_LIBS)
  53. BASE_DEFS += $(AUDIO_DEFS)
  54. BASE_DEFS += $(GL_DEFS)
  55. # libferit, File transfer via HTTP/FTP/etc support
  56. LIBFERIT_LIB=/usr/local/lib/libferit.so
  57. LIBFERIT=$(shell if test -e $(LIBFERIT_LIB) > /dev/null; then echo yes; fi)
  58. ifeq ($(LIBFERIT), yes)
  59. BASE_DEFS += -DHAVE_LIBFERIT
  60. BASE_LIBS += -lferit
  61. endif
  62. ###############################################################
  63. TREE_DIR=OpenRaider
  64. BUILD_DEBUG_DIR=bin/debug
  65. BUILD_RELEASE_DIR=bin/release
  66. BUILD_PROF_DIR=bin/prof
  67. BUILD_TEST_DIR=bin/test
  68. BUILD_MEM_DIR=bin/mem
  69. BUILD_INSTALL_DIR=bin/$(BUILD_SELECT)
  70. DEB_DIR=/tmp/$(NAME).deb
  71. # Edited for Debian GNU/Linux.
  72. DESTDIR =
  73. INSTALL_BIN=$(DESTDIR)/usr/games
  74. INSTALL_LIB=$(DESTDIR)/usr/lib
  75. INSTALL_DOC=$(DESTDIR)/usr/share/doc/$(NAME)
  76. INSTALL_SHARE=$(DESTDIR)/usr/share/$(NAME)
  77. INSTALL_INCLUDE=$(DESTDIR)/usr/include
  78. ###############################################################
  79. CC=gcc
  80. BASE_CFLAGS=-Wall $(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
  87. DEBUG_CFLAGS=$(BASE_CFLAGS) -g -O0 $(DEBUG_DEFS)
  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_MEMEORY_VERBOSE
  128. # -DDEBUG_MEMEORY
  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_MEMEORY" \
  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. # Later hel will become a seperate library once it matures
  142. HEL_OBJ = \
  143. $(BUILDDIR)/math.o \
  144. $(BUILDDIR)/Matrix.o \
  145. $(BUILDDIR)/Quaternion.o \
  146. $(BUILDDIR)/Vector3d.o \
  147. $(BUILDDIR)/ViewVolume.o
  148. OBJS = \
  149. $(DEBUG_OBJ) \
  150. $(HEL_OBJ) \
  151. $(BUILDDIR)/Camera.o \
  152. $(BUILDDIR)/Emitter.o \
  153. $(BUILDDIR)/GLString.o \
  154. $(BUILDDIR)/Light.o \
  155. $(BUILDDIR)/mtk_tga.o \
  156. $(BUILDDIR)/Network.o \
  157. $(BUILDDIR)/OpenGLMesh.o \
  158. $(BUILDDIR)/OpenRaider.o \
  159. $(BUILDDIR)/Particle.o \
  160. $(BUILDDIR)/Render.o \
  161. $(BUILDDIR)/SDLSystem.o \
  162. $(BUILDDIR)/SkeletalModel.o \
  163. $(BUILDDIR)/Sound.o \
  164. $(BUILDDIR)/System.o \
  165. $(BUILDDIR)/Texture.o \
  166. $(BUILDDIR)/TombRaider.o \
  167. $(BUILDDIR)/World.o
  168. $(BUILDDIR)/$(NAME) : $(OBJS)
  169. $(CC) $(CFLAGS) $(LD_FLAGS) -o $@ $(OBJS)
  170. #################################################################
  171. clean: clean-small clean-dep
  172. clean-small: clean-build clean-test clean-obj
  173. @-rm -rf bin/OpenRaider.app
  174. @-rm -rf bin/OpenRaider.dmg
  175. @-rm -rf bin/OpenRaider.zip
  176. clean-dep:
  177. @-echo "Cleaning dependencies"
  178. @-rm -f depend
  179. @-echo "[DONE]"
  180. clean-test:
  181. @-echo "Cleaning test builds"
  182. @-rm -f $(BUILD_TEST_DIR)/*.o
  183. @-rm -f $(BUILD_TEST_DIR)/*.test
  184. @-rm -rf $(BUILD_TEST_DIR)/*.build
  185. @-echo "[DONE]"
  186. clean-obj:
  187. @-echo "Cleaning objects"
  188. @-rm -f $(BUILD_PROF_DIR)/*.o
  189. @-rm -f $(BUILD_DEBUG_DIR)/*.o
  190. @-rm -f $(BUILD_RELEASE_DIR)/*.o
  191. @-rm -f $(BUILD_TEST_DIR)/*.o
  192. @-rm -f $(BUILD_MEM_DIR)/*.o
  193. @-echo "[DONE]"
  194. clean-build:
  195. @-echo "Cleaning builds"
  196. @-rm -f $(BUILD_PROF_DIR)/$(NAME)
  197. @-rm -f $(BUILD_DEBUG_DIR)/$(NAME)
  198. @-rm -f $(BUILD_RELEASE_DIR)/$(NAME)
  199. @-rm -f $(BUILD_MEM_DIR)/$(NAME)
  200. @-echo "[DONE]"
  201. #################################################################
  202. -include depend
  203. #################################################################
  204. ifneq ($(UNAME),Darwin)
  205. install:
  206. mkdir -p $(INSTALL_SHARE)/data
  207. cp setup.sh $(INSTALL_SHARE)
  208. cp data/* $(INSTALL_SHARE)/data
  209. mkdir -p $(INSTALL_DOC)
  210. cp README.md README.old ChangeLog
  211. mkdir -p $(INSTALL_BIN)
  212. cp bin/$(BUILD_SELECT)/OpenRaider $(INSTALL_BIN)
  213. bin-tarball: clean-build clean-test clean-obj $(BUILD_SELECT)
  214. @-cd .. && tar zcvf $(NAME_TAR)-$(VERSION_DEB)-$(ARCH).tar.gz \
  215. $(TREE_DIR)/Makefile $(TREE_DIR)/data \
  216. $(TREE_DIR)/bin/$(BUILD_SELECT)/OpenRaider \
  217. $(TREE_DIR)/README.md $(TREE_DIR)/ChangeLog
  218. endif
  219. #################################################################
  220. # Unit Test builds
  221. #################################################################
  222. TEST_FLAGS=-Wall -g -O0 -DDEBUG -lstdc++
  223. TEST_MAP_TR5=~/projects/Data/models/tombraider/tr5/demo.trc
  224. TEST_MAP_TR4=~/projects/Data/models/tombraider/tr4/angkor1.tr4
  225. TEST_MAP_TR3=~/projects/Data/models/tombraider/tr3/scotland.tr2
  226. TEST_MAP_TR2=~/projects/Data/models/tombraider/tr2/unwater.tr2
  227. TEST_MAP_TR1=~/projects/Data/models/tombraider/tr1/level1.phd
  228. TombRaider.reg_test:
  229. $(MAKE) TombRaider.test
  230. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR1) > /tmp/log.tr1
  231. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR2) > /tmp/log.tr2
  232. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR3) > /tmp/log.tr3
  233. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR4) > /tmp/log.tr4
  234. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR5) > /tmp/log.tr5
  235. TombRaider.test:
  236. @-mkdir -p $(BUILD_TEST_DIR)
  237. $(MAKE) targets NAME=TombRaider.test BUILDDIR=$(BUILD_TEST_DIR) \
  238. OBJS="$(BUILD_TEST_DIR)/TombRaider.o $(BUILD_TEST_DIR)/mtk_tga.o $(BUILD_TEST_DIR)/memeory_test.o" \
  239. CFLAGS="$(BASE_CFLAGS) -g -D__TOMBRAIDER_TEST__ -D__TEST_TR5_DUMP_TGA -D__TEST_32BIT_TEXTILES -DDEBUG_MEMEORY" \
  240. LD_FLAGS="-lz -lstdc++"
  241. #################################################################
  242. GLString.test:
  243. mkdir -p $(BUILD_TEST_DIR)
  244. $(CC) -Wall -Isrc -D__TEST__ -DHAVE_MTK -DHAVE_SDL -DUSING_MTK_TGA \
  245. $(shell sdl-config --cflags) $(shell sdl-config --libs) \
  246. $(GL_LIBS) $(GL_DEFS) -lm -lstdc++ \
  247. src/Texture.cpp src/mtk_tga.cpp \
  248. src/GLString.cpp -o $(BUILD_TEST_DIR)/GLString.test
  249. #################################################################
  250. Hel.test: Quaternion.test Matrix.test Math.test
  251. Matrix.test:
  252. @-echo "Building Matrix unit test"
  253. mkdir -p $(BUILD_TEST_DIR)
  254. $(CC) -Wall -g -DMATRIX_UNIT_TEST -lm -lstdc++ -Isrc \
  255. src/hel/Matrix.cpp src/hel/Quaternion.cpp src/hel/Vector3d.cpp \
  256. -o $(BUILD_TEST_DIR)/Matrix.test
  257. @-echo "================================================="
  258. @-echo "Running Matrix unit test"
  259. $(BUILD_TEST_DIR)/Matrix.test
  260. Quaternion.test:
  261. @-echo "Building Quaternion unit test"
  262. mkdir -p $(BUILD_TEST_DIR)
  263. $(CC) -Wall -g -DUNIT_TEST_QUATERNION -lm -lstdc++ -Isrc \
  264. src/hel/Quaternion.cpp -o $(BUILD_TEST_DIR)/Quaternion.test
  265. @-echo "================================================="
  266. @-echo "Running Quaternion unit test"
  267. $(BUILD_TEST_DIR)/Quaternion.test
  268. Math.test:
  269. @-echo "Building Math unit test"
  270. mkdir -p $(BUILD_TEST_DIR)
  271. $(CC) -Wall -g -DMATH_UNIT_TEST -lm -lstdc++ -Isrc \
  272. src/hel/math.cpp src/hel/Vector3d.cpp -o $(BUILD_TEST_DIR)/Math.test
  273. @-echo "================================================="
  274. @-echo "Running hel unit test"
  275. $(BUILD_TEST_DIR)/Math.test
  276. #################################################################
  277. Memory.test:
  278. mkdir -p $(BUILD_TEST_DIR)
  279. $(CC) -Wall -g -D__TEST__ -lstdc++ \
  280. -DDEBUG_MEMEORY -DDEBUG_MEMEORY_ERROR \
  281. src/memeory_test.cpp -o $(BUILD_TEST_DIR)/memory_test.test
  282. #################################################################
  283. Network.test:
  284. mkdir -p $(BUILD_TEST_DIR)
  285. $(CC) $(TEST_FLAGS) -DUNIT_TEST_NETWORK \
  286. src/Network.cpp -o $(BUILD_TEST_DIR)/Network.test
  287. #################################################################
  288. Sound.test:
  289. mkdir -p $(BUILD_TEST_DIR)
  290. $(CC) $(TEST_FLAGS) -DUNIT_TEST_SOUND \
  291. -DUSING_OPENAL $(AUDIO_LIBS) \
  292. src/Sound.cpp -o $(BUILD_TEST_DIR)/Sound.test
  293. ifeq ($(UNAME),Darwin)
  294. install_name_tool -change libalut.0.1.0.dylib /opt/local/lib/libalut.0.1.0.dylib $(BUILD_TEST_DIR)/Sound.test
  295. endif
  296. #################################################################
  297. TGA.test:
  298. mkdir -p $(BUILD_TEST_DIR)
  299. $(CC) $(TEST_FLAGS) -D__TEST_ \
  300. src/mtk_tga.cpp -o $(BUILD_TEST_DIR)/TGA.test
  301. #################################################################