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.

969 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 ($(WITH_LTO),true)
  272. BASE_FLAGS += -fno-strict-aliasing -flto
  273. LINK_OPTS += -fno-strict-aliasing -flto -Werror=odr
  274. ifeq ($(GCC),true)
  275. LINK_OPTS += -Werror=lto-type-mismatch
  276. endif
  277. endif
  278. BUILD_C_FLAGS = $(BASE_FLAGS) -std=gnu99 $(CFLAGS)
  279. BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=gnu++11 $(CXXFLAGS)
  280. LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
  281. ifeq ($(WASM),true)
  282. # Special flag for emscripten
  283. LINK_FLAGS += -sENVIRONMENT=web -sLLD_REPORT_UNDEFINED
  284. else ifneq ($(MACOS),true)
  285. # Not available on MacOS
  286. LINK_FLAGS += -Wl,--no-undefined
  287. endif
  288. ifeq ($(MACOS_OLD),true)
  289. BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS) -DHAVE_CPP11_SUPPORT=0
  290. endif
  291. ifeq ($(WASM_CLIPBOARD),true)
  292. BUILD_CXX_FLAGS += -DPUGL_WASM_ASYNC_CLIPBOARD
  293. LINK_FLAGS += -sASYNCIFY -sASYNCIFY_IMPORTS=puglGetAsyncClipboardData
  294. endif
  295. ifeq ($(WASM_EXCEPTIONS),true)
  296. BUILD_CXX_FLAGS += -fexceptions
  297. LINK_FLAGS += -fexceptions
  298. endif
  299. ifeq ($(WINDOWS),true)
  300. # Always build statically on windows
  301. LINK_FLAGS += -static -static-libgcc -static-libstdc++
  302. endif
  303. # ---------------------------------------------------------------------------------------------------------------------
  304. # Strict test build
  305. ifeq ($(TESTBUILD),true)
  306. BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wformat -Wformat-security -Wredundant-decls -Wshadow -Wstrict-overflow -fstrict-overflow -Wundef -Wwrite-strings
  307. BASE_FLAGS += -Wpointer-arith -Wabi=98 -Winit-self -Wuninitialized -Wstrict-overflow=5
  308. # BASE_FLAGS += -Wfloat-equal
  309. ifeq ($(CLANG),true)
  310. BASE_FLAGS += -Wdocumentation -Wdocumentation-unknown-command
  311. BASE_FLAGS += -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-exit-time-destructors -Wno-float-equal
  312. else
  313. BASE_FLAGS += -Wcast-align -Wunsafe-loop-optimizations
  314. endif
  315. ifneq ($(MACOS),true)
  316. BASE_FLAGS += -Wmissing-declarations -Wsign-conversion
  317. ifeq ($(GCC),true)
  318. BASE_FLAGS += -Wlogical-op
  319. endif
  320. endif
  321. CFLAGS += -Wold-style-definition -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
  322. CXXFLAGS += -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual
  323. endif
  324. # ---------------------------------------------------------------------------------------------------------------------
  325. # Check for required libraries
  326. ifneq ($(HAIKU)$(WASM),true)
  327. HAVE_CAIRO = $(shell $(PKG_CONFIG) --exists cairo && echo true)
  328. endif
  329. ifeq ($(HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS),true)
  330. HAVE_OPENGL = true
  331. else
  332. HAVE_OPENGL = $(shell $(PKG_CONFIG) --exists gl && echo true)
  333. HAVE_DBUS = $(shell $(PKG_CONFIG) --exists dbus-1 && echo true)
  334. HAVE_X11 = $(shell $(PKG_CONFIG) --exists x11 && echo true)
  335. HAVE_XCURSOR = $(shell $(PKG_CONFIG) --exists xcursor && echo true)
  336. HAVE_XEXT = $(shell $(PKG_CONFIG) --exists xext && echo true)
  337. HAVE_XRANDR = $(shell $(PKG_CONFIG) --exists xrandr && echo true)
  338. endif
  339. # Vulkan is not supported yet
  340. # HAVE_VULKAN = $(shell $(PKG_CONFIG) --exists vulkan && echo true)
  341. # ---------------------------------------------------------------------------------------------------------------------
  342. # Check for optional libraries
  343. HAVE_LIBLO = $(shell $(PKG_CONFIG) --exists liblo && echo true)
  344. ifneq ($(SKIP_NATIVE_AUDIO_FALLBACK),true)
  345. ifneq ($(SKIP_RTAUDIO_FALLBACK),true)
  346. ifeq ($(MACOS),true)
  347. HAVE_RTAUDIO = true
  348. else ifeq ($(WINDOWS),true)
  349. HAVE_RTAUDIO = true
  350. else
  351. HAVE_ALSA = $(shell $(PKG_CONFIG) --exists alsa && echo true)
  352. HAVE_PULSEAUDIO = $(shell $(PKG_CONFIG) --exists libpulse-simple && echo true)
  353. HAVE_SDL2 = $(shell $(PKG_CONFIG) --exists sdl2 && echo true)
  354. ifeq ($(HAVE_ALSA),true)
  355. HAVE_RTAUDIO = true
  356. else ifeq ($(HAVE_PULSEAUDIO),true)
  357. HAVE_RTAUDIO = true
  358. endif
  359. endif
  360. endif
  361. endif
  362. # backwards compat, always available/enabled
  363. ifneq ($(FORCE_NATIVE_AUDIO_FALLBACK),true)
  364. ifeq ($(STATIC_BUILD),true)
  365. HAVE_JACK = $(shell $(PKG_CONFIG) --exists jack && echo true)
  366. else
  367. HAVE_JACK = true
  368. endif
  369. endif
  370. # ---------------------------------------------------------------------------------------------------------------------
  371. # Set Generic DGL stuff
  372. ifeq ($(HAIKU),true)
  373. DGL_SYSTEM_LIBS += -lbe
  374. else ifeq ($(MACOS),true)
  375. DGL_SYSTEM_LIBS += -framework Cocoa
  376. DGL_SYSTEM_LIBS += -framework CoreVideo
  377. ifeq ($(USE_WEB_VIEW),true)
  378. DGL_SYSTEM_LIBS += -framework WebKit
  379. endif
  380. else ifeq ($(WASM),true)
  381. # wasm builds cannot work using regular desktop OpenGL
  382. ifeq (,$(findstring true,$(USE_GLES2)$(USE_GLES3)))
  383. USE_GLES2 = true
  384. endif
  385. else ifeq ($(WINDOWS),true)
  386. DGL_SYSTEM_LIBS += -lcomdlg32
  387. DGL_SYSTEM_LIBS += -ldwmapi
  388. DGL_SYSTEM_LIBS += -lgdi32
  389. # DGL_SYSTEM_LIBS += -lole32
  390. ifeq ($(USE_WEB_VIEW),true)
  391. DGL_SYSTEM_LIBS += -lole32
  392. DGL_SYSTEM_LIBS += -luuid
  393. endif
  394. else
  395. ifeq ($(USE_FILEBROWSER)$(HAVE_DBUS),truetrue)
  396. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags dbus-1) -DHAVE_DBUS
  397. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs dbus-1)
  398. endif
  399. ifeq ($(HAVE_X11),true)
  400. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags x11) -DHAVE_X11
  401. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs x11)
  402. ifeq ($(HAVE_XCURSOR),true)
  403. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags xcursor) -DHAVE_XCURSOR
  404. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs xcursor)
  405. endif
  406. ifeq ($(HAVE_XEXT),true)
  407. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags xext) -DHAVE_XEXT -DHAVE_XSYNC
  408. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs xext)
  409. endif
  410. ifeq ($(HAVE_XRANDR),true)
  411. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags xrandr) -DHAVE_XRANDR
  412. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs xrandr)
  413. endif
  414. ifeq ($(USE_WEB_VIEW),true)
  415. DGL_FLAGS += -pthread
  416. DGL_SYSTEM_LIBS += -pthread -lrt
  417. endif
  418. endif # HAVE_X11
  419. endif
  420. # ---------------------------------------------------------------------------------------------------------------------
  421. # Set Cairo specific stuff
  422. ifeq ($(HAVE_CAIRO),true)
  423. DGL_FLAGS += -DHAVE_CAIRO
  424. CAIRO_FLAGS = $(shell $(PKG_CONFIG) --cflags cairo)
  425. CAIRO_LIBS = $(shell $(PKG_CONFIG) --libs cairo)
  426. HAVE_CAIRO_OR_OPENGL = true
  427. endif # HAVE_CAIRO
  428. # ---------------------------------------------------------------------------------------------------------------------
  429. # Set OpenGL specific stuff
  430. ifeq ($(HAVE_OPENGL),true)
  431. DGL_FLAGS += -DHAVE_OPENGL
  432. ifeq ($(HAIKU),true)
  433. OPENGL_FLAGS =
  434. OPENGL_LIBS = -lGL
  435. else ifeq ($(MACOS),true)
  436. OPENGL_FLAGS = -DGL_SILENCE_DEPRECATION=1 -Wno-deprecated-declarations
  437. OPENGL_LIBS = -framework OpenGL
  438. else ifeq ($(WASM),true)
  439. OPENGL_FLAGS =
  440. ifeq ($(USE_GLES3),true)
  441. OPENGL_LIBS = -sMIN_WEBGL_VERSION=3 -sMAX_WEBGL_VERSION=3
  442. else ifeq ($(USE_GLES2),true)
  443. OPENGL_LIBS = -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2
  444. else
  445. OPENGL_LIBS = -sLEGACY_GL_EMULATION -sGL_UNSAFE_OPTS=0
  446. endif
  447. else ifeq ($(WINDOWS),true)
  448. OPENGL_FLAGS =
  449. OPENGL_LIBS = -lopengl32
  450. else
  451. OPENGL_FLAGS = $(shell $(PKG_CONFIG) --cflags gl x11)
  452. OPENGL_LIBS = $(shell $(PKG_CONFIG) --libs gl x11)
  453. endif
  454. HAVE_CAIRO_OR_OPENGL = true
  455. endif # HAVE_OPENGL
  456. # ---------------------------------------------------------------------------------------------------------------------
  457. # Set Stub specific stuff
  458. ifeq ($(HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS),true)
  459. HAVE_STUB = true
  460. else
  461. HAVE_STUB = $(HAVE_X11)
  462. endif
  463. # ---------------------------------------------------------------------------------------------------------------------
  464. # Set Vulkan specific stuff
  465. ifeq ($(HAVE_VULKAN),true)
  466. DGL_FLAGS += -DHAVE_VULKAN
  467. VULKAN_FLAGS = $(shell $(PKG_CONFIG) --cflags vulkan)
  468. VULKAN_LIBS = $(shell $(PKG_CONFIG) --libs vulkan)
  469. ifneq ($(HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS),true)
  470. VULKAN_LIBS += -ldl
  471. endif
  472. endif
  473. # ---------------------------------------------------------------------------------------------------------------------
  474. # Set optional libraries specific stuff
  475. ifeq ($(HAVE_ALSA),true)
  476. ALSA_FLAGS = $(shell $(PKG_CONFIG) --cflags alsa)
  477. ALSA_LIBS = $(shell $(PKG_CONFIG) --libs alsa)
  478. endif
  479. ifeq ($(HAVE_LIBLO),true)
  480. LIBLO_FLAGS = $(shell $(PKG_CONFIG) --cflags liblo)
  481. LIBLO_LIBS = $(shell $(PKG_CONFIG) --libs liblo)
  482. endif
  483. ifeq ($(HAVE_PULSEAUDIO),true)
  484. PULSEAUDIO_FLAGS = $(shell $(PKG_CONFIG) --cflags libpulse-simple)
  485. PULSEAUDIO_LIBS = $(shell $(PKG_CONFIG) --libs libpulse-simple)
  486. endif
  487. ifeq ($(HAVE_SDL2),true)
  488. SDL2_FLAGS = $(shell $(PKG_CONFIG) --cflags sdl2)
  489. SDL2_LIBS = $(shell $(PKG_CONFIG) --libs sdl2)
  490. endif
  491. ifeq ($(HAVE_JACK),true)
  492. ifeq ($(STATIC_BUILD),true)
  493. JACK_FLAGS = $(shell $(PKG_CONFIG) --cflags jack)
  494. JACK_LIBS = $(shell $(PKG_CONFIG) --libs jack)
  495. endif
  496. endif
  497. ifneq ($(HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS),true)
  498. SHARED_MEMORY_LIBS = -lrt
  499. endif
  500. # ---------------------------------------------------------------------------------------------------------------------
  501. # Generic HAVE_DGL
  502. ifeq ($(HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS),true)
  503. HAVE_DGL = true
  504. else
  505. HAVE_DGL = $(HAVE_X11)
  506. endif
  507. # ---------------------------------------------------------------------------------------------------------------------
  508. # Namespace flags
  509. ifneq ($(DISTRHO_NAMESPACE),)
  510. BUILD_CXX_FLAGS += -DDISTRHO_NAMESPACE=$(DISTRHO_NAMESPACE)
  511. endif
  512. ifneq ($(DGL_NAMESPACE),)
  513. BUILD_CXX_FLAGS += -DDGL_NAMESPACE=$(DGL_NAMESPACE)
  514. endif
  515. # ---------------------------------------------------------------------------------------------------------------------
  516. # Optional flags
  517. ifeq ($(NVG_DISABLE_SKIPPING_WHITESPACE),true)
  518. BUILD_CXX_FLAGS += -DNVG_DISABLE_SKIPPING_WHITESPACE
  519. endif
  520. ifneq ($(NVG_FONT_TEXTURE_FLAGS),)
  521. BUILD_CXX_FLAGS += -DNVG_FONT_TEXTURE_FLAGS=$(NVG_FONT_TEXTURE_FLAGS)
  522. endif
  523. ifneq ($(WINDOWS_ICON_ID),)
  524. BUILD_CXX_FLAGS += -DDGL_WINDOWS_ICON_ID=$(WINDOWS_ICON_ID)
  525. endif
  526. ifneq ($(X11_WINDOW_ICON_NAME),)
  527. BUILD_CXX_FLAGS += -DDGL_X11_WINDOW_ICON_NAME=$(X11_WINDOW_ICON_NAME)
  528. endif
  529. ifneq ($(X11_WINDOW_ICON_SIZE),)
  530. BUILD_CXX_FLAGS += -DDGL_X11_WINDOW_ICON_SIZE=$(X11_WINDOW_ICON_SIZE)
  531. endif
  532. ifeq ($(USE_GLES2),true)
  533. BUILD_CXX_FLAGS += -DDGL_USE_OPENGL3 -DDGL_USE_GLES -DDGL_USE_GLES2
  534. endif
  535. ifeq ($(USE_GLES3),true)
  536. BUILD_CXX_FLAGS += -DDGL_USE_OPENGL3 -DDGL_USE_GLES -DDGL_USE_GLES3
  537. endif
  538. ifeq ($(USE_OPENGL3),true)
  539. BUILD_CXX_FLAGS += -DDGL_USE_OPENGL3
  540. endif
  541. ifeq ($(USE_NANOVG_FBO),true)
  542. BUILD_CXX_FLAGS += -DDGL_USE_NANOVG_FBO
  543. endif
  544. ifeq ($(USE_NANOVG_FREETYPE),true)
  545. BUILD_CXX_FLAGS += -DFONS_USE_FREETYPE $(shell $(PKG_CONFIG) --cflags freetype2)
  546. endif
  547. ifeq ($(USE_RGBA),true)
  548. BUILD_CXX_FLAGS += -DDGL_USE_RGBA
  549. endif
  550. ifeq ($(USE_FILE_BROWSER),true)
  551. BUILD_CXX_FLAGS += -DDGL_USE_FILE_BROWSER
  552. endif
  553. ifeq ($(USE_WEB_VIEW),true)
  554. BUILD_CXX_FLAGS += -DDGL_USE_WEB_VIEW
  555. endif
  556. # ---------------------------------------------------------------------------------------------------------------------
  557. # Set app extension
  558. ifeq ($(WASM),true)
  559. APP_EXT = .html
  560. else ifeq ($(WINDOWS),true)
  561. APP_EXT = .exe
  562. endif
  563. # ---------------------------------------------------------------------------------------------------------------------
  564. # Set shared lib extension
  565. ifeq ($(MACOS),true)
  566. LIB_EXT = .dylib
  567. else ifeq ($(WASM),true)
  568. LIB_EXT = .wasm
  569. else ifeq ($(WINDOWS),true)
  570. LIB_EXT = .dll
  571. else
  572. LIB_EXT = .so
  573. endif
  574. # ---------------------------------------------------------------------------------------------------------------------
  575. # Set shared library CLI arg
  576. ifeq ($(MACOS),true)
  577. SHARED = -dynamiclib
  578. else ifeq ($(WASM),true)
  579. SHARED = -sSIDE_MODULE=2
  580. else
  581. SHARED = -shared
  582. endif
  583. # ---------------------------------------------------------------------------------------------------------------------
  584. # Set CLAP binary directory
  585. ifeq ($(MACOS),true)
  586. CLAP_BINARY_DIR = Contents/MacOS
  587. else
  588. CLAP_BINARY_DIR =
  589. endif
  590. # ---------------------------------------------------------------------------------------------------------------------
  591. # Set VST2 binary directory
  592. ifeq ($(MACOS),true)
  593. VST2_BINARY_DIR = Contents/MacOS
  594. else
  595. VST2_BINARY_DIR =
  596. endif
  597. # ---------------------------------------------------------------------------------------------------------------------
  598. # Set VST3 binary directory, see https://vst3sdk-doc.diatonic.jp/doc/vstinterfaces/vst3loc.html
  599. ifeq ($(LINUX),true)
  600. # This must match `uname -m`, which differs from `gcc -dumpmachine` on PowerPC.
  601. VST3_ARCHITECTURE := $(patsubst powerpc%,ppc%,$(TARGET_PROCESSOR))
  602. VST3_BINARY_DIR = Contents/$(VST3_ARCHITECTURE)-linux
  603. else ifeq ($(MACOS),true)
  604. VST3_BINARY_DIR = Contents/MacOS
  605. else ifeq ($(WASM),true)
  606. VST3_BINARY_DIR = Contents/wasm
  607. else ifeq ($(WINDOWS)$(CPU_I386),truetrue)
  608. VST3_BINARY_DIR = Contents/x86-win
  609. else ifeq ($(WINDOWS)$(CPU_X86_64),truetrue)
  610. VST3_BINARY_DIR = Contents/x86_64-win
  611. else
  612. VST3_BINARY_DIR =
  613. endif
  614. # ---------------------------------------------------------------------------------------------------------------------
  615. # Handle the verbosity switch
  616. SILENT =
  617. ifeq ($(VERBOSE),1)
  618. else ifeq ($(VERBOSE),y)
  619. else ifeq ($(VERBOSE),yes)
  620. else ifeq ($(VERBOSE),true)
  621. else
  622. SILENT = @
  623. endif
  624. # ---------------------------------------------------------------------------------------------------------------------
  625. # all needs to be first
  626. all:
  627. # ---------------------------------------------------------------------------------------------------------------------
  628. # helper to print what is available/possible to build
  629. print_available = @echo $(1): $(shell echo $($(1)) | grep -q true && echo Yes || echo No)
  630. features:
  631. @echo === Detected Compiler
  632. $(call print_available,CLANG)
  633. $(call print_available,GCC)
  634. @echo === Detected CPU
  635. $(call print_available,CPU_ARM)
  636. $(call print_available,CPU_ARM32)
  637. $(call print_available,CPU_ARM64)
  638. $(call print_available,CPU_ARM_OR_ARM64)
  639. $(call print_available,CPU_I386)
  640. $(call print_available,CPU_I386_OR_X86_64)
  641. $(call print_available,CPU_RISCV64)
  642. $(call print_available,CPU_X86_64)
  643. @echo === Detected OS
  644. $(call print_available,BSD)
  645. $(call print_available,HAIKU)
  646. $(call print_available,HURD)
  647. $(call print_available,LINUX)
  648. $(call print_available,MACOS)
  649. $(call print_available,WASM)
  650. $(call print_available,WINDOWS)
  651. $(call print_available,HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS)
  652. $(call print_available,HAIKU_OR_MACOS_OR_WINDOWS)
  653. $(call print_available,LINUX_OR_MACOS)
  654. $(call print_available,MACOS_OR_WASM_OR_WINDOWS)
  655. $(call print_available,MACOS_OR_WINDOWS)
  656. $(call print_available,UNIX)
  657. @echo === Detected features
  658. $(call print_available,HAVE_ALSA)
  659. $(call print_available,HAVE_DBUS)
  660. $(call print_available,HAVE_CAIRO)
  661. $(call print_available,HAVE_DGL)
  662. $(call print_available,HAVE_JACK)
  663. $(call print_available,HAVE_LIBLO)
  664. $(call print_available,HAVE_OPENGL)
  665. $(call print_available,HAVE_PULSEAUDIO)
  666. $(call print_available,HAVE_RTAUDIO)
  667. $(call print_available,HAVE_SDL2)
  668. $(call print_available,HAVE_STUB)
  669. $(call print_available,HAVE_VULKAN)
  670. $(call print_available,HAVE_X11)
  671. $(call print_available,HAVE_XCURSOR)
  672. $(call print_available,HAVE_XEXT)
  673. $(call print_available,HAVE_XRANDR)
  674. # ---------------------------------------------------------------------------------------------------------------------
  675. # Extra rules for MOD Audio stuff
  676. # NOTE: path must be absolute
  677. WORKDIR ?= $(HOME)/mod-workdir
  678. MOD_ENVIRONMENT = \
  679. AR=${1}/host/usr/bin/${2}-gcc-ar \
  680. CC=${1}/host/usr/bin/${2}-gcc \
  681. CPP=${1}/host/usr/bin/${2}-cpp \
  682. CXX=${1}/host/usr/bin/${2}-g++ \
  683. LD=${1}/host/usr/bin/${2}-ld \
  684. PKG_CONFIG=${1}/host/usr/bin/pkg-config \
  685. PKG_CONFIG_PATH="${1}/staging/usr/lib/pkgconfig" \
  686. STRIP=${1}/host/usr/bin/${2}-strip \
  687. CFLAGS="-I${1}/staging/usr/include $(EXTRA_MOD_FLAGS)" \
  688. CPPFLAGS= \
  689. CXXFLAGS="-I${1}/staging/usr/include $(EXTRA_MOD_FLAGS)" \
  690. LDFLAGS="-L${1}/staging/usr/lib $(EXTRA_MOD_FLAGS)" \
  691. EXE_WRAPPER="qemu-${3}-static -L ${1}/target" \
  692. HAVE_CAIRO=false \
  693. HAVE_OPENGL=false \
  694. MOD_BUILD=true \
  695. NOOPT=true
  696. darkglass-anagram:
  697. $(MAKE) $(call MOD_ENVIRONMENT,$(WORKDIR)/darkglass-anagram,aarch64-modaudio.generic-linux-gnu,aarch64)
  698. modduo:
  699. $(MAKE) $(call MOD_ENVIRONMENT,$(WORKDIR)/modduo-static,arm-mod-linux-gnueabihf.static,arm)
  700. modduo-new:
  701. $(MAKE) $(call MOD_ENVIRONMENT,$(WORKDIR)/modduo-new,arm-modaudio-linux-gnueabihf,arm)
  702. modduox:
  703. $(MAKE) $(call MOD_ENVIRONMENT,$(WORKDIR)/modduox-static,aarch64-mod-linux-gnueabi.static,aarch64)
  704. modduox-new:
  705. $(MAKE) $(call MOD_ENVIRONMENT,$(WORKDIR)/modduox-new,aarch64-modaudio-linux-gnueabi,aarch64)
  706. moddwarf:
  707. $(MAKE) $(call MOD_ENVIRONMENT,$(WORKDIR)/moddwarf,aarch64-mod-linux-gnu,aarch64)
  708. moddwarf-new:
  709. $(MAKE) $(call MOD_ENVIRONMENT,$(WORKDIR)/moddwarf-new,aarch64-modaudio-linux-gnu,aarch64)
  710. modpush:
  711. tar -C bin -chz $(subst bin/,,$(wildcard bin/*.lv2)) | base64 | curl -F 'package=@-' http://192.168.51.1/sdk/install && echo
  712. ifneq (,$(findstring darkglass-anagram-,$(MAKECMDGOALS)))
  713. $(MAKECMDGOALS):
  714. $(MAKE) $(call MOD_ENVIRONMENT,$(WORKDIR)/darkglass-anagram,aarch64-modaudio.generic-linux-gnu,aarch64) $(subst darkglass-anagram-,,$(MAKECMDGOALS))
  715. endif
  716. ifneq (,$(findstring modduo-new-,$(MAKECMDGOALS)))
  717. $(MAKECMDGOALS):
  718. $(MAKE) $(call MOD_ENVIRONMENT,$(WORKDIR)/modduo-new,arm-modaudio-linux-gnueabihf,arm) $(subst modduo-new-,,$(MAKECMDGOALS))
  719. else ifneq (,$(findstring modduo-,$(filter-out modduo-new,$(MAKECMDGOALS))))
  720. $(MAKECMDGOALS):
  721. $(MAKE) $(call MOD_ENVIRONMENT,$(WORKDIR)/modduo-static,arm-mod-linux-gnueabihf.static,arm) $(subst modduo-,,$(MAKECMDGOALS))
  722. endif
  723. ifneq (,$(findstring modduox-new-,$(MAKECMDGOALS)))
  724. $(MAKECMDGOALS):
  725. $(MAKE) $(call MOD_ENVIRONMENT,$(WORKDIR)/modduox-new,aarch64-modaudio-linux-gnueabi,aarch64) $(subst modduox-new-,,$(MAKECMDGOALS))
  726. else ifneq (,$(findstring modduox-,$(filter-out modduox-new,$(MAKECMDGOALS))))
  727. $(MAKECMDGOALS):
  728. $(MAKE) $(call MOD_ENVIRONMENT,$(WORKDIR)/modduox-static,aarch64-mod-linux-gnueabi.static,aarch64) $(subst modduox-,,$(MAKECMDGOALS))
  729. endif
  730. ifneq (,$(findstring moddwarf-new-,$(MAKECMDGOALS)))
  731. $(MAKECMDGOALS):
  732. $(MAKE) $(call MOD_ENVIRONMENT,$(WORKDIR)/moddwarf-new,aarch64-modaudio-linux-gnu,aarch64) $(subst moddwarf-new-,,$(MAKECMDGOALS))
  733. else ifneq (,$(findstring moddwarf-,$(filter-out moddwarf-new,$(MAKECMDGOALS))))
  734. $(MAKECMDGOALS):
  735. $(MAKE) $(call MOD_ENVIRONMENT,$(WORKDIR)/moddwarf,aarch64-mod-linux-gnu,aarch64) $(subst moddwarf-,,$(MAKECMDGOALS))
  736. endif
  737. # ---------------------------------------------------------------------------------------------------------------------
  738. # Convenience rules for common builds
  739. macos-intel-10.8:
  740. $(MAKE) \
  741. 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" \
  742. 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++" \
  743. LDFLAGS="$(LDFLAGS) -stdlib=libc++" \
  744. PKG_CONFIG=/usr/bin/false \
  745. PKG_CONFIG_PATH=/NOT
  746. macos-universal-10.8:
  747. $(MAKE) \
  748. 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" \
  749. 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++" \
  750. LDFLAGS="$(LDFLAGS) -stdlib=libc++" \
  751. PKG_CONFIG=/usr/bin/false \
  752. PKG_CONFIG_PATH=/NOT
  753. macos-intel-10.15:
  754. $(MAKE) \
  755. 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" \
  756. 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" \
  757. PKG_CONFIG=/usr/bin/false \
  758. PKG_CONFIG_PATH=/NOT
  759. macos-universal-10.15:
  760. $(MAKE) \
  761. 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" \
  762. 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" \
  763. PKG_CONFIG=/usr/bin/false \
  764. PKG_CONFIG_PATH=/NOT
  765. mingw32:
  766. $(MAKE) \
  767. AR=i686-w64-mingw32-ar \
  768. CC=i686-w64-mingw32-gcc \
  769. CXX=i686-w64-mingw32-g++ \
  770. EXE_WRAPPER=wine \
  771. PKG_CONFIG=/usr/bin/false \
  772. PKG_CONFIG_PATH=/NOT
  773. mingw64:
  774. $(MAKE) \
  775. AR=x86_64-w64-mingw32-ar \
  776. CC=x86_64-w64-mingw32-gcc \
  777. CXX=x86_64-w64-mingw32-g++ \
  778. EXE_WRAPPER=wine \
  779. PKG_CONFIG=/usr/bin/false \
  780. PKG_CONFIG_PATH=/NOT
  781. # ---------------------------------------------------------------------------------------------------------------------
  782. # Protect against multiple inclusion
  783. endif # DPF_MAKEFILE_BASE_INCLUDED
  784. # ---------------------------------------------------------------------------------------------------------------------