makefile 17 KB

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