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