Make the app icon work on macOS, Windows, and Linux.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
pepaskopec-blip 2026-09-15 14:44:45 +02:00
commit 3ea022dd4f
16 changed files with 236 additions and 17 deletions

View file

@ -17,12 +17,15 @@ GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk4)
CFLAGS = -Wall -Wextra -Wno-deprecated-declarations $(GTK_CFLAGS)
LIBS = $(GTK_LIBS) -lm
# Windows (MSYS2 / MinGW): .exe suffix and no console window for the GUI.
# 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
else
TARGET = maturita
RC_OBJ =
# macOS Dock icon is set via AppKit (see macos_dock.c).
ifeq ($(shell uname -s 2>/dev/null),Darwin)
LIBS += -framework AppKit -framework Foundation
@ -34,6 +37,7 @@ OBJ = $(SRC:.c=.o)
ICON_SRC = assets/app-icon.png
ICON_DST = assets/icons/hicolor/512x512/apps/maturita.png
ICON_ICO = assets/app-icon.ico
all: $(TARGET)
@ -41,11 +45,19 @@ $(ICON_DST): $(ICON_SRC)
mkdir -p $(dir $@)
cp "$(ICON_SRC)" "$@"
ifeq ($(OS),Windows_NT)
$(RC_OBJ): maturita.rc $(ICON_ICO)
$(WINDRES) maturita.rc -o $(RC_OBJ)
$(TARGET): $(SRC) $(ICON_DST) $(RC_OBJ)
$(CC) $(CFLAGS) -o $(TARGET) $(SRC) $(RC_OBJ) $(LIBS)
else
$(TARGET): $(SRC) $(ICON_DST)
$(CC) $(CFLAGS) -o $(TARGET) $(SRC) $(LIBS)
endif
clean:
rm -f $(TARGET) maturita.exe $(OBJ)
rm -f $(TARGET) maturita.exe $(OBJ) $(RC_OBJ) maturita_rc.o
run: $(TARGET)
./$(TARGET)
@ -61,6 +73,7 @@ bundle: $(TARGET)
@cp style.css dist/
@mkdir -p dist/icons/hicolor/512x512/apps
@cp "$(ICON_DST)" dist/icons/hicolor/512x512/apps/
@cp -R share dist/
@ldd $(TARGET) | grep -Ei '/(ucrt64|mingw64)/bin/' | awk '{print $$3}' \
| xargs -r -I{} cp -f {} dist/
@echo "Bundled into dist/ - run dist/$(TARGET)"