cookutils annotate cross @ rev 651

cross: some clean-up now ARM v6 hard float compile!
author Christophe Lincoln <pankso@slitaz.org>
date Tue Mar 04 18:56:37 2014 +0100 (2014-03-04)
parents 5dfdf8fe7dcd
children 818b7f937fcf
rev   line source
pankso@361 1 #!/bin/sh
pankso@361 2 #
pankso@361 3 # Cross - Help build a cross toolchain on SliTaz.
pankso@361 4 #
pankso@651 5 # Copyright 2012-2014 (C) SliTaz GNU/Linux - BSD License
pankso@361 6 # Author: Christophe Lincoln <pankso@slitaz.org>
pankso@361 7 #
pankso@361 8 . /lib/libtaz.sh
pankso@370 9
pankso@370 10 [ -f "/etc/slitaz/cross.conf" ] && . /etc/slitaz/cross.conf
pankso@370 11 [ -f "cross.conf" ] && . ./cross.conf
pankso@361 12
pankso@374 13 # Handle --config=/path/to/cross.conf
pankso@374 14 [ "$config" ] && . $config
pankso@412 15 source=$WORK/source
pankso@441 16 tools=$WORK/tools
pankso@441 17 sysroot=$WORK/sysroot
pankso@412 18 logdir=$WORK/log
pankso@374 19
pankso@649 20 # Cross-tools tarballs
pankso@649 21 binutils_tarball="binutils-$BINUTILS_VERSION.tar.bz2"
pankso@649 22 linux_tarball="linux-$LINUX_VERSION.tar.xz"
pankso@649 23 glibc_tarball="glibc-$GLIBC_VERSION.tar.bz2"
pankso@649 24 eglibc_tarball="eglibc-$EGLIBC_VERSION.tar.bz2"
pankso@649 25 gcc_tarball="gcc-$GCC_VERSION.tar.bz2"
pankso@649 26
pankso@649 27 # Cross-tools URLs
pankso@649 28 binutils_wget="http://ftp.gnu.org/gnu/binutils/$binutils_tarball"
pankso@649 29 linux_wget="http://www.kernel.org/pub/linux/kernel/v3.x/$linux_tarball"
pankso@649 30 glibc_wget="http://ftp.gnu.org/gnu/libc/$glibc_tarball"
pankso@649 31 eglibc_wget="svn://svn.eglibc.org/branches/eglibc-2_13"
pankso@649 32 gcc_wget="http://ftp.gnu.org/gnu/gcc/gcc-$GCC_VERSION/$gcc_tarball"
pankso@649 33
pankso@361 34 # Help and usage.
pankso@361 35 usage() {
pankso@361 36 cat << EOT
pankso@361 37
pankso@361 38 Usage: $(basename $0) command --option
pankso@361 39
pankso@361 40 Commands:
paul@495 41 howto Man[like] page and howto
paul@382 42 info Display cross-tools info
pankso@361 43 testsuite Execute a small testsuite
pankso@649 44 setup [arch] Setup build host environment
pankso@361 45 download Download necessary sources
pankso@361 46 show-log Show a compile log
pankso@361 47 binutils Compile Binutils
pankso@421 48 linux-headers Install Kernel headers
pankso@361 49 gcc-static Compile GCC static
pankso@361 50 glibc Compile GNU Glibc
pankso@361 51 gcc-final Compile final GCC
pankso@361 52 compile Compile everything at once
pankso@419 53 clean Clean-up build environment
pankso@441 54 clean-tools Clean: $tools
paul@455 55 gen-prebuilt Create a prebuilt toolchain archive
pankso@361 56
pankso@361 57 EOT
pankso@361 58 }
pankso@361 59
pankso@420 60 # Prebuilt README
pankso@420 61 prebuilt_readme() {
pankso@420 62 echo -n "Creating toolchain README..."
pankso@420 63 cat >> $package/README << EOT
pankso@420 64
pankso@420 65 SliTaz Prebuilt $ARCH cross toolchain
pankso@420 66 ================================================================================
pankso@420 67 Move this $ARCH cross compilation toolchain to /usr/cross then add tools
pankso@420 68 to your PATH environment and test the toolchain:
pankso@420 69
pankso@441 70 # mv $ARCH /cross
pankso@441 71 # export PATH=\$PATH:/cross/$ARCH/tools/bin
pankso@420 72
pankso@420 73 # echo 'int main() { return 0; }' > test.c
pankso@420 74 # $TARGET-gcc -v -o test.out test.c
pankso@420 75 # readelf -h test.out
pankso@420 76
pankso@420 77 ================================================================================
pankso@420 78
pankso@420 79 EOT
pankso@420 80 status
pankso@420 81 }
pankso@420 82
pankso@361 83 # Make sure we have all directories.
pankso@361 84 init_compile() {
pankso@441 85 unset CFLAGS CXXFLAGS
pankso@361 86 export LC_ALL=POSIX LANG=POSIX
pankso@441 87 export PATH=$PATH:$tools/bin
pankso@400 88 export CROSS_COMPILE=${TARGET}-
pankso@441 89 mkdir -p $source $logdir $sysroot $tools
pankso@441 90 echo "Tools prefix : --prefix=$tools "
pankso@441 91 echo "Target sysroot : --with-sysroot=$sysroot"
pankso@361 92 cd $source
pankso@361 93 }
pankso@361 94
pankso@651 95 # Some arch may need custom CFLAGS to build Glibc/Eglibc
pankso@651 96 init_cflags() {
pankso@651 97 case "$ARCH" in
pankso@651 98 arm|armv6) export CFLAGS="-march=armv6 -O2" ;;
pankso@651 99 armv6hf) export CFLAGS="-O2 -march=armv6j -mfpu=vfp -mfloat-abi=hard" ;;
pankso@651 100 armv7) export CFLAGS="-Os -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -pipe" ;;
pankso@651 101 esac
pankso@651 102 }
pankso@651 103
pankso@361 104 # Get source if not yet in $SRC.
pankso@361 105 download_src() {
pankso@361 106 mkdir -p $SRC && cd $SRC
pankso@649 107 [ -f "$binutils_tarball" ] || wget $binutils_wget
pankso@649 108 [ -f "$linux_tarball" ] || wget $linux_wget
pankso@649 109 [ -f "$glibc_tarball" ] || wget $glibc_wget
pankso@649 110 [ -f "$gcc_tarball" ] || wget $gcc_wget
pankso@403 111 }
pankso@403 112
pankso@361 113 # 1. Binutils
pankso@361 114 binutils() {
pankso@408 115 init_compile
pankso@411 116 rm -rf binutils-$BINUTILS_VERSION
pankso@649 117 echo "Extracting: $binutils_tarball"
pankso@649 118 tar xjf $SRC/$binutils_tarball
pankso@421 119 echo "Configure: $BINUTILS_ARGS"
pankso@361 120 cd binutils-$BINUTILS_VERSION
pankso@361 121 ./configure \
pankso@441 122 --prefix=$tools \
pankso@361 123 --target=$TARGET \
pankso@440 124 --enable-plugins \
pankso@440 125 --enable-threads \
pankso@361 126 --enable-targets=$BUILD_SYSTEM \
pankso@441 127 --with-sysroot=$sysroot \
pankso@442 128 $BINUTILS_ARGS &&
pankso@361 129 make || exit 1
pankso@361 130 make install
pankso@421 131 echo "cross: binutils compiled on: $(date)"
pankso@361 132 }
pankso@361 133
paul@455 134 # 2. Kernel headers could use CROSS_COMPILE but gcc is not yet built.
pankso@421 135 linux_headers() {
pankso@421 136 init_compile
pankso@451 137 if [ ! -d "linux-$LINUX_VERSION" ]; then
pankso@649 138 echo "Extracting: $linux_tarball"
pankso@649 139 tar xJf $SRC/$linux_tarball
pankso@451 140 fi
pankso@649 141 case "$ARCH" in
pankso@649 142 armv6hf) KARCH="arm" ;;
pankso@649 143 *) KARCH="$ARCH" ;;
pankso@649 144 esac
pankso@451 145 rm -rf linux-headers
pankso@421 146 cd linux-$LINUX_VERSION
pankso@649 147 make CROSS_COMPILE="" mrproper
pankso@649 148 make ARCH=$KARCH headers_check
pankso@649 149 make ARCH=$KARCH headers_install \
pankso@450 150 INSTALL_HDR_PATH=$source/linux-headers
pankso@453 151 rm $source/linux-headers/include/.*install*
pankso@450 152 echo "Copying headers to: $sysroot/usr"
pankso@450 153 cp -a $source/linux-headers/* $sysroot/usr
pankso@421 154 }
pankso@421 155
pankso@447 156 # 2.1 Glibc headers needed to compile x86_64 gcc-static.
pankso@447 157 glibc_headers() {
pankso@447 158 init_compile
pankso@649 159 echo "Extracting: $glibc_tarball"
pankso@649 160 tar xjf $SRC/$glibc_tarball
pankso@447 161 rm -rf glibc-headers
pankso@447 162 mkdir glibc-headers && cd glibc-headers
pankso@450 163 libc_cv_forced_unwind=yes \
pankso@450 164 libc_cv_c_cleanup=yes \
pankso@447 165 ../glibc-$GLIBC_VERSION/configure \
pankso@447 166 --prefix=/usr \
pankso@447 167 --host=$TARGET \
pankso@447 168 --with-headers=$sysroot/usr/include \
pankso@447 169 --without-cvs \
pankso@447 170 --disable-sanity-checks \
pankso@447 171 --enable-kernel=2.6.32 &&
pankso@447 172 make -k install-headers install_root=$sysroot
pankso@448 173 # Fixes
pankso@448 174 mkdir -p $sysroot/usr/include/gnu
pankso@448 175 touch $sysroot/usr/include/gnu/stubs.h
pankso@448 176 cp bits/stdio_lim.h $sysroot/usr/include/bits
pankso@447 177 }
pankso@447 178
pankso@421 179 # 3. GCC static (first pass)
pankso@361 180 gcc_static() {
pankso@408 181 init_compile
pankso@649 182 echo "Extracting: $gcc_tarball"
pankso@649 183 tar xjf $SRC/$gcc_tarball
pankso@421 184 echo "Configure: $GCC_STATIC_ARGS"
pankso@361 185 rm -rf gcc-static
pankso@361 186 mkdir gcc-static && cd gcc-static
pankso@361 187 ../gcc-$GCC_VERSION/configure \
pankso@441 188 --prefix=$tools \
pankso@441 189 --libexec=$tools/lib \
pankso@361 190 --target=$TARGET \
pankso@361 191 --disable-shared \
pankso@361 192 --disable-threads \
pankso@441 193 --disable-libgomp \
pankso@441 194 --disable-libmudflap \
pankso@441 195 --disable-libssp \
pankso@361 196 --without-headers \
pankso@361 197 --with-newlib \
pankso@441 198 --with-sysroot=$sysroot \
pankso@442 199 $GCC_STATIC_ARGS &&
pankso@361 200 make all-gcc all-target-libgcc || exit 1
pankso@361 201 make install-gcc install-target-libgcc
pankso@421 202 echo "cross: gcc-static compiled on: $(date)"
pankso@403 203 }
pankso@403 204
pankso@651 205 # 4. GNU Glibc: TODO Improve ARM support
pankso@361 206 glibc() {
pankso@408 207 init_compile
pankso@649 208 echo "Extracting: $glibc_tarball"
pankso@649 209 tar xjf $SRC/$glibc_tarball
pankso@421 210 echo "Configure: $GLIBC_ARGS"
pankso@400 211 # Some arch may need glibc-ports and custom CFLAGS
pankso@403 212 case "$ARCH" in
pankso@650 213 arm*)
pankso@433 214 export CFLAGS="-march=armv6 -O2"
pankso@362 215 [ -f "$SRC/glibc-ports-$GLIBC_VERSION.tar.bz2" ] || wget \
pankso@362 216 http://ftp.gnu.org/gnu/libc/glibc-ports-$GLIBC_VERSION.tar.bz2 \
pankso@362 217 -O $SRC/glibc-ports-$GLIBC_VERSION.tar.bz2 || exit 1
pankso@361 218 echo "Extracting: glibc-ports-$GLIBC_VERSION.tar.bz2"
pankso@361 219 rm -rf glibc-$GLIBC_VERSION/ports
pankso@361 220 tar xjf $SRC/glibc-ports-$GLIBC_VERSION.tar.bz2
pankso@449 221 mv glibc-ports-$GLIBC_VERSION glibc-$GLIBC_VERSION/ports
pankso@449 222 libexec=/usr/lib/glibc ;;
pankso@418 223 x86_64)
pankso@449 224 #export CFLAGS="-march=nocona -O2 -pipe"
pankso@449 225 ccflags="-m64"
pankso@449 226 libexec=/usr/lib64/glibc ;;
pankso@361 227 esac
pankso@441 228 # Disable linking to libgcc_eh
pankso@441 229 cd glibc-$GLIBC_VERSION
pankso@441 230 cp Makeconfig Makeconfig.orig
pankso@441 231 sed -e 's/-lgcc_eh//g' Makeconfig.orig > Makeconfig
pankso@441 232 cd ..
pankso@421 233 echo "CFLAGS: $CFLAGS"
pankso@441 234 rm -rf glibc-build
pankso@361 235 mkdir -p glibc-build && cd glibc-build
pankso@365 236 BUILD_CC="gcc" \
pankso@418 237 CC="${TARGET}-gcc $ccflags" \
pankso@441 238 AR="${TARGET}-ar" \
pankso@441 239 RANLIB="${TARGET}-ranlib" \
pankso@361 240 libc_cv_forced_unwind=yes \
pankso@361 241 libc_cv_c_cleanup=yes \
pankso@361 242 ../glibc-$GLIBC_VERSION/configure \
pankso@441 243 --prefix=/usr \
pankso@449 244 --libexec=$libexec \
pankso@361 245 --host=$TARGET \
pankso@441 246 --with-headers=$sysroot/usr/include \
pankso@441 247 --with-binutils=$tools/bin \
pankso@425 248 --enable-kernel=2.6.32 \
pankso@442 249 $GLIBC_ARGS &&
pankso@361 250 make || exit 1
pankso@441 251 make install_root=$sysroot install
pankso@454 252 # Symlink lib64 to lib
pankso@454 253 case "$ARCH" in
pankso@454 254 x86_64)
pankso@454 255 rm -f $sysroot/lib $sysroot/usr/lib
pankso@454 256 cd $sysroot && ln -s lib64 lib
pankso@454 257 cd usr && ln -s lib64 lib ;;
pankso@454 258 esac
pankso@421 259 echo "cross: glibc compiled on: $(date)"
pankso@361 260 }
pankso@361 261
pankso@649 262 # 4. eglibc: always use --prefix=/usr
pankso@441 263 eglibc() {
pankso@441 264 init_compile
pankso@651 265 init_cflags
pankso@441 266 rm -rf eglibc-build eglibc-$EGLIBC_VERSION
pankso@649 267 echo "Extracting: $eglibc_tarball"
pankso@649 268 tar xjf $SRC/$eglibc_tarball || exit 1
pankso@650 269 case "$ARCH" in
pankso@650 270 arm*)
pankso@441 271 if [ ! -d "$source/eglibc-ports-$EGLIBC_VERSION" ]; then
pankso@649 272 echo "Cloning $eglibc_wget/ports"
pankso@649 273 svn co $eglibc_wget/ports eglibc-ports-$EGLIBC_VERSION >/dev/null
pankso@441 274 fi
pankso@449 275 cp -a eglibc-ports-$EGLIBC_VERSION eglibc-$EGLIBC_VERSION/ports
pankso@449 276 libexec=/usr/lib/eglibc ;;
pankso@441 277 x86_64)
pankso@449 278 #export CFLAGS="-march=nocona -O2 -pipe"
pankso@449 279 ccflags="-m64"
pankso@449 280 libexec=/usr/lib64/eglibc ;;
pankso@441 281 esac
pankso@441 282 # Disable linking to libgcc_eh
pankso@441 283 cd eglibc-$EGLIBC_VERSION
pankso@441 284 cp Makeconfig Makeconfig.orig
pankso@441 285 sed -e 's/-lgcc_eh//g' Makeconfig.orig > Makeconfig
pankso@441 286 cd ..
pankso@651 287 echo "CFLAGS: $CFLAGS"
pankso@441 288 mkdir -p eglibc-build && cd eglibc-build
pankso@441 289 # config.cache
pankso@441 290 cat > config.cache << EOT
pankso@441 291 libc_cv_forced_unwind=yes
pankso@441 292 libc_cv_c_cleanup=yes
pankso@441 293 libc_cv_gnu89_inline=yes
pankso@441 294 EOT
pankso@441 295 BUILD_CC="gcc" \
pankso@441 296 CC="${TARGET}-gcc $ccflags" \
pankso@441 297 AR="${TARGET}-ar" \
pankso@441 298 RANLIB="${TARGET}-ranlib" \
pankso@441 299 ../eglibc-$EGLIBC_VERSION/configure \
pankso@441 300 --prefix=/usr \
pankso@449 301 --libexec=$libexec \
pankso@441 302 --host=$TARGET \
pankso@441 303 --with-headers=$sysroot/usr/include \
pankso@441 304 --with-binutils=$tools/bin \
pankso@441 305 --enable-kernel=2.6.32 \
pankso@441 306 --with-__thread \
pankso@441 307 --without-gd \
pankso@441 308 --without-cvs \
pankso@441 309 --cache-file=config.cache \
pankso@442 310 $EGLIBC_ARGS &&
pankso@441 311 make || exit 1
pankso@441 312 make install_root=$sysroot install
pankso@641 313 echo "cross: eglibc compiled on: $(date)"
pankso@441 314 }
pankso@441 315
pankso@361 316 # 5. GCC final
pankso@361 317 gcc_final() {
pankso@408 318 init_compile
pankso@361 319 if [ ! -d "gcc-$GCC_VERSION" ]; then
pankso@649 320 echo "Extracting: $gcc_tarball"
pankso@649 321 tar xjf $SRC/$gcc_tarball
pankso@361 322 fi
pankso@421 323 echo "Configure: $GCC_FINAL_ARGS"
pankso@441 324 rm -rf gcc-build
pankso@421 325 mkdir -p gcc-build && cd gcc-build
pankso@441 326 AR=ar \
pankso@361 327 ../gcc-$GCC_VERSION/configure \
pankso@441 328 --prefix=$tools \
pankso@441 329 --libexec=$tools/lib \
pankso@361 330 --target=$TARGET \
pankso@361 331 --enable-shared \
pankso@361 332 --enable-c99 \
pankso@361 333 --enable-long-long \
pankso@361 334 --enable-__cxa_atexit \
pankso@440 335 --with-system-zlib \
pankso@440 336 --enable-plugin \
pankso@440 337 --disable-multilib \
pankso@440 338 --disable-libssp \
pankso@441 339 --disable-checking \
pankso@441 340 --disable-werror \
pankso@400 341 --with-pkgversion="SliTaz" \
pankso@648 342 --with-bugurl="http://bugs.slitaz.org/" \
pankso@442 343 --with-sysroot=$sysroot \
pankso@442 344 $GCC_FINAL_ARGS &&
pankso@441 345 make AS_FOR_TARGET="${TARGET}-as" \
pankso@441 346 LD_FOR_TARGET="${TARGET}-ld" || exit 1
pankso@441 347 make install
pankso@421 348 echo "cross: GCC final compiled on: $(date)"
pankso@361 349 }
pankso@361 350
pankso@361 351 #
pankso@361 352 # Commands
pankso@361 353 #
pankso@361 354
pankso@361 355 case "$1" in
pankso@361 356 howto|man)
pankso@361 357 doc=/usr/share/doc/cookutils/cross.txt
pankso@361 358 [ -f "$doc" ] && less -E $doc ;;
pankso@361 359 info)
pankso@361 360 init_compile
pankso@651 361 init_cflags
pankso@361 362 CC=${TARGET}-gcc
paul@382 363 echo -e "\nCross Toolchain information" && separator
pankso@374 364 [ "$config" ] && echo "Config file : $config"
pankso@361 365 cat << EOT
pankso@374 366 Target arch : $ARCH
pankso@374 367 C Compiler : $CC
pankso@651 368 CFLAGS : $CFLAGS
pankso@374 369 Build directory : $WORK
pankso@441 370 Tools prefix : $tools/bin
pankso@441 371 Arch sysroot : $sysroot
pankso@361 372 EOT
pankso@361 373 separator && echo ""
pankso@361 374 echo "GCC version" && separator
pankso@441 375 if [ -x "$tools/bin/$CC" ]; then
pankso@374 376 $CC -v
pankso@374 377 else
pankso@374 378 echo "No C compiler. To build a toolchain run: cross compile"
pankso@441 379 echo "Missing: $tools/bin/$CC"
pankso@374 380 fi
pankso@361 381 separator && echo "" ;;
pankso@361 382 testsuite)
pankso@361 383 init_compile
pankso@361 384 echo "[COMPILING] $TARGET-gcc -v -Wall -o test.out test.c" \
pankso@361 385 | tee $logdir/testsuite.log
pankso@361 386 echo 'int main() { return 0; }' > test.c
pankso@361 387 $TARGET-gcc -v -Wall -o test.out test.c 2>&1 | tee -a $logdir/testsuite.log
pankso@361 388 if [ -x /usr/bin/file ]; then
pankso@361 389 echo -e "\n[CHECKING] file test.out" | tee -a $logdir/testsuite.log
pankso@361 390 file test.out | tee -a $logdir/testsuite.log
pankso@361 391 fi
pankso@361 392 echo -e "\n[CHECKING] readelf -h test.out" | tee -a $logdir/testsuite.log
pankso@361 393 readelf -h test.out | tee -a $logdir/testsuite.log ;;
pankso@649 394 *setup)
pankso@649 395 data="/usr/share/cross"
pankso@649 396 arch=${1%-setup}
pankso@649 397 [ "$arch" == "setup" ] && arch="arm"
pankso@649 398 newline
pankso@421 399 echo "Checking: build system packages"
pankso@421 400 for pkg in slitaz-toolchain mpfr mpfr-dev gmp gmp-dev mpc-library \
pankso@421 401 gawk autoconf; do
pankso@361 402 if [ ! -d "/var/lib/tazpkg/installed/$pkg" ]; then
pankso@361 403 echo "Missing packages: $pkg"
pankso@421 404 if [ -x /usr/sbin/spk-add ]; then
pankso@421 405 spk-add $pkg
pankso@421 406 else
pankso@421 407 tazpkg -gi $pkg
pankso@421 408 fi
pankso@361 409 fi
pankso@421 410 done
pankso@649 411 echo "Getting $arch cross.conf"
pankso@649 412 cp -f ${data}/cross-${arch}.conf /etc/slitaz/cross.conf
pankso@649 413 cook ${arch}-setup
pankso@649 414 newline ;;
pankso@361 415 download)
pankso@361 416 download_src ;;
pankso@361 417 show-log)
pankso@361 418 pkg=$2
pankso@371 419 log=$logdir/$pkg.log
pankso@371 420 if [ ! -f "$log" ]; then
pankso@371 421 echo "No log file found for: $pkg" && exit 1
pankso@371 422 fi
pankso@371 423 less -E $log ;;
pankso@361 424 binutils)
pankso@412 425 rm -f $logdir/binutils.log
pankso@361 426 binutils 2>&1 | tee $logdir/binutils.log ;;
pankso@447 427 linux-headers)
pankso@447 428 linux_headers 2>&1 | tee $logdir/linux-headers.log ;;
pankso@447 429 glibc-headers)
pankso@447 430 glibc_headers 2>&1 | tee $logdir/glibc-headers.log ;;
pankso@403 431 gcc-static)
pankso@403 432 gcc_static 2>&1 | tee $logdir/gcc-static.log ;;
pankso@361 433 glibc)
pankso@361 434 glibc 2>&1 | tee $logdir/glibc.log ;;
pankso@441 435 eglibc)
pankso@441 436 eglibc 2>&1 | tee $logdir/eglibc.log ;;
pankso@361 437 gcc-final)
pankso@361 438 gcc_final 2>&1 | tee $logdir/gcc-final.log ;;
pankso@361 439 compile)
pankso@400 440 # Compile the full toolchain.
pankso@400 441 time=$(date +%s)
pankso@361 442 init_compile
pankso@361 443 echo "Compile start: $(date)" | tee $logdir/compile.log
pankso@361 444 download_src
pankso@361 445 binutils 2>&1 | tee $logdir/binutils.log
pankso@447 446 case "$ARCH" in
pankso@447 447 x86_64) glibc_headers 2>&1 | tee $logdir/glibc-headers.log ;;
pankso@447 448 esac
pankso@403 449 gcc_static 2>&1 | tee $logdir/gcc-static.log
pankso@361 450 linux_headers 2>&1 | tee $logdir/linux-headers.log
pankso@441 451 case "$ARCH" in
pankso@649 452 arm*) eglibc 2>&1 | tee $logdir/eglibc.log ;;
pankso@441 453 x86_64) glibc 2>&1 | tee $logdir/glibc.log ;;
pankso@441 454 esac
pankso@361 455 gcc_final 2>&1 | tee $logdir/gcc-final.log
pankso@361 456 echo ""
pankso@365 457 echo "Compile end : $(date)" | tee -a $logdir/compile.log
pankso@400 458 time=$(($(date +%s) - $time))
pankso@400 459 sec=$time
pankso@400 460 div=$(( ($time + 30) / 60))
pankso@400 461 [ "$div" != 0 ] && min="~ ${div}m"
pankso@401 462 echo "Build time : ${sec}s $min" | tee -a $logdir/compile.log
pankso@361 463 echo "" ;;
pankso@416 464 clean)
pankso@416 465 echo -n "Removing all source files..."
pankso@441 466 rm -rf $WORK/source && status
pankso@441 467 [ "$log" ] && rm -f $WORK/log/*.log ;;
pankso@371 468 clean-tools)
pankso@371 469 # Remove crap :-)
pankso@371 470 init_compile
pankso@441 471 echo "Cleaning : $tools ($(du -sh $tools | awk '{print $1}'))"
pankso@443 472 for file in share/info share/man share/local
pankso@371 473 do
pankso@440 474 echo -n "Removing : $file"
pankso@441 475 rm -rf $tools/$file && status
pankso@371 476 done
pankso@419 477 echo -n "Stripping : shared libs and binaries"
pankso@443 478 find $tools/bin -type f -exec strip -s '{}' 2>/dev/null \;
pankso@443 479 find $tools/lib -name cc1* -exec strip -s '{}' 2>/dev/null \;
pankso@443 480 find $tools/lib -name lto* -exec strip -s '{}' 2>/dev/null \;
pankso@444 481 find $sysroot -name "*.so*" -exec ${TARGET}-strip -s '{}' 2>/dev/null \;
pankso@416 482 sleep 1 && status
pankso@441 483 echo -n "Tools size : " && du -sh $tools | awk '{print $1}' ;;
pankso@416 484 gen-prebuilt)
pankso@420 485 # Create a prebuilt cross toolchain tarball.
pankso@416 486 init_compile
pankso@420 487 date=$(date "+%Y%m%d")
pankso@443 488 package="slitaz-$ARCH-toolchain-$date"
pankso@419 489 tarball="$package.tar.bz2"
pankso@441 490 cd /cross
pankso@443 491 mkdir -p $package/$ARCH || exit 1
pankso@419 492 echo ""
pankso@419 493 echo -n "Copying $ARCH to: $package"
pankso@443 494 cp -a $ARCH/tools $package/$ARCH
pankso@443 495 cp -a $ARCH/sysroot $package/$ARCH
pankso@419 496 status
pankso@420 497 prebuilt_readme
pankso@416 498 echo -n "Creating prebuilt $ARCH toolchain tarball..."
pankso@419 499 tar cjf $tarball $package
pankso@416 500 status
pankso@419 501 rm -rf $package
pankso@441 502 size=$(du -sh $tarball | awk '{print $1}')
pankso@441 503 echo "Tarball path: $(pwd)/$tarball"
pankso@419 504 echo "Tarball size: $size"
pankso@419 505 echo "" ;;
pankso@361 506 *)
pankso@361 507 usage ;;
pankso@361 508 esac
pankso@361 509