makefile 15 KB

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