NAME=ginput CC=gcc CFLAGS=$(shell pkg-config --cflags gtk4 libadwaita-1) -O3 -I src LDFLAGS=$(shell pkg-config --libs gtk4 libadwaita-1) BUILD_DIR=build CMB := $(wildcard ui/*.cmb) C_FILES := $(shell find $(src) -name '*.c') all: resources $(BUILD_DIR)/$(NAME) # Top-level targets resources: $(BUILD_DIR)/glib-2.0/schemas/gschemas.compiled $(BUILD_DIR)/$(NAME): $(BUILD_DIR)/resource.c $(C_FILES) | $(BUILD_DIR) gcc $(CFLAGS) -o $@ $^ $(LDFLAGS) # Build directory $(BUILD_DIR): mkdir -p $(BUILD_DIR) # UI : Cambalache contains all of the UI files, just compile them all $(BUILD_DIR)/%.ui: ui/$(NAME).cmb | $(BUILD_DIR) cambalache -E $^ mv ui/*.ui $(BUILD_DIR)/ # Resources $(BUILD_DIR)/resource.c: ui/ginput.gresource.xml ui/style.css $(BUILD_DIR)/main-window.ui cp ui/style.css $(BUILD_DIR)/ cp ui/ginput.gresource.xml $(BUILD_DIR)/ cd $(BUILD_DIR) && glib-compile-resources --generate-source --target=resource.c ginput.gresource.xml $(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 # Phony targets .PHONY: clean clean: rm -f ui/*.ui # Remove compiled UI files that might be left over rm -rf $(BUILD_DIR) .PHONY: run .SILENT: run run: all XDG_DATA_DIRS=./$(BUILD_DIR) ./$(BUILD_DIR)/ginput