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.

965 lines
28KB

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