-
Notifications
You must be signed in to change notification settings - Fork 0
/
bselect
executable file
·159 lines (133 loc) · 6.2 KB
/
bselect
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
#!/bin/bash
set -e
echo -e "Build Select v1.0.2\nAlex Free, (c) 2020-2024 (3-BSD)"
if [ ! -d "/Developer" ]; then
echo "Xcode must be installed to /Developer to use bselect"
exit 1
fi
if [ -z "$1" ]; then
echo "First argument must be -i, -u, 3.3, 4.0, or 4.2"
exit 1
elif [ "$1" = "-i" ]; then
rm -rf ~/Library/Preferences/build_select
mkdir ~/Library/Preferences/build_select
echo "#!/bin/bash
/usr/bin/gcc-4.0 "'"$@"'"" > ~/Library/Preferences/build_select/cc
echo "#!/bin/bash
/usr/bin/gcc-4.0 "'"$@"'"" > ~/Library/Preferences/build_select/gcc
echo "#!/bin/bash
/usr/bin/c++-4.0 "'"$@"'"" > ~/Library/Preferences/build_select/c++
echo "#!/bin/bash
/usr/bin/g++-4.0 "'"$@"'"" > ~/Library/Preferences/build_select/g++
chmod -R 775 ~/Library/Preferences/build_select/cc ~/Library/Preferences/build_select/gcc ~/Library/Preferences/build_select/c++ ~/Library/Preferences/build_select/g++
echo "Info: root privileges are required to finish installation"
sudo rm -rf /usr/bin/gcc /usr/bin/cc /usr/bin/c++ /usr/bin/g++
sudo ln -s ~/Library/Preferences/build_select/cc /usr/bin/cc
sudo ln -s ~/Library/Preferences/build_select/gcc /usr/bin/gcc
sudo ln -s ~/Library/Preferences/build_select/c++ /usr/bin/c++
sudo ln -s ~/Library/Preferences/build_select/g++ /usr/bin/g++
echo -e "\nBuild select has been installed. Run build select again to set up additional settings."
exit 0
elif [ "$1" = "-u" ]; then
echo "Info: root privileges are required to finish installation"
rm -rf ~/Library/Preferences/build_select
sudo rm -rf /usr/bin/gcc /usr/bin/cc /usr/bin/c++ /usr/bin/g++
sudo ln -s /usr/bin/gcc-4.0 /usr/bin/cc
sudo ln -s /usr/bin/gcc-4.0 /usr/bin/gcc
sudo ln -s /usr/bin/g++-4.0 /usr/bin/g++
sudo ln -s /usr/bin/c++-4.0 /usr/bin/c++
echo "Xcode compiler has been reset to defaults:"
gcc --version
g++ --version
exit 0
elif [ "$1" = "--help" ]; then
echo "
Usage:
bselect -i Install build select.
bselect -u Uninstall build select.
bselect --help Display this text.
bselect <compiler_version> <sdk_version> <arch> <macosx_deployment_target> <additional_flags>
The first argument is the compiler version. Valid options are 3.3, 4.0, and 4.2.
The second argument is the SDK version. Valid options are 10.3.9, 10.4u, and 10.5.
The third argument is the arch to compile for. Valid options are ppc, ppc750, ppc7400, ppc7450, and ppc970. If you compile for a newer arch then what your Mac is itself, you will not be able to execute what you compile on that Mac.
The fourth argument is the MACOSX_DEPLOYMENT_TARGET value. This may be the same as your SDK or lower. Valid options are 10.3, 10.4, and 10.5.
The fifth argument of additional flags is the only argument that is optional. If you specify additional flags that contain spaces, you must double quote them.
Example: Compile with the GCC 4.2 compiler using the MAC OS X 10.4u SDK for the generic ppc arch at the Mac OS X 10.3 panther API value. Targets Mac OS X 10.3.9 ppc.
"$0" 4.2 10.4u ppc 10.3 "'"-I/usr/local/my_custom_include_dir -L/usr/local/my_custom_lib_dir"'""
exit 0
fi
if [ ! -e "/usr/bin/gcc-4.2" ] && [ "$1" = 4.2 ]; then
echo "Error: GCC 4.2 is not installed, this is expected when using older Xcode versions and or an OS older then Leopard. You may not select this compiler."
exit 1
elif [ ! -e "/usr/bin/gcc-3.3" ] && [ "$1" = 3.3 ]; then
echo "Error: GCC 3.3 is not installed, you may have not selected it when installing Xcode. You may not select this compiler."
exit 1
else
if [ "$1" = 3.3 ] || [ "$1" = 4.0 ] || [ "$1" = 4.2 ]; then
echo "Compiler: GCC "$1""
else
echo
echo ""$1" is not 3.3, 4.0, or 4.2."
exit 1
fi
fi
if [ -z "$2" ]; then
echo "Second argument must be 10.3.9, 10.4u, or 10.5"
exit 1
else
if [ "$2" = 10.3.9 ] || [ "$2" = 10.4u ] || [ "$2" = 10.5 ]; then
echo "SDK: "$2""
else
echo
echo "SDK "$2" is not 10.3.9, 10.4u, or 10.5"
exit 1
fi
fi
if [ -z "$3" ]; then
echo "Third argument must be ppc, ppc750, ppc7400, ppc7450, or ppc970"
exit 1
else
if [ "$3" = ppc750 ] || [ "$3" = ppc7400 ] || [ "$3" = ppc7450 ] || [ "$3" = ppc970 ] || [ "$3" = ppc ];then
echo "Arch: "$3""
else
echo
echo "Arch "$3" is not ppc, ppc750, ppc7400, ppc7450, or ppc970"
exit 1
fi
fi
if [ -z "$4" ]; then
echo "Forth argument must be 10.3, 10.4, or 10.5"
exit 1
else
if [ "$4" = 10.3 ] || [ "$4" = 10.4 ] || [ "$4" = 10.5 ];then
echo "MACOSX_DEPLOYMENT_TARGET: "$4""
else
echo
echo "MACOSX_DEPLOYMENT_TARGET "$4" is not 10.3, 10.4, or 10.5"
exit 1
fi
fi
if [ ! -d "$HOME/Library/Preferences/build_select" ]; then
echo "You must install build select before using these options."
exit 1
fi
if [ -z "$5" ]; then
echo "#!/bin/bash
/usr/bin/gcc-"$1" -arch "$3" -isysroot/Developer/SDKs/MacOSX"$2".sdk -mmacosx-version-min="$4" "'"$@"'"" > ~/Library/Preferences/build_select/cc
echo "#!/bin/bash
/usr/bin/gcc-"$1" -arch "$3" -isysroot/Developer/SDKs/MacOSX"$2".sdk -mmacosx-version-min="$4" "'"$@"'"" > ~/Library/Preferences/build_select/gcc
echo "#!/bin/bash
/usr/bin/c++-"$1" -arch "$3" -isysroot/Developer/SDKs/MacOSX"$2".sdk -mmacosx-version-min="$4" "'"$@"'"" > ~/Library/Preferences/build_select/c++
echo "#!/bin/bash
/usr/bin/g++-"$1" -arch "$3" -isysroot/Developer/SDKs/MacOSX"$2".sdk -mmacosx-version-min="$4" "'"$@"'"" > ~/Library/Preferences/build_select/g++
else
echo "Additional flags: "$5""
echo "#!/bin/bash
/usr/bin/gcc-"$1" -arch "$3" -isysroot/Developer/SDKs/MacOSX"$2".sdk -mmacosx-version-min="$4" "$5" "'"$@"'"" > ~/Library/Preferences/build_select/cc
echo "#!/bin/bash
/usr/bin/gcc-"$1" -arch "$3" -isysroot/Developer/SDKs/MacOSX"$2".sdk -mmacosx-version-min="$4" "$5" "'"$@"'"" > ~/Library/Preferences/build_select/gcc
echo "#!/bin/bash
/usr/bin/c++-"$1" -arch "$3" -isysroot/Developer/SDKs/MacOSX"$2".sdk -mmacosx-version-min="$4" "$5" "'"$@"'"" > ~/Library/Preferences/build_select/c++
echo "#!/bin/bash
/usr/bin/g++-"$1" -arch "$3" -isysroot/Developer/SDKs/MacOSX"$2".sdk -mmacosx-version-min="$4" "$5" "'"$@"'"" > ~/Library/Preferences/build_select/g++
fi