From 6675a1e81d35fe73a83b8ed7f20fcdf735e1fb3d Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 21 Oct 2021 17:35:41 +0100 Subject: [PATCH] Allow to link against system dependencies Signed-off-by: falkTX --- Makefile | 24 ++++++++++++++++++------ plugins/Makefile | 16 ++++++++++++---- src/CardinalPlugin.cpp | 2 ++ src/Makefile | 15 ++++++++++++++- 4 files changed, 46 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index c643a05..5b8dab3 100644 --- a/Makefile +++ b/Makefile @@ -18,12 +18,22 @@ SYSDEPS ?= false # -------------------------------------------------------------- # Check for system-wide dependencies -# HAVE_LIBARCHIVE = $(shell pkg-config --exists libarchive && echo true) -# -# libjansson.a -# libsamplerate.a -# libspeexdsp.a -# libzstd.a +ifeq ($(SYSDEPS),true) + +ifneq ($(shell pkg-config --exists jansson && echo true),true) +$(error jansson dpendency not installed/available) +endif +ifneq ($(shell pkg-config --exists libarchive && echo true),true) +$(error libarchive dpendency not installed/available) +endif +ifneq ($(shell pkg-config --exists samplerate && echo true),true) +$(error samplerate dpendency not installed/available) +endif +ifneq ($(shell pkg-config --exists speexdsp && echo true),true) +$(error speexdsp dpendency not installed/available) +endif + +endif # -------------------------------------------------------------- @@ -31,7 +41,9 @@ cardinal: deps dgl plugins $(MAKE) all -C src deps: +ifneq ($(SYSDEPS),true) $(MAKE) all -C deps +endif dgl: $(MAKE) USE_NANOVG_FBO=true USE_RGBA=true -C dpf/dgl opengl diff --git a/plugins/Makefile b/plugins/Makefile index 5bf34e8..fc0b6ba 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -4,7 +4,12 @@ # Created by falkTX # -DEP_PATH = $(abspath ../src/Rack/dep) +# -------------------------------------------------------------- +# Build config + +PREFIX ?= /usr/local +DESTDIR ?= +SYSDEPS ?= false # -------------------------------------------------------------- # Import base definitions @@ -259,9 +264,6 @@ BASE_FLAGS += -I../include/neon-compat BASE_FLAGS += -I../src BASE_FLAGS += -I../src/Rack/include BASE_FLAGS += -I../src/Rack/include/dsp -BASE_FLAGS += -I../src/Rack/dep/include -# BASE_FLAGS += -I../src/Rack/dep/filesystem/include -# BASE_FLAGS += -I../src/Rack/dep/fuzzysearchdatabase/src BASE_FLAGS += -I../src/Rack/dep/glfw/include BASE_FLAGS += -I../src/Rack/dep/nanosvg/src BASE_FLAGS += -I../src/Rack/dep/osdialog @@ -269,6 +271,12 @@ BASE_FLAGS += -I../src/Rack/dep/oui-blendish BASE_FLAGS += -I../src/Rack/dep/pffft BASE_FLAGS += -pthread +# ifneq ($(SYSDEPS),true) +# BASE_FLAGS += -I../src/Rack/dep/include +# # BASE_FLAGS += -I../src/Rack/dep/filesystem/include +# # BASE_FLAGS += -I../src/Rack/dep/fuzzysearchdatabase/src +# endif + ifeq ($(WINDOWS),true) BASE_FLAGS += -D_USE_MATH_DEFINES BASE_FLAGS += -DWIN32_LEAN_AND_MEAN diff --git a/src/CardinalPlugin.cpp b/src/CardinalPlugin.cpp index 59940e4..1ba312d 100644 --- a/src/CardinalPlugin.cpp +++ b/src/CardinalPlugin.cpp @@ -85,11 +85,13 @@ struct Initializer { if (asset::systemDir.empty()) { + #ifdef CARDINAL_PLUGIN_SOURCE_DIR // Make system dir point to source code location as fallback asset::systemDir = CARDINAL_PLUGIN_SOURCE_DIR DISTRHO_OS_SEP_STR "Rack"; // And if that fails, use install target prefix if (! system::isDirectory(system::join(asset::systemDir, "res"))) + #endif { asset::bundlePath = CARDINAL_PLUGIN_PREFIX "/share/Cardinal/PluginManifests"; asset::systemDir = CARDINAL_PLUGIN_PREFIX "/share/Cardinal"; diff --git a/src/Makefile b/src/Makefile index b6a5a59..95b2937 100644 --- a/src/Makefile +++ b/src/Makefile @@ -60,6 +60,7 @@ FILES_DSP += $(filter-out Rack/src/window/Window.cpp, $(wildcard Rack/src/*/*.cp # -------------------------------------------------------------- # Extra libraries to link against +ifneq ($(SYSDEPS),true) EXTRA_LIBS = ../plugins/plugins.a EXTRA_LIBS += Rack/dep/lib/libjansson.a EXTRA_LIBS += Rack/dep/lib/libsamplerate.a @@ -72,6 +73,7 @@ endif EXTRA_LIBS += Rack/dep/lib/libzstd.a EXTRA_DEPENDENCIES = $(EXTRA_LIBS) +endif # -------------------------------------------------------------- # Do some magic @@ -98,7 +100,11 @@ BASE_FLAGS += -I../dpf/dgl/src/nanovg BASE_FLAGS += -I../include BASE_FLAGS += -I../include/neon-compat BASE_FLAGS += -IRack/include +ifeq ($(SYSDEPS),true) +BASE_FLAGS += $(shell pkg-config --cflags jansson libarchive samplerate speexdsp) +else BASE_FLAGS += -IRack/dep/include +endif BASE_FLAGS += -IRack/dep/filesystem/include BASE_FLAGS += -IRack/dep/fuzzysearchdatabase/src BASE_FLAGS += -IRack/dep/glfw/include @@ -144,12 +150,16 @@ LINK_FLAGS += -ldbghelp -lshlwapi EXTRA_LIBS += -lws2_32 -lwinmm endif +ifeq ($(SYSDEPS),true) +LINK_FLAGS += $(shell pkg-config --libs jansson libarchive samplerate speexdsp) +endif + ifeq ($(WITH_LTO),true) LINK_FLAGS += -fno-strict-aliasing -flto -Werror=odr -Werror=lto-type-mismatch endif # -------------------------------------------------------------- -# temporary macro just to get the ball rolling +# fallback path to resource files ifeq ($(EXE_WRAPPER),wine) SOURCE_DIR = Z:$(subst /,\\,$(CURDIR)) @@ -157,7 +167,10 @@ else SOURCE_DIR = $(CURDIR) endif +ifneq ($(SYSDEPS),true) BUILD_CXX_FLAGS += -DCARDINAL_PLUGIN_SOURCE_DIR='"$(SOURCE_DIR)"' +endif + BUILD_CXX_FLAGS += -DCARDINAL_PLUGIN_PREFIX='"$(PREFIX)"' # --------------------------------------------------------------