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.

820 lines
23KB

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