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