Point the build and runtime paths at src/ and data/.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
pepaskopec-blip 2026-09-17 17:01:17 +02:00
commit 72deed70e8
11 changed files with 134 additions and 260 deletions

View file

@ -8,13 +8,15 @@ ifeq ($(PKG_CONFIG),)
PKG_CONFIG := pkg-config
endif
# Use $(shell ...) instead of backticks so the flags are expanded by make
# itself; IDEs that import the Makefile via a dry run then see the real
# include paths.
GTK_CFLAGS := $(shell $(PKG_CONFIG) --cflags gtk4)
GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk4)
CFLAGS = -Wall -Wextra -Wno-deprecated-declarations $(GTK_CFLAGS)
SRC_DIR := src
DATA_DIR := data
BUILD_DIR := build
CFLAGS = -Wall -Wextra -Wno-deprecated-declarations -I$(SRC_DIR) \
-MMD -MP $(GTK_CFLAGS)
LIBS = $(GTK_LIBS) -lm
# Published builds pass the commit they were made from (the CI workflow
@ -25,69 +27,67 @@ ifneq ($(COMMIT),)
CFLAGS += -DAPP_COMMIT='"$(COMMIT)"'
endif
# Windows (MSYS2 / MinGW): .exe suffix, no console window, embed .ico.
ifeq ($(OS),Windows_NT)
TARGET = maturita.exe
LIBS += -mwindows
WINDRES ?= windres
RC_OBJ = maturita_rc.o
RC_SRC = $(DATA_DIR)/windows/maturita.rc
RC_OBJ = $(BUILD_DIR)/maturita_rc.o
UNAME_S :=
else
TARGET = maturita
RC_SRC =
RC_OBJ =
UNAME_S := $(shell uname -s 2>/dev/null)
# macOS Dock icon is set via AppKit (see macos_dock.c).
ifeq ($(UNAME_S),Darwin)
LIBS += -framework AppKit -framework Foundation
endif
endif
SRC = $(wildcard *.c)
OBJ = $(SRC:.c=.o)
SRC = $(wildcard $(SRC_DIR)/*.c)
OBJ = $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SRC))
DEP = $(OBJ:.o=.d)
ICON_SRC = assets/app-icon.png
# Always use the real 512×512 asset — copying app-icon.png (1024×1024) breaks
# linuxdeploy, which rejects non-standard icon resolutions.
ICON_DST = share/icons/hicolor/512x512/apps/maturita.png
ICON_RUNTIME = assets/icons/hicolor/512x512/apps/maturita.png
ICON_DST = $(DATA_DIR)/share/icons/hicolor/512x512/apps/maturita.png
ICON_ICO = assets/app-icon.ico
all: $(TARGET)
$(ICON_RUNTIME): $(ICON_DST)
mkdir -p $(dir $@)
cp "$(ICON_DST)" "$@"
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR)
$(CC) $(CFLAGS) -c -o $@ $<
ifeq ($(OS),Windows_NT)
$(RC_OBJ): maturita.rc $(ICON_ICO)
$(WINDRES) maturita.rc -o $(RC_OBJ)
$(RC_OBJ): $(RC_SRC) $(ICON_ICO) | $(BUILD_DIR)
$(WINDRES) -I. -o $@ $<
$(TARGET): $(SRC) $(ICON_RUNTIME) $(RC_OBJ)
$(CC) $(CFLAGS) -o $(TARGET) $(SRC) $(RC_OBJ) $(LIBS)
$(TARGET): $(OBJ) $(RC_OBJ)
$(CC) $(CFLAGS) -o $@ $(OBJ) $(RC_OBJ) $(LIBS)
else
$(TARGET): $(SRC) $(ICON_RUNTIME)
$(CC) $(CFLAGS) -o $(TARGET) $(SRC) $(LIBS)
$(TARGET): $(OBJ)
$(CC) $(CFLAGS) -o $@ $(OBJ) $(LIBS)
endif
clean:
rm -f $(TARGET) maturita.exe $(OBJ) $(RC_OBJ) maturita_rc.o
rm -f $(TARGET) maturita.exe
rm -rf $(BUILD_DIR)
run: $(TARGET)
./$(TARGET)
# Self-contained package for the current platform into dist/.
ifeq ($(OS),Windows_NT)
bundle: $(TARGET)
@rm -rf dist
@mkdir -p dist
@cp $(TARGET) dist/
@cp style.css dist/
@cp $(DATA_DIR)/style.css dist/
@mkdir -p dist/icons/hicolor/512x512/apps
@cp "$(ICON_DST)" dist/icons/hicolor/512x512/apps/
@cp -R share dist/
@cp -R $(DATA_DIR)/share dist/
@ldd $(TARGET) | grep -Ei '/(ucrt64|mingw64)/bin/' | awk '{print $$3}' \
| xargs -r -I{} cp -f {} dist/
@# GTK runtime data (schemas / pixbuf loaders) next to the exe.
@GTK_PREFIX="$$($(PKG_CONFIG) --variable=prefix gtk4)"; \
if [ -d "$$GTK_PREFIX/share/glib-2.0" ]; then \
mkdir -p dist/share && cp -R "$$GTK_PREFIX/share/glib-2.0" dist/share/; \
@ -106,4 +106,6 @@ bundle:
@./scripts/bundle-linux.sh
endif
-include $(DEP)
.PHONY: all clean run bundle