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.

766 lines
21KB

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