makefile 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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 vs2015
  34. $(GENIE) --with-tools --with-combined-examples --with-shared-lib vs2017
  35. $(GENIE) --with-tools --with-combined-examples --vs=winstore100 vs2017
  36. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --gcc=mingw-gcc gmake
  37. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --gcc=linux-gcc gmake
  38. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --gcc=osx gmake
  39. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --xcode=osx xcode4
  40. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --xcode=ios xcode4
  41. $(GENIE) --with-combined-examples --with-shared-lib --gcc=freebsd gmake
  42. $(GENIE) --with-combined-examples --gcc=android-arm gmake
  43. $(GENIE) --with-combined-examples --gcc=android-mips gmake
  44. $(GENIE) --with-combined-examples --gcc=android-x86 gmake
  45. $(GENIE) --with-combined-examples --gcc=asmjs gmake
  46. $(GENIE) --with-combined-examples --gcc=ios-arm gmake
  47. $(GENIE) --with-combined-examples --gcc=ios-arm64 gmake
  48. $(GENIE) --with-combined-examples --gcc=ios-simulator gmake
  49. $(GENIE) --with-combined-examples --gcc=ios-simulator64 gmake
  50. $(GENIE) --with-combined-examples --gcc=rpi gmake
  51. .build/projects/gmake-android-arm:
  52. $(GENIE) --gcc=android-arm gmake
  53. android-arm-debug: .build/projects/gmake-android-arm ## Build - Android ARM Debug
  54. $(MAKE) -R -C .build/projects/gmake-android-arm config=debug
  55. android-arm-release: .build/projects/gmake-android-arm ## Build - Android ARM Release
  56. $(MAKE) -R -C .build/projects/gmake-android-arm config=release
  57. android-arm: android-arm-debug android-arm-release ## Build - Android ARM Debug and Release
  58. .build/projects/gmake-android-mips:
  59. $(GENIE) --gcc=android-mips gmake
  60. android-mips-debug: .build/projects/gmake-android-mips ## Build - Android MIPS Debug
  61. $(MAKE) -R -C .build/projects/gmake-android-mips config=debug
  62. android-mips-release: .build/projects/gmake-android-mips ## Build - Android MIPS Release
  63. $(MAKE) -R -C .build/projects/gmake-android-mips config=release
  64. android-mips: android-mips-debug android-mips-release ## Build - Android MIPS Debug and Release
  65. .build/projects/gmake-android-x86:
  66. $(GENIE) --gcc=android-x86 gmake
  67. android-x86-debug: .build/projects/gmake-android-x86 ## Build - Android x86 Debug and Release
  68. $(MAKE) -R -C .build/projects/gmake-android-x86 config=debug
  69. android-x86-release: .build/projects/gmake-android-x86 ## Build - Android x86 Debug and Release
  70. $(MAKE) -R -C .build/projects/gmake-android-x86 config=release
  71. android-x86: android-x86-debug android-x86-release ## Build - Android x86 Debug and Release
  72. .build/projects/gmake-asmjs:
  73. $(GENIE) --gcc=asmjs gmake
  74. asmjs-debug: .build/projects/gmake-asmjs ## Build - Emscripten Debug
  75. $(MAKE) -R -C .build/projects/gmake-asmjs config=debug
  76. asmjs-release: .build/projects/gmake-asmjs ## Build - Emscripten Release
  77. $(MAKE) -R -C .build/projects/gmake-asmjs config=release
  78. asmjs: asmjs-debug asmjs-release ## Build - Emscripten Debug and Release
  79. .build/projects/gmake-linux:
  80. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --gcc=linux-gcc gmake
  81. linux-debug64: .build/projects/gmake-linux ## Build - Linux x64 Debug
  82. $(MAKE) -R -C .build/projects/gmake-linux config=debug64
  83. linux-release64: .build/projects/gmake-linux ## Build - Linux x64 Release
  84. $(MAKE) -R -C .build/projects/gmake-linux config=release64
  85. linux: linux-debug64 linux-release64 ## Build - Linux x86/x64 Debug and Release
  86. .build/projects/gmake-freebsd:
  87. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --gcc=freebsd gmake
  88. freebsd-debug32: .build/projects/gmake-freebsd ## Build - FreeBSD x86 Debug
  89. $(MAKE) -R -C .build/projects/gmake-freebsd config=debug32
  90. freebsd-release32: .build/projects/gmake-freebsd ## Build - FreeBSD x86 Release
  91. $(MAKE) -R -C .build/projects/gmake-freebsd config=release32
  92. freebsd-debug64: .build/projects/gmake-freebsd ## Build - FreeBSD x86 Debug
  93. $(MAKE) -R -C .build/projects/gmake-freebsd config=debug64
  94. freebsd-release64: .build/projects/gmake-freebsd ## Build - FreeBSD x86 Release
  95. $(MAKE) -R -C .build/projects/gmake-freebsd config=release64
  96. freebsd: freebsd-debug32 freebsd-release32 freebsd-debug64 freebsd-release64 ## Build - FreeBSD x86/x64 Debug and Release
  97. .build/projects/gmake-mingw-gcc:
  98. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --gcc=mingw-gcc gmake
  99. mingw-gcc-debug32: .build/projects/gmake-mingw-gcc ## Build - MinGW GCC x86 Debug
  100. $(MAKE) -R -C .build/projects/gmake-mingw-gcc config=debug32
  101. mingw-gcc-release32: .build/projects/gmake-mingw-gcc ## Build - MinGW GCC x86 Release
  102. $(MAKE) -R -C .build/projects/gmake-mingw-gcc config=release32
  103. mingw-gcc-debug64: .build/projects/gmake-mingw-gcc ## Build - MinGW GCC x64 Debug
  104. $(MAKE) -R -C .build/projects/gmake-mingw-gcc config=debug64
  105. mingw-gcc-release64: .build/projects/gmake-mingw-gcc ## Build - MinGW GCC x64 Release
  106. $(MAKE) -R -C .build/projects/gmake-mingw-gcc config=release64
  107. mingw-gcc: mingw-gcc-debug32 mingw-gcc-release32 mingw-gcc-debug64 mingw-gcc-release64 ## Build - MinGW GCC x86/x64 Debug and Release
  108. .build/projects/gmake-mingw-clang:
  109. $(GENIE) --gcc=mingw-clang gmake
  110. mingw-clang-debug32: .build/projects/gmake-mingw-clang ## Build - MinGW Clang x86 Debug
  111. $(MAKE) -R -C .build/projects/gmake-mingw-clang config=debug32
  112. mingw-clang-release32: .build/projects/gmake-mingw-clang ## Build - MinGW Clang x86 Release
  113. $(MAKE) -R -C .build/projects/gmake-mingw-clang config=release32
  114. mingw-clang-debug64: .build/projects/gmake-mingw-clang ## Build - MinGW Clang x64 Debug
  115. $(MAKE) -R -C .build/projects/gmake-mingw-clang config=debug64
  116. mingw-clang-release64: .build/projects/gmake-mingw-clang ## Build - MinGW Clang x64 Release
  117. $(MAKE) -R -C .build/projects/gmake-mingw-clang config=release64
  118. mingw-clang: mingw-clang-debug32 mingw-clang-release32 mingw-clang-debug64 mingw-clang-release64 ## Build - MinGW Clang x86/x64 Debug and Release
  119. .build/projects/vs2015:
  120. $(GENIE) --with-tools --with-combined-examples --with-shared-lib vs2015
  121. vs2015-debug32: .build/projects/vs2015 ## Build - VS2015 x86 Debug
  122. devenv .build/projects/vs2015/bgfx.sln /Build "Debug|Win32"
  123. vs2015-release32: .build/projects/vs2015 ## Build - VS2015 x86 Release
  124. devenv .build/projects/vs2015/bgfx.sln /Build "Release|Win32"
  125. vs2015-debug64: .build/projects/vs2015 ## Build - VS2015 x64 Debug
  126. devenv .build/projects/vs2015/bgfx.sln /Build "Debug|x64"
  127. vs2015-release64: .build/projects/vs2015 ## Build - VS2015 x64 Release
  128. devenv .build/projects/vs2015/bgfx.sln /Build "Release|x64"
  129. vs2015: vs2015-debug32 vs2015-release32 vs2015-debug64 vs2015-release64 ## Build - VS2015 x86/x64 Debug and Release
  130. .build/projects/vs2017:
  131. $(GENIE) --with-tools --with-combined-examples --with-shared-lib vs2017
  132. vs2017-debug32: .build/projects/vs2017 ## Build - vs2017 x86 Debug
  133. devenv .build/projects/vs2017/bgfx.sln /Build "Debug|Win32"
  134. vs2017-release32: .build/projects/vs2017 ## Build - vs2017 x86 Release
  135. devenv .build/projects/vs2017/bgfx.sln /Build "Release|Win32"
  136. vs2017-debug64: .build/projects/vs2017 ## Build - vs2017 x64 Debug
  137. devenv .build/projects/vs2017/bgfx.sln /Build "Debug|x64"
  138. vs2017-release64: .build/projects/vs2017 ## Build - vs2017 x64 Release
  139. devenv .build/projects/vs2017/bgfx.sln /Build "Release|x64"
  140. vs2017: vs2017-debug32 vs2017-release32 vs2017-debug64 vs2017-release64 ## Build - vs2017 x86/x64 Debug and Release
  141. .build/projects/vs2017-winstore100:
  142. $(GENIE) --with-combined-examples --vs=winstore100 vs2017
  143. vs2017-winstore100-debug32: .build/projects/vs2017-winstore100 ## Build - vs2017-winstore100 x86 Debug
  144. devenv .build/projects/vs2017-winstore100/bgfx.sln /Build "Debug|Win32"
  145. vs2017-winstore100-release32: .build/projects/vs2017-winstore100 ## Build - vs2017-winstore100 x86 Release
  146. devenv .build/projects/vs2017-winstore100/bgfx.sln /Build "Release|Win32"
  147. vs2017-winstore100-debug64: .build/projects/vs2017-winstore100 ## Build - vs2017-winstore100 x64 Debug
  148. devenv .build/projects/vs2017-winstore100/bgfx.sln /Build "Debug|x64"
  149. vs2017-winstore100-release64: .build/projects/vs2017-winstore100 ## Build - vs2017-winstore100 x64 Release
  150. devenv .build/projects/vs2017-winstore100/bgfx.sln /Build "Release|x64"
  151. vs2017-winstore100: vs2017-winstore100-debug32 vs2017-winstore100-release32 vs2017-winstore100-debug64 vs2017-winstore100-release64 ## Build - vs2017-winstore100 x86/x64 Debug and Release
  152. .build/projects/gmake-osx:
  153. $(GENIE) --with-tools --with-combined-examples --with-shared-lib --gcc=osx gmake
  154. osx-debug64: .build/projects/gmake-osx ## Build - OSX x64 Debug
  155. $(MAKE) -C .build/projects/gmake-osx config=debug64
  156. osx-release64: .build/projects/gmake-osx ## Build - OSX x64 Release
  157. $(MAKE) -C .build/projects/gmake-osx config=release64
  158. osx: osx-debug64 osx-release64 ## Build - OSX x86/x64 Debug and Release
  159. .build/projects/gmake-ios-arm:
  160. $(GENIE) --gcc=ios-arm gmake
  161. ios-arm-debug: .build/projects/gmake-ios-arm ## Build - iOS ARM Debug
  162. $(MAKE) -R -C .build/projects/gmake-ios-arm config=debug
  163. ios-arm-release: .build/projects/gmake-ios-arm ## Build - iOS ARM Release
  164. $(MAKE) -R -C .build/projects/gmake-ios-arm config=release
  165. ios-arm: ios-arm-debug ios-arm-release ## Build - iOS ARM Debug and Release
  166. .build/projects/gmake-ios-arm64:
  167. $(GENIE) --gcc=ios-arm64 gmake
  168. ios-arm64-debug: .build/projects/gmake-ios-arm64 ## Build - iOS ARM64 Debug
  169. $(MAKE) -R -C .build/projects/gmake-ios-arm64 config=debug
  170. ios-arm64-release: .build/projects/gmake-ios-arm64 ## Build - iOS ARM64 Release
  171. $(MAKE) -R -C .build/projects/gmake-ios-arm64 config=release
  172. ios-arm64: ios-arm64-debug ios-arm64-release ## Build - iOS ARM64 Debug and Release
  173. .build/projects/gmake-ios-simulator:
  174. $(GENIE) --gcc=ios-simulator gmake
  175. ios-simulator-debug: .build/projects/gmake-ios-simulator ## Build - iOS Simulator Debug
  176. $(MAKE) -R -C .build/projects/gmake-ios-simulator config=debug
  177. ios-simulator-release: .build/projects/gmake-ios-simulator ## Build - iOS Simulator Release
  178. $(MAKE) -R -C .build/projects/gmake-ios-simulator config=release
  179. ios-simulator: ios-simulator-debug ios-simulator-release ## Build - iOS Simulator Debug and Release
  180. .build/projects/gmake-ios-simulator64:
  181. $(GENIE) --gcc=ios-simulator64 gmake
  182. ios-simulator64-debug: .build/projects/gmake-ios-simulator64 ## Build - iOS Simulator Debug
  183. $(MAKE) -R -C .build/projects/gmake-ios-simulator64 config=debug
  184. ios-simulator64-release: .build/projects/gmake-ios-simulator64 ## Build - iOS Simulator Release
  185. $(MAKE) -R -C .build/projects/gmake-ios-simulator64 config=release
  186. ios-simulator64: ios-simulator64-debug ios-simulator64-release ## Build - iOS Simulator Debug and Release
  187. .build/projects/gmake-rpi:
  188. $(GENIE) --gcc=rpi gmake
  189. rpi-debug: .build/projects/gmake-rpi ## Build - RasberryPi Debug
  190. $(MAKE) -R -C .build/projects/gmake-rpi config=debug
  191. rpi-release: .build/projects/gmake-rpi ## Build - RasberryPi Release
  192. $(MAKE) -R -C .build/projects/gmake-rpi config=release
  193. rpi: rpi-debug rpi-release ## Build - RasberryPi Debug and Release
  194. build-darwin: osx
  195. build-linux: linux-debug64 linux-release64
  196. build-windows: mingw-gcc
  197. build: build-$(OS)
  198. rebuild-shaders:
  199. $(MAKE) -R -C examples rebuild
  200. assets: # Build assets.
  201. $(NINJA) -C scripts
  202. analyze:
  203. cppcheck src/
  204. cppcheck examples/
  205. docs:
  206. doxygen scripts/bgfx.doxygen
  207. markdown README.md > .build/docs/readme.html
  208. ###
  209. SILENT ?= @
  210. UNAME := $(shell uname)
  211. ifeq ($(UNAME),$(filter $(UNAME),Linux Darwin FreeBSD GNU/kFreeBSD))
  212. ifeq ($(UNAME),$(filter $(UNAME),Darwin))
  213. OS=darwin
  214. BUILD_PROJECT_DIR=gmake-osx
  215. BUILD_OUTPUT_DIR=osx64_clang
  216. BUILD_TOOLS_CONFIG=release64
  217. BUILD_TOOLS_SUFFIX=Release
  218. EXE=
  219. else
  220. ifeq ($(UNAME),$(filter $(UNAME),FreeBSD GNU/kFreeBSD))
  221. OS=bsd
  222. BUILD_PROJECT_DIR=gmake-freebsd
  223. BUILD_OUTPUT_DIR=freebsd64_gcc
  224. BUILD_TOOLS_CONFIG=release64
  225. BUILD_TOOLS_SUFFIX=Release
  226. EXE=
  227. else
  228. OS=linux
  229. BUILD_PROJECT_DIR=gmake-linux
  230. BUILD_OUTPUT_DIR=linux64_gcc
  231. BUILD_TOOLS_CONFIG=release64
  232. BUILD_TOOLS_SUFFIX=Release
  233. EXE=
  234. endif
  235. endif
  236. else
  237. OS=windows
  238. BUILD_PROJECT_DIR=gmake-mingw-gcc
  239. BUILD_OUTPUT_DIR=win64_mingw-gcc
  240. BUILD_TOOLS_CONFIG=release64
  241. BUILD_TOOLS_SUFFIX=Release
  242. EXE=.exe
  243. endif
  244. geometryc: .build/projects/$(BUILD_PROJECT_DIR) ## Build geometryc tool.
  245. $(SILENT) $(MAKE) -C .build/projects/$(BUILD_PROJECT_DIR) geometryc config=$(BUILD_TOOLS_CONFIG)
  246. $(SILENT) cp .build/$(BUILD_OUTPUT_DIR)/bin/geometryc$(BUILD_TOOLS_SUFFIX)$(EXE) tools/bin/$(OS)/geometryc$(EXE)
  247. shaderc: .build/projects/$(BUILD_PROJECT_DIR) ## Build shaderc tool.
  248. $(SILENT) $(MAKE) -C .build/projects/$(BUILD_PROJECT_DIR) shaderc config=$(BUILD_TOOLS_CONFIG)
  249. $(SILENT) cp .build/$(BUILD_OUTPUT_DIR)/bin/shaderc$(BUILD_TOOLS_SUFFIX)$(EXE) tools/bin/$(OS)/shaderc$(EXE)
  250. texturec: .build/projects/$(BUILD_PROJECT_DIR) ## Build texturec tool.
  251. $(SILENT) $(MAKE) -C .build/projects/$(BUILD_PROJECT_DIR) texturec config=$(BUILD_TOOLS_CONFIG)
  252. $(SILENT) cp .build/$(BUILD_OUTPUT_DIR)/bin/texturec$(BUILD_TOOLS_SUFFIX)$(EXE) tools/bin/$(OS)/texturec$(EXE)
  253. texturev: .build/projects/$(BUILD_PROJECT_DIR) ## Build texturev tool.
  254. $(SILENT) $(MAKE) -C .build/projects/$(BUILD_PROJECT_DIR) texturev config=$(BUILD_TOOLS_CONFIG)
  255. $(SILENT) cp .build/$(BUILD_OUTPUT_DIR)/bin/texturev$(BUILD_TOOLS_SUFFIX)$(EXE) tools/bin/$(OS)/texturev$(EXE)
  256. tools: geometryc shaderc texturec texturev ## Build tools.
  257. clean-tools: ## Clean tools projects.
  258. -$(SILENT) rm -r .build/projects/$(BUILD_PROJECT_DIR)
  259. dist-windows: .build/projects/gmake-mingw-gcc
  260. $(SILENT) $(MAKE) -C .build/projects/gmake-mingw-gcc config=release64 -j 6 geometryc
  261. $(SILENT) cp .build/win64_mingw-gcc/bin/geometrycRelease.exe tools/bin/windows/geometryc.exe
  262. $(SILENT) $(MAKE) -C .build/projects/gmake-mingw-gcc config=release64 -j 6 shaderc
  263. $(SILENT) cp .build/win64_mingw-gcc/bin/shadercRelease.exe tools/bin/windows/shaderc.exe
  264. $(SILENT) $(MAKE) -C .build/projects/gmake-mingw-gcc config=release64 -j 6 texturec
  265. $(SILENT) cp .build/win64_mingw-gcc/bin/texturecRelease.exe tools/bin/windows/texturec.exe
  266. $(SILENT) $(MAKE) -C .build/projects/gmake-mingw-gcc config=release64 -j 6 texturev
  267. $(SILENT) cp .build/win64_mingw-gcc/bin/texturevRelease.exe tools/bin/windows/texturev.exe
  268. dist-linux: .build/projects/gmake-linux
  269. $(SILENT) $(MAKE) -C .build/projects/gmake-linux config=release64 -j 6 geometryc
  270. $(SILENT) cp .build/linux64_gcc/bin/geometrycRelease tools/bin/linux/geometryc
  271. $(SILENT) $(MAKE) -C .build/projects/gmake-linux config=release64 -j 6 shaderc
  272. $(SILENT) cp .build/linux64_gcc/bin/shadercRelease tools/bin/linux/shaderc
  273. $(SILENT) $(MAKE) -C .build/projects/gmake-linux config=release64 -j 6 texturec
  274. $(SILENT) cp .build/linux64_gcc/bin/texturecRelease tools/bin/linux/texturec
  275. $(SILENT) $(MAKE) -C .build/projects/gmake-linux config=release64 -j 6 texturev
  276. $(SILENT) cp .build/linux64_gcc/bin/texturevRelease tools/bin/linux/texturev
  277. dist-darwin: .build/projects/gmake-osx
  278. $(SILENT) $(MAKE) -C .build/projects/gmake-osx config=release64 -j 6 geometryc
  279. $(SILENT) cp .build/osx64_clang/bin/geometrycRelease tools/bin/darwin/geometryc
  280. $(SILENT) $(MAKE) -C .build/projects/gmake-osx config=release64 -j 6 shaderc
  281. $(SILENT) cp .build/osx64_clang/bin/shadercRelease tools/bin/darwin/shaderc
  282. $(SILENT) $(MAKE) -C .build/projects/gmake-osx config=release64 -j 6 texturec
  283. $(SILENT) cp .build/osx64_clang/bin/texturecRelease tools/bin/darwin/texturec
  284. $(SILENT) $(MAKE) -C .build/projects/gmake-osx config=release64 -j 6 texturev
  285. $(SILENT) cp .build/osx64_clang/bin/texturevRelease tools/bin/darwin/texturev
  286. dist: clean dist-windows dist-linux dist-darwin