makefile 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. #
  2. # Copyright 2011-2018 Branimir Karadzic. All rights reserved.
  3. # License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
  4. #
  5. UNAME := $(shell uname)
  6. ifeq ($(UNAME),$(filter $(UNAME),Linux Darwin FreeBSD GNU/kFreeBSD))
  7. ifeq ($(UNAME),$(filter $(UNAME),Darwin))
  8. OS=darwin
  9. else
  10. ifeq ($(UNAME),$(filter $(UNAME),FreeBSD GNU/kFreeBSD))
  11. OS=bsd
  12. else
  13. OS=linux
  14. endif
  15. endif
  16. else
  17. OS=windows
  18. help: projgen
  19. endif
  20. # $(info $(OS))
  21. BX_DIR?=../bx
  22. GENIE?=$(BX_DIR)/tools/bin/$(OS)/genie
  23. NINJA?=$(BX_DIR)/tools/bin/$(OS)/ninja
  24. .PHONY: help
  25. help:
  26. @echo Available targets:
  27. @grep -E "^[a-zA-Z0-9_-]+:.*?## .*$$" $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
  28. clean: ## Clean all intermediate files.
  29. @echo Cleaning...
  30. -@rm -rf .build
  31. @mkdir .build
  32. projgen: ## Generate project files for all configurations.
  33. $(GENIE) --with-tools --with-combined-examples --with-shared-lib vs2017
  34. $(GENIE) --with-tools --with-combined-examples --vs=winstore100 vs2017
  35. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --gcc=mingw-gcc gmake
  36. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --gcc=linux-gcc gmake
  37. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --gcc=osx gmake
  38. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --xcode=osx xcode8
  39. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --xcode=ios xcode8
  40. $(GENIE) --with-combined-examples --with-shared-lib --gcc=freebsd gmake
  41. $(GENIE) --with-combined-examples --gcc=android-arm gmake
  42. $(GENIE) --with-combined-examples --gcc=android-x86 gmake
  43. $(GENIE) --with-combined-examples --gcc=asmjs gmake
  44. $(GENIE) --with-combined-examples --gcc=ios-arm gmake
  45. $(GENIE) --with-combined-examples --gcc=ios-arm64 gmake
  46. $(GENIE) --with-combined-examples --gcc=ios-simulator gmake
  47. $(GENIE) --with-combined-examples --gcc=ios-simulator64 gmake
  48. $(GENIE) --with-combined-examples --gcc=rpi gmake
  49. .build/projects/gmake-android-arm:
  50. $(GENIE) --gcc=android-arm gmake
  51. android-arm-debug: .build/projects/gmake-android-arm ## Build - Android ARM Debug
  52. $(MAKE) -R -C .build/projects/gmake-android-arm config=debug
  53. android-arm-release: .build/projects/gmake-android-arm ## Build - Android ARM Release
  54. $(MAKE) -R -C .build/projects/gmake-android-arm config=release
  55. android-arm: android-arm-debug android-arm-release ## Build - Android ARM Debug and Release
  56. .build/projects/gmake-android-x86:
  57. $(GENIE) --gcc=android-x86 gmake
  58. android-x86-debug: .build/projects/gmake-android-x86 ## Build - Android x86 Debug and Release
  59. $(MAKE) -R -C .build/projects/gmake-android-x86 config=debug
  60. android-x86-release: .build/projects/gmake-android-x86 ## Build - Android x86 Debug and Release
  61. $(MAKE) -R -C .build/projects/gmake-android-x86 config=release
  62. android-x86: android-x86-debug android-x86-release ## Build - Android x86 Debug and Release
  63. .build/projects/gmake-asmjs:
  64. $(GENIE) --gcc=asmjs gmake
  65. asmjs-debug: .build/projects/gmake-asmjs ## Build - Emscripten Debug
  66. $(MAKE) -R -C .build/projects/gmake-asmjs config=debug
  67. asmjs-release: .build/projects/gmake-asmjs ## Build - Emscripten Release
  68. $(MAKE) -R -C .build/projects/gmake-asmjs config=release
  69. asmjs: asmjs-debug asmjs-release ## Build - Emscripten Debug and Release
  70. .build/projects/gmake-linux:
  71. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --gcc=linux-gcc gmake
  72. linux-debug64: .build/projects/gmake-linux ## Build - Linux x64 Debug
  73. $(MAKE) -R -C .build/projects/gmake-linux config=debug64
  74. linux-release64: .build/projects/gmake-linux ## Build - Linux x64 Release
  75. $(MAKE) -R -C .build/projects/gmake-linux config=release64
  76. linux: linux-debug64 linux-release64 ## Build - Linux x86/x64 Debug and Release
  77. .build/projects/gmake-freebsd:
  78. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --gcc=freebsd gmake
  79. freebsd-debug32: .build/projects/gmake-freebsd ## Build - FreeBSD x86 Debug
  80. $(MAKE) -R -C .build/projects/gmake-freebsd config=debug32
  81. freebsd-release32: .build/projects/gmake-freebsd ## Build - FreeBSD x86 Release
  82. $(MAKE) -R -C .build/projects/gmake-freebsd config=release32
  83. freebsd-debug64: .build/projects/gmake-freebsd ## Build - FreeBSD x86 Debug
  84. $(MAKE) -R -C .build/projects/gmake-freebsd config=debug64
  85. freebsd-release64: .build/projects/gmake-freebsd ## Build - FreeBSD x86 Release
  86. $(MAKE) -R -C .build/projects/gmake-freebsd config=release64
  87. freebsd: freebsd-debug32 freebsd-release32 freebsd-debug64 freebsd-release64 ## Build - FreeBSD x86/x64 Debug and Release
  88. .build/projects/gmake-mingw-gcc:
  89. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --os=windows --gcc=mingw-gcc gmake
  90. mingw-gcc-debug32: .build/projects/gmake-mingw-gcc ## Build - MinGW GCC x86 Debug
  91. $(MAKE) -R -C .build/projects/gmake-mingw-gcc config=debug32
  92. mingw-gcc-release32: .build/projects/gmake-mingw-gcc ## Build - MinGW GCC x86 Release
  93. $(MAKE) -R -C .build/projects/gmake-mingw-gcc config=release32
  94. mingw-gcc-debug64: .build/projects/gmake-mingw-gcc ## Build - MinGW GCC x64 Debug
  95. $(MAKE) -R -C .build/projects/gmake-mingw-gcc config=debug64
  96. mingw-gcc-release64: .build/projects/gmake-mingw-gcc ## Build - MinGW GCC x64 Release
  97. $(MAKE) -R -C .build/projects/gmake-mingw-gcc config=release64
  98. mingw-gcc: mingw-gcc-debug32 mingw-gcc-release32 mingw-gcc-debug64 mingw-gcc-release64 ## Build - MinGW GCC x86/x64 Debug and Release
  99. .build/projects/gmake-mingw-clang:
  100. $(GENIE) --gcc=mingw-clang gmake
  101. mingw-clang-debug32: .build/projects/gmake-mingw-clang ## Build - MinGW Clang x86 Debug
  102. $(MAKE) -R -C .build/projects/gmake-mingw-clang config=debug32
  103. mingw-clang-release32: .build/projects/gmake-mingw-clang ## Build - MinGW Clang x86 Release
  104. $(MAKE) -R -C .build/projects/gmake-mingw-clang config=release32
  105. mingw-clang-debug64: .build/projects/gmake-mingw-clang ## Build - MinGW Clang x64 Debug
  106. $(MAKE) -R -C .build/projects/gmake-mingw-clang config=debug64
  107. mingw-clang-release64: .build/projects/gmake-mingw-clang ## Build - MinGW Clang x64 Release
  108. $(MAKE) -R -C .build/projects/gmake-mingw-clang config=release64
  109. mingw-clang: mingw-clang-debug32 mingw-clang-release32 mingw-clang-debug64 mingw-clang-release64 ## Build - MinGW Clang x86/x64 Debug and Release
  110. .build/projects/vs2017:
  111. $(GENIE) --with-tools --with-combined-examples --with-shared-lib vs2017
  112. vs2017-debug32: .build/projects/vs2017 ## Build - vs2017 x86 Debug
  113. devenv .build/projects/vs2017/bgfx.sln /Build "Debug|Win32"
  114. vs2017-release32: .build/projects/vs2017 ## Build - vs2017 x86 Release
  115. devenv .build/projects/vs2017/bgfx.sln /Build "Release|Win32"
  116. vs2017-debug64: .build/projects/vs2017 ## Build - vs2017 x64 Debug
  117. devenv .build/projects/vs2017/bgfx.sln /Build "Debug|x64"
  118. vs2017-release64: .build/projects/vs2017 ## Build - vs2017 x64 Release
  119. devenv .build/projects/vs2017/bgfx.sln /Build "Release|x64"
  120. vs2017: vs2017-debug32 vs2017-release32 vs2017-debug64 vs2017-release64 ## Build - vs2017 x86/x64 Debug and Release
  121. .build/projects/vs2017-winstore100:
  122. $(GENIE) --with-combined-examples --vs=winstore100 vs2017
  123. vs2017-winstore100-debug32: .build/projects/vs2017-winstore100 ## Build - vs2017-winstore100 x86 Debug
  124. devenv .build/projects/vs2017-winstore100/bgfx.sln /Build "Debug|Win32"
  125. vs2017-winstore100-release32: .build/projects/vs2017-winstore100 ## Build - vs2017-winstore100 x86 Release
  126. devenv .build/projects/vs2017-winstore100/bgfx.sln /Build "Release|Win32"
  127. vs2017-winstore100-debug64: .build/projects/vs2017-winstore100 ## Build - vs2017-winstore100 x64 Debug
  128. devenv .build/projects/vs2017-winstore100/bgfx.sln /Build "Debug|x64"
  129. vs2017-winstore100-release64: .build/projects/vs2017-winstore100 ## Build - vs2017-winstore100 x64 Release
  130. devenv .build/projects/vs2017-winstore100/bgfx.sln /Build "Release|x64"
  131. vs2017-winstore100: vs2017-winstore100-debug32 vs2017-winstore100-release32 vs2017-winstore100-debug64 vs2017-winstore100-release64 ## Build - vs2017-winstore100 x86/x64 Debug and Release
  132. .build/projects/gmake-osx:
  133. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --gcc=osx gmake
  134. osx-debug64: .build/projects/gmake-osx ## Build - OSX x64 Debug
  135. $(MAKE) -C .build/projects/gmake-osx config=debug64
  136. osx-release64: .build/projects/gmake-osx ## Build - OSX x64 Release
  137. $(MAKE) -C .build/projects/gmake-osx config=release64
  138. osx: osx-debug64 osx-release64 ## Build - OSX x86/x64 Debug and Release
  139. .build/projects/gmake-ios-arm:
  140. $(GENIE) --gcc=ios-arm gmake
  141. ios-arm-debug: .build/projects/gmake-ios-arm ## Build - iOS ARM Debug
  142. $(MAKE) -R -C .build/projects/gmake-ios-arm config=debug
  143. ios-arm-release: .build/projects/gmake-ios-arm ## Build - iOS ARM Release
  144. $(MAKE) -R -C .build/projects/gmake-ios-arm config=release
  145. ios-arm: ios-arm-debug ios-arm-release ## Build - iOS ARM Debug and Release
  146. .build/projects/gmake-ios-arm64:
  147. $(GENIE) --gcc=ios-arm64 gmake
  148. ios-arm64-debug: .build/projects/gmake-ios-arm64 ## Build - iOS ARM64 Debug
  149. $(MAKE) -R -C .build/projects/gmake-ios-arm64 config=debug
  150. ios-arm64-release: .build/projects/gmake-ios-arm64 ## Build - iOS ARM64 Release
  151. $(MAKE) -R -C .build/projects/gmake-ios-arm64 config=release
  152. ios-arm64: ios-arm64-debug ios-arm64-release ## Build - iOS ARM64 Debug and Release
  153. .build/projects/gmake-ios-simulator:
  154. $(GENIE) --gcc=ios-simulator gmake
  155. ios-simulator-debug: .build/projects/gmake-ios-simulator ## Build - iOS Simulator Debug
  156. $(MAKE) -R -C .build/projects/gmake-ios-simulator config=debug
  157. ios-simulator-release: .build/projects/gmake-ios-simulator ## Build - iOS Simulator Release
  158. $(MAKE) -R -C .build/projects/gmake-ios-simulator config=release
  159. ios-simulator: ios-simulator-debug ios-simulator-release ## Build - iOS Simulator Debug and Release
  160. .build/projects/gmake-ios-simulator64:
  161. $(GENIE) --gcc=ios-simulator64 gmake
  162. ios-simulator64-debug: .build/projects/gmake-ios-simulator64 ## Build - iOS Simulator Debug
  163. $(MAKE) -R -C .build/projects/gmake-ios-simulator64 config=debug
  164. ios-simulator64-release: .build/projects/gmake-ios-simulator64 ## Build - iOS Simulator Release
  165. $(MAKE) -R -C .build/projects/gmake-ios-simulator64 config=release
  166. ios-simulator64: ios-simulator64-debug ios-simulator64-release ## Build - iOS Simulator Debug and Release
  167. .build/projects/gmake-rpi:
  168. $(GENIE) --gcc=rpi gmake
  169. rpi-debug: .build/projects/gmake-rpi ## Build - RasberryPi Debug
  170. $(MAKE) -R -C .build/projects/gmake-rpi config=debug
  171. rpi-release: .build/projects/gmake-rpi ## Build - RasberryPi Release
  172. $(MAKE) -R -C .build/projects/gmake-rpi config=release
  173. rpi: rpi-debug rpi-release ## Build - RasberryPi Debug and Release
  174. build-darwin: osx
  175. build-linux: linux-debug64 linux-release64
  176. build-windows: mingw-gcc
  177. build: build-$(OS)
  178. rebuild-shaders:
  179. $(MAKE) -R -C examples rebuild
  180. assets: # Build assets.
  181. $(NINJA) -C scripts
  182. analyze:
  183. cppcheck src/
  184. cppcheck examples/
  185. docs:
  186. doxygen scripts/bgfx.doxygen
  187. markdown README.md > .build/docs/readme.html
  188. ###
  189. SILENT ?= @
  190. UNAME := $(shell uname)
  191. ifeq ($(UNAME),$(filter $(UNAME),Linux Darwin FreeBSD GNU/kFreeBSD))
  192. ifeq ($(UNAME),$(filter $(UNAME),Darwin))
  193. OS=darwin
  194. BUILD_PROJECT_DIR=gmake-osx
  195. BUILD_OUTPUT_DIR=osx64_clang
  196. BUILD_TOOLS_CONFIG=release64
  197. BUILD_TOOLS_SUFFIX=Release
  198. EXE=
  199. else
  200. ifeq ($(UNAME),$(filter $(UNAME),FreeBSD GNU/kFreeBSD))
  201. OS=bsd
  202. BUILD_PROJECT_DIR=gmake-freebsd
  203. BUILD_OUTPUT_DIR=freebsd64_gcc
  204. BUILD_TOOLS_CONFIG=release64
  205. BUILD_TOOLS_SUFFIX=Release
  206. EXE=
  207. else
  208. OS=linux
  209. BUILD_PROJECT_DIR=gmake-linux
  210. BUILD_OUTPUT_DIR=linux64_gcc
  211. BUILD_TOOLS_CONFIG=release64
  212. BUILD_TOOLS_SUFFIX=Release
  213. EXE=
  214. endif
  215. endif
  216. else
  217. OS=windows
  218. BUILD_PROJECT_DIR=gmake-mingw-gcc
  219. BUILD_OUTPUT_DIR=win64_mingw-gcc
  220. BUILD_TOOLS_CONFIG=release64
  221. BUILD_TOOLS_SUFFIX=Release
  222. EXE=.exe
  223. endif
  224. geometryc: .build/projects/$(BUILD_PROJECT_DIR) ## Build geometryc tool.
  225. $(SILENT) $(MAKE) -C .build/projects/$(BUILD_PROJECT_DIR) geometryc config=$(BUILD_TOOLS_CONFIG)
  226. $(SILENT) cp .build/$(BUILD_OUTPUT_DIR)/bin/geometryc$(BUILD_TOOLS_SUFFIX)$(EXE) tools/bin/$(OS)/geometryc$(EXE)
  227. shaderc: .build/projects/$(BUILD_PROJECT_DIR) ## Build shaderc tool.
  228. $(SILENT) $(MAKE) -C .build/projects/$(BUILD_PROJECT_DIR) shaderc config=$(BUILD_TOOLS_CONFIG)
  229. $(SILENT) cp .build/$(BUILD_OUTPUT_DIR)/bin/shaderc$(BUILD_TOOLS_SUFFIX)$(EXE) tools/bin/$(OS)/shaderc$(EXE)
  230. texturec: .build/projects/$(BUILD_PROJECT_DIR) ## Build texturec tool.
  231. $(SILENT) $(MAKE) -C .build/projects/$(BUILD_PROJECT_DIR) texturec config=$(BUILD_TOOLS_CONFIG)
  232. $(SILENT) cp .build/$(BUILD_OUTPUT_DIR)/bin/texturec$(BUILD_TOOLS_SUFFIX)$(EXE) tools/bin/$(OS)/texturec$(EXE)
  233. texturev: .build/projects/$(BUILD_PROJECT_DIR) ## Build texturev tool.
  234. $(SILENT) $(MAKE) -C .build/projects/$(BUILD_PROJECT_DIR) texturev config=$(BUILD_TOOLS_CONFIG)
  235. $(SILENT) cp .build/$(BUILD_OUTPUT_DIR)/bin/texturev$(BUILD_TOOLS_SUFFIX)$(EXE) tools/bin/$(OS)/texturev$(EXE)
  236. tools: geometryc shaderc texturec texturev ## Build tools.
  237. clean-tools: ## Clean tools projects.
  238. -$(SILENT) rm -r .build/projects/$(BUILD_PROJECT_DIR)
  239. dist-windows: .build/projects/gmake-mingw-gcc
  240. $(SILENT) $(MAKE) -C .build/projects/gmake-mingw-gcc config=release64 -j 6 geometryc
  241. $(SILENT) cp .build/win64_mingw-gcc/bin/geometrycRelease.exe tools/bin/windows/geometryc.exe
  242. $(SILENT) $(MAKE) -C .build/projects/gmake-mingw-gcc config=release64 -j 6 shaderc
  243. $(SILENT) cp .build/win64_mingw-gcc/bin/shadercRelease.exe tools/bin/windows/shaderc.exe
  244. $(SILENT) $(MAKE) -C .build/projects/gmake-mingw-gcc config=release64 -j 6 texturec
  245. $(SILENT) cp .build/win64_mingw-gcc/bin/texturecRelease.exe tools/bin/windows/texturec.exe
  246. $(SILENT) $(MAKE) -C .build/projects/gmake-mingw-gcc config=release64 -j 6 texturev
  247. $(SILENT) cp .build/win64_mingw-gcc/bin/texturevRelease.exe tools/bin/windows/texturev.exe
  248. dist-linux: .build/projects/gmake-linux
  249. $(SILENT) $(MAKE) -C .build/projects/gmake-linux config=release64 -j 6 geometryc
  250. $(SILENT) cp .build/linux64_gcc/bin/geometrycRelease tools/bin/linux/geometryc
  251. $(SILENT) $(MAKE) -C .build/projects/gmake-linux config=release64 -j 6 shaderc
  252. $(SILENT) cp .build/linux64_gcc/bin/shadercRelease tools/bin/linux/shaderc
  253. $(SILENT) $(MAKE) -C .build/projects/gmake-linux config=release64 -j 6 texturec
  254. $(SILENT) cp .build/linux64_gcc/bin/texturecRelease tools/bin/linux/texturec
  255. $(SILENT) $(MAKE) -C .build/projects/gmake-linux config=release64 -j 6 texturev
  256. $(SILENT) cp .build/linux64_gcc/bin/texturevRelease tools/bin/linux/texturev
  257. dist-darwin: .build/projects/gmake-osx
  258. $(SILENT) $(MAKE) -C .build/projects/gmake-osx config=release64 -j 6 geometryc
  259. $(SILENT) cp .build/osx64_clang/bin/geometrycRelease tools/bin/darwin/geometryc
  260. $(SILENT) $(MAKE) -C .build/projects/gmake-osx config=release64 -j 6 shaderc
  261. $(SILENT) cp .build/osx64_clang/bin/shadercRelease tools/bin/darwin/shaderc
  262. $(SILENT) $(MAKE) -C .build/projects/gmake-osx config=release64 -j 6 texturec
  263. $(SILENT) cp .build/osx64_clang/bin/texturecRelease tools/bin/darwin/texturec
  264. $(SILENT) $(MAKE) -C .build/projects/gmake-osx config=release64 -j 6 texturev
  265. $(SILENT) cp .build/osx64_clang/bin/texturevRelease tools/bin/darwin/texturev
  266. dist: clean dist-windows dist-linux dist-darwin