DISTRHO Plugin Framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

703 lines
19KB

  1. #!/usr/bin/make -f
  2. # Makefile for DPF #
  3. # ---------------- #
  4. # Created by falkTX
  5. #
  6. AR ?= ar
  7. CC ?= gcc
  8. CXX ?= g++
  9. # Before including this file, a few variables can be set in order to tweak build behaviour:
  10. # DEBUG=true
  11. # NOOPT=true
  12. # SKIP_STRIPPING=true
  13. # NVG_DISABLE_SKIPPING_WHITESPACE=true
  14. # NVG_FONT_TEXTURE_FLAGS=0
  15. # FILE_BROWSER_DISABLED=true
  16. # WINDOWS_ICON_ID=0
  17. # USE_GLES2=true
  18. # USE_GLES3=true
  19. # USE_OPENGL3=true
  20. # USE_NANOVG_FBO=true
  21. # USE_NANOVG_FREETYPE=true
  22. # STATIC_BUILD=true
  23. # FORCE_NATIVE_AUDIO_FALLBACK=true
  24. # SKIP_NATIVE_AUDIO_FALLBACK=true
  25. # ---------------------------------------------------------------------------------------------------------------------
  26. # Protect against multiple inclusion
  27. ifneq ($(DPF_MAKEFILE_BASE_INCLUDED),true)
  28. DPF_MAKEFILE_BASE_INCLUDED = true
  29. # ---------------------------------------------------------------------------------------------------------------------
  30. # Auto-detect target compiler if not defined
  31. TARGET_COMPILER = $(shell echo '\#ifdef __clang__\nclang\n\#else\ngcc\n\#endif' | $(CC) -E -P -x c - 2>/dev/null)
  32. ifneq ($(CLANG),true)
  33. ifneq ($(GCC),true)
  34. ifneq (,$(findstring clang,$(TARGET_COMPILER)))
  35. CLANG = true
  36. else
  37. GCC = true
  38. endif
  39. endif
  40. endif
  41. # ---------------------------------------------------------------------------------------------------------------------
  42. # Auto-detect target OS if not defined
  43. TARGET_MACHINE := $(shell $(CC) -dumpmachine)
  44. ifneq ($(BSD),true)
  45. ifneq ($(HAIKU),true)
  46. ifneq ($(HURD),true)
  47. ifneq ($(LINUX),true)
  48. ifneq ($(MACOS),true)
  49. ifneq ($(WASM),true)
  50. ifneq ($(WINDOWS),true)
  51. ifneq (,$(findstring bsd,$(TARGET_MACHINE)))
  52. BSD = true
  53. else ifneq (,$(findstring haiku,$(TARGET_MACHINE)))
  54. HAIKU = true
  55. else ifneq (,$(findstring linux,$(TARGET_MACHINE)))
  56. LINUX = true
  57. else ifneq (,$(findstring gnu,$(TARGET_MACHINE)))
  58. HURD = true
  59. else ifneq (,$(findstring apple,$(TARGET_MACHINE)))
  60. MACOS = true
  61. else ifneq (,$(findstring mingw,$(TARGET_MACHINE)))
  62. WINDOWS = true
  63. else ifneq (,$(findstring msys,$(TARGET_MACHINE)))
  64. WINDOWS = true
  65. else ifneq (,$(findstring wasm,$(TARGET_MACHINE)))
  66. WASM = true
  67. else ifneq (,$(findstring windows,$(TARGET_MACHINE)))
  68. WINDOWS = true
  69. endif
  70. endif # WINDOWS
  71. endif # WASM
  72. endif # MACOS
  73. endif # LINUX
  74. endif # HURD
  75. endif # HAIKU
  76. endif # BSD
  77. # ---------------------------------------------------------------------------------------------------------------------
  78. # Auto-detect target processor
  79. TARGET_PROCESSOR := $(firstword $(subst -, ,$(TARGET_MACHINE)))
  80. ifneq (,$(filter i%86,$(TARGET_PROCESSOR)))
  81. CPU_I386 = true
  82. CPU_I386_OR_X86_64 = true
  83. endif
  84. ifneq (,$(filter wasm32,$(TARGET_PROCESSOR)))
  85. CPU_I386 = true
  86. CPU_I386_OR_X86_64 = true
  87. endif
  88. ifneq (,$(filter x86_64,$(TARGET_PROCESSOR)))
  89. CPU_X86_64 = true
  90. CPU_I386_OR_X86_64 = true
  91. endif
  92. ifneq (,$(filter arm%,$(TARGET_PROCESSOR)))
  93. CPU_ARM = true
  94. CPU_ARM_OR_ARM64 = true
  95. endif
  96. ifneq (,$(filter arm64%,$(TARGET_PROCESSOR)))
  97. CPU_ARM64 = true
  98. CPU_ARM_OR_ARM64 = true
  99. endif
  100. ifneq (,$(filter aarch64%,$(TARGET_PROCESSOR)))
  101. CPU_ARM64 = true
  102. CPU_ARM_OR_ARM64 = true
  103. endif
  104. ifneq (,$(filter riscv64%,$(TARGET_PROCESSOR)))
  105. CPU_RISCV64 = true
  106. endif
  107. ifeq ($(CPU_ARM),true)
  108. ifneq ($(CPU_ARM64),true)
  109. CPU_ARM32 = true
  110. endif
  111. endif
  112. # ---------------------------------------------------------------------------------------------------------------------
  113. # Set PKG_CONFIG (can be overridden by environment variable)
  114. ifeq ($(WASM),true)
  115. # Skip on wasm by default
  116. PKG_CONFIG ?= false
  117. else ifeq ($(WINDOWS),true)
  118. # Build statically on Windows by default
  119. PKG_CONFIG ?= pkg-config --static
  120. else
  121. PKG_CONFIG ?= pkg-config
  122. endif
  123. # ---------------------------------------------------------------------------------------------------------------------
  124. # Set cross compiling flag
  125. ifeq ($(WASM),true)
  126. CROSS_COMPILING = true
  127. endif
  128. # ---------------------------------------------------------------------------------------------------------------------
  129. # Set LINUX_OR_MACOS
  130. ifeq ($(LINUX),true)
  131. LINUX_OR_MACOS = true
  132. endif
  133. ifeq ($(MACOS),true)
  134. LINUX_OR_MACOS = true
  135. endif
  136. # ---------------------------------------------------------------------------------------------------------------------
  137. # Set MACOS_OR_WINDOWS, MACOS_OR_WASM_OR_WINDOWS, HAIKU_OR_MACOS_OR_WINDOWS and HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS
  138. ifeq ($(HAIKU),true)
  139. HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS = true
  140. HAIKU_OR_MACOS_OR_WINDOWS = true
  141. endif
  142. ifeq ($(MACOS),true)
  143. HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS = true
  144. HAIKU_OR_MACOS_OR_WINDOWS = true
  145. MACOS_OR_WASM_OR_WINDOWS = true
  146. MACOS_OR_WINDOWS = true
  147. endif
  148. ifeq ($(WASM),true)
  149. HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS = true
  150. MACOS_OR_WASM_OR_WINDOWS = true
  151. endif
  152. ifeq ($(WINDOWS),true)
  153. HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS = true
  154. HAIKU_OR_MACOS_OR_WINDOWS = true
  155. MACOS_OR_WASM_OR_WINDOWS = true
  156. MACOS_OR_WINDOWS = true
  157. endif
  158. # ---------------------------------------------------------------------------------------------------------------------
  159. # Set UNIX
  160. ifeq ($(BSD),true)
  161. UNIX = true
  162. endif
  163. ifeq ($(HURD),true)
  164. UNIX = true
  165. endif
  166. ifeq ($(LINUX),true)
  167. UNIX = true
  168. endif
  169. ifeq ($(MACOS),true)
  170. UNIX = true
  171. endif
  172. # ---------------------------------------------------------------------------------------------------------------------
  173. # Set build and link flags
  174. BASE_FLAGS = -Wall -Wextra -pipe -MD -MP
  175. BASE_OPTS = -O3 -ffast-math -fdata-sections -ffunction-sections
  176. LINK_OPTS = -fdata-sections -ffunction-sections
  177. ifeq ($(GCC),true)
  178. BASE_FLAGS += -fno-gnu-unique
  179. endif
  180. ifeq ($(SKIP_STRIPPING),true)
  181. BASE_FLAGS += -g
  182. endif
  183. ifeq ($(STATIC_BUILD),true)
  184. BASE_FLAGS += -DSTATIC_BUILD
  185. endif
  186. ifeq ($(WINDOWS),true)
  187. # Assume we want posix
  188. BASE_FLAGS += -posix -D__STDC_FORMAT_MACROS=1 -D__USE_MINGW_ANSI_STDIO=1
  189. # Needed for windows, see https://github.com/falkTX/Carla/issues/855
  190. BASE_FLAGS += -mstackrealign
  191. else
  192. # Not needed for Windows
  193. BASE_FLAGS += -fPIC -DPIC
  194. endif
  195. ifeq ($(WASM),true)
  196. BASE_OPTS += -msse -msse2 -msse3 -msimd128
  197. else ifeq ($(CPU_ARM32),true)
  198. BASE_OPTS += -mfpu=neon-vfpv4 -mfloat-abi=hard
  199. else ifeq ($(CPU_I386_OR_X86_64),true)
  200. BASE_OPTS += -mtune=generic -msse -msse2 -mfpmath=sse
  201. endif
  202. ifeq ($(MACOS),true)
  203. LINK_OPTS += -Wl,-dead_strip,-dead_strip_dylibs
  204. else ifeq ($(WASM),true)
  205. LINK_OPTS += -O3
  206. LINK_OPTS += -Wl,--gc-sections
  207. else
  208. LINK_OPTS += -Wl,-O1,--gc-sections
  209. LINK_OPTS += -Wl,--as-needed
  210. endif
  211. ifneq ($(SKIP_STRIPPING),true)
  212. ifeq ($(MACOS),true)
  213. LINK_OPTS += -Wl,-x
  214. else ifeq ($(WASM),true)
  215. LINK_OPTS += -sAGGRESSIVE_VARIABLE_ELIMINATION=1
  216. else
  217. LINK_OPTS += -Wl,--strip-all
  218. endif
  219. endif
  220. ifeq ($(NOOPT),true)
  221. # Non-CPU-specific optimization flags
  222. BASE_OPTS = -O2 -ffast-math -fdata-sections -ffunction-sections
  223. endif
  224. ifeq ($(DEBUG),true)
  225. BASE_FLAGS += -DDEBUG -O0 -g
  226. LINK_OPTS =
  227. ifeq ($(WASM),true)
  228. LINK_OPTS += -sASSERTIONS=1
  229. endif
  230. else
  231. BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
  232. CXXFLAGS += -fvisibility-inlines-hidden
  233. endif
  234. ifeq ($(WITH_LTO),true)
  235. BASE_FLAGS += -fno-strict-aliasing -flto
  236. LINK_OPTS += -fno-strict-aliasing -flto -Werror=odr -Werror=lto-type-mismatch
  237. endif
  238. BUILD_C_FLAGS = $(BASE_FLAGS) -std=gnu99 $(CFLAGS)
  239. BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=gnu++11 $(CXXFLAGS)
  240. LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
  241. ifeq ($(WASM),true)
  242. # Special flag for emscripten
  243. LINK_FLAGS += -sENVIRONMENT=web -sLLD_REPORT_UNDEFINED
  244. else ifneq ($(MACOS),true)
  245. # Not available on MacOS
  246. LINK_FLAGS += -Wl,--no-undefined
  247. endif
  248. ifeq ($(MACOS_OLD),true)
  249. BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS) -DHAVE_CPP11_SUPPORT=0
  250. endif
  251. ifeq ($(WASM_CLIPBOARD),true)
  252. BUILD_CXX_FLAGS += -DPUGL_WASM_ASYNC_CLIPBOARD
  253. LINK_FLAGS += -sASYNCIFY -sASYNCIFY_IMPORTS=puglGetAsyncClipboardData
  254. endif
  255. ifeq ($(WASM_EXCEPTIONS),true)
  256. BUILD_CXX_FLAGS += -fexceptions
  257. LINK_FLAGS += -fexceptions
  258. endif
  259. ifeq ($(WINDOWS),true)
  260. # Always build statically on windows
  261. LINK_FLAGS += -static -static-libgcc -static-libstdc++
  262. endif
  263. # ---------------------------------------------------------------------------------------------------------------------
  264. # Strict test build
  265. ifeq ($(TESTBUILD),true)
  266. BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wformat -Wformat-security -Wredundant-decls -Wshadow -Wstrict-overflow -fstrict-overflow -Wundef -Wwrite-strings
  267. BASE_FLAGS += -Wpointer-arith -Wabi=98 -Winit-self -Wuninitialized -Wstrict-overflow=5
  268. # BASE_FLAGS += -Wfloat-equal
  269. ifeq ($(CLANG),true)
  270. BASE_FLAGS += -Wdocumentation -Wdocumentation-unknown-command
  271. BASE_FLAGS += -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-exit-time-destructors -Wno-float-equal
  272. else
  273. BASE_FLAGS += -Wcast-align -Wunsafe-loop-optimizations
  274. endif
  275. ifneq ($(MACOS),true)
  276. BASE_FLAGS += -Wmissing-declarations -Wsign-conversion
  277. ifeq ($(GCC),true)
  278. BASE_FLAGS += -Wlogical-op
  279. endif
  280. endif
  281. CFLAGS += -Wold-style-definition -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
  282. CXXFLAGS += -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual
  283. endif
  284. # ---------------------------------------------------------------------------------------------------------------------
  285. # Check for required libraries
  286. HAVE_CAIRO = $(shell $(PKG_CONFIG) --exists cairo && echo true)
  287. ifeq ($(MACOS_OR_WASM_OR_WINDOWS),true)
  288. HAVE_OPENGL = true
  289. else
  290. HAVE_OPENGL = $(shell $(PKG_CONFIG) --exists gl && echo true)
  291. HAVE_DBUS = $(shell $(PKG_CONFIG) --exists dbus-1 && echo true)
  292. HAVE_X11 = $(shell $(PKG_CONFIG) --exists x11 && echo true)
  293. HAVE_XCURSOR = $(shell $(PKG_CONFIG) --exists xcursor && echo true)
  294. HAVE_XEXT = $(shell $(PKG_CONFIG) --exists xext && echo true)
  295. HAVE_XRANDR = $(shell $(PKG_CONFIG) --exists xrandr && echo true)
  296. endif
  297. # Vulkan is not supported yet
  298. # HAVE_VULKAN = $(shell $(PKG_CONFIG) --exists vulkan && echo true)
  299. # ---------------------------------------------------------------------------------------------------------------------
  300. # Check for optional libraries
  301. HAVE_LIBLO = $(shell $(PKG_CONFIG) --exists liblo && echo true)
  302. ifneq ($(SKIP_NATIVE_AUDIO_FALLBACK),true)
  303. ifneq ($(SKIP_RTAUDIO_FALLBACK),true)
  304. ifeq ($(MACOS),true)
  305. HAVE_RTAUDIO = true
  306. else ifeq ($(WINDOWS),true)
  307. HAVE_RTAUDIO = true
  308. else
  309. HAVE_ALSA = $(shell $(PKG_CONFIG) --exists alsa && echo true)
  310. HAVE_PULSEAUDIO = $(shell $(PKG_CONFIG) --exists libpulse-simple && echo true)
  311. HAVE_SDL2 = $(shell $(PKG_CONFIG) --exists sdl2 && echo true)
  312. ifeq ($(HAVE_ALSA),true)
  313. HAVE_RTAUDIO = true
  314. else ifeq ($(HAVE_PULSEAUDIO),true)
  315. HAVE_RTAUDIO = true
  316. endif
  317. endif
  318. endif
  319. endif
  320. # backwards compat, always available/enabled
  321. ifneq ($(FORCE_NATIVE_AUDIO_FALLBACK),true)
  322. ifeq ($(STATIC_BUILD),true)
  323. HAVE_JACK = $(shell $(PKG_CONFIG) --exists jack && echo true)
  324. else
  325. HAVE_JACK = true
  326. endif
  327. endif
  328. # ---------------------------------------------------------------------------------------------------------------------
  329. # Set Generic DGL stuff
  330. ifeq ($(HAIKU),true)
  331. DGL_SYSTEM_LIBS += -lbe
  332. else ifeq ($(MACOS),true)
  333. DGL_SYSTEM_LIBS += -framework Cocoa -framework CoreVideo
  334. else ifeq ($(WASM),true)
  335. else ifeq ($(WINDOWS),true)
  336. DGL_SYSTEM_LIBS += -lgdi32 -lcomdlg32
  337. # -lole32
  338. else
  339. ifeq ($(HAVE_DBUS),true)
  340. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags dbus-1) -DHAVE_DBUS
  341. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs dbus-1)
  342. endif
  343. ifeq ($(HAVE_X11),true)
  344. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags x11) -DHAVE_X11
  345. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs x11)
  346. ifeq ($(HAVE_XCURSOR),true)
  347. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags xcursor) -DHAVE_XCURSOR
  348. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs xcursor)
  349. endif
  350. ifeq ($(HAVE_XEXT),true)
  351. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags xext) -DHAVE_XEXT -DHAVE_XSYNC
  352. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs xext)
  353. endif
  354. ifeq ($(HAVE_XRANDR),true)
  355. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags xrandr) -DHAVE_XRANDR
  356. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs xrandr)
  357. endif
  358. endif
  359. endif
  360. # ---------------------------------------------------------------------------------------------------------------------
  361. # Set Cairo specific stuff
  362. ifeq ($(HAVE_CAIRO),true)
  363. DGL_FLAGS += -DHAVE_CAIRO
  364. CAIRO_FLAGS = $(shell $(PKG_CONFIG) --cflags cairo)
  365. CAIRO_LIBS = $(shell $(PKG_CONFIG) --libs cairo)
  366. HAVE_CAIRO_OR_OPENGL = true
  367. endif
  368. # ---------------------------------------------------------------------------------------------------------------------
  369. # Set OpenGL specific stuff
  370. ifeq ($(HAVE_OPENGL),true)
  371. DGL_FLAGS += -DHAVE_OPENGL
  372. ifeq ($(HAIKU),true)
  373. OPENGL_FLAGS = $(shell $(PKG_CONFIG) --cflags gl)
  374. OPENGL_LIBS = $(shell $(PKG_CONFIG) --libs gl)
  375. else ifeq ($(MACOS),true)
  376. OPENGL_FLAGS = -DGL_SILENCE_DEPRECATION=1 -Wno-deprecated-declarations
  377. OPENGL_LIBS = -framework OpenGL
  378. else ifeq ($(WASM),true)
  379. ifeq ($(USE_GLES2),true)
  380. OPENGL_LIBS = -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2
  381. else
  382. ifneq ($(USE_GLES3),true)
  383. OPENGL_LIBS = -sLEGACY_GL_EMULATION -sGL_UNSAFE_OPTS=0
  384. endif
  385. endif
  386. else ifeq ($(WINDOWS),true)
  387. OPENGL_LIBS = -lopengl32
  388. else
  389. OPENGL_FLAGS = $(shell $(PKG_CONFIG) --cflags gl x11)
  390. OPENGL_LIBS = $(shell $(PKG_CONFIG) --libs gl x11)
  391. endif
  392. HAVE_CAIRO_OR_OPENGL = true
  393. endif
  394. # ---------------------------------------------------------------------------------------------------------------------
  395. # Set Stub specific stuff
  396. ifeq ($(MACOS_OR_WASM_OR_WINDOWS),true)
  397. HAVE_STUB = true
  398. else
  399. HAVE_STUB = $(HAVE_X11)
  400. endif
  401. # ---------------------------------------------------------------------------------------------------------------------
  402. # Set Vulkan specific stuff
  403. ifeq ($(HAVE_VULKAN),true)
  404. DGL_FLAGS += -DHAVE_VULKAN
  405. VULKAN_FLAGS = $(shell $(PKG_CONFIG) --cflags vulkan)
  406. VULKAN_LIBS = $(shell $(PKG_CONFIG) --libs vulkan)
  407. ifneq ($(WINDOWS),true)
  408. VULKAN_LIBS += -ldl
  409. endif
  410. endif
  411. # ---------------------------------------------------------------------------------------------------------------------
  412. # Set optional libraries specific stuff
  413. ifeq ($(HAVE_ALSA),true)
  414. ALSA_FLAGS = $(shell $(PKG_CONFIG) --cflags alsa)
  415. ALSA_LIBS = $(shell $(PKG_CONFIG) --libs alsa)
  416. endif
  417. ifeq ($(HAVE_LIBLO),true)
  418. LIBLO_FLAGS = $(shell $(PKG_CONFIG) --cflags liblo)
  419. LIBLO_LIBS = $(shell $(PKG_CONFIG) --libs liblo)
  420. endif
  421. ifeq ($(HAVE_PULSEAUDIO),true)
  422. PULSEAUDIO_FLAGS = $(shell $(PKG_CONFIG) --cflags libpulse-simple)
  423. PULSEAUDIO_LIBS = $(shell $(PKG_CONFIG) --libs libpulse-simple)
  424. endif
  425. ifeq ($(HAVE_SDL2),true)
  426. SDL2_FLAGS = $(shell $(PKG_CONFIG) --cflags sdl2)
  427. SDL2_LIBS = $(shell $(PKG_CONFIG) --libs sdl2)
  428. endif
  429. ifeq ($(HAVE_JACK),true)
  430. ifeq ($(STATIC_BUILD),true)
  431. JACK_FLAGS = $(shell $(PKG_CONFIG) --cflags jack)
  432. JACK_LIBS = $(shell $(PKG_CONFIG) --libs jack)
  433. endif
  434. endif
  435. ifneq ($(HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS),true)
  436. SHARED_MEMORY_LIBS = -lrt
  437. endif
  438. # ---------------------------------------------------------------------------------------------------------------------
  439. # Backwards-compatible HAVE_DGL
  440. ifeq ($(MACOS_OR_WASM_OR_WINDOWS),true)
  441. HAVE_DGL = true
  442. else ifeq ($(HAVE_OPENGL),true)
  443. HAVE_DGL = $(HAVE_X11)
  444. endif
  445. # ---------------------------------------------------------------------------------------------------------------------
  446. # Namespace flags
  447. ifneq ($(DISTRHO_NAMESPACE),)
  448. BUILD_CXX_FLAGS += -DDISTRHO_NAMESPACE=$(DISTRHO_NAMESPACE)
  449. endif
  450. ifneq ($(DGL_NAMESPACE),)
  451. BUILD_CXX_FLAGS += -DDGL_NAMESPACE=$(DGL_NAMESPACE)
  452. endif
  453. # ---------------------------------------------------------------------------------------------------------------------
  454. # Optional flags
  455. ifeq ($(NVG_DISABLE_SKIPPING_WHITESPACE),true)
  456. BUILD_CXX_FLAGS += -DNVG_DISABLE_SKIPPING_WHITESPACE
  457. endif
  458. ifneq ($(NVG_FONT_TEXTURE_FLAGS),)
  459. BUILD_CXX_FLAGS += -DNVG_FONT_TEXTURE_FLAGS=$(NVG_FONT_TEXTURE_FLAGS)
  460. endif
  461. ifeq ($(FILE_BROWSER_DISABLED),true)
  462. BUILD_CXX_FLAGS += -DDGL_FILE_BROWSER_DISABLED
  463. endif
  464. ifneq ($(WINDOWS_ICON_ID),)
  465. BUILD_CXX_FLAGS += -DDGL_WINDOWS_ICON_ID=$(WINDOWS_ICON_ID)
  466. endif
  467. ifeq ($(USE_GLES2),true)
  468. BUILD_CXX_FLAGS += -DDGL_USE_GLES -DDGL_USE_GLES2
  469. endif
  470. ifeq ($(USE_GLES3),true)
  471. BUILD_CXX_FLAGS += -DDGL_USE_GLES -DDGL_USE_GLES3
  472. endif
  473. ifeq ($(USE_OPENGL3),true)
  474. BUILD_CXX_FLAGS += -DDGL_USE_OPENGL3
  475. endif
  476. ifeq ($(USE_NANOVG_FBO),true)
  477. BUILD_CXX_FLAGS += -DDGL_USE_NANOVG_FBO
  478. endif
  479. ifeq ($(USE_NANOVG_FREETYPE),true)
  480. BUILD_CXX_FLAGS += -DFONS_USE_FREETYPE $(shell $(PKG_CONFIG) --cflags freetype2)
  481. endif
  482. ifeq ($(USE_RGBA),true)
  483. BUILD_CXX_FLAGS += -DDGL_USE_RGBA
  484. endif
  485. # ---------------------------------------------------------------------------------------------------------------------
  486. # Set app extension
  487. ifeq ($(WASM),true)
  488. APP_EXT = .html
  489. else ifeq ($(WINDOWS),true)
  490. APP_EXT = .exe
  491. endif
  492. # ---------------------------------------------------------------------------------------------------------------------
  493. # Set shared lib extension
  494. ifeq ($(MACOS),true)
  495. LIB_EXT = .dylib
  496. else ifeq ($(WASM),true)
  497. LIB_EXT = .wasm
  498. else ifeq ($(WINDOWS),true)
  499. LIB_EXT = .dll
  500. else
  501. LIB_EXT = .so
  502. endif
  503. # ---------------------------------------------------------------------------------------------------------------------
  504. # Set shared library CLI arg
  505. ifeq ($(MACOS),true)
  506. SHARED = -dynamiclib
  507. else ifeq ($(WASM),true)
  508. SHARED = -sSIDE_MODULE=2
  509. else
  510. SHARED = -shared
  511. endif
  512. # ---------------------------------------------------------------------------------------------------------------------
  513. # Handle the verbosity switch
  514. SILENT =
  515. ifeq ($(VERBOSE),1)
  516. else ifeq ($(VERBOSE),y)
  517. else ifeq ($(VERBOSE),yes)
  518. else ifeq ($(VERBOSE),true)
  519. else
  520. SILENT = @
  521. endif
  522. # ---------------------------------------------------------------------------------------------------------------------
  523. # all needs to be first
  524. all:
  525. # ---------------------------------------------------------------------------------------------------------------------
  526. # helper to print what is available/possible to build
  527. print_available = @echo $(1): $(shell echo $($(1)) | grep -q true && echo Yes || echo No)
  528. features:
  529. @echo === Detected Compiler
  530. $(call print_available,CLANG)
  531. $(call print_available,GCC)
  532. @echo === Detected CPU
  533. $(call print_available,CPU_ARM)
  534. $(call print_available,CPU_ARM32)
  535. $(call print_available,CPU_ARM64)
  536. $(call print_available,CPU_ARM_OR_ARM64)
  537. $(call print_available,CPU_I386)
  538. $(call print_available,CPU_I386_OR_X86_64)
  539. $(call print_available,CPU_RISCV64)
  540. @echo === Detected OS
  541. $(call print_available,BSD)
  542. $(call print_available,HAIKU)
  543. $(call print_available,HURD)
  544. $(call print_available,LINUX)
  545. $(call print_available,MACOS)
  546. $(call print_available,WASM)
  547. $(call print_available,WINDOWS)
  548. $(call print_available,HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS)
  549. $(call print_available,HAIKU_OR_MACOS_OR_WINDOWS)
  550. $(call print_available,LINUX_OR_MACOS)
  551. $(call print_available,MACOS_OR_WASM_OR_WINDOWS)
  552. $(call print_available,MACOS_OR_WINDOWS)
  553. $(call print_available,UNIX)
  554. @echo === Detected features
  555. $(call print_available,HAVE_ALSA)
  556. $(call print_available,HAVE_DBUS)
  557. $(call print_available,HAVE_CAIRO)
  558. $(call print_available,HAVE_DGL)
  559. $(call print_available,HAVE_JACK)
  560. $(call print_available,HAVE_LIBLO)
  561. $(call print_available,HAVE_OPENGL)
  562. $(call print_available,HAVE_PULSEAUDIO)
  563. $(call print_available,HAVE_RTAUDIO)
  564. $(call print_available,HAVE_SDL2)
  565. $(call print_available,HAVE_STUB)
  566. $(call print_available,HAVE_VULKAN)
  567. $(call print_available,HAVE_X11)
  568. $(call print_available,HAVE_XCURSOR)
  569. $(call print_available,HAVE_XEXT)
  570. $(call print_available,HAVE_XRANDR)
  571. # ---------------------------------------------------------------------------------------------------------------------
  572. # Protect against multiple inclusion
  573. endif # DPF_MAKEFILE_BASE_INCLUDED
  574. # ---------------------------------------------------------------------------------------------------------------------