Open Source Tomb Raider Engine
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Makefile 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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_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=-lm $(BASE_LIBS)
  80. RELEASE_CFLAGS=$(BASE_CFLAGS) -ffast-math -funroll-loops \
  81. -fomit-frame-pointer -O2 -Wall
  82. DEBUG_CFLAGS=$(BASE_CFLAGS) -g -O0 $(DEBUG_DEFS) $(WARNINGS)
  83. ################################################################
  84. DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
  85. DO_SHLIB_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
  86. TARGETS=$(BUILDDIR)/$(NAME)
  87. ################################################################
  88. auto: $(BUILD_SELECT)
  89. run: $(BUILD_SELECT)
  90. bin/$(BUILD_SELECT)/OpenRaider
  91. targets: $(TARGETS)
  92. bundle: release
  93. mac_dist/bundle.sh
  94. mac_dist/plist.sh $(NAME) $(VERSION) $(BUILD_ID) > bin/OpenRaider.app/Contents/Info.plist
  95. mac_dist/frameworks.sh
  96. bundle-image: bundle
  97. mac_dist/image.sh
  98. bundle-archive: bundle
  99. mac_dist/archive.sh
  100. all: debug release prof
  101. debug:
  102. @-mkdir -p $(BUILD_DEBUG_DIR)
  103. $(MAKE) targets BUILDDIR=$(BUILD_DEBUG_DIR) \
  104. CFLAGS="$(DEBUG_CFLAGS)" \
  105. LD_FLAGS="$(LD_FLAGS)"
  106. prof:
  107. @-mkdir -p $(BUILD_PROF_DIR)
  108. $(MAKE) targets BUILDDIR=$(BUILD_PROF_DIR) \
  109. CFLAGS="$(DEBUG_CFLAGS) -pg" \
  110. LD_FLAGS="$(LD_FLAGS) -pg"
  111. release:
  112. @-mkdir -p $(BUILD_RELEASE_DIR)
  113. $(MAKE) targets BUILDDIR=$(BUILD_RELEASE_DIR) \
  114. CFLAGS="$(RELEASE_CFLAGS)" \
  115. LD_FLAGS="$(LD_FLAGS)"
  116. #####################################
  117. ded:
  118. @-mkdir -p $(BUILD_DEBUG_DIR)/ded
  119. $(MAKE) targets BUILDDIR=$(BUILD_DEBUG_DIR)/ded \
  120. CFLAGS="$(DEBUG_CFLAGS) -DDEDICATED_SERVER" \
  121. LD_FLAGS="$(LD_FLAGS)"
  122. depend:
  123. @-echo "Making deps..."
  124. @-echo "# Autogenerated dependency file" > depend
  125. @-find ./src -name "*.cpp" -exec ./deps.sh $(BASE_DEFS) {} \; >> depend
  126. @-echo "[DONE]"
  127. ################################################################
  128. OBJS = \
  129. $(DEBUG_OBJ) \
  130. $(BUILDDIR)/Camera.o \
  131. $(BUILDDIR)/Emitter.o \
  132. $(BUILDDIR)/GLString.o \
  133. $(BUILDDIR)/MatMath.o \
  134. $(BUILDDIR)/Matrix.o \
  135. $(BUILDDIR)/Mesh.o \
  136. $(BUILDDIR)/Network.o \
  137. $(BUILDDIR)/OpenRaider.o \
  138. $(BUILDDIR)/Particle.o \
  139. $(BUILDDIR)/Quaternion.o \
  140. $(BUILDDIR)/Render.o \
  141. $(BUILDDIR)/SDLSystem.o \
  142. $(BUILDDIR)/SkeletalModel.o \
  143. $(BUILDDIR)/Sound.o \
  144. $(BUILDDIR)/System.o \
  145. $(BUILDDIR)/Texture.o \
  146. $(BUILDDIR)/tga.o \
  147. $(BUILDDIR)/TombRaider.o \
  148. $(BUILDDIR)/Vector3d.o \
  149. $(BUILDDIR)/ViewVolume.o \
  150. $(BUILDDIR)/World.o
  151. $(BUILDDIR)/$(NAME) : $(OBJS)
  152. $(CC) $(CFLAGS) $(LD_FLAGS) -o $@ $(OBJS)
  153. #################################################################
  154. CHECK_BIN=cppcheck
  155. CHECK_DIR=.
  156. CHECK_STD=--std=c++11 --std=posix
  157. CHECK_FLAGS=--quiet --force
  158. CHECK_INC=-Iinclude
  159. CHECK_NORMAL=--enable=information,warning,performance,portability
  160. CHECK_FULL=--enable=all
  161. CHECK_CONFIG=--check-config
  162. check:
  163. $(CHECK_BIN) $(CHECK_FLAGS) $(CHECK_INC) $(CHECK_STD) \
  164. $(CHECK_NORMAL) $(CHECK_DIR)
  165. checkFull:
  166. $(CHECK_BIN) $(CHECK_FLAGS) $(CHECK_INC) $(CHECK_STD) \
  167. $(CHECK_FULL) $(CHECK_DIR)
  168. checkConfig:
  169. $(CHECK_BIN) $(CHECK_FLAGS) $(CHECK_INC) $(CHECK_CONFIG) $(CHECK_DIR)
  170. #################################################################
  171. docLocal:
  172. sed -i '' 's/HAVE_DOT = YES/HAVE_DOT = NO/g' Doxyfile
  173. doxygen
  174. cp -R doc/html/* ../apache/
  175. rm -rf doc
  176. sed -i '' 's/HAVE_DOT = NO/HAVE_DOT = YES/g' Doxyfile
  177. #################################################################
  178. clean: clean-small clean-dep clean-doc
  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 -rf $(BUILD_TEST_DIR)/*.dSYM
  191. @-rm -f $(BUILD_TEST_DIR)/*.test
  192. @-rm -rf $(BUILD_TEST_DIR)/*.build
  193. @-echo "[DONE]"
  194. clean-obj:
  195. @-echo "Cleaning objects"
  196. @-rm -f $(BUILD_PROF_DIR)/*.o
  197. @-rm -f $(BUILD_DEBUG_DIR)/*.o
  198. @-rm -f $(BUILD_RELEASE_DIR)/*.o
  199. @-rm -f $(BUILD_TEST_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. @-echo "[DONE]"
  207. clean-doc:
  208. @-echo "Cleaning docs"
  209. @-rm -rf doc
  210. @-echo "[DONE]"
  211. #################################################################
  212. -include depend
  213. #################################################################
  214. ifneq ($(UNAME),Darwin)
  215. install:
  216. mkdir -p $(INSTALL_SHARE)/data
  217. cp setup.sh $(INSTALL_SHARE)
  218. cp data/* $(INSTALL_SHARE)/data
  219. mkdir -p $(INSTALL_DOC)
  220. cp README.md README.old ChangeLog
  221. mkdir -p $(INSTALL_BIN)
  222. cp bin/$(BUILD_SELECT)/OpenRaider $(INSTALL_BIN)
  223. bin-tarball: clean-build clean-test clean-obj $(BUILD_SELECT)
  224. @-cd .. && tar zcvf $(NAME_TAR)-$(VERSION_DEB)-$(ARCH).tar.gz \
  225. $(TREE_DIR)/Makefile $(TREE_DIR)/data \
  226. $(TREE_DIR)/bin/$(BUILD_SELECT)/OpenRaider \
  227. $(TREE_DIR)/README.md $(TREE_DIR)/ChangeLog
  228. endif
  229. #################################################################
  230. # Unit Test builds
  231. #################################################################
  232. TEST_FLAGS=$(FLAGS_ALL) -g -O0 -DDEBUG -DUNIT_TEST -lstdc++ -Iinclude
  233. TEST_MAP_TR5=~/.OpenRaider/paks/tr5/demo.trc
  234. TEST_MAP_TR4=~/.OpenRaider/paks/tr4/angkor1.tr4
  235. TEST_MAP_TR3=~/.OpenRaider/paks/tr3/scotland.tr2
  236. TEST_MAP_TR2=~/.OpenRaider/paks/tr2/unwater.tr2
  237. TEST_MAP_TR1=~/.OpenRaider/paks/tr1/level1.phd
  238. test.build: Matrix.test Math.test Network.test Sound.test tga.test GLString.test TombRaider.test
  239. test: test.build
  240. @-echo "================================================="
  241. @-echo "Running Matrix unit test"
  242. $(BUILD_TEST_DIR)/Matrix.test
  243. @-echo "================================================="
  244. @-echo "Running Math unit test"
  245. $(BUILD_TEST_DIR)/Math.test
  246. @-echo "================================================="
  247. @-echo "Running Sound unit test"
  248. $(BUILD_TEST_DIR)/Sound.test
  249. @-echo "================================================="
  250. @-echo "Running TGA unit test"
  251. $(BUILD_TEST_DIR)/tga.test
  252. @-echo "================================================="
  253. @-echo "Running GLString unit test"
  254. $(BUILD_TEST_DIR)/GLString.test
  255. @-echo "================================================="
  256. @-echo "Running TombRaider unit test"
  257. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR1)
  258. TombRaider.reg_test:
  259. $(MAKE) TombRaider.test
  260. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR1) > /tmp/log.tr1
  261. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR2) > /tmp/log.tr2
  262. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR3) > /tmp/log.tr3
  263. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR4) > /tmp/log.tr4
  264. $(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR5) > /tmp/log.tr5
  265. TR_FLAGS = -D__TEST_TR5_DUMP_TGA -D__TEST_32BIT_TEXTILES
  266. TombRaider.test:
  267. @-mkdir -p $(BUILD_TEST_DIR)
  268. $(CC) $(FLAGS_ALL) $(WARNINGS) -Iinclude $(TR_FLAGS) -o $(BUILD_TEST_DIR)/TombRaiderTest.o -c test/TombRaider.cpp
  269. $(MAKE) targets NAME=TombRaider.test BUILDDIR=$(BUILD_TEST_DIR) \
  270. OBJS="$(BUILD_TEST_DIR)/TombRaiderTest.o $(BUILD_TEST_DIR)/TombRaider.o $(BUILD_TEST_DIR)/tga.o" \
  271. CFLAGS="$(BASE_CFLAGS) -g $(TR_FLAGS)" \
  272. LD_FLAGS="-lz -lstdc++"
  273. #################################################################
  274. GLString.test:
  275. mkdir -p $(BUILD_TEST_DIR)
  276. $(CC) $(FLAGS_ALL) $(WARNINGS) -Iinclude \
  277. $(shell sdl2-config --libs) \
  278. $(GL_LIBS) $(GL_DEFS) -lSDL2_ttf -lm -lstdc++ \
  279. src/Texture.cpp src/tga.cpp src/GLString.cpp \
  280. test/GLString.cpp -o $(BUILD_TEST_DIR)/GLString.test
  281. #################################################################
  282. Matrix.test:
  283. @-echo "Building Matrix unit test"
  284. mkdir -p $(BUILD_TEST_DIR)
  285. $(CC) $(FLAGS_ALL) $(WARNINGS) -g -lm -lstdc++ -Iinclude \
  286. src/Matrix.cpp src/Quaternion.cpp src/Vector3d.cpp src/MatMath.cpp \
  287. test/Matrix.cpp -o $(BUILD_TEST_DIR)/Matrix.test
  288. Math.test:
  289. @-echo "Building Math unit test"
  290. mkdir -p $(BUILD_TEST_DIR)
  291. $(CC) $(FLAGS_ALL) $(WARNINGS) -g -lm -lstdc++ -Iinclude \
  292. src/MatMath.cpp src/Vector3d.cpp test/MatMath.cpp -o $(BUILD_TEST_DIR)/Math.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. $(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. #################################################################