cookutils annotate cross @ rev 649

cros: add support for armv6hf and armv7 arch + better setup command
author Christophe Lincoln <pankso@slitaz.org>
date Mon Mar 03 23:18:29 2014 +0100 (2014-03-03)
parents 9298c9293ae0
children 5dfdf8fe7dcd
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@361 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@441 261 arm)
pankso@441 262 export CFLAGS="-march=armv6 -O2"
pankso@441 263 if [ ! -d "$source/eglibc-ports-$EGLIBC_VERSION" ]; then
pankso@649 264 echo "Cloning $eglibc_wget/ports"
pankso@649 265 svn co $eglibc_wget/ports eglibc-ports-$EGLIBC_VERSION >/dev/null
pankso@441 266 fi
pankso@449 267 cp -a eglibc-ports-$EGLIBC_VERSION eglibc-$EGLIBC_VERSION/ports
pankso@449 268 libexec=/usr/lib/eglibc ;;
pankso@441 269 x86_64)
pankso@449 270 #export CFLAGS="-march=nocona -O2 -pipe"
pankso@449 271 ccflags="-m64"
pankso@449 272 libexec=/usr/lib64/eglibc ;;
pankso@441 273 esac
pankso@441 274 # Disable linking to libgcc_eh
pankso@441 275 cd eglibc-$EGLIBC_VERSION
pankso@441 276 cp Makeconfig Makeconfig.orig
pankso@441 277 sed -e 's/-lgcc_eh//g' Makeconfig.orig > Makeconfig
pankso@441 278 cd ..
pankso@441 279 mkdir -p eglibc-build && cd eglibc-build
pankso@441 280 # config.cache
pankso@441 281 cat > config.cache << EOT
pankso@441 282 libc_cv_forced_unwind=yes
pankso@441 283 libc_cv_c_cleanup=yes
pankso@441 284 libc_cv_gnu89_inline=yes
pankso@441 285 EOT
pankso@441 286 BUILD_CC="gcc" \
pankso@441 287 CC="${TARGET}-gcc $ccflags" \
pankso@441 288 AR="${TARGET}-ar" \
pankso@441 289 RANLIB="${TARGET}-ranlib" \
pankso@441 290 ../eglibc-$EGLIBC_VERSION/configure \
pankso@441 291 --prefix=/usr \
pankso@449 292 --libexec=$libexec \
pankso@441 293 --host=$TARGET \
pankso@441 294 --with-headers=$sysroot/usr/include \
pankso@441 295 --with-binutils=$tools/bin \
pankso@441 296 --enable-kernel=2.6.32 \
pankso@441 297 --with-__thread \
pankso@441 298 --without-gd \
pankso@441 299 --without-cvs \
pankso@441 300 --cache-file=config.cache \
pankso@442 301 $EGLIBC_ARGS &&
pankso@441 302 make || exit 1
pankso@441 303 make install_root=$sysroot install
pankso@641 304 echo "cross: eglibc compiled on: $(date)"
pankso@441 305 }
pankso@441 306
pankso@361 307 # 5. GCC final
pankso@361 308 gcc_final() {
pankso@408 309 init_compile
pankso@361 310 if [ ! -d "gcc-$GCC_VERSION" ]; then
pankso@649 311 echo "Extracting: $gcc_tarball"
pankso@649 312 tar xjf $SRC/$gcc_tarball
pankso@361 313 fi
pankso@421 314 echo "Configure: $GCC_FINAL_ARGS"
pankso@441 315 rm -rf gcc-build
pankso@421 316 mkdir -p gcc-build && cd gcc-build
pankso@441 317 AR=ar \
pankso@361 318 ../gcc-$GCC_VERSION/configure \
pankso@441 319 --prefix=$tools \
pankso@441 320 --libexec=$tools/lib \
pankso@361 321 --target=$TARGET \
pankso@361 322 --enable-shared \
pankso@361 323 --enable-c99 \
pankso@361 324 --enable-long-long \
pankso@361 325 --enable-__cxa_atexit \
pankso@440 326 --with-system-zlib \
pankso@440 327 --enable-plugin \
pankso@440 328 --disable-multilib \
pankso@440 329 --disable-libssp \
pankso@441 330 --disable-checking \
pankso@441 331 --disable-werror \
pankso@400 332 --with-pkgversion="SliTaz" \
pankso@648 333 --with-bugurl="http://bugs.slitaz.org/" \
pankso@442 334 --with-sysroot=$sysroot \
pankso@442 335 $GCC_FINAL_ARGS &&
pankso@441 336 make AS_FOR_TARGET="${TARGET}-as" \
pankso@441 337 LD_FOR_TARGET="${TARGET}-ld" || exit 1
pankso@441 338 make install
pankso@421 339 echo "cross: GCC final compiled on: $(date)"
pankso@361 340 }
pankso@361 341
pankso@361 342 #
pankso@361 343 # Commands
pankso@361 344 #
pankso@361 345
pankso@361 346 case "$1" in
pankso@361 347 howto|man)
pankso@361 348 doc=/usr/share/doc/cookutils/cross.txt
pankso@361 349 [ -f "$doc" ] && less -E $doc ;;
pankso@361 350 info)
pankso@361 351 init_compile
pankso@361 352 CC=${TARGET}-gcc
paul@382 353 echo -e "\nCross Toolchain information" && separator
pankso@374 354 [ "$config" ] && echo "Config file : $config"
pankso@361 355 cat << EOT
pankso@374 356 Target arch : $ARCH
pankso@374 357 C Compiler : $CC
pankso@374 358 Build directory : $WORK
pankso@441 359 Tools prefix : $tools/bin
pankso@441 360 Arch sysroot : $sysroot
pankso@361 361 EOT
pankso@361 362 separator && echo ""
pankso@361 363 echo "GCC version" && separator
pankso@441 364 if [ -x "$tools/bin/$CC" ]; then
pankso@374 365 $CC -v
pankso@374 366 else
pankso@374 367 echo "No C compiler. To build a toolchain run: cross compile"
pankso@441 368 echo "Missing: $tools/bin/$CC"
pankso@374 369 fi
pankso@361 370 separator && echo "" ;;
pankso@361 371 testsuite)
pankso@361 372 init_compile
pankso@361 373 echo "[COMPILING] $TARGET-gcc -v -Wall -o test.out test.c" \
pankso@361 374 | tee $logdir/testsuite.log
pankso@361 375 echo 'int main() { return 0; }' > test.c
pankso@361 376 $TARGET-gcc -v -Wall -o test.out test.c 2>&1 | tee -a $logdir/testsuite.log
pankso@361 377 if [ -x /usr/bin/file ]; then
pankso@361 378 echo -e "\n[CHECKING] file test.out" | tee -a $logdir/testsuite.log
pankso@361 379 file test.out | tee -a $logdir/testsuite.log
pankso@361 380 fi
pankso@361 381 echo -e "\n[CHECKING] readelf -h test.out" | tee -a $logdir/testsuite.log
pankso@361 382 readelf -h test.out | tee -a $logdir/testsuite.log ;;
pankso@649 383 *setup)
pankso@649 384 data="/usr/share/cross"
pankso@649 385 arch=${1%-setup}
pankso@649 386 [ "$arch" == "setup" ] && arch="arm"
pankso@649 387 newline
pankso@421 388 echo "Checking: build system packages"
pankso@421 389 for pkg in slitaz-toolchain mpfr mpfr-dev gmp gmp-dev mpc-library \
pankso@421 390 gawk autoconf; do
pankso@361 391 if [ ! -d "/var/lib/tazpkg/installed/$pkg" ]; then
pankso@361 392 echo "Missing packages: $pkg"
pankso@421 393 if [ -x /usr/sbin/spk-add ]; then
pankso@421 394 spk-add $pkg
pankso@421 395 else
pankso@421 396 tazpkg -gi $pkg
pankso@421 397 fi
pankso@361 398 fi
pankso@421 399 done
pankso@649 400 echo "Getting $arch cross.conf"
pankso@649 401 cp -f ${data}/cross-${arch}.conf /etc/slitaz/cross.conf
pankso@649 402 cook ${arch}-setup
pankso@649 403 echo "Setting up cook environment"
pankso@649 404 cook setup >/dev/null
pankso@649 405 newline ;;
pankso@361 406 download)
pankso@361 407 download_src ;;
pankso@361 408 show-log)
pankso@361 409 pkg=$2
pankso@371 410 log=$logdir/$pkg.log
pankso@371 411 if [ ! -f "$log" ]; then
pankso@371 412 echo "No log file found for: $pkg" && exit 1
pankso@371 413 fi
pankso@371 414 less -E $log ;;
pankso@361 415 binutils)
pankso@412 416 rm -f $logdir/binutils.log
pankso@361 417 binutils 2>&1 | tee $logdir/binutils.log ;;
pankso@447 418 linux-headers)
pankso@447 419 linux_headers 2>&1 | tee $logdir/linux-headers.log ;;
pankso@447 420 glibc-headers)
pankso@447 421 glibc_headers 2>&1 | tee $logdir/glibc-headers.log ;;
pankso@403 422 gcc-static)
pankso@403 423 gcc_static 2>&1 | tee $logdir/gcc-static.log ;;
pankso@361 424 glibc)
pankso@361 425 glibc 2>&1 | tee $logdir/glibc.log ;;
pankso@441 426 eglibc)
pankso@441 427 eglibc 2>&1 | tee $logdir/eglibc.log ;;
pankso@361 428 gcc-final)
pankso@361 429 gcc_final 2>&1 | tee $logdir/gcc-final.log ;;
pankso@361 430 compile)
pankso@400 431 # Compile the full toolchain.
pankso@400 432 time=$(date +%s)
pankso@361 433 init_compile
pankso@361 434 echo "Compile start: $(date)" | tee $logdir/compile.log
pankso@361 435 download_src
pankso@361 436 binutils 2>&1 | tee $logdir/binutils.log
pankso@447 437 case "$ARCH" in
pankso@447 438 x86_64) glibc_headers 2>&1 | tee $logdir/glibc-headers.log ;;
pankso@447 439 esac
pankso@403 440 gcc_static 2>&1 | tee $logdir/gcc-static.log
pankso@361 441 linux_headers 2>&1 | tee $logdir/linux-headers.log
pankso@441 442 case "$ARCH" in
pankso@649 443 arm*) eglibc 2>&1 | tee $logdir/eglibc.log ;;
pankso@441 444 x86_64) glibc 2>&1 | tee $logdir/glibc.log ;;
pankso@441 445 esac
pankso@361 446 gcc_final 2>&1 | tee $logdir/gcc-final.log
pankso@361 447 echo ""
pankso@365 448 echo "Compile end : $(date)" | tee -a $logdir/compile.log
pankso@400 449 time=$(($(date +%s) - $time))
pankso@400 450 sec=$time
pankso@400 451 div=$(( ($time + 30) / 60))
pankso@400 452 [ "$div" != 0 ] && min="~ ${div}m"
pankso@401 453 echo "Build time : ${sec}s $min" | tee -a $logdir/compile.log
pankso@361 454 echo "" ;;
pankso@416 455 clean)
pankso@416 456 echo -n "Removing all source files..."
pankso@441 457 rm -rf $WORK/source && status
pankso@441 458 [ "$log" ] && rm -f $WORK/log/*.log ;;
pankso@371 459 clean-tools)
pankso@371 460 # Remove crap :-)
pankso@371 461 init_compile
pankso@441 462 echo "Cleaning : $tools ($(du -sh $tools | awk '{print $1}'))"
pankso@443 463 for file in share/info share/man share/local
pankso@371 464 do
pankso@440 465 echo -n "Removing : $file"
pankso@441 466 rm -rf $tools/$file && status
pankso@371 467 done
pankso@419 468 echo -n "Stripping : shared libs and binaries"
pankso@443 469 find $tools/bin -type f -exec strip -s '{}' 2>/dev/null \;
pankso@443 470 find $tools/lib -name cc1* -exec strip -s '{}' 2>/dev/null \;
pankso@443 471 find $tools/lib -name lto* -exec strip -s '{}' 2>/dev/null \;
pankso@444 472 find $sysroot -name "*.so*" -exec ${TARGET}-strip -s '{}' 2>/dev/null \;
pankso@416 473 sleep 1 && status
pankso@441 474 echo -n "Tools size : " && du -sh $tools | awk '{print $1}' ;;
pankso@416 475 gen-prebuilt)
pankso@420 476 # Create a prebuilt cross toolchain tarball.
pankso@416 477 init_compile
pankso@420 478 date=$(date "+%Y%m%d")
pankso@443 479 package="slitaz-$ARCH-toolchain-$date"
pankso@419 480 tarball="$package.tar.bz2"
pankso@441 481 cd /cross
pankso@443 482 mkdir -p $package/$ARCH || exit 1
pankso@419 483 echo ""
pankso@419 484 echo -n "Copying $ARCH to: $package"
pankso@443 485 cp -a $ARCH/tools $package/$ARCH
pankso@443 486 cp -a $ARCH/sysroot $package/$ARCH
pankso@419 487 status
pankso@420 488 prebuilt_readme
pankso@416 489 echo -n "Creating prebuilt $ARCH toolchain tarball..."
pankso@419 490 tar cjf $tarball $package
pankso@416 491 status
pankso@419 492 rm -rf $package
pankso@441 493 size=$(du -sh $tarball | awk '{print $1}')
pankso@441 494 echo "Tarball path: $(pwd)/$tarball"
pankso@419 495 echo "Tarball size: $size"
pankso@419 496 echo "" ;;
pankso@361 497 *)
pankso@361 498 usage ;;
pankso@361 499 esac
pankso@361 500