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.

977 lines
29KB

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