forked from SaturnSDK/Saturn-SDK-GCC-SH2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-canadian.sh
executable file
·126 lines (99 loc) · 2.56 KB
/
build-canadian.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
#!/bin/bash
if [[ "$HOSTMACH" == "$BUILDMACH" ]]; then
echo "Build and host are the same. Building a cross compiler for one host/build architecture"
./build.sh
exit $?
fi
if [ -z $INSTALLDIR_BUILD_TARGET ]; then
INSTALLDIR_BUILD_TARGET=${INSTALLDIR}_build_target
fi
if [ -z $NCPU ]; then
# Mac OS X
if $(command -v sysctl >/dev/null 2>&1); then
export NCPU=`sysctl -n hw.ncpu`
# coreutils
elif $(command -v nproc >/dev/null 2>&1); then
export NCPU=`nproc`
# fallback to non-parallel build if we still have no idea
else
export NCPU=1
fi
fi
[ -d $INSTALLDIR ] && rm -rf $INSTALLDIR
[ -d ${INSTALLDIR_BUILD_TARGET} ] && rm -rf ${INSTALLDIR_BUILD_TARGET}
HOSTORIG=$HOSTMACH
PREFIXORIG=$PROGRAM_PREFIX
if [ -z $SKIP_DOWNLOAD ]; then
./download.sh
if [ $? -ne 0 ]; then
echo "Failed to retrieve the files necessary for building GCC"
exit 1
fi
fi
./extract-source.sh
if [ $? -ne 0 ]; then
echo "Failed to extract the source files"
exit 1
fi
./patch.sh
if [ $? -ne 0 ]; then
echo "Failed to patch packages"
exit 1
fi
# Build the cross compiler for the build
# NOT IMPLEMENTED
# Build the cross compiler for the target
export HOSTMACH=$BUILDMACH
export PROGRAM_PREFIX=${TARGETMACH}-
CURRENT_COMPILER="${TARGETMACH} running on ${HOSTMACH}"
#export PROGRAM_PREFIX=${PREFIXORIG}
./build-binutils.sh
if [ $? -ne 0 ]; then
echo "Failed to build binutils for ${CURRENT_COMPILER}"
exit 1
fi
./build-gcc-bootstrap.sh
if [ $? -ne 0 ]; then
echo "Failed to build GCC bootstrap for ${CURRENT_COMPILER}"
exit 1
fi
./build-newlib.sh
if [ $? -ne 0 ]; then
echo "Failed to build newlib for ${CURRENT_COMPILER}"
exit 1
fi
./build-gcc-final.sh
if [ $? -ne 0 ]; then
echo "Failed to build final GCC for ${CURRENT_COMPILER}"
exit 1
fi
export PROGRAM_PREFIX=$PREFIXORIG
mv ${INSTALLDIR} ${INSTALLDIR_BUILD_TARGET}
export PATH=${INSTALLDIR_BUILD_TARGET}/bin:$PATH
# Build the cross compiler for the target using the host to build
export HOSTMACH=$HOSTORIG
CURRENT_COMPILER="${TARGETMACH} running on ${HOSTMACH}"
./build-binutils.sh
if [ $? -ne 0 ]; then
echo "Failed to build binutils for ${CURRENT_COMPILER}"
exit 1
fi
./build-gcc-bootstrap.sh
if [ $? -ne 0 ]; then
echo "Failed to build GCC bootstrap for ${CURRENT_COMPILER}"
exit 1
fi
export PROGRAM_PREFIX=${TARGETMACH}-
./build-newlib.sh
if [ $? -ne 0 ]; then
echo "Failed to build newlib for ${CURRENT_COMPILER}"
exit 1
fi
export PROGRAM_PREFIX=$PREFIXORIG
./build-gcc-final.sh
if [ $? -ne 0 ]; then
echo "Failed to build final GCC for ${CURRENT_COMPILER}"
exit 1
else
echo "Successfully built GCC for ${CURRENT_COMPILER}"
fi