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