Gnome input devices manager
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
ginput/Makefile

66 lines
2.1 KiB

NAME=ginput
BUILD_DIR=build
CC=gcc
VALAC=valac
VALA_FLAGS=--pkg libadwaita-1 --gresources ui/ginput.gresource.xml
CFLAGS=$(shell pkg-config --cflags gtk4 libadwaita-1 libusb-1.0 glib-2.0) -O3 -Wall -I src -I $(BUILD_DIR)/vala
LDFLAGS=$(shell pkg-config --libs gtk4 libadwaita-1 libusb-1.0 glib-2.0) -lm
UI := $(shell find ui/ -name '*.ui')
C_FILES := $(shell find src/ -name '*.c')
VALA_FILES := $(shell find src/ -name '*.vala')
VAPI_FILES := $(shell find src/ -name '*.vapi')
VALA_OBJECTS := $(VALA_FILES)
VALA_OBJECTS := $(patsubst %.vala,%.c,$(VALA_OBJECTS))
VALA_OBJECTS := $(VALA_OBJECTS:%=$(BUILD_DIR)/vala/%)
all: resources $(BUILD_DIR)/$(NAME) $(BUILD_DIR)/drivers
# Top-level targets
resources: $(BUILD_DIR)/glib-2.0/schemas/gschemas.compiled
$(VALA_OBJECTS): $(VALA_FILES) $(VAPI_FILES) | $(BUILD_DIR)/vala
rm -rf $(BUILD_DIR)/vala
$(VALAC) -d $(BUILD_DIR)/vala $(VALA_FLAGS) --header=$(BUILD_DIR)/vala/vala.h -C $^ $(VALA_PKG)
$(BUILD_DIR)/$(NAME): $(BUILD_DIR)/resource.c $(C_FILES) $(VALA_OBJECTS) | $(BUILD_DIR)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
# Build directory
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(BUILD_DIR)/vala: | $(BUILD_DIR)
mkdir -p $(BUILD_DIR)/vala
# Resources
$(BUILD_DIR)/resource.c: ui/ginput.gresource.xml ui/style.css $(UI)
cp ui/style.css $(BUILD_DIR)/
cd ui && glib-compile-resources --generate-source --target=resource.c ginput.gresource.xml
mv ui/resource.c $(BUILD_DIR)/
$(BUILD_DIR)/glib-2.0/schemas/gschemas.compiled: v.ginput.gschema.xml | $(BUILD_DIR)
mkdir -p $(BUILD_DIR)/glib-2.0/schemas
glib-compile-schemas . --targetdir=$(BUILD_DIR)/glib-2.0/schemas
# Drivers
.PHONY: $(BUILD_DIR)/drivers
$(BUILD_DIR)/drivers:
cd drivers && make
# Phony targets
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
.PHONY: run
.SILENT: run
run: all
XDG_DATA_DIRS=./$(BUILD_DIR) ./$(BUILD_DIR)/$(NAME)
$(BUILD_DIR)/$(NAME).dbg: $(BUILD_DIR)/resource.c $(C_FILES) $(VALA_OBJECTS) | $(BUILD_DIR)
$(CC) $(CFLAGS) -g -o $@ $^ $(LDFLAGS)
debug: $(BUILD_DIR)/$(NAME).dbg $(BUILD_DIR)/drivers resources
XDG_DATA_DIRS=./$(BUILD_DIR) gdb --args ./$(BUILD_DIR)/$(NAME).dbg