Rev 11 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 11 | Rev 13 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #!/bin/sh |
1 | #!/bin/sh |
2 | 2 | ||
3 | MY_PATH="$(dirname "$0")" |
3 | MY_PATH="$(dirname "$0")" |
4 | 4 | ||
5 | APP_NAME="Rick Dangerous" |
5 | APP_NAME="Rick Dangerous" |
6 | APP_VERSION="1. |
6 | APP_VERSION="1.5" |
7 | APP_COPYRIGHT="© |
7 | APP_COPYRIGHT="© 2024 Pierre-Marie Baty |
8 | © 2002 BigOrno |
8 | © 2002 BigOrno |
9 | © 1989 CORE Design |
9 | © 1989 CORE Design |
10 | Artwork by Simon Phipps" |
10 | Artwork by Simon Phipps" |
11 | BUNDLE_ID="com.pmbaty |
11 | BUNDLE_ID="com.pmbaty.rickdangerous" |
12 | ICON_FILE="icon.png" |
12 | ICON_FILE="icon.png" |
- | 13 | CS_IDENTITY="Apple Distribution: Pierre-Marie Baty" |
|
13 | 14 | ||
14 | # compiler and linker flags to use |
15 | # compiler and linker flags to use |
15 | CPPFLAGS="-Isrc -Ilib/SDL2/include" |
16 | CPPFLAGS="-Isrc -Ilib/SDL2/include" |
16 | LDFLAGS="" |
17 | LDFLAGS="" |
17 | 18 | ||
Line 72... | Line 73... | ||
72 | 73 | ||
73 | # generate and deploy fat Mach-O executable |
74 | # generate and deploy fat Mach-O executable |
74 | echo "Generating fat executable..." |
75 | echo "Generating fat executable..." |
75 | lipo ${THIN_OUTPUTS} -create -output "${APP_NAME}.app/Contents/MacOS/${APP_NAME}" || exit 1 |
76 | lipo ${THIN_OUTPUTS} -create -output "${APP_NAME}.app/Contents/MacOS/${APP_NAME}" || exit 1 |
76 | 77 | ||
77 | # deploy the SDL2 framework |
78 | # deploy the SDL2 framework without the symlinks and change the LC_LOAD_DYLIB in the main executable |
- | 79 | # (macOS codesign will refuse to sign the executable if a bundled framework contains symlinks) |
|
78 | echo "Deploying SDL2 framework..." |
80 | echo "Deploying SDL2 framework..." |
79 | mkdir "${APP_NAME}.app/Contents/Frameworks/SDL2.framework" |
81 | mkdir "${APP_NAME}.app/Contents/Frameworks/SDL2.framework" || exit 1 |
80 |
|
82 | cp lib/SDL2/macOS/SDL2.framework/SDL2 "${APP_NAME}.app/Contents/Frameworks/SDL2.framework/SDL2" || exit 1 |
81 |
|
83 | install_name_tool -change "@rpath/SDL2.framework/Versions/A/SDL2" "@rpath/SDL2.framework/SDL2" "${APP_NAME}.app/Contents/MacOS/${APP_NAME}" |
82 | cp lib/SDL2/macOS/SDL2.framework/ |
84 | cp -LR lib/SDL2/macOS/SDL2.framework/Resources "${APP_NAME}.app/Contents/Frameworks/SDL2.framework" || exit 1 |
83 |
|
85 | find "${APP_NAME}.app/Contents/Frameworks/SDL2.framework" -name Thumbs.db -exec rm {} \; |
84 |
|
86 | find "${APP_NAME}.app/Contents/Frameworks/SDL2.framework" -name .DS_Store -exec rm {} \; |
85 |
|
87 | find "${APP_NAME}.app/Contents/Frameworks/SDL2.framework" -type f -exec chmod -x {} \; |
86 | 88 | ||
87 | # deploy the game |
89 | # deploy the game data, remove executable flags from files and remove junk files |
88 | echo "Deploying game data..." |
90 | echo "Deploying game data..." |
89 | cp -LR sounds "${APP_NAME}.app/Contents/Resources" || exit 1 |
91 | cp -LR sounds "${APP_NAME}.app/Contents/Resources" || exit 1 |
- | 92 | find "${APP_NAME}.app/Contents/Resources" -name Thumbs.db -exec rm {} \; |
|
- | 93 | find "${APP_NAME}.app/Contents/Resources" -name .DS_Store -exec rm {} \; |
|
- | 94 | find "${APP_NAME}.app/Contents/Resources" -type f -exec chmod -x {} \; |
|
90 | 95 | ||
91 | # generate and deploy the app icon |
96 | # generate and deploy the app icon |
92 | echo "Generating app icon..." |
97 | echo "Generating app icon..." |
93 | mkdir ".build/${APP_NAME}.iconset" || exit 1 |
98 | mkdir ".build/${APP_NAME}.iconset" || exit 1 |
94 | sips -z 16 16 "${ICON_FILE}" --out ".build/${APP_NAME}.iconset/icon_16x16.png" > /dev/null |
99 | sips -z 16 16 "${ICON_FILE}" --out ".build/${APP_NAME}.iconset/icon_16x16.png" > /dev/null |
Line 133... | Line 138... | ||
133 | echo " <key>CFBundleSignature</key>" |
138 | echo " <key>CFBundleSignature</key>" |
134 | echo " <string>????</string>" |
139 | echo " <string>????</string>" |
135 | echo "</dict>" |
140 | echo "</dict>" |
136 | echo "</plist>" |
141 | echo "</plist>" |
137 | ) > "${APP_NAME}.app/Contents/Info.plist" || exit 1 |
142 | ) > "${APP_NAME}.app/Contents/Info.plist" || exit 1 |
- | 143 | ||
- | 144 | # code signing is mandatory |
|
- | 145 | codesign --force --deep --sign "${CS_IDENTITY}" --timestamp "${APP_NAME}.app" |
|
138 | 146 | ||
139 | echo "Output app bundle: ${APP_NAME}.app" |
147 | echo "Output app bundle: ${APP_NAME}.app" |
- | 148 | ||
- | 149 | # zip on Mac to preserve executable flags |
|
- | 150 | zip -r "${APP_NAME} (Mac).zip" "${APP_NAME}.app" && echo "A Zip file of the app bundle was created for convenience." |
|
140 | else |
151 | else |
141 | # Linux/BSD/whatever: simply retrieve the compiled executable |
152 | # Linux/BSD/whatever: simply retrieve the compiled executable |
142 | cp ".build/${ARCH}/a.out" "${APP_NAME}.$(uname)-$(uname -m)" |
153 | cp ".build/${ARCH}/a.out" "${APP_NAME}.$(uname)-$(uname -m)" |
143 | 154 | ||
144 | echo "Output executable: ${APP_NAME}.$(uname)-$(uname -m)" |
155 | echo "Output executable: ${APP_NAME}.$(uname)-$(uname -m)" |
145 | fi |
156 | fi |
146 | 157 | ||
147 | # finished |
158 | # finished |
148 | echo "${APP_NAME} was built successfully" |
159 | echo "${APP_NAME} was built successfully" |
149 | exit 0 |
- | |
150 | - | ||
151 | - | ||
152 | - | ||
153 | - | ||
154 | - | ||
155 | - | ||
156 | - | ||
157 | - | ||
158 | - | ||
159 | - | ||
160 | - | ||
161 | - | ||
162 | rm -rf "${APP_NAME}.app" |
- | |
163 | - | ||
164 | # create app bundle |
- | |
165 | echo "Creating macOS app layout..." |
- | |
166 | mkdir "${APP_NAME}.app" || exit 1 |
- | |
167 | mkdir "${APP_NAME}.app/Contents" || exit 1 |
- | |
168 | mkdir "${APP_NAME}.app/Contents/MacOS" || exit 1 |
- | |
169 | mkdir "${APP_NAME}.app/Contents/Frameworks" || exit 1 |
- | |
170 | mkdir "${APP_NAME}.app/Contents/Resources" || exit 1 |
- | |
171 | - | ||
172 | # target El Capitan |
- | |
173 | for ARCH in x86_64 arm64; do |
- | |
174 | cc -mmacosx-version-min=10.11 -arch "${ARCH}" *.c osx-sdlmain.m -I3rdparty/SDL2/include -framework Foundation -framework Cocoa -F3rdparty/SDL2/macOS -framework SDL2 -rpath "@loader_path/../Frameworks" -o "${APP_NAME}.mac-${ARCH}" |
- | |
175 | if [ ! "_$?" = "_0" ]; then |
- | |
176 | rm -rf "${APP_NAME}.app" |
- | |
177 | exit 1 |
- | |
178 | fi |
- | |
179 | done |
- | |
180 | lipo "${APP_NAME}.mac-x86_64" "${APP_NAME}.mac-arm64" -create -output "${APP_NAME}.app/Contents/MacOS/${APP_NAME}" |
- | |
181 | if [ ! "_$?" = "_0" ]; then |
- | |
182 | rm "${APP_NAME}.mac-x86_64" "${APP_NAME}.mac-arm64" |
- | |
183 | rm -rf "${APP_NAME}.app" |
- | |
184 | exit 1 |
- | |
185 | fi |
- | |
186 | rm "${APP_NAME}.mac-x86_64" "${APP_NAME}.mac-arm64" |
- | |
187 | - | ||
188 | # deploy the SDL2 framework |
- | |
189 | mkdir "${APP_NAME}.app/Contents/Frameworks/SDL2.framework" || exit 1 |
- | |
190 | mkdir "${APP_NAME}.app/Contents/Frameworks/SDL2.framework/Versions" || exit 1 |
- | |
191 | mkdir "${APP_NAME}.app/Contents/Frameworks/SDL2.framework/Versions/A" || exit 1 |
- | |
192 | cp 3rdparty/SDL2/macOS/SDL2.framework/SDL2 "${APP_NAME}.app/Contents/Frameworks/SDL2.framework/Versions/A/SDL2" || exit 1 |
- | |
193 | ln -s Versions/A/SDL2 "${APP_NAME}.app/Contents/Frameworks/SDL2.framework/SDL2" || exit 1 |
- | |
194 | cp -LR 3rdparty/SDL2/macOS/SDL2.framework/Resources "${APP_NAME}.app/Contents/Frameworks/SDL2.framework/Versions/A" || exit 1 |
- | |
195 | ln -s Versions/A/Resources "${APP_NAME}.app/Contents/Frameworks/SDL2.framework/Resources" || exit 1 |
- | |
196 | - | ||
197 | # deploy icon |
- | |
198 | mkdir "__${APP_NAME}.iconset" |
- | |
199 | sips -z 16 16 "${ICON_FILE}" --out "__${APP_NAME}.iconset/icon_16x16.png" > /dev/null |
- | |
200 | sips -z 32 32 "${ICON_FILE}" --out "__${APP_NAME}.iconset/icon_16x16@2x.png" > /dev/null |
- | |
201 | sips -z 32 32 "${ICON_FILE}" --out "__${APP_NAME}.iconset/icon_32x32.png" > /dev/null |
- | |
202 | sips -z 64 64 "${ICON_FILE}" --out "__${APP_NAME}.iconset/icon_32x32@2x.png" > /dev/null |
- | |
203 | sips -z 128 128 "${ICON_FILE}" --out "__${APP_NAME}.iconset/icon_128x128.png" > /dev/null |
- | |
204 | sips -z 256 256 "${ICON_FILE}" --out "__${APP_NAME}.iconset/icon_128x128@2x.png" > /dev/null |
- | |
205 | sips -z 256 256 "${ICON_FILE}" --out "__${APP_NAME}.iconset/icon_256x256.png" > /dev/null |
- | |
206 | sips -z 512 512 "${ICON_FILE}" --out "__${APP_NAME}.iconset/icon_256x256@2x.png" > /dev/null |
- | |
207 | sips -z 512 512 "${ICON_FILE}" --out "__${APP_NAME}.iconset/icon_512x512.png" > /dev/null |
- | |
208 | sips -z 1024 1024 "${ICON_FILE}" --out "__${APP_NAME}.iconset/icon_512x512@2x.png" > /dev/null |
- | |
209 | iconutil -c icns "__${APP_NAME}.iconset" |
- | |
210 | if [ ! "_$?" = "_0" ]; then |
- | |
211 | rm -rf "__${APP_NAME}.iconset" |
- | |
212 | rm -rf "${APP_NAME}.app" |
- | |
213 | exit 1 |
- | |
214 | fi |
- | |
215 | rm -rf "__${APP_NAME}.iconset" |
- | |
216 | mv "__${APP_NAME}.icns" "${APP_NAME}.app/Contents/Resources/${APP_NAME}.icns" |
- | |
217 | - | ||
218 | # deploy resources |
- | |
219 | cp -r "../sounds" "${APP_NAME}.app/Contents/Resources" |
- | |
220 | - | ||
221 | # create PkgInfo file |
- | |
222 | printf "%s" "APPL???" > "${APP_NAME}.app/Contents/PkgInfo" |
- | |
223 | - | ||
224 | # create Info.plist |
- | |
225 | ( |
- | |
226 | echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
- | |
227 | echo "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" |
- | |
228 | echo "<plist version=\"1.0\">" |
- | |
229 | echo "<dict>" |
- | |
230 | echo " <key>CFBundleDevelopmentRegion</key>" |
- | |
231 | echo " <string>en</string>" |
- | |
232 | echo " <key>CFBundleExecutable</key>" |
- | |
233 | echo " <string>${APP_NAME}</string>" |
- | |
234 | echo " <key>CFBundleIconFile</key>" |
- | |
235 | echo " <string>${APP_NAME}.icns</string>" |
- | |
236 | echo " <key>CFBundleIdentifier</key>" |
- | |
237 | echo " <string>${BUNDLE_ID}</string>" |
- | |
238 | echo " <key>CFBundleInfoDictionaryVersion</key>" |
- | |
239 | echo " <string>6.0</string>" |
- | |
240 | echo " <key>CFBundleName</key>" |
- | |
241 | echo " <string>${APP_NAME}</string>" |
- | |
242 | echo " <key>CFBundleVersion</key>" |
- | |
243 | echo " <string>${APP_VERSION}</string>" |
- | |
244 | echo " <key>NSHumanReadableCopyright</key>" |
- | |
245 | echo " <string>${APP_COPYRIGHT}</string>" |
- | |
246 | echo " <key>CFBundlePackageType</key>" |
- | |
247 | echo " <string>APPL</string>" |
- | |
248 | echo " <key>CFBundleSignature</key>" |
- | |
249 | echo " <string>????</string>" |
- | |
250 | echo "</dict>" |
- | |
251 | echo "</plist>" |
- | |
252 | ) > "${APP_NAME}.app/Contents/Info.plist" |
- | |
253 | - | ||
254 | # finished |
- | |
255 | echo "${APP_NAME} was built successfully" |
- | |
256 | exit 0 |
160 | exit 0 |