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.

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