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=ftp://sourceware.org/pub/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 # use kernel headers from vanilla linux kernel - may be necessary for porting to a bleeding-edge arch
42 # LINUX_HEADERS_URL=http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.12.6.tar.xz
43 # use patched sabotage-linux kernel-headers package (fixes userspace clashes of some kernel structs)
44 # from upstream repo https://github.com/sabotage-linux/kernel-headers
45 LINUX_HEADERS_URL
=http
://ftp.barfooze.de
/pub
/sabotage
/tarballs
/kernel-headers-3.12
.6-5.
tar.xz
47 # musl can optionally be checked out from GIT, in which case MUSL_VERSION must
48 # be set to a git tag and MUSL_GIT set to yes in config.sh
49 MUSL_DEFAULT_VERSION
=1.1.15
50 MUSL_GIT_VERSION
=faf69b9a73d09fafcbe4fd3007b8d8724293d8e1
51 MUSL_GIT_REPO
='git://repo.or.cz/musl.git'
52 MUSL_VERSION
="$MUSL_DEFAULT_VERSION"
55 # You can choose languages
62 # Auto-deteect an ARCH if not specified
65 for MAYBECC
in cc gcc clang
67 $MAYBECC -dumpmachine > /dev
/null
2> /dev
/null
&&
68 ARCH
=`$MAYBECC -dumpmachine | sed 's/-.*//'` &&
73 [ -z "$ARCH" ] && ARCH
=`uname -m`
76 # Auto-detect a TRIPLE if not specified
82 TRIPLE
="$ARCH-linux-musleabihf"
86 TRIPLE
="$ARCH-linux-musleabi"
90 TRIPLE
="x86_64-x32-linux-musl"
94 TRIPLE
="$ARCH-linux-musl"
99 # Choose our languages
101 [ "$LANG_CXX" = "yes" ] && LANGUAGES
="$LANGUAGES,c++"
102 [ "$LANG_OBJC" = "yes" ] && LANGUAGES
="$LANGUAGES,objc"
103 [ "$LANG_CXX" = "yes" -a "$LANG_OBJC" = "yes" ] && LANGUAGES
="$LANGUAGES,obj-c++"
104 [ "$LANG_FORTRAN" = "yes" ] && LANGUAGES
="$LANGUAGES,fortran"
106 # Use gmake if it exists
110 gmake
--help > /dev
/null
2>&1 && MAKE
=gmake
113 # Generate CC_PREFIX from CC_BASE_PREFIX and TRIPLE if not specified
114 [ -n "$CC_BASE_PREFIX" -a -z "$CC_PREFIX" ] && CC_PREFIX
="$CC_BASE_PREFIX/$TRIPLE"
115 [ -z "$CC_PREFIX" ] && die
'Failed to determine a CC_PREFIX.'
117 PATH
="$CC_PREFIX/bin:$PATH"
120 # Get our Linux arch and defconfig
121 LINUX_ARCH
=`echo "$ARCH" | sed 's/-.*//'`
122 LINUX_DEFCONFIG
=defconfig
123 case "$LINUX_ARCH" in
124 i
*86) LINUX_ARCH
=i386
;;
125 x32
) LINUX_ARCH
=x86_64
;;
126 arm
*) LINUX_ARCH
=arm
;;
127 aarch64
*) LINUX_ARCH
=arm64
;;
128 mips
*) LINUX_ARCH
=mips
;;
129 or1k
*) LINUX_ARCH
=openrisc
;;
130 sh
*) LINUX_ARCH
=sh
;;
134 LINUX_DEFCONFIG
=g5_defconfig
138 LINUX_DEFCONFIG
=mmu_defconfig
143 # Get the target-specific multilib option, if applicable
144 GCC_MULTILIB_CONFFLAGS
="--disable-multilib --with-multilib-list="
145 if [ "$ARCH" = "x32" ]
147 GCC_MULTILIB_CONFFLAGS
="--with-multilib-list=mx32"
156 if [ ! -e "$MUSL_CC_BASE/tarballs/$2" ]
158 wget
-O "$MUSL_CC_BASE/tarballs/$2.part" -c "$1""$2"
159 mv "$MUSL_CC_BASE/tarballs/$2.part" "$MUSL_CC_BASE/tarballs/$2"
165 if [ ! -e "$2/extracted" ]
167 tar xf
"$MUSL_CC_BASE/tarballs/$1" ||
168 tar Jxf
"$MUSL_CC_BASE/tarballs/$1" ||
169 tar jxf
"$MUSL_CC_BASE/tarballs/$1" ||
170 tar zxf
"$MUSL_CC_BASE/tarballs/$1"
178 *.
tar.
*) printf "%s" "$1"|
sed 's/\.tar\.[0-9a-z]*$//' ;;
179 *) basename "$1" |
sed 's/\..*//' ;;
185 [ -z "$2" ] && baseurl
=$
(printf "%s" "$1" |
sed 's/\(.*\/\).*/\1/')
187 [ -z "$dir" ] && dir
=$
(stripfileext $
(basename "$1"))
189 [ -z "$fn" ] && fn
=$
(basename "$1")
191 fetch
"$baseurl" "$fn"
196 if [ ! -e "$MUSL_CC_BASE/tarballs/$3".
tar.gz
]
198 git archive
--format=tar --remote="$1" "$2" | \
199 gzip -c > "$MUSL_CC_BASE/tarballs/$3".
tar.gz || die
"Failed to fetch $3-$2"
201 if [ ! -e "$3/extracted" ]
205 cd "$3" || die
"Failed to cd $3"
206 extract
"$3".
tar.gz extracted
213 if [ "$MUSL_GIT" = "yes" ]
215 gitfetchextract
"$MUSL_GIT_REPO" $MUSL_VERSION musl-
$MUSL_VERSION
217 fetchextract http
://www.musl-libc.org
/releases
/ musl-
$MUSL_VERSION .
tar.gz
222 if [ ! -e gcc-
$GCC_VERSION/gmp
]
224 fetchextract http
://gmplib.org
/download
/gmp
/archive
/ gmp-
$GMP_VERSION .
tar.bz2
225 mv gmp-
$GMP_VERSION gcc-
$GCC_VERSION/gmp
228 if [ ! -e gcc-
$GCC_VERSION/mpfr
]
230 fetchextract http
://ftp.gnu.org
/gnu
/mpfr
/ mpfr-
$MPFR_VERSION .
tar.bz2
231 mv mpfr-
$MPFR_VERSION gcc-
$GCC_VERSION/mpfr
234 if [ ! -e gcc-
$GCC_VERSION/mpc
]
236 fetchextract http
://www.multiprecision.org
/mpc
/download
/ mpc-
$MPC_VERSION .
tar.gz
237 mv mpc-
$MPC_VERSION gcc-
$GCC_VERSION/mpc
245 cd "$BD" || die
"Failed to cd $BD"
249 for f
in "$MUSL_CC_BASE/patches/$BD"-*.
diff ; do
250 if [ -e "$f" ] ; then patch -p1 < "$f" || die
"Failed to apply patch $f to $BD" ; fi
261 BUILT
="$PWD/$BD/built$BP"
269 cd "$BD" || die
"Failed to cd $BD"
274 cd build
"$BP" || die
"Failed to cd to build dir for $BD $BP"
277 ( $CF --prefix="$PREFIX" "$@" &&
280 die
"Failed to build $BD"
288 BUILT
="$PWD/$BD/built"
296 cd "$BD" || die
"Failed to cd $BD"
298 ( $MAKE "$@" $MAKEFLAGS &&
300 die
"Failed to build $BD"
309 INSTALLED
="$PWD/$BD/installed$BP"
312 if [ ! -e "$INSTALLED" ]
315 cd "$BD" || die
"Failed to cd $BD"
319 cd build
"$BP" || die
"Failed to cd build$BP"
322 ( $MAKE install "$@" $MAKEINSTALLFLAGS &&
323 touch "$INSTALLED" ) ||
324 die
"Failed to install $BP"