Skip to content

Commit

Permalink
tweaks to makefile
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed May 8, 2024
1 parent a0b65dd commit 4c4f6e4
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
62 changes: 50 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,67 @@
# Copyright 2024 Filipe Coelho <[email protected]>
# 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
5 changes: 4 additions & 1 deletion src/ui-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[])
Expand Down

0 comments on commit 4c4f6e4

Please sign in to comment.