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.

754 lines
21KB

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