1 # Definitions for build scripts
3 # Copyright (C) 2012-2014 Gregor Richards
5 # Permission to use, copy, modify, and/or distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10 # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 # AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12 # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14 # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 # PERFORMANCE OF THIS SOFTWARE.
26 echo 'Create a config.sh file.'
30 # Versions of things (do this before config.sh so they can be config'd)
31 #BINUTILS_URL=http://ftp.gnu.org/gnu/binutils/binutils-2.25.1.tar.bz2
32 BINUTILS_URL
=http
://mirrors.kernel.org
/sourceware
/binutils
/snapshots
/binutils-2.24
.90.
tar.bz2
33 #last GPL2 release is 2.17, with backported -Bsymbolic support
34 #BINUTILS_URL=http://landley.net/aboriginal/mirror/binutils-2.17.tar.bz2
41 # check available versions at ftp://sourceware.org/pub/newlib/index.html
44 # You can choose languages
51 # Auto-deteect an ARCH if not specified
52 test -z "$ARCH" && ARCH
=mmix
53 test -z "$TRIPLE" && TRIPLE
=mmix
55 # Choose our languages
57 [ "$LANG_CXX" = "yes" ] && LANGUAGES
="$LANGUAGES,c++"
58 [ "$LANG_OBJC" = "yes" ] && LANGUAGES
="$LANGUAGES,objc"
59 [ "$LANG_CXX" = "yes" -a "$LANG_OBJC" = "yes" ] && LANGUAGES
="$LANGUAGES,obj-c++"
60 [ "$LANG_FORTRAN" = "yes" ] && LANGUAGES
="$LANGUAGES,fortran"
62 # Use gmake if it exists
66 gmake
--help > /dev
/null
2>&1 && MAKE
=gmake
69 # Generate CC_PREFIX from CC_BASE_PREFIX and TRIPLE if not specified
70 [ -n "$CC_BASE_PREFIX" -a -z "$CC_PREFIX" ] && CC_PREFIX
="$CC_BASE_PREFIX/$TRIPLE"
71 [ -z "$CC_PREFIX" ] && die
'Failed to determine a CC_PREFIX.'
73 PATH
="$CC_PREFIX/bin:$PATH"
76 # Get the target-specific multilib option, if applicable
77 GCC_MULTILIB_CONFFLAGS
="--disable-multilib --with-multilib-list="
78 if [ "$ARCH" = "x32" ]
80 GCC_MULTILIB_CONFFLAGS
="--with-multilib-list=mx32"
89 if [ ! -e "$MUSL_CC_BASE/tarballs/$2" ]
91 wget
-O "$MUSL_CC_BASE/tarballs/$2.part" -c "$1""$2"
92 mv "$MUSL_CC_BASE/tarballs/$2.part" "$MUSL_CC_BASE/tarballs/$2"
98 if [ ! -e "$2/extracted.$3" ]
100 tar xf
"$MUSL_CC_BASE/tarballs/$1" ||
101 tar Jxf
"$MUSL_CC_BASE/tarballs/$1" ||
102 tar jxf
"$MUSL_CC_BASE/tarballs/$1" ||
103 tar zxf
"$MUSL_CC_BASE/tarballs/$1"
105 touch "$2/extracted.$3"
111 *.
tar.
*) printf "%s" "$1"|
sed 's/\.tar\.[0-9a-z]*$//' ;;
112 *) basename "$1" |
sed 's/\..*//' ;;
120 [ -z "$2" ] && baseurl
=$
(printf "%s" "$1" |
sed 's/\(.*\/\).*/\1/')
122 [ -z "$dir" ] && dir
=$
(stripfileext $
(basename "$1"))
124 [ -z "$fn" ] && fn
=$
(basename "$1")
126 fetch
"$baseurl" "$fn"
127 extract
"$fn" "$dir" "$name"
133 if [ ! -e "$MUSL_CC_BASE/tarballs/$3".
tar.gz
]
135 git archive
--format=tar --remote="$1" "$2" | \
136 gzip -c > "$MUSL_CC_BASE/tarballs/$3".
tar.gz || die
"Failed to fetch $3-$2"
138 if [ ! -e "$3/extracted.$name" ]
142 cd "$3" || die
"Failed to cd $3"
143 extract
"$3".
tar.gz extracted
144 touch extracted.
$name
149 newlibfetchextract
() {
150 fetchextract newlib http
://sourceware.org
/pub
/newlib
/ newlib-
${NEWLIB_VERSION} .
tar.gz
154 if [ ! -e gcc-
$GCC_VERSION/gmp
]
156 fetchextract gmp http
://ftp.gnu.org
/pub
/gnu
/gmp
/ gmp-
$GMP_VERSION .
tar.bz2
157 mv gmp-
$GMP_VERSION gcc-
$GCC_VERSION/gmp
160 if [ ! -e gcc-
$GCC_VERSION/mpfr
]
162 fetchextract mpfr http
://ftp.gnu.org
/gnu
/mpfr
/ mpfr-
$MPFR_VERSION .
tar.bz2
163 mv mpfr-
$MPFR_VERSION gcc-
$GCC_VERSION/mpfr
166 if [ ! -e gcc-
$GCC_VERSION/mpc
]
168 fetchextract mpc https
://ftp.gnu.org
/gnu
/mpc
/ mpc-
$MPC_VERSION .
tar.gz
169 mv mpc-
$MPC_VERSION gcc-
$GCC_VERSION/mpc
177 cd "$BD" || die
"Failed to cd $BD"
181 for f
in "$MUSL_CC_BASE/patches/$BD"-*.
diff ; do
182 if [ -e "$f" ] ; then patch -p1 < "$f" || die
"Failed to apply patch $f to $BD" ; fi
193 BUILT
="$PWD/$BD/built$BP"
201 cd "$BD" || die
"Failed to cd $BD"
206 cd build
"$BP" || die
"Failed to cd to build dir for $BD $BP"
209 ( $CF --prefix="$PREFIX" "$@" &&
212 die
"Failed to build $BD"
220 BUILT
="$PWD/$BD/built"
228 cd "$BD" || die
"Failed to cd $BD"
230 ( $MAKE "$@" $MAKEFLAGS &&
232 die
"Failed to build $BD"
241 INSTALLED
="$PWD/$BD/installed$BP"
244 if [ ! -e "$INSTALLED" ]
247 cd "$BD" || die
"Failed to cd $BD"
251 cd build
"$BP" || die
"Failed to cd build$BP"
254 ( $MAKE install "$@" $MAKEINSTALLFLAGS &&
255 touch "$INSTALLED" ) ||
256 die
"Failed to install $BP"