cookutils rev 419

cross: better x86_64 support and create prebuilt toolchain (again)
author Christophe Lincoln <pankso@slitaz.org>
date Tue May 15 00:32:46 2012 +0200 (2012-05-15)
parents 4753a4a48547
children 9c322a61167d
files cross
line diff
     1.1 --- a/cross	Tue May 15 00:27:37 2012 +0200
     1.2 +++ b/cross	Tue May 15 00:32:46 2012 +0200
     1.3 @@ -28,8 +28,6 @@
     1.4    testsuite       Execute a small testsuite
     1.5    check-env       Check build host tools
     1.6    download        Download necessary sources
     1.7 -  clean           Clean-up build environment
     1.8 -  clean-tools     Clean: $PREFIX
     1.9    show-log        Show a compile log
    1.10    binutils        Compile Binutils
    1.11    gcc-static      Compile GCC static
    1.12 @@ -38,6 +36,9 @@
    1.13    gcc-final       Compile final GCC
    1.14    busybox         Cross compile Busybox
    1.15    compile         Compile everything at once
    1.16 +  clean           Clean-up build environment
    1.17 +  clean-tools     Clean: $PREFIX
    1.18 +  gen-prebuilt    Create an prebuilt toolchain archive
    1.19  
    1.20  EOT
    1.21  }
    1.22 @@ -334,64 +335,57 @@
    1.23  		for dir in info man locale
    1.24  		do
    1.25  			echo -n "Removing   : $dir"
    1.26 -			rm -rf $PREFIX/share && status
    1.27 +			rm -rf $PREFIX/share/$dir && status
    1.28  		done
    1.29  		rm -f $PREFIX/lib/*-gdb.py
    1.30 -		#echo -n "Stripping  : shared libs"
    1.31 -		#${TARGET}-strip -s $PREFIX/lib/*.so.*
    1.32 -		#status
    1.33 -		echo -n "Stripping  : GCC libs"
    1.34 +		echo -n "Stripping  : shared libs and binaries"
    1.35 +		${TARGET}-strip -s $PREFIX/lib/*.so* 2>/dev/null
    1.36 +		${TARGET}-strip -s $PREFIX/bin/* 2>/dev/null
    1.37 +		${TARGET}-strip -s $PREFIX/${TARGET}/bin/* 2>/dev/null
    1.38  		${TARGET}-strip -s $PREFIX/$TARGET/lib/gcc/$TARGET/*/cc1*
    1.39  		${TARGET}-strip -s $PREFIX/$TARGET/lib/gcc/$TARGET/*/lto*
    1.40  		sleep 1 && status
    1.41 -		echo -n "Stripping  : binaries"
    1.42 -		for bin in $PREFIX/bin/${TARGET}-*
    1.43 -		do
    1.44 -			[ "$bin" == "$PREFIX/bin/${TARGET}-strip" ] && continue
    1.45 -			if [ -x "$bin" ]; then
    1.46 -				${TARGET}-strip -s $bin 2>/dev/null
    1.47 -			fi
    1.48 -		done && status
    1.49  		echo -n "Tools size : " && du -sh $PREFIX | awk '{print $1}' ;;
    1.50  	gen-rootfs)
    1.51 -		#
    1.52 -		# TESTING
    1.53 -		#
    1.54 -		# Create a bootable rootfs ? dd for an HD image ?
    1.55 -		init_compile
    1.56 -		rootfs=/tmp/cross/rootfs
    1.57 -		tarball="rootfs.tar.bz2"
    1.58 -		rm -rf $rootfs && mkdir -p $rootfs
    1.59 -		cd /tmp/cross
    1.60 -		echo -n "Installing SliTaz base files..."
    1.61 -		tar xzf $SRC/slitaz-base-files-5.2.tar.gz
    1.62 -		cp -a slitaz-base-files-*/rootfs/* $rootfs
    1.63 -		status
    1.64 -		echo -n "Installing Busybox..."
    1.65 -		cp -a $source/busybox-$BUSYBOX_VERSION/_install/* $rootfs
    1.66 -		status
    1.67 -		echo -n "Creating tarball: $tarball"
    1.68 -		tar cjf $tarball rootfs
    1.69 -		status
    1.70 -		echo -n "Moving rootfs to: $WORK"
    1.71 -		mv $tarball $WORK
    1.72 -		status
    1.73 -		du -sh $WORK/$tarball
    1.74 -		rm -rf /tmp/cross ;;
    1.75 +		echo "Use arm packages: basefile, boot-scripts, busybox and glibc-base"
    1.76 +		echo "Install them in a rootfs: tazpkg *-arm.tazpkg --root=/my/rootfs" ;;
    1.77  	gen-prebuilt)
    1.78  		#
    1.79  		# TESTING
    1.80  		#
    1.81  		# Create a prebuilt cross toolchain tarball (or package ?)
    1.82  		init_compile
    1.83 +		package="slitaz-cross-$ARCH-toolchain"
    1.84 +		tarball="$package.tar.bz2"
    1.85  		cd /usr/cross
    1.86 -		tarball="slitaz-cross-$ARCH-toolchain.tar.bz2"
    1.87 +		mkdir $package || exit 1
    1.88 +		echo ""
    1.89 +		echo -n "Copying $ARCH to: $package"
    1.90 +		cp -a $ARCH $package
    1.91 +		rm -rf $package/share $package/etc
    1.92 +		status
    1.93 +		echo -n "Creating toolchain README..."
    1.94 +		cat >> $package/README << EOT
    1.95 +
    1.96 +
    1.97 +Move this $ARCH cross compilation toolchain to /usr/cross then add tools
    1.98 +to your PATH environment:
    1.99 +
   1.100 +	# mv $ARCH /usr/cross
   1.101 +	# export PATH=\$PATH:/usr/cross/$ARCH/bin
   1.102 +
   1.103 +
   1.104 +EOT
   1.105 +		status
   1.106  		echo -n "Creating prebuilt $ARCH toolchain tarball..."
   1.107 -		tar cjf $tarball $ARCH
   1.108 +		tar cjf $tarball $package
   1.109  		status
   1.110  		mv -f $tarball $WORK
   1.111 -		#echo "Tarball size: $(du -sh $WORK/$tarball | awk '{print $1}')"
   1.112 -		du -sh $WORK/$tarball ;;
   1.113 +		rm -rf $package
   1.114 +		size=$(du -sh $WORK/$tarball | awk '{print $1}')
   1.115 +		echo "Tarball path: $WORK/$tarball"
   1.116 +		echo "Tarball size: $size"
   1.117 +		echo "" ;;
   1.118  	*)
   1.119  		usage ;;
   1.120  esac