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.

919 lines
27KB

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