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.

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