2 # Build tarballs of various musl cross-compilers
5 # build-tarballs.sh /opt/cross/musl crossx86- -1.1 i486 x86_64 x32 arm \
6 # armeb armhf microblaze mips mipsel mips-sf mipsel-sf powerpc sh4 sh4eb
8 # Copyright (C) 2012-2014 Gregor Richards
10 # Permission to use, copy, modify, and/or distribute this software for any
11 # purpose with or without fee is hereby granted, provided that the above
12 # copyright notice and this permission notice appear in all copies.
14 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
15 # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
16 # AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
17 # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
18 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19 # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 # PERFORMANCE OF THIS SOFTWARE.
22 if [ ! "$MUSL_CC_BASE" ]
24 MUSL_CC_BASE
=`dirname "$0"`/..
30 HG_ID
=`cd "$MUSL_CC_BASE" ; hg id | sed 's/ .*//'`
33 for pkg
in binutils gcc linux kernel-headers musl gmp mpfr mpc
35 for bf
in configured build built installed
42 for pkg
in musl-
*/ gmp-
*/ mpfr-
*/ mpc-
*/
46 make distclean || true
54 echo 'Please use a fresh directory.'
61 echo 'Use: .../build-tarballs.sh <install prefix> <tarball prefix> <tarball suffix> <native arch> [other archs]'
77 TRIPLE
="arm-linux-musleabihf"
80 TRIPLE
="$ARCH-linux-musleabi"
83 TRIPLE
="x86_64-x32-linux-musl"
86 TRIPLE
="$ARCH-linux-musl"
90 if [ "$ARCH" = "$NATIVE_ARCH" ]
92 if [ ! -e "$PREFIX_BASE/bootstrap/bin/$TRIPLE-g++" ]
97 CC_PREFIX="'"$PREFIX_BASE/bootstrap"'"
98 MAKEFLAGS="'"$MAKEFLAGS"'"
99 . ./extraconfig.sh' > config.sh
101 # Build the bootstrap one first
102 "$MUSL_CC_BASE"/build.sh
103 "$MUSL_CC_BASE"/extra
/build-gcc-deps.sh
108 NATIVE_CROSS
="$PREFIX_BASE/bootstrap/bin/$TRIPLE"
110 # Get rid of dlfcn.h as a cheap hack to disable building plugins
111 rm -f "$PREFIX_BASE/bootstrap/$TRIPLE/include/dlfcn.h"
114 if [ ! -e "$PREFIX_BASE/$TRIPLE/bin/$TRIPLE-g++" ]
119 CC_PREFIX="'"$PREFIX_BASE/$TRIPLE"'"
120 MAKEFLAGS="'"$MAKEFLAGS"'"
121 CC="'"$NATIVE_CROSS-gcc"' -static -Wl,-Bstatic -static-libgcc"
122 CXX="'"$NATIVE_CROSS-g++"' -static -Wl,-Bstatic -static-libgcc"
124 GCC_BOOTSTRAP_CONFFLAGS=--disable-lto-plugin
125 GCC_CONFFLAGS=--disable-lto-plugin
126 . ./extraconfig.sh' > config.sh
129 "$MUSL_CC_BASE"/build.sh
130 sed -E '/^C(C|XX)=/d ; /^export/d' -i config.sh
131 [ "$NO_GCC_DEPS" != "yes"] && "$MUSL_CC_BASE"/extra
/build-gcc-deps.sh
138 cp -f extraconfig.sh
"$PREFIX_BASE/$TRIPLE/extraconfig.sh"
141 rm -rf "$TRIPLE/share"
142 find "$TRIPLE/bin" "$TRIPLE/libexec/gcc" -type f
-exec "$NATIVE_CROSS-strip" --strip-unneeded '{}' ';'
143 echo 'Cross-compiler prefix built by musl-cross '"$HG_ID"': http://www.bitbucket.org/GregorR/musl-cross' > "$TRIPLE/info.txt"
144 tar -cf - "$TRIPLE/" | xz
-c > "$T_PRE$TRIPLE$T_SUFF.tar.xz"