comparison DPF-Prymula-audioplugins/dpf/Makefile.base.mk @ 3:84e66ea83026

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