cookutils annotate cross @ rev 650

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