makefile 15 KB

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