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.

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