Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | pmbaty | 1 | #!/bin/sh |
2 | |||
3 | MY_PATH="$(dirname "$0")" |
||
4 | APP_NAME="Carmageddon" |
||
5 | APP_VERSION="1.0" |
||
6 | APP_COPYRIGHT="© 2023 Pierre-Marie Baty |
||
7 | © 2023 Dethrace Labs |
||
8 | © 1997 Stainless Games" |
||
9 | BUNDLE_ID="com.pmbaty.carmageddon" |
||
10 | ICON_FILE="icon.png" |
||
11 | |||
12 | cd "${MY_PATH}" || exit 1 |
||
13 | |||
14 | # cleanup |
||
15 | rm -rf .build |
||
16 | rm -rf "${APP_NAME}.app" |
||
17 | |||
18 | # compiler and linker flags to use |
||
19 | CPPFLAGS="-DDETHRACE_FIX_BUGS=1 -Isrc/harness/include -Isrc/harness -Isrc/smackw32/include -Isrc/BRSRC13/include -Isrc/BRSRC13 -Isrc/S3/include -Isrc/S3 -Isrc/DETHRACE/common -Isrc/DETHRACE/pd -Isrc/DETHRACE -Ilib/glad/include -Ilib/libsmacker -Ilib/miniaudio/include -Ilib/miniaudio/include/miniaudio -Ilib/SDL2 -Ilib" |
||
20 | |||
21 | # read the source files list from the Visual Studio project file |
||
22 | SRCLIST="$(grep "<ClCompile " Carmageddon.vcxproj|awk -F\" '{print $2}'|tr '\\' '/')" |
||
23 | |||
24 | # target x86_64 and ARM64 |
||
25 | for ARCH in x86_64 arm64; do |
||
26 | echo "Compiling for ${ARCH}..." |
||
27 | rm -rf ".build/${ARCH}" |
||
28 | mkdir -p ".build/${ARCH}" || exit 1 |
||
29 | |||
30 | # compile source files |
||
31 | for SRCFILE in ${SRCLIST}; do |
||
32 | echo "${SRCFILE}" |
||
33 | cc -o ".build/${ARCH}/$(basename "${SRCFILE}").o" -mmacosx-version-min=10.11 -arch "${ARCH}" ${CPPFLAGS} -c "${SRCFILE}" || exit 1 |
||
34 | done |
||
35 | |||
36 | # link them together |
||
37 | echo "Linking for ${ARCH}..." |
||
38 | cc -o ".build/${ARCH}/${APP_NAME}" ".build/${ARCH}/"*".o" -mmacosx-version-min=10.11 -arch "${ARCH}" -framework Cocoa -framework OpenGL -F. -framework SDL2 -rpath @loader_path/../Frameworks || exit 1 |
||
39 | done |
||
40 | |||
41 | # create the app layout |
||
42 | mkdir "${APP_NAME}.app" |
||
43 | mkdir "${APP_NAME}.app/Contents" |
||
44 | mkdir "${APP_NAME}.app/Contents/MacOS" |
||
45 | mkdir "${APP_NAME}.app/Contents/Frameworks" |
||
46 | mkdir "${APP_NAME}.app/Contents/Resources" |
||
47 | |||
48 | # generate and deploy fat Mach-O executable |
||
49 | echo "Generating fat executable..." |
||
50 | lipo ".build/x86_64/${APP_NAME}" ".build/arm64/${APP_NAME}" -create -output "${APP_NAME}.app/Contents/MacOS/${APP_NAME}" || exit 1 |
||
51 | |||
52 | # deploy the SDL2 framework |
||
53 | echo "Deploying SDL2 framework..." |
||
54 | cp -pPR SDL2.framework "${APP_NAME}.app/Contents/Frameworks" || exit 1 |
||
55 | rm -rf "${APP_NAME}.app/Contents/Frameworks/SDL2.framework/Versions/A/_CodeSignature" |
||
56 | rm -rf "${APP_NAME}.app/Contents/Frameworks/SDL2.framework/Versions/A/Headers" |
||
57 | rm -rf "${APP_NAME}.app/Contents/Frameworks/SDL2.framework/Headers" |
||
58 | |||
59 | # deploy the game data |
||
60 | echo "Deploying game data..." |
||
61 | cp -pPR DATA "${APP_NAME}.app/Contents/Resources" || exit 1 |
||
62 | |||
63 | # generate and deploy the app icon |
||
64 | echo "Generating app icon..." |
||
65 | mkdir ".build/${APP_NAME}.iconset" || exit 1 |
||
66 | sips -z 16 16 "${ICON_FILE}" --out ".build/${APP_NAME}.iconset/icon_16x16.png" > /dev/null |
||
67 | sips -z 32 32 "${ICON_FILE}" --out ".build/${APP_NAME}.iconset/icon_16x16@2x.png" > /dev/null |
||
68 | sips -z 32 32 "${ICON_FILE}" --out ".build/${APP_NAME}.iconset/icon_32x32.png" > /dev/null |
||
69 | sips -z 64 64 "${ICON_FILE}" --out ".build/${APP_NAME}.iconset/icon_32x32@2x.png" > /dev/null |
||
70 | sips -z 128 128 "${ICON_FILE}" --out ".build/${APP_NAME}.iconset/icon_128x128.png" > /dev/null |
||
71 | sips -z 256 256 "${ICON_FILE}" --out ".build/${APP_NAME}.iconset/icon_128x128@2x.png" > /dev/null |
||
72 | sips -z 256 256 "${ICON_FILE}" --out ".build/${APP_NAME}.iconset/icon_256x256.png" > /dev/null |
||
73 | sips -z 512 512 "${ICON_FILE}" --out ".build/${APP_NAME}.iconset/icon_256x256@2x.png" > /dev/null |
||
74 | sips -z 512 512 "${ICON_FILE}" --out ".build/${APP_NAME}.iconset/icon_512x512.png" > /dev/null |
||
75 | sips -z 1024 1024 "${ICON_FILE}" --out ".build/${APP_NAME}.iconset/icon_512x512@2x.png" > /dev/null |
||
76 | iconutil -c icns ".build/${APP_NAME}.iconset" -o "${APP_NAME}.app/Contents/Resources/AppIcon.icns" || exit 1 |
||
77 | |||
78 | # generate the PkgInfo file |
||
79 | echo -n "APPL???" > "${APP_NAME}.app/Contents/PkgInfo" || exit 1 |
||
80 | |||
81 | # generate the Info.plist |
||
82 | ( |
||
83 | echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
||
84 | echo "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" |
||
85 | echo "<plist version=\"1.0\">" |
||
86 | echo "<dict>" |
||
87 | echo " <key>CFBundleDevelopmentRegion</key>" |
||
88 | echo " <string>en</string>" |
||
89 | echo " <key>CFBundleExecutable</key>" |
||
90 | echo " <string>${APP_NAME}</string>" |
||
91 | echo " <key>CFBundleIconFile</key>" |
||
92 | echo " <string>AppIcon.icns</string>" |
||
93 | echo " <key>CFBundleIdentifier</key>" |
||
94 | echo " <string>${BUNDLE_ID}</string>" |
||
95 | echo " <key>CFBundleInfoDictionaryVersion</key>" |
||
96 | echo " <string>6.0</string>" |
||
97 | echo " <key>CFBundleName</key>" |
||
98 | echo " <string>${APP_NAME}</string>" |
||
99 | echo " <key>CFBundleVersion</key>" |
||
100 | echo " <string>${APP_VERSION}</string>" |
||
101 | echo " <key>NSHumanReadableCopyright</key>" |
||
102 | echo " <string>${APP_COPYRIGHT}</string>" |
||
103 | echo " <key>CFBundlePackageType</key>" |
||
104 | echo " <string>APPL</string>" |
||
105 | echo " <key>CFBundleSignature</key>" |
||
106 | echo " <string>????</string>" |
||
107 | echo "</dict>" |
||
108 | echo "</plist>" |
||
109 | ) > "${APP_NAME}.app/Contents/Info.plist" || exit 1 |
||
110 | |||
111 | # finished |
||
112 | echo "Carmageddon was built successfully" |
||
113 | exit 0 |