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.

760 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 -fsanitize=address
  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
  240. ifeq ($(GCC),true)
  241. LINK_OPTS += -Werror=lto-type-mismatch
  242. endif
  243. endif
  244. BUILD_C_FLAGS = $(BASE_FLAGS) -std=gnu99 $(CFLAGS)
  245. BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=gnu++11 $(CXXFLAGS)
  246. LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
  247. ifeq ($(WASM),true)
  248. # Special flag for emscripten
  249. LINK_FLAGS += -sENVIRONMENT=web -sLLD_REPORT_UNDEFINED
  250. else ifneq ($(MACOS),true)
  251. # Not available on MacOS
  252. LINK_FLAGS += -Wl,--no-undefined
  253. endif
  254. ifeq ($(MACOS_OLD),true)
  255. BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS) -DHAVE_CPP11_SUPPORT=0
  256. endif
  257. ifeq ($(WASM_CLIPBOARD),true)
  258. BUILD_CXX_FLAGS += -DPUGL_WASM_ASYNC_CLIPBOARD
  259. LINK_FLAGS += -sASYNCIFY -sASYNCIFY_IMPORTS=puglGetAsyncClipboardData
  260. endif
  261. ifeq ($(WASM_EXCEPTIONS),true)
  262. BUILD_CXX_FLAGS += -fexceptions
  263. LINK_FLAGS += -fexceptions
  264. endif
  265. ifeq ($(WINDOWS),true)
  266. # Always build statically on windows
  267. LINK_FLAGS += -static -static-libgcc -static-libstdc++
  268. endif
  269. # ---------------------------------------------------------------------------------------------------------------------
  270. # Strict test build
  271. ifeq ($(TESTBUILD),true)
  272. BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wformat -Wformat-security -Wredundant-decls -Wshadow -Wstrict-overflow -fstrict-overflow -Wundef -Wwrite-strings
  273. BASE_FLAGS += -Wpointer-arith -Wabi=98 -Winit-self -Wuninitialized -Wstrict-overflow=5
  274. # BASE_FLAGS += -Wfloat-equal
  275. ifeq ($(CLANG),true)
  276. BASE_FLAGS += -Wdocumentation -Wdocumentation-unknown-command
  277. BASE_FLAGS += -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-exit-time-destructors -Wno-float-equal
  278. else
  279. BASE_FLAGS += -Wcast-align -Wunsafe-loop-optimizations
  280. endif
  281. ifneq ($(MACOS),true)
  282. BASE_FLAGS += -Wmissing-declarations -Wsign-conversion
  283. ifeq ($(GCC),true)
  284. BASE_FLAGS += -Wlogical-op
  285. endif
  286. endif
  287. CFLAGS += -Wold-style-definition -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
  288. CXXFLAGS += -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual
  289. endif
  290. # ---------------------------------------------------------------------------------------------------------------------
  291. # Check for required libraries
  292. HAVE_CAIRO = $(shell $(PKG_CONFIG) --exists cairo && echo true)
  293. ifeq ($(MACOS_OR_WASM_OR_WINDOWS),true)
  294. HAVE_OPENGL = true
  295. else
  296. HAVE_OPENGL = $(shell $(PKG_CONFIG) --exists gl && echo true)
  297. HAVE_DBUS = $(shell $(PKG_CONFIG) --exists dbus-1 && echo true)
  298. HAVE_X11 = $(shell $(PKG_CONFIG) --exists x11 && echo true)
  299. HAVE_XCURSOR = $(shell $(PKG_CONFIG) --exists xcursor && echo true)
  300. HAVE_XEXT = $(shell $(PKG_CONFIG) --exists xext && echo true)
  301. HAVE_XRANDR = $(shell $(PKG_CONFIG) --exists xrandr && echo true)
  302. endif
  303. # Vulkan is not supported yet
  304. # HAVE_VULKAN = $(shell $(PKG_CONFIG) --exists vulkan && echo true)
  305. # ---------------------------------------------------------------------------------------------------------------------
  306. # Check for optional libraries
  307. HAVE_LIBLO = $(shell $(PKG_CONFIG) --exists liblo && echo true)
  308. ifneq ($(SKIP_NATIVE_AUDIO_FALLBACK),true)
  309. ifneq ($(SKIP_RTAUDIO_FALLBACK),true)
  310. ifeq ($(MACOS),true)
  311. HAVE_RTAUDIO = true
  312. else ifeq ($(WINDOWS),true)
  313. HAVE_RTAUDIO = true
  314. else
  315. HAVE_ALSA = $(shell $(PKG_CONFIG) --exists alsa && echo true)
  316. HAVE_PULSEAUDIO = $(shell $(PKG_CONFIG) --exists libpulse-simple && echo true)
  317. HAVE_SDL2 = $(shell $(PKG_CONFIG) --exists sdl2 && echo true)
  318. ifeq ($(HAVE_ALSA),true)
  319. HAVE_RTAUDIO = true
  320. else ifeq ($(HAVE_PULSEAUDIO),true)
  321. HAVE_RTAUDIO = true
  322. endif
  323. endif
  324. endif
  325. endif
  326. # backwards compat, always available/enabled
  327. ifneq ($(FORCE_NATIVE_AUDIO_FALLBACK),true)
  328. ifeq ($(STATIC_BUILD),true)
  329. HAVE_JACK = $(shell $(PKG_CONFIG) --exists jack && echo true)
  330. else
  331. HAVE_JACK = true
  332. endif
  333. endif
  334. # ---------------------------------------------------------------------------------------------------------------------
  335. # Set Generic DGL stuff
  336. ifeq ($(HAIKU),true)
  337. DGL_SYSTEM_LIBS += -lbe
  338. else ifeq ($(MACOS),true)
  339. DGL_SYSTEM_LIBS += -framework Cocoa -framework CoreVideo
  340. else ifeq ($(WASM),true)
  341. else ifeq ($(WINDOWS),true)
  342. DGL_SYSTEM_LIBS += -lgdi32 -lcomdlg32
  343. # -lole32
  344. else
  345. ifeq ($(HAVE_DBUS),true)
  346. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags dbus-1) -DHAVE_DBUS
  347. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs dbus-1)
  348. endif
  349. ifeq ($(HAVE_X11),true)
  350. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags x11) -DHAVE_X11
  351. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs x11)
  352. ifeq ($(HAVE_XCURSOR),true)
  353. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags xcursor) -DHAVE_XCURSOR
  354. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs xcursor)
  355. endif
  356. ifeq ($(HAVE_XEXT),true)
  357. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags xext) -DHAVE_XEXT -DHAVE_XSYNC
  358. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs xext)
  359. endif
  360. ifeq ($(HAVE_XRANDR),true)
  361. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags xrandr) -DHAVE_XRANDR
  362. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs xrandr)
  363. endif
  364. endif
  365. endif
  366. # ---------------------------------------------------------------------------------------------------------------------
  367. # Set Cairo specific stuff
  368. ifeq ($(HAVE_CAIRO),true)
  369. DGL_FLAGS += -DHAVE_CAIRO
  370. CAIRO_FLAGS = $(shell $(PKG_CONFIG) --cflags cairo)
  371. CAIRO_LIBS = $(shell $(PKG_CONFIG) --libs cairo)
  372. HAVE_CAIRO_OR_OPENGL = true
  373. endif
  374. # ---------------------------------------------------------------------------------------------------------------------
  375. # Set OpenGL specific stuff
  376. ifeq ($(HAVE_OPENGL),true)
  377. DGL_FLAGS += -DHAVE_OPENGL
  378. ifeq ($(HAIKU),true)
  379. OPENGL_FLAGS = $(shell $(PKG_CONFIG) --cflags gl)
  380. OPENGL_LIBS = $(shell $(PKG_CONFIG) --libs gl)
  381. else ifeq ($(MACOS),true)
  382. OPENGL_FLAGS = -DGL_SILENCE_DEPRECATION=1 -Wno-deprecated-declarations
  383. OPENGL_LIBS = -framework OpenGL
  384. else ifeq ($(WASM),true)
  385. ifeq ($(USE_GLES2),true)
  386. OPENGL_LIBS = -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2
  387. else
  388. ifneq ($(USE_GLES3),true)
  389. OPENGL_LIBS = -sLEGACY_GL_EMULATION -sGL_UNSAFE_OPTS=0
  390. endif
  391. endif
  392. else ifeq ($(WINDOWS),true)
  393. OPENGL_LIBS = -lopengl32
  394. else
  395. OPENGL_FLAGS = $(shell $(PKG_CONFIG) --cflags gl x11)
  396. OPENGL_LIBS = $(shell $(PKG_CONFIG) --libs gl x11)
  397. endif
  398. HAVE_CAIRO_OR_OPENGL = true
  399. endif
  400. # ---------------------------------------------------------------------------------------------------------------------
  401. # Set Stub specific stuff
  402. ifeq ($(MACOS_OR_WASM_OR_WINDOWS),true)
  403. HAVE_STUB = true
  404. else
  405. HAVE_STUB = $(HAVE_X11)
  406. endif
  407. # ---------------------------------------------------------------------------------------------------------------------
  408. # Set Vulkan specific stuff
  409. ifeq ($(HAVE_VULKAN),true)
  410. DGL_FLAGS += -DHAVE_VULKAN
  411. VULKAN_FLAGS = $(shell $(PKG_CONFIG) --cflags vulkan)
  412. VULKAN_LIBS = $(shell $(PKG_CONFIG) --libs vulkan)
  413. ifneq ($(WINDOWS),true)
  414. VULKAN_LIBS += -ldl
  415. endif
  416. endif
  417. # ---------------------------------------------------------------------------------------------------------------------
  418. # Set optional libraries specific stuff
  419. ifeq ($(HAVE_ALSA),true)
  420. ALSA_FLAGS = $(shell $(PKG_CONFIG) --cflags alsa)
  421. ALSA_LIBS = $(shell $(PKG_CONFIG) --libs alsa)
  422. endif
  423. ifeq ($(HAVE_LIBLO),true)
  424. LIBLO_FLAGS = $(shell $(PKG_CONFIG) --cflags liblo)
  425. LIBLO_LIBS = $(shell $(PKG_CONFIG) --libs liblo)
  426. endif
  427. ifeq ($(HAVE_PULSEAUDIO),true)
  428. PULSEAUDIO_FLAGS = $(shell $(PKG_CONFIG) --cflags libpulse-simple)
  429. PULSEAUDIO_LIBS = $(shell $(PKG_CONFIG) --libs libpulse-simple)
  430. endif
  431. ifeq ($(HAVE_SDL2),true)
  432. SDL2_FLAGS = $(shell $(PKG_CONFIG) --cflags sdl2)
  433. SDL2_LIBS = $(shell $(PKG_CONFIG) --libs sdl2)
  434. endif
  435. ifeq ($(HAVE_JACK),true)
  436. ifeq ($(STATIC_BUILD),true)
  437. JACK_FLAGS = $(shell $(PKG_CONFIG) --cflags jack)
  438. JACK_LIBS = $(shell $(PKG_CONFIG) --libs jack)
  439. endif
  440. endif
  441. ifneq ($(HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS),true)
  442. SHARED_MEMORY_LIBS = -lrt
  443. endif
  444. # ---------------------------------------------------------------------------------------------------------------------
  445. # Backwards-compatible HAVE_DGL
  446. ifeq ($(MACOS_OR_WASM_OR_WINDOWS),true)
  447. HAVE_DGL = true
  448. else ifeq ($(HAVE_OPENGL),true)
  449. HAVE_DGL = $(HAVE_X11)
  450. endif
  451. # ---------------------------------------------------------------------------------------------------------------------
  452. # Namespace flags
  453. ifneq ($(DISTRHO_NAMESPACE),)
  454. BUILD_CXX_FLAGS += -DDISTRHO_NAMESPACE=$(DISTRHO_NAMESPACE)
  455. endif
  456. ifneq ($(DGL_NAMESPACE),)
  457. BUILD_CXX_FLAGS += -DDGL_NAMESPACE=$(DGL_NAMESPACE)
  458. endif
  459. # ---------------------------------------------------------------------------------------------------------------------
  460. # Optional flags
  461. ifeq ($(NVG_DISABLE_SKIPPING_WHITESPACE),true)
  462. BUILD_CXX_FLAGS += -DNVG_DISABLE_SKIPPING_WHITESPACE
  463. endif
  464. ifneq ($(NVG_FONT_TEXTURE_FLAGS),)
  465. BUILD_CXX_FLAGS += -DNVG_FONT_TEXTURE_FLAGS=$(NVG_FONT_TEXTURE_FLAGS)
  466. endif
  467. ifeq ($(FILE_BROWSER_DISABLED),true)
  468. BUILD_CXX_FLAGS += -DDGL_FILE_BROWSER_DISABLED
  469. endif
  470. ifneq ($(WINDOWS_ICON_ID),)
  471. BUILD_CXX_FLAGS += -DDGL_WINDOWS_ICON_ID=$(WINDOWS_ICON_ID)
  472. endif
  473. ifeq ($(USE_GLES2),true)
  474. BUILD_CXX_FLAGS += -DDGL_USE_OPENGL3 -DDGL_USE_GLES -DDGL_USE_GLES2
  475. endif
  476. ifeq ($(USE_GLES3),true)
  477. BUILD_CXX_FLAGS += -DDGL_USE_OPENGL3 -DDGL_USE_GLES -DDGL_USE_GLES3
  478. endif
  479. ifeq ($(USE_OPENGL3),true)
  480. BUILD_CXX_FLAGS += -DDGL_USE_OPENGL3
  481. endif
  482. ifeq ($(USE_NANOVG_FBO),true)
  483. BUILD_CXX_FLAGS += -DDGL_USE_NANOVG_FBO
  484. endif
  485. ifeq ($(USE_NANOVG_FREETYPE),true)
  486. BUILD_CXX_FLAGS += -DFONS_USE_FREETYPE $(shell $(PKG_CONFIG) --cflags freetype2)
  487. endif
  488. ifeq ($(USE_RGBA),true)
  489. BUILD_CXX_FLAGS += -DDGL_USE_RGBA
  490. endif
  491. # ---------------------------------------------------------------------------------------------------------------------
  492. # Set app extension
  493. ifeq ($(WASM),true)
  494. APP_EXT = .html
  495. else ifeq ($(WINDOWS),true)
  496. APP_EXT = .exe
  497. endif
  498. # ---------------------------------------------------------------------------------------------------------------------
  499. # Set shared lib extension
  500. ifeq ($(MACOS),true)
  501. LIB_EXT = .dylib
  502. else ifeq ($(WASM),true)
  503. LIB_EXT = .wasm
  504. else ifeq ($(WINDOWS),true)
  505. LIB_EXT = .dll
  506. else
  507. LIB_EXT = .so
  508. endif
  509. # ---------------------------------------------------------------------------------------------------------------------
  510. # Set shared library CLI arg
  511. ifeq ($(MACOS),true)
  512. SHARED = -dynamiclib
  513. else ifeq ($(WASM),true)
  514. SHARED = -sSIDE_MODULE=2
  515. else
  516. SHARED = -shared
  517. endif
  518. # ---------------------------------------------------------------------------------------------------------------------
  519. # Handle the verbosity switch
  520. SILENT =
  521. ifeq ($(VERBOSE),1)
  522. else ifeq ($(VERBOSE),y)
  523. else ifeq ($(VERBOSE),yes)
  524. else ifeq ($(VERBOSE),true)
  525. else
  526. SILENT = @
  527. endif
  528. # ---------------------------------------------------------------------------------------------------------------------
  529. # all needs to be first
  530. all:
  531. # ---------------------------------------------------------------------------------------------------------------------
  532. # helper to print what is available/possible to build
  533. print_available = @echo $(1): $(shell echo $($(1)) | grep -q true && echo Yes || echo No)
  534. features:
  535. @echo === Detected Compiler
  536. $(call print_available,CLANG)
  537. $(call print_available,GCC)
  538. @echo === Detected CPU
  539. $(call print_available,CPU_ARM)
  540. $(call print_available,CPU_ARM32)
  541. $(call print_available,CPU_ARM64)
  542. $(call print_available,CPU_ARM_OR_ARM64)
  543. $(call print_available,CPU_I386)
  544. $(call print_available,CPU_I386_OR_X86_64)
  545. $(call print_available,CPU_RISCV64)
  546. $(call print_available,CPU_X86_64)
  547. @echo === Detected OS
  548. $(call print_available,BSD)
  549. $(call print_available,HAIKU)
  550. $(call print_available,HURD)
  551. $(call print_available,LINUX)
  552. $(call print_available,MACOS)
  553. $(call print_available,WASM)
  554. $(call print_available,WINDOWS)
  555. $(call print_available,HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS)
  556. $(call print_available,HAIKU_OR_MACOS_OR_WINDOWS)
  557. $(call print_available,LINUX_OR_MACOS)
  558. $(call print_available,MACOS_OR_WASM_OR_WINDOWS)
  559. $(call print_available,MACOS_OR_WINDOWS)
  560. $(call print_available,UNIX)
  561. @echo === Detected features
  562. $(call print_available,HAVE_ALSA)
  563. $(call print_available,HAVE_DBUS)
  564. $(call print_available,HAVE_CAIRO)
  565. $(call print_available,HAVE_DGL)
  566. $(call print_available,HAVE_JACK)
  567. $(call print_available,HAVE_LIBLO)
  568. $(call print_available,HAVE_OPENGL)
  569. $(call print_available,HAVE_PULSEAUDIO)
  570. $(call print_available,HAVE_RTAUDIO)
  571. $(call print_available,HAVE_SDL2)
  572. $(call print_available,HAVE_STUB)
  573. $(call print_available,HAVE_VULKAN)
  574. $(call print_available,HAVE_X11)
  575. $(call print_available,HAVE_XCURSOR)
  576. $(call print_available,HAVE_XEXT)
  577. $(call print_available,HAVE_XRANDR)
  578. # ---------------------------------------------------------------------------------------------------------------------
  579. # Extra rules for MOD Audio stuff
  580. # NOTE: note path must be absolute
  581. MOD_WORKDIR ?= $(HOME)/mod-workdir
  582. MOD_ENVIRONMENT = \
  583. AR=${1}/host/usr/bin/${2}-gcc-ar \
  584. CC=${1}/host/usr/bin/${2}-gcc \
  585. CPP=${1}/host/usr/bin/${2}-cpp \
  586. CXX=${1}/host/usr/bin/${2}-g++ \
  587. LD=${1}/host/usr/bin/${2}-ld \
  588. PKG_CONFIG=${1}/host/usr/bin/pkg-config \
  589. STRIP=${1}/host/usr/bin/${2}-strip \
  590. CFLAGS="-I${1}/staging/usr/include $(EXTRA_MOD_FLAGS)" \
  591. CPPFLAGS= \
  592. CXXFLAGS="-I${1}/staging/usr/include $(EXTRA_MOD_FLAGS)" \
  593. LDFLAGS="-L${1}/staging/usr/lib $(EXTRA_MOD_FLAGS)" \
  594. EXE_WRAPPER="qemu-${3}-static -L ${1}/target" \
  595. HAVE_CAIRO=false \
  596. HAVE_OPENGL=false \
  597. MOD_BUILD=true \
  598. NOOPT=true
  599. modduo:
  600. $(MAKE) $(call MOD_ENVIRONMENT,$(MOD_WORKDIR)/modduo-static,arm-mod-linux-gnueabihf.static,arm)
  601. modduox:
  602. $(MAKE) $(call MOD_ENVIRONMENT,$(MOD_WORKDIR)/modduox-static,aarch64-mod-linux-gnueabi.static,aarch64)
  603. moddwarf:
  604. $(MAKE) $(call MOD_ENVIRONMENT,$(MOD_WORKDIR)/moddwarf,aarch64-mod-linux-gnu,aarch64)
  605. modpush:
  606. tar -C bin -cz $(subst bin/,,$(wildcard bin/*.lv2)) | base64 | curl -F 'package=@-' http://192.168.51.1/sdk/install && echo
  607. ifneq (,$(findstring modduo-,$(MAKECMDGOALS)))
  608. $(MAKECMDGOALS):
  609. $(MAKE) $(call MOD_ENVIRONMENT,$(MOD_WORKDIR)/modduo,arm-mod-linux-gnueabihf,arm) $(subst modduo-,,$(MAKECMDGOALS))
  610. endif
  611. ifneq (,$(findstring modduox-,$(MAKECMDGOALS)))
  612. $(MAKECMDGOALS):
  613. $(MAKE) $(call MOD_ENVIRONMENT,$(MOD_WORKDIR)/modduox,aarch64-mod-linux-gnueabi,aarch64) $(subst modduox-,,$(MAKECMDGOALS))
  614. endif
  615. ifneq (,$(findstring moddwarf-,$(MAKECMDGOALS)))
  616. $(MAKECMDGOALS):
  617. $(MAKE) $(call MOD_ENVIRONMENT,$(MOD_WORKDIR)/moddwarf,aarch64-mod-linux-gnu,aarch64) $(subst moddwarf-,,$(MAKECMDGOALS))
  618. endif
  619. # ---------------------------------------------------------------------------------------------------------------------
  620. # Protect against multiple inclusion
  621. endif # DPF_MAKEFILE_BASE_INCLUDED
  622. # ---------------------------------------------------------------------------------------------------------------------