From 4c4f6e4b0af98d53bcc7bf5706b2975356ddada9 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 8 May 2024 11:08:45 +0200 Subject: [PATCH] tweaks to makefile Signed-off-by: falkTX --- .github/workflows/build.yml | 2 +- Makefile | 62 ++++++++++++++++++++++++++++++------- src/ui-client.c | 5 ++- 3 files changed, 55 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1f602b7..85ecd5a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,7 +27,7 @@ jobs: - name: Set up dependencies run: | apt-get update -qq - apt-get install -yqq gcc libgtk2.0-dev libgtk-3-dev liblilv-dev lv2-dev libx11-dev make pkg-config + apt-get install -yqq g++ libgtk2.0-dev libgtk-3-dev liblilv-dev lv2-dev libx11-dev make pkg-config - name: Regular build env: CFLAGS: -Werror diff --git a/Makefile b/Makefile index fdcad4a..2ccac86 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,67 @@ # Copyright 2024 Filipe Coelho # SPDX-License-Identifier: ISC -CFLAGS += -std=c11 +# --------------------------------------------------------------------------------------------------------------------- +# Set C / C++ language version and base flags -TARGETS = lv2-gtk-ui-bridge.lv2/lv2-gtk-ui-bridge.so +CFLAGS += -std=c11 -Wall -Wextra -Wno-unused-value +CXXFLAGS += -std=c++11 -Wall -Wextra -Wno-unused-value -TARGETS += lv2-gtk-ui-bridge.lv2/lv2-gtk2-ui-bridge -TARGETS += lv2-gtk-ui-bridge.lv2/lv2-gtk3-ui-bridge +# --------------------------------------------------------------------------------------------------------------------- +# Use vendored LV2 if available + +ifneq (,$(wildcard lv2/include)) +LV2_FLAGS = -Ilv2/include +else +LV2_FLAGS = $(shell pkg-config --cflags --libs lv2) +endif + +# --------------------------------------------------------------------------------------------------------------------- +# Set per-system flags + +TARGET_MACHINE := $(shell $(CC) -dumpmachine) + +ifneq (,$(findstring apple,$(TARGET_MACHINE))) +SERVER_FLAGS = -fPIC -dynamiclib +else ifneq (,$(findstring mingw,$(TARGET_MACHINE))) +APP_EXT = .exe +CFLAGS += -mstackrealign +CXXFLAGS += -mstackrealign +LDFLAGS += -static +SERVER_FLAGS = -shared -Wl,-no-undefined +else +CLIENT_FLAGS = $(shell pkg-config --cflags --libs x11) -ldl +SERVER_FLAGS = -fPIC -shared -Wl,-no-undefined +SHM_LIBS = -lrt +endif + +# --------------------------------------------------------------------------------------------------------------------- +# Build targets + +TARGETS = lv2-gtk-ui-bridge.lv2/lv2-gtk-ui-bridge.so +TARGETS += lv2-gtk-ui-bridge.lv2/lv2-gtk2-ui-bridge$(APP_EXT) +TARGETS += lv2-gtk-ui-bridge.lv2/lv2-gtk3-ui-bridge$(APP_EXT) + +# --------------------------------------------------------------------------------------------------------------------- all: $(TARGETS) lv2-gtk-ui-bridge.lv2/lv2-gtk-ui-bridge.so: src/ui-server.c src/ipc/*.h - $(CC) $< $(CFLAGS) $(LDFLAGS) $(shell pkg-config --cflags --libs lv2) -fPIC -shared -lrt -Wl,-no-undefined -o $@ + $(CC) $< $(CFLAGS) $(LDFLAGS) $(LV2_FLAGS) $(SERVER_FLAGS) $(SHM_LIBS) -o $@ + +lv2-gtk-ui-bridge.lv2/lv2-gtk2-ui-bridge$(APP_EXT): src/ui-client.c src/ipc/*.h + $(CC) $< $(CFLAGS) $(LDFLAGS) $(LV2_FLAGS) $(shell pkg-config --cflags --libs gtk+-2.0 lilv-0) -DUI_GTK2 $(CLIENT_FLAGS) $(SHM_LIBS) -Wno-deprecated-declarations -o $@ -lv2-gtk-ui-bridge.lv2/lv2-gtk2-ui-bridge: src/ui-client.c src/ipc/*.h - $(CC) $< $(CFLAGS) $(LDFLAGS) $(shell pkg-config --cflags --libs gtk+-2.0 lilv-0 lv2 x11) -DUI_GTK2 -ldl -lrt -Wno-deprecated-declarations -o $@ +lv2-gtk-ui-bridge.lv2/lv2-gtk3-ui-bridge$(APP_EXT): src/ui-client.c src/ipc/*.h + $(CC) $< $(CFLAGS) $(LDFLAGS) $(LV2_FLAGS) $(shell pkg-config --cflags --libs gtk+-3.0 lilv-0) -DUI_GTK3 $(CLIENT_FLAGS) $(SHM_LIBS) -Wno-deprecated-declarations -o $@ -lv2-gtk-ui-bridge.lv2/lv2-gtk3-ui-bridge: src/ui-client.c src/ipc/*.h - $(CC) $< $(CFLAGS) $(LDFLAGS) $(shell pkg-config --cflags --libs gtk+-3.0 lilv-0 lv2 x11) -DUI_GTK3 -ldl -lrt -Wno-deprecated-declarations -o $@ +# --------------------------------------------------------------------------------------------------------------------- test: src/test.c src/ipc/*.h - $(CC) $< $(CFLAGS) $(LDFLAGS) -Wall -Wextra -o $@ + $(CC) $< $(CFLAGS) $(LDFLAGS) -Wall -Wextra -o $@$(APP_EXT) testxx: src/test.c src/ipc/*.h - $(CXX) $< $(CXXFLAGS) $(LDFLAGS) -Wall -Wextra -o $@ + $(CXX) $< $(CXXFLAGS) $(LDFLAGS) -Wall -Wextra -o $@$(APP_EXT) clean: - rm -f $(TARGETS) + rm -f $(TARGETS) test testxx *.exe diff --git a/src/ui-client.c b/src/ui-client.c index 3819618..8fe7112 100644 --- a/src/ui-client.c +++ b/src/ui-client.c @@ -318,9 +318,12 @@ static void* lv2ui_thread_run(void* const ptr) return NULL; } -static void signal_handler(int) +static void signal_handler(const int sig) { gtk_main_quit(); + + // unused + (void)sig; } int main(int argc, char* argv[])