forked from Leseratte10/d2xl-cios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maked2x.sh
executable file
·174 lines (149 loc) · 6.18 KB
/
maked2x.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/bash
OLD_DIR=`pwd`
# Set clean var, removes build and dist, and calls make_modules
make_clean() {
export CLEAN=clean
[ -d "build" ] && rm -rf build
[ -d "dist" ] && rm -rf dist
make_modules
}
# Replace variables on certain files
replace_vars() {
echo -n Replacing variables in $1...
awk -v major_ver=${MAJOR_VERSION} -v minor_ver=${MINOR_VERSION} -f replace.awk "data/$1" > "$2/$1"
echo done
}
# Build or clean library, plugins and modules
make_modules() {
do_make cios-lib "" ${CLEAN}
do_make dip-plugin ${D2XBUILD}/DIPP ${CLEAN}
do_make ehci-module ${D2XBUILD}/EHCI ${CLEAN}
do_make es-plugin ${D2XBUILD}/ES ${CLEAN}
do_make fat-module ${D2XBUILD}/FAT ${CLEAN}
do_make ffs-plugin ${D2XBUILD}/FFSP ${CLEAN}
do_make mload-module ${D2XBUILD}/MLOAD ${CLEAN}
do_make sdhc-module ${D2XBUILD}/SDHC ${CLEAN}
do_make usb-module ${D2XBUILD}/USBS ${CLEAN}
[ "${CLEAN}" == "clean" ] && completed
# Replace variables in some files
replace_vars ciosmaps.xml build
replace_vars d2x-beta.bat build/${D2XBUILD}
replace_vars ReadMe.txt build
# Copy Changelog.txt to the build directory
cp data/Changelog.txt build
# When docker is built it has downloaded some content in its image, e.g. FAKEMOTE by xerpi please see
# https://gbatemp.net/threads/release-fakemote-an-ios-module-that-fakes-wiimotes-from-the-input-of-usb-game-controllers.601771/
cp -p /opt/content/* "build/${D2XBUILD}"
# Make duplicates of binaries so that they will show up as different groups in d2x-cios-installer. In my opinion this is the
# less risky solution in the wrong hands. Leseratte added console= and region= tags to ciosmaps.xml. A new d2x-cios-installer
# is needed with enhancements to support those new tags and filter the user interface so that only the options pertinent to the
# user's hardware are shown. However, nothing stops users from using this cIOS with existing the d2x-cios-installer with no
# such support, and then proceed to install the wrong cIOS on the wrong console (e.g. Wii cIOS on vWii). The safest thing to do
# IMO is to group them into ciosgroups. Time comes when somebody makes a new d2x-cios-installer it can still support
# Leseratte's new tags and filter the options. The only cost to this arrangement is file duplication and extra disk/SD card
# space.
cp -fprT "build/${D2XBUILD}" "build/${D2XBASENAME}-vWii"
cp -fprT "build/${D2XBUILD}" "build/${D2XBASENAME}-WiiMini-NTSCU"
cp -fprT "build/${D2XBUILD}" "build/${D2XBASENAME}-WiiMini-PAL"
[ -z "${DIST}" ] && completed
echo
echo -n Creating distribution package...
# Copy files to ModMii
[ -d "dist/Support/d2x-beta" ] && rm -rf dist/Support/d2x-beta
mkdir -p dist/Support/d2x-beta
cp build/${D2XBUILD}/* dist/Support/d2x-beta
cp build/ciosmaps.xml dist/Support/d2x-beta
cp build/ReadMe.txt dist/Support/d2x-beta
cp build/Changelog.txt dist/Support/d2x-beta
echo done
echo
echo "The files are copied to the directory dist/Support/d2x-beta. From there"
echo "you need to copy/move the Support directory into the ModMii directory."
echo
echo "You need to invoke ModMii yourself, on a Windows installation :|"
echo
}
do_make() {
echo
echo Making $1 $3...
cd source/$1
make $3 STRIP=../stripios
if [ $? != 0 ]; then
echo
echo Build failed!!!
quit
fi
if [ "$3" != "clean" ]; then
if [ ! -z "$2" ]; then
cp $1.elf ../../build/$2.app
fi
fi
cd - > /dev/null
}
quit() {
cd ${OLD_DIR}
exit 1
}
completed() {
echo
echo Done!
echo
exit 0
}
menu() {
echo
echo "Usage 1: $0 [<major_version> [<minor_version> [dist | DIST]]]"
echo " It builds d2xl with the specified major and minor version."
echo " Default values are \"999\" and \"unknown\" respectively."
echo " If option dist or DIST is specified then a zip file is generated, i.e. the"
echo " distribution package. Be aware that:"
echo " - it may take several minutes"
echo " - ModMii is required --> http://gbatemp.net/topic/207126-modmii-for-windows"
echo " - the MODMII environment variable must be set to ModMii install directory"
echo " - internet connection is required"
echo " Contrary to DIST, the dist option removes the generated files from ModMii,"
echo " allowing you to keep it clean."
echo " Examples:"
echo " "$0
echo " "$0 1
echo " "$0 1 final
echo
echo "Usage 2: "$0 clean
echo " It permanently deletes any previous build and dist."
echo
exit 0
}
[ "$1" == "/?" ] && menu
[ "$1" == "-h" ] && menu
[ "$1" == "clean" ] && make_clean
# Set default values
export CLEAN=""
export MAJOR_VERSION=$1
[ -z "${MAJOR_VERSION}" ] && export MAJOR_VERSION="999"
export MINOR_VERSION=$2
[ -z "${MINOR_VERSION}" ] && export MINOR_VERSION=".unknown"
export DIST=$3
# Check arguments
if [[ "${MAJOR_VERSION}" =~ [^0-9] ]]; then
echo "ERROR: The argument <major_version> must be a number"
menu
fi
if [ "${MAJOR_VERSION}" -gt 999 ]; then
echo "ERROR: The argument <major_version> can't be greater than 999"
menu
fi
if [ ${#MINOR_VERSION} -gt 15 ]; then
echo "ERROR: The argument <minor_version> can\'t be longer than 15 characters"
menu
fi
if [ ! -z "${DIST}" ] && [ "${DIST}" != "dist" ]; then
echo ERROR: The 3rd argument must be \"dist\" or empty
menu
fi
D2XBASENAME=d2xl-v${MAJOR_VERSION}${MINOR_VERSION}
export D2XBUILD=${D2XBASENAME}-Wii
echo -----------------------------
echo Building ${D2XBUILD}
echo -----------------------------
[ ! -d "build/${D2XBUILD}" ] && mkdir -p "build/${D2XBUILD}"
make_modules