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.

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