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.

818 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. 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
  345. DGL_SYSTEM_LIBS += -framework CoreVideo
  346. else ifeq ($(WASM),true)
  347. # wasm builds cannot work using regular desktop OpenGL
  348. ifeq (,$(USE_GLES2)$(USE_GLES3))
  349. USE_GLES2 = true
  350. endif
  351. else ifeq ($(WINDOWS),true)
  352. DGL_SYSTEM_LIBS += -lcomdlg32
  353. DGL_SYSTEM_LIBS += -lgdi32
  354. # DGL_SYSTEM_LIBS += -lole32
  355. else
  356. ifeq ($(HAVE_DBUS),true)
  357. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags dbus-1) -DHAVE_DBUS
  358. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs dbus-1)
  359. endif
  360. ifeq ($(HAVE_X11),true)
  361. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags x11) -DHAVE_X11
  362. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs x11)
  363. ifeq ($(HAVE_XCURSOR),true)
  364. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags xcursor) -DHAVE_XCURSOR
  365. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs xcursor)
  366. endif
  367. ifeq ($(HAVE_XEXT),true)
  368. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags xext) -DHAVE_XEXT -DHAVE_XSYNC
  369. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs xext)
  370. endif
  371. ifeq ($(HAVE_XRANDR),true)
  372. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags xrandr) -DHAVE_XRANDR
  373. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs xrandr)
  374. endif
  375. endif # HAVE_X11
  376. endif
  377. # ---------------------------------------------------------------------------------------------------------------------
  378. # Set Cairo specific stuff
  379. ifeq ($(HAVE_CAIRO),true)
  380. DGL_FLAGS += -DHAVE_CAIRO
  381. CAIRO_FLAGS = $(shell $(PKG_CONFIG) --cflags cairo)
  382. CAIRO_LIBS = $(shell $(PKG_CONFIG) --libs cairo)
  383. HAVE_CAIRO_OR_OPENGL = true
  384. endif # HAVE_CAIRO
  385. # ---------------------------------------------------------------------------------------------------------------------
  386. # Set OpenGL specific stuff
  387. ifeq ($(HAVE_OPENGL),true)
  388. DGL_FLAGS += -DHAVE_OPENGL
  389. ifeq ($(HAIKU),true)
  390. OPENGL_FLAGS =
  391. OPENGL_LIBS = -lGL
  392. else ifeq ($(MACOS),true)
  393. OPENGL_FLAGS = -DGL_SILENCE_DEPRECATION=1 -Wno-deprecated-declarations
  394. OPENGL_LIBS = -framework OpenGL
  395. else ifeq ($(WASM),true)
  396. ifeq ($(USE_GLES2),true)
  397. OPENGL_LIBS = -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2
  398. else
  399. ifneq ($(USE_GLES3),true)
  400. OPENGL_LIBS = -sLEGACY_GL_EMULATION -sGL_UNSAFE_OPTS=0
  401. endif
  402. endif
  403. else ifeq ($(WINDOWS),true)
  404. OPENGL_LIBS = -lopengl32
  405. else
  406. OPENGL_FLAGS = $(shell $(PKG_CONFIG) --cflags gl x11)
  407. OPENGL_LIBS = $(shell $(PKG_CONFIG) --libs gl x11)
  408. endif
  409. HAVE_CAIRO_OR_OPENGL = true
  410. endif # HAVE_OPENGL
  411. # ---------------------------------------------------------------------------------------------------------------------
  412. # Set Stub specific stuff
  413. ifeq ($(HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS),true)
  414. HAVE_STUB = true
  415. else
  416. HAVE_STUB = $(HAVE_X11)
  417. endif
  418. # ---------------------------------------------------------------------------------------------------------------------
  419. # Set Vulkan specific stuff
  420. ifeq ($(HAVE_VULKAN),true)
  421. DGL_FLAGS += -DHAVE_VULKAN
  422. VULKAN_FLAGS = $(shell $(PKG_CONFIG) --cflags vulkan)
  423. VULKAN_LIBS = $(shell $(PKG_CONFIG) --libs vulkan)
  424. ifneq ($(WINDOWS),true)
  425. VULKAN_LIBS += -ldl
  426. endif
  427. endif
  428. # ---------------------------------------------------------------------------------------------------------------------
  429. # Set optional libraries specific stuff
  430. ifeq ($(HAVE_ALSA),true)
  431. ALSA_FLAGS = $(shell $(PKG_CONFIG) --cflags alsa)
  432. ALSA_LIBS = $(shell $(PKG_CONFIG) --libs alsa)
  433. endif
  434. ifeq ($(HAVE_LIBLO),true)
  435. LIBLO_FLAGS = $(shell $(PKG_CONFIG) --cflags liblo)
  436. LIBLO_LIBS = $(shell $(PKG_CONFIG) --libs liblo)
  437. endif
  438. ifeq ($(HAVE_PULSEAUDIO),true)
  439. PULSEAUDIO_FLAGS = $(shell $(PKG_CONFIG) --cflags libpulse-simple)
  440. PULSEAUDIO_LIBS = $(shell $(PKG_CONFIG) --libs libpulse-simple)
  441. endif
  442. ifeq ($(HAVE_SDL2),true)
  443. SDL2_FLAGS = $(shell $(PKG_CONFIG) --cflags sdl2)
  444. SDL2_LIBS = $(shell $(PKG_CONFIG) --libs sdl2)
  445. endif
  446. ifeq ($(HAVE_JACK),true)
  447. ifeq ($(STATIC_BUILD),true)
  448. JACK_FLAGS = $(shell $(PKG_CONFIG) --cflags jack)
  449. JACK_LIBS = $(shell $(PKG_CONFIG) --libs jack)
  450. endif
  451. endif
  452. ifneq ($(HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS),true)
  453. SHARED_MEMORY_LIBS = -lrt
  454. endif
  455. # ---------------------------------------------------------------------------------------------------------------------
  456. # Backwards-compatible HAVE_DGL
  457. ifeq ($(HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS),true)
  458. HAVE_DGL = true
  459. else ifeq ($(HAVE_OPENGL),true)
  460. HAVE_DGL = $(HAVE_X11)
  461. endif
  462. # ---------------------------------------------------------------------------------------------------------------------
  463. # Namespace flags
  464. ifneq ($(DISTRHO_NAMESPACE),)
  465. BUILD_CXX_FLAGS += -DDISTRHO_NAMESPACE=$(DISTRHO_NAMESPACE)
  466. endif
  467. ifneq ($(DGL_NAMESPACE),)
  468. BUILD_CXX_FLAGS += -DDGL_NAMESPACE=$(DGL_NAMESPACE)
  469. endif
  470. # ---------------------------------------------------------------------------------------------------------------------
  471. # Optional flags
  472. ifeq ($(NVG_DISABLE_SKIPPING_WHITESPACE),true)
  473. BUILD_CXX_FLAGS += -DNVG_DISABLE_SKIPPING_WHITESPACE
  474. endif
  475. ifneq ($(NVG_FONT_TEXTURE_FLAGS),)
  476. BUILD_CXX_FLAGS += -DNVG_FONT_TEXTURE_FLAGS=$(NVG_FONT_TEXTURE_FLAGS)
  477. endif
  478. ifeq ($(FILE_BROWSER_DISABLED),true)
  479. BUILD_CXX_FLAGS += -DDGL_FILE_BROWSER_DISABLED
  480. endif
  481. ifneq ($(WINDOWS_ICON_ID),)
  482. BUILD_CXX_FLAGS += -DDGL_WINDOWS_ICON_ID=$(WINDOWS_ICON_ID)
  483. endif
  484. ifeq ($(USE_GLES2),true)
  485. BUILD_CXX_FLAGS += -DDGL_USE_OPENGL3 -DDGL_USE_GLES -DDGL_USE_GLES2
  486. endif
  487. ifeq ($(USE_GLES3),true)
  488. BUILD_CXX_FLAGS += -DDGL_USE_OPENGL3 -DDGL_USE_GLES -DDGL_USE_GLES3
  489. endif
  490. ifeq ($(USE_OPENGL3),true)
  491. BUILD_CXX_FLAGS += -DDGL_USE_OPENGL3
  492. endif
  493. ifeq ($(USE_NANOVG_FBO),true)
  494. BUILD_CXX_FLAGS += -DDGL_USE_NANOVG_FBO
  495. endif
  496. ifeq ($(USE_NANOVG_FREETYPE),true)
  497. BUILD_CXX_FLAGS += -DFONS_USE_FREETYPE $(shell $(PKG_CONFIG) --cflags freetype2)
  498. endif
  499. ifeq ($(USE_RGBA),true)
  500. BUILD_CXX_FLAGS += -DDGL_USE_RGBA
  501. endif
  502. # ---------------------------------------------------------------------------------------------------------------------
  503. # Set app extension
  504. ifeq ($(WASM),true)
  505. APP_EXT = .html
  506. else ifeq ($(WINDOWS),true)
  507. APP_EXT = .exe
  508. endif
  509. # ---------------------------------------------------------------------------------------------------------------------
  510. # Set shared lib extension
  511. ifeq ($(MACOS),true)
  512. LIB_EXT = .dylib
  513. else ifeq ($(WASM),true)
  514. LIB_EXT = .wasm
  515. else ifeq ($(WINDOWS),true)
  516. LIB_EXT = .dll
  517. else
  518. LIB_EXT = .so
  519. endif
  520. # ---------------------------------------------------------------------------------------------------------------------
  521. # Set shared library CLI arg
  522. ifeq ($(MACOS),true)
  523. SHARED = -dynamiclib
  524. else ifeq ($(WASM),true)
  525. SHARED = -sSIDE_MODULE=2
  526. else
  527. SHARED = -shared
  528. endif
  529. # ---------------------------------------------------------------------------------------------------------------------
  530. # Set CLAP binary directory
  531. ifeq ($(MACOS),true)
  532. CLAP_BINARY_DIR = Contents/MacOS
  533. else
  534. CLAP_BINARY_DIR =
  535. endif
  536. # ---------------------------------------------------------------------------------------------------------------------
  537. # Set VST2 binary directory
  538. ifeq ($(MACOS),true)
  539. VST2_BINARY_DIR = Contents/MacOS
  540. else
  541. VST2_BINARY_DIR =
  542. endif
  543. # ---------------------------------------------------------------------------------------------------------------------
  544. # Set VST3 binary directory, see https://vst3sdk-doc.diatonic.jp/doc/vstinterfaces/vst3loc.html
  545. ifeq ($(LINUX),true)
  546. VST3_BINARY_DIR = Contents/$(TARGET_PROCESSOR)-linux
  547. else ifeq ($(MACOS),true)
  548. VST3_BINARY_DIR = Contents/MacOS
  549. else ifeq ($(WASM),true)
  550. VST3_BINARY_DIR = Contents/wasm
  551. else ifeq ($(WINDOWS)$(CPU_I386),truetrue)
  552. VST3_BINARY_DIR = Contents/x86-win
  553. else ifeq ($(WINDOWS)$(CPU_X86_64),truetrue)
  554. VST3_BINARY_DIR = Contents/x86_64-win
  555. else
  556. VST3_BINARY_DIR =
  557. endif
  558. # ---------------------------------------------------------------------------------------------------------------------
  559. # Handle the verbosity switch
  560. SILENT =
  561. ifeq ($(VERBOSE),1)
  562. else ifeq ($(VERBOSE),y)
  563. else ifeq ($(VERBOSE),yes)
  564. else ifeq ($(VERBOSE),true)
  565. else
  566. SILENT = @
  567. endif
  568. # ---------------------------------------------------------------------------------------------------------------------
  569. # all needs to be first
  570. all:
  571. # ---------------------------------------------------------------------------------------------------------------------
  572. # helper to print what is available/possible to build
  573. print_available = @echo $(1): $(shell echo $($(1)) | grep -q true && echo Yes || echo No)
  574. features:
  575. @echo === Detected Compiler
  576. $(call print_available,CLANG)
  577. $(call print_available,GCC)
  578. @echo === Detected CPU
  579. $(call print_available,CPU_ARM)
  580. $(call print_available,CPU_ARM32)
  581. $(call print_available,CPU_ARM64)
  582. $(call print_available,CPU_ARM_OR_ARM64)
  583. $(call print_available,CPU_I386)
  584. $(call print_available,CPU_I386_OR_X86_64)
  585. $(call print_available,CPU_RISCV64)
  586. $(call print_available,CPU_X86_64)
  587. @echo === Detected OS
  588. $(call print_available,BSD)
  589. $(call print_available,HAIKU)
  590. $(call print_available,HURD)
  591. $(call print_available,LINUX)
  592. $(call print_available,MACOS)
  593. $(call print_available,WASM)
  594. $(call print_available,WINDOWS)
  595. $(call print_available,HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS)
  596. $(call print_available,HAIKU_OR_MACOS_OR_WINDOWS)
  597. $(call print_available,LINUX_OR_MACOS)
  598. $(call print_available,MACOS_OR_WASM_OR_WINDOWS)
  599. $(call print_available,MACOS_OR_WINDOWS)
  600. $(call print_available,UNIX)
  601. @echo === Detected features
  602. $(call print_available,HAVE_ALSA)
  603. $(call print_available,HAVE_DBUS)
  604. $(call print_available,HAVE_CAIRO)
  605. $(call print_available,HAVE_DGL)
  606. $(call print_available,HAVE_JACK)
  607. $(call print_available,HAVE_LIBLO)
  608. $(call print_available,HAVE_OPENGL)
  609. $(call print_available,HAVE_PULSEAUDIO)
  610. $(call print_available,HAVE_RTAUDIO)
  611. $(call print_available,HAVE_SDL2)
  612. $(call print_available,HAVE_STUB)
  613. $(call print_available,HAVE_VULKAN)
  614. $(call print_available,HAVE_X11)
  615. $(call print_available,HAVE_XCURSOR)
  616. $(call print_available,HAVE_XEXT)
  617. $(call print_available,HAVE_XRANDR)
  618. # ---------------------------------------------------------------------------------------------------------------------
  619. # Extra rules for MOD Audio stuff
  620. # NOTE: note path must be absolute
  621. MOD_WORKDIR ?= $(HOME)/mod-workdir
  622. MOD_ENVIRONMENT = \
  623. AR=${1}/host/usr/bin/${2}-gcc-ar \
  624. CC=${1}/host/usr/bin/${2}-gcc \
  625. CPP=${1}/host/usr/bin/${2}-cpp \
  626. CXX=${1}/host/usr/bin/${2}-g++ \
  627. LD=${1}/host/usr/bin/${2}-ld \
  628. PKG_CONFIG=${1}/host/usr/bin/pkg-config \
  629. PKG_CONFIG_PATH="${1}/staging/usr/lib/pkgconfig" \
  630. STRIP=${1}/host/usr/bin/${2}-strip \
  631. CFLAGS="-I${1}/staging/usr/include $(EXTRA_MOD_FLAGS)" \
  632. CPPFLAGS= \
  633. CXXFLAGS="-I${1}/staging/usr/include $(EXTRA_MOD_FLAGS)" \
  634. LDFLAGS="-L${1}/staging/usr/lib $(EXTRA_MOD_FLAGS)" \
  635. EXE_WRAPPER="qemu-${3}-static -L ${1}/target" \
  636. HAVE_CAIRO=false \
  637. HAVE_OPENGL=false \
  638. MOD_BUILD=true \
  639. NOOPT=true
  640. modduo:
  641. $(MAKE) $(call MOD_ENVIRONMENT,$(MOD_WORKDIR)/modduo-static,arm-mod-linux-gnueabihf.static,arm)
  642. modduox:
  643. $(MAKE) $(call MOD_ENVIRONMENT,$(MOD_WORKDIR)/modduox-static,aarch64-mod-linux-gnueabi.static,aarch64)
  644. moddwarf:
  645. $(MAKE) $(call MOD_ENVIRONMENT,$(MOD_WORKDIR)/moddwarf,aarch64-mod-linux-gnu,aarch64)
  646. modpush:
  647. tar -C bin -cz $(subst bin/,,$(wildcard bin/*.lv2)) | base64 | curl -F 'package=@-' http://192.168.51.1/sdk/install && echo
  648. ifneq (,$(findstring modduo-,$(MAKECMDGOALS)))
  649. $(MAKECMDGOALS):
  650. $(MAKE) $(call MOD_ENVIRONMENT,$(MOD_WORKDIR)/modduo-static,arm-mod-linux-gnueabihf.static,arm) $(subst modduo-,,$(MAKECMDGOALS))
  651. endif
  652. ifneq (,$(findstring modduox-,$(MAKECMDGOALS)))
  653. $(MAKECMDGOALS):
  654. $(MAKE) $(call MOD_ENVIRONMENT,$(MOD_WORKDIR)/modduox-static,aarch64-mod-linux-gnueabi.static,aarch64) $(subst modduox-,,$(MAKECMDGOALS))
  655. endif
  656. ifneq (,$(findstring moddwarf-,$(MAKECMDGOALS)))
  657. $(MAKECMDGOALS):
  658. $(MAKE) $(call MOD_ENVIRONMENT,$(MOD_WORKDIR)/moddwarf,aarch64-mod-linux-gnu,aarch64) $(subst moddwarf-,,$(MAKECMDGOALS))
  659. endif
  660. # ---------------------------------------------------------------------------------------------------------------------
  661. # Protect against multiple inclusion
  662. endif # DPF_MAKEFILE_BASE_INCLUDED
  663. # ---------------------------------------------------------------------------------------------------------------------