77VERSION := $(shell git describe --tags --exact-match 2>/dev/null || git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown")
88endif
99
10+ # Extract semantic version for Info.plist (e.g., "1.0.3" from tag "v1.0.3")
11+ SHORT_VERSION := $(shell echo $(VERSION ) | grep -oE 'v?[0-9]+\.[0-9]+\.[0-9]+' || echo "0.0.0")
12+
1013APP_NAME_VERSION = $(APP_NAME ) $(VERSION )
11- APP_EXE = $( APP_NAME )
14+ APP_MANIFEST = src/Info.plist
1215APP_BUNDLE = $(APP_NAME ) .app
16+ APP_EXE = $(APP_NAME )
17+
18+
1319
1420CC = clang++
1521CFLAGS = -std=c++17 -Wall -mmacosx-version-min=11.0 -arch x86_64 -arch arm64 -MMD -MP -DAPPNAME_VERSION='"$(APP_NAME_VERSION ) "'
@@ -60,6 +66,10 @@ $(LICENSE_HEADER): ../LICENSE
6066$(BOOTROM_HEADER ) : $(BOOTROM_SOURCE )
6167 python3 ../tools/generate_bootrom_header.py $(BOOTROM_SOURCE ) $(BOOTROM_HEADER )
6268
69+ # Generate Info.plist from template with version substitution
70+ $(APP_MANIFEST ) : $(APP_MANIFEST ) .in
71+ sed -e ' s/@VERSION@/$(VERSION)/g' -e ' s/@SHORT_VERSION@/$(SHORT_VERSION)/g' $< > $@
72+
6373# Pattern rules for incremental compilation
6474% .o : ../shared/% .cc $(LICENSE_HEADER ) $(BOOTROM_HEADER )
6575 $(CC ) $(CFLAGS ) $(INCS ) -c $< -o $@
@@ -88,15 +98,15 @@ release/$(APP_BUNDLE)/Contents/MacOS/$(APP_EXE): $(SDL_LIB) $(OBJS)
8898 $(CC ) $(CFLAGS ) $(LIBS ) $(INCS ) $(OBJS ) -o $@ $(LFLAGS )
8999
90100# .app bundle
91- release/$(APP_BUNDLE ) : release/$(APP_BUNDLE ) /Contents/MacOS/$(APP_EXE ) $(SDL_LIB ) resources/Kiwi8.icns src/Info.plist
101+ release/$(APP_BUNDLE ) : release/$(APP_BUNDLE ) /Contents/MacOS/$(APP_EXE ) $(SDL_LIB ) resources/Kiwi8.icns $( APP_MANIFEST )
92102 mkdir -p release/$(APP_BUNDLE ) /Contents/{Resources,Frameworks}
93103
94104 # Copying the frameworks into .app bundle
95105 cp $(SDL_LIB) release/$(APP_BUNDLE)/Contents/Frameworks/libSDL2-2.0.0.dylib
96106
97107 # Moving other files into .app bundle
98108 cp resources/Kiwi8.icns release/$(APP_BUNDLE)/Contents/Resources/Kiwi8.icns
99- cp src/Info.plist release/$(APP_BUNDLE)/Contents/Info.plist
109+ cp $(APP_MANIFEST) release/$(APP_BUNDLE)/Contents/Info.plist
100110
101111 # Set the dylib's install name to be relative to the bundle
102112 install_name_tool -id @executable_path/../Frameworks/libSDL2-2.0.0.dylib release/$(APP_BUNDLE)/Contents/Frameworks/libSDL2-2.0.0.dylib
@@ -119,6 +129,7 @@ clean:
119129 $(RM ) -r debug
120130 $(RM ) -r release
121131 $(RM ) $(LICENSE_HEADER ) $(BOOTROM_HEADER )
132+ $(RM ) $(APP_MANIFEST )
122133
123134# Removes everything including SDL installation and build artifacts (full reset)
124135distclean : clean
0 commit comments