cookutils rev 400

cross: use nes config var and optimisze glibc for arm
author Christophe Lincoln <pankso@slitaz.org>
date Sun May 13 15:21:25 2012 +0200 (2012-05-13)
parents 4404a7c56359
children c78dde3b62ef
files cross
line diff
     1.1 --- a/cross	Sun May 13 14:19:02 2012 +0200
     1.2 +++ b/cross	Sun May 13 15:21:25 2012 +0200
     1.3 @@ -43,7 +43,7 @@
     1.4  init_compile() {
     1.5  	export LC_ALL=POSIX LANG=POSIX
     1.6  	export PATH=$PATH:$PREFIX/bin
     1.7 -	export CROSS_COMPILE=$TARGET-
     1.8 +	export CROSS_COMPILE=${TARGET}-
     1.9  	source=$WORK/source
    1.10  	logdir=$WORK/log
    1.11  	mkdir -p $source $logdir $install
    1.12 @@ -64,17 +64,13 @@
    1.13  binutils() {
    1.14  	echo "Extracting: binutils-$BINUTILS_VERSION.tar.bz2"
    1.15  	tar xjf $SRC/binutils-$BINUTILS_VERSION.tar.bz2
    1.16 -	# Peer arch options --disable-werror
    1.17 -	case $ARCH in
    1.18 -		arm) archopts="--enable-shared" ;;
    1.19 -		x86_64) archopts="--disable-multilib" ;;
    1.20 -	esac
    1.21 +	: ${BINUTILS_ARGS=--enable-shared}
    1.22  	cd binutils-$BINUTILS_VERSION
    1.23  	./configure \
    1.24  		--prefix=$PREFIX \
    1.25  		--target=$TARGET \
    1.26  		--enable-targets=$BUILD_SYSTEM \
    1.27 -		$archopts
    1.28 +		$BINUTILS_ARGS
    1.29  	make || exit 1
    1.30  	make install
    1.31  }
    1.32 @@ -94,11 +90,6 @@
    1.33  gcc_static() {
    1.34  	echo "Extracting: gcc-$GCC_VERSION.tar.bz2"
    1.35  	tar xjf $SRC/gcc-$GCC_VERSION.tar.bz2
    1.36 -	# Peer arch options
    1.37 -	case $ARCH in
    1.38 -		arm) archopts="" ;;
    1.39 -		x86_64) archopts="" ;;
    1.40 -	esac
    1.41  	rm -rf gcc-static
    1.42  	mkdir gcc-static && cd gcc-static
    1.43  	../gcc-$GCC_VERSION/configure \
    1.44 @@ -109,7 +100,7 @@
    1.45  		--disable-threads \
    1.46  		--without-headers \
    1.47  		--with-newlib \
    1.48 -		--enable-languages=c
    1.49 +		$GCC_STATIC_ARGS
    1.50  	make all-gcc all-target-libgcc || exit 1
    1.51  	make install-gcc install-target-libgcc
    1.52  	cd $PREFIX/lib/gcc/$TARGET/$GCC_VERSION
    1.53 @@ -122,10 +113,10 @@
    1.54  	echo "Extracting: glibc-$GLIBC_VERSION.tar.bz2"
    1.55  	tar xjf $SRC/glibc-$GLIBC_VERSION.tar.bz2
    1.56  	[ "$continue" ] || rm -rf glibc-build
    1.57 -	# Peer arch options
    1.58 +	# Some arch may need glibc-ports and custom CFLAGS
    1.59  	case $ARCH in
    1.60  		arm)
    1.61 -			archopts=""
    1.62 +			export CFLAGS="-march=armv6 -mtune=generic -g -O2"
    1.63  			[ -f "$SRC/glibc-ports-$GLIBC_VERSION.tar.bz2" ] || wget \
    1.64  				http://ftp.gnu.org/gnu/libc/glibc-ports-$GLIBC_VERSION.tar.bz2 \
    1.65  				-O $SRC/glibc-ports-$GLIBC_VERSION.tar.bz2 || exit 1
    1.66 @@ -133,9 +124,8 @@
    1.67  			rm -rf glibc-$GLIBC_VERSION/ports
    1.68  			tar xjf $SRC/glibc-ports-$GLIBC_VERSION.tar.bz2
    1.69  			mv glibc-ports-$GLIBC_VERSION glibc-$GLIBC_VERSION/ports ;;
    1.70 -		x86_64)
    1.71 -			archopts="" ;;
    1.72  	esac
    1.73 +	echo "CFLAGS: $CFLAGS"
    1.74  	mkdir -p glibc-build && cd glibc-build
    1.75  	BUILD_CC="gcc" \
    1.76  	CC="$PREFIX/bin/$TARGET-gcc" \
    1.77 @@ -146,13 +136,14 @@
    1.78  		--host=$TARGET \
    1.79  		--with-headers=$PREFIX/include \
    1.80  		--with-binutils=$PREFIX/bin \
    1.81 -		--enable-add-ons
    1.82 +		--enable-add-ons $GLIBC_ARGS
    1.83  	make || exit 1
    1.84  	make install
    1.85  	cd $PREFIX/$TARGET
    1.86  	rm -rf lib include
    1.87  	ln -s ../lib lib
    1.88  	ln -s ../include include
    1.89 +	unset CFLAGS
    1.90  }
    1.91  
    1.92  # 5. GCC final
    1.93 @@ -161,11 +152,6 @@
    1.94  		echo "Extracting: gcc-$GCC_VERSION.tar.bz2"
    1.95  		tar xjf $SRC/gcc-$GCC_VERSION.tar.bz2
    1.96  	fi
    1.97 -	# Peer arch options
    1.98 -	case $ARCH in
    1.99 -		arm) archopts="" ;;
   1.100 -		x86_64) archopts="" ;;
   1.101 -	esac
   1.102  	rm -rf gcc-build
   1.103  	mkdir gcc-build && cd gcc-build
   1.104  	../gcc-$GCC_VERSION/configure \
   1.105 @@ -173,11 +159,11 @@
   1.106  		--libexec=$PREFIX/lib \
   1.107  		--target=$TARGET \
   1.108  		--enable-shared \
   1.109 -		--enable-languages=c,c++ \
   1.110  		--enable-c99 \
   1.111  		--enable-long-long \
   1.112  		--enable-__cxa_atexit \
   1.113 -		--with-pkgversion="SliTaz"
   1.114 +		--with-pkgversion="SliTaz" \
   1.115 +		$GCC_FINAL_ARGS
   1.116  	make || exit 1
   1.117  	make install
   1.118  }
   1.119 @@ -188,10 +174,10 @@
   1.120  	echo "Extracting: busybox-$BUSYBOX_VERSION.tar.bz2"
   1.121  	tar xjf $SRC/busybox-$BUSYBOX_VERSION.tar.bz2
   1.122  	cd busybox-$BUSYBOX_VERSION
   1.123 -	# CROSS_COMPILE is exported via init_compile, but be sure.
   1.124 -	make CROSS_COMPILE=$TARGET- defconfig
   1.125 -	make CROSS_COMPILE=$TARGET- || exit 1
   1.126 -	make CROSS_COMPILE=$TARGET- install
   1.127 +	# CROSS_COMPILE is exported via init_compile.
   1.128 +	make defconfig
   1.129 +	make || exit 1
   1.130 +	make install
   1.131  	chmod 4755 _install/bin/busybox
   1.132  	readelf -h _install/bin/busybox
   1.133  }
   1.134 @@ -212,7 +198,7 @@
   1.135  		cat << EOT
   1.136  Target arch     : $ARCH
   1.137  C Compiler      : $CC
   1.138 -Additional path : /usr/cross/$ARCH/bin
   1.139 +Additional path : $PREFIX/bin
   1.140  Build directory : $WORK
   1.141  EOT
   1.142  		separator && echo ""
   1.143 @@ -277,6 +263,8 @@
   1.144  		init_compile
   1.145  		cross_busybox 2>&1 | tee $logdir/busybox.log ;;
   1.146  	compile)
   1.147 +		# Compile the full toolchain.
   1.148 +		time=$(date +%s)
   1.149  		init_compile
   1.150  		echo "Compile start: $(date)" | tee $logdir/compile.log
   1.151  		download_src
   1.152 @@ -287,6 +275,11 @@
   1.153  		gcc_final 2>&1 | tee $logdir/gcc-final.log
   1.154  		echo ""
   1.155  		echo "Compile end  : $(date)" | tee -a $logdir/compile.log
   1.156 +		time=$(($(date +%s) - $time))
   1.157 +		sec=$time
   1.158 +		div=$(( ($time + 30) / 60))
   1.159 +		[ "$div" != 0 ] && min="~ ${div}m"
   1.160 +		echo "Build time: ${sec}s $min" | tee -a $logdir/compile.log
   1.161  		echo "" ;;
   1.162  	clean-tools)
   1.163  		# Remove crap :-)