cookutils annotate cross @ rev 638
cooklinux: tiny edits
author | Paul Issott <paul@slitaz.org> |
---|---|
date | Thu Feb 13 19:48:12 2014 +0000 (2014-02-13) |
parents | cda07120fb9e |
children | ebc414af08c7 |
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@361 | 20 # Help and usage. |
pankso@361 | 21 usage() { |
pankso@361 | 22 cat << EOT |
pankso@361 | 23 |
pankso@361 | 24 Usage: $(basename $0) command --option |
pankso@361 | 25 |
pankso@361 | 26 Commands: |
paul@495 | 27 howto Man[like] page and howto |
paul@382 | 28 info Display cross-tools info |
pankso@361 | 29 testsuite Execute a small testsuite |
pankso@421 | 30 check Check build host environment |
pankso@361 | 31 download Download necessary sources |
pankso@361 | 32 show-log Show a compile log |
pankso@361 | 33 binutils Compile Binutils |
pankso@421 | 34 linux-headers Install Kernel headers |
pankso@361 | 35 gcc-static Compile GCC static |
pankso@361 | 36 glibc Compile GNU Glibc |
pankso@361 | 37 gcc-final Compile final GCC |
pankso@361 | 38 compile Compile everything at once |
pankso@419 | 39 clean Clean-up build environment |
pankso@441 | 40 clean-tools Clean: $tools |
paul@455 | 41 gen-prebuilt Create a prebuilt toolchain archive |
pankso@361 | 42 |
pankso@361 | 43 EOT |
pankso@361 | 44 } |
pankso@361 | 45 |
pankso@420 | 46 # Prebuilt README |
pankso@420 | 47 prebuilt_readme() { |
pankso@420 | 48 echo -n "Creating toolchain README..." |
pankso@420 | 49 cat >> $package/README << EOT |
pankso@420 | 50 |
pankso@420 | 51 SliTaz Prebuilt $ARCH cross toolchain |
pankso@420 | 52 ================================================================================ |
pankso@420 | 53 Move this $ARCH cross compilation toolchain to /usr/cross then add tools |
pankso@420 | 54 to your PATH environment and test the toolchain: |
pankso@420 | 55 |
pankso@441 | 56 # mv $ARCH /cross |
pankso@441 | 57 # export PATH=\$PATH:/cross/$ARCH/tools/bin |
pankso@420 | 58 |
pankso@420 | 59 # echo 'int main() { return 0; }' > test.c |
pankso@420 | 60 # $TARGET-gcc -v -o test.out test.c |
pankso@420 | 61 # readelf -h test.out |
pankso@420 | 62 |
pankso@420 | 63 ================================================================================ |
pankso@420 | 64 |
pankso@420 | 65 EOT |
pankso@420 | 66 status |
pankso@420 | 67 } |
pankso@420 | 68 |
pankso@361 | 69 # Make sure we have all directories. |
pankso@361 | 70 init_compile() { |
pankso@441 | 71 unset CFLAGS CXXFLAGS |
pankso@361 | 72 export LC_ALL=POSIX LANG=POSIX |
pankso@441 | 73 export PATH=$PATH:$tools/bin |
pankso@400 | 74 export CROSS_COMPILE=${TARGET}- |
pankso@441 | 75 mkdir -p $source $logdir $sysroot $tools |
pankso@441 | 76 echo "Tools prefix : --prefix=$tools " |
pankso@441 | 77 echo "Target sysroot : --with-sysroot=$sysroot" |
pankso@361 | 78 cd $source |
pankso@361 | 79 } |
pankso@361 | 80 |
pankso@361 | 81 # Get source if not yet in $SRC. |
pankso@361 | 82 download_src() { |
pankso@361 | 83 mkdir -p $SRC && cd $SRC |
pankso@421 | 84 [ -f "$BINUTILS_TARBALL" ] || wget $BINUTILS_WGET |
pankso@421 | 85 [ -f "$LINUX_TARBALL" ] || wget $LINUX_WGET |
pankso@421 | 86 [ -f "$GLIBC_TARBALL" ] || wget $GLIBC_WGET |
pankso@421 | 87 [ -f "$GCC_TARBALL" ] || wget $GCC_WGET |
pankso@403 | 88 } |
pankso@403 | 89 |
pankso@361 | 90 # 1. Binutils |
pankso@361 | 91 binutils() { |
pankso@408 | 92 init_compile |
pankso@411 | 93 rm -rf binutils-$BINUTILS_VERSION |
pankso@421 | 94 echo "Extracting: $BINUTILS_TARBALL" |
pankso@421 | 95 tar xjf $SRC/$BINUTILS_TARBALL |
pankso@421 | 96 echo "Configure: $BINUTILS_ARGS" |
pankso@361 | 97 cd binutils-$BINUTILS_VERSION |
pankso@361 | 98 ./configure \ |
pankso@441 | 99 --prefix=$tools \ |
pankso@361 | 100 --target=$TARGET \ |
pankso@440 | 101 --enable-plugins \ |
pankso@440 | 102 --enable-threads \ |
pankso@361 | 103 --enable-targets=$BUILD_SYSTEM \ |
pankso@441 | 104 --with-sysroot=$sysroot \ |
pankso@442 | 105 $BINUTILS_ARGS && |
pankso@361 | 106 make || exit 1 |
pankso@361 | 107 make install |
pankso@421 | 108 echo "cross: binutils compiled on: $(date)" |
pankso@361 | 109 } |
pankso@361 | 110 |
paul@455 | 111 # 2. Kernel headers could use CROSS_COMPILE but gcc is not yet built. |
pankso@421 | 112 linux_headers() { |
pankso@421 | 113 init_compile |
pankso@451 | 114 if [ ! -d "linux-$LINUX_VERSION" ]; then |
pankso@451 | 115 echo "Extracting: $LINUX_TARBALL" |
pankso@637 | 116 tar xJf $SRC/$LINUX_TARBALL |
pankso@451 | 117 fi |
pankso@451 | 118 rm -rf linux-headers |
pankso@421 | 119 cd linux-$LINUX_VERSION |
pankso@421 | 120 make mrproper |
pankso@421 | 121 make ARCH=$ARCH headers_check |
pankso@450 | 122 make ARCH=$ARCH headers_install \ |
pankso@450 | 123 INSTALL_HDR_PATH=$source/linux-headers |
pankso@453 | 124 rm $source/linux-headers/include/.*install* |
pankso@450 | 125 echo "Copying headers to: $sysroot/usr" |
pankso@450 | 126 cp -a $source/linux-headers/* $sysroot/usr |
pankso@421 | 127 } |
pankso@421 | 128 |
pankso@447 | 129 # 2.1 Glibc headers needed to compile x86_64 gcc-static. |
pankso@447 | 130 glibc_headers() { |
pankso@447 | 131 init_compile |
pankso@447 | 132 echo "Extracting: $GLIBC_TARBALL" |
pankso@447 | 133 tar xjf $SRC/$GLIBC_TARBALL |
pankso@447 | 134 rm -rf glibc-headers |
pankso@447 | 135 mkdir glibc-headers && cd glibc-headers |
pankso@450 | 136 libc_cv_forced_unwind=yes \ |
pankso@450 | 137 libc_cv_c_cleanup=yes \ |
pankso@447 | 138 ../glibc-$GLIBC_VERSION/configure \ |
pankso@447 | 139 --prefix=/usr \ |
pankso@447 | 140 --host=$TARGET \ |
pankso@447 | 141 --with-headers=$sysroot/usr/include \ |
pankso@447 | 142 --without-cvs \ |
pankso@447 | 143 --disable-sanity-checks \ |
pankso@447 | 144 --enable-kernel=2.6.32 && |
pankso@447 | 145 make -k install-headers install_root=$sysroot |
pankso@448 | 146 # Fixes |
pankso@448 | 147 mkdir -p $sysroot/usr/include/gnu |
pankso@448 | 148 touch $sysroot/usr/include/gnu/stubs.h |
pankso@448 | 149 cp bits/stdio_lim.h $sysroot/usr/include/bits |
pankso@447 | 150 } |
pankso@447 | 151 |
pankso@421 | 152 # 3. GCC static (first pass) |
pankso@361 | 153 gcc_static() { |
pankso@408 | 154 init_compile |
pankso@421 | 155 echo "Extracting: $GCC_TARBALL" |
pankso@421 | 156 tar xjf $SRC/$GCC_TARBALL |
pankso@421 | 157 echo "Configure: $GCC_STATIC_ARGS" |
pankso@361 | 158 rm -rf gcc-static |
pankso@361 | 159 mkdir gcc-static && cd gcc-static |
pankso@361 | 160 ../gcc-$GCC_VERSION/configure \ |
pankso@441 | 161 --prefix=$tools \ |
pankso@441 | 162 --libexec=$tools/lib \ |
pankso@361 | 163 --target=$TARGET \ |
pankso@361 | 164 --disable-shared \ |
pankso@361 | 165 --disable-threads \ |
pankso@441 | 166 --disable-libgomp \ |
pankso@441 | 167 --disable-libmudflap \ |
pankso@441 | 168 --disable-libssp \ |
pankso@361 | 169 --without-headers \ |
pankso@361 | 170 --with-newlib \ |
pankso@441 | 171 --with-sysroot=$sysroot \ |
pankso@442 | 172 $GCC_STATIC_ARGS && |
pankso@361 | 173 make all-gcc all-target-libgcc || exit 1 |
pankso@361 | 174 make install-gcc install-target-libgcc |
pankso@421 | 175 echo "cross: gcc-static compiled on: $(date)" |
pankso@403 | 176 } |
pankso@403 | 177 |
pankso@361 | 178 # 4. GNU Glibc |
pankso@361 | 179 glibc() { |
pankso@408 | 180 init_compile |
pankso@421 | 181 echo "Extracting: $GLIBC_TARBALL" |
pankso@421 | 182 tar xjf $SRC/$GLIBC_TARBALL |
pankso@421 | 183 echo "Configure: $GLIBC_ARGS" |
pankso@400 | 184 # Some arch may need glibc-ports and custom CFLAGS |
pankso@403 | 185 case "$ARCH" in |
pankso@361 | 186 arm) |
pankso@433 | 187 export CFLAGS="-march=armv6 -O2" |
pankso@362 | 188 [ -f "$SRC/glibc-ports-$GLIBC_VERSION.tar.bz2" ] || wget \ |
pankso@362 | 189 http://ftp.gnu.org/gnu/libc/glibc-ports-$GLIBC_VERSION.tar.bz2 \ |
pankso@362 | 190 -O $SRC/glibc-ports-$GLIBC_VERSION.tar.bz2 || exit 1 |
pankso@361 | 191 echo "Extracting: glibc-ports-$GLIBC_VERSION.tar.bz2" |
pankso@361 | 192 rm -rf glibc-$GLIBC_VERSION/ports |
pankso@361 | 193 tar xjf $SRC/glibc-ports-$GLIBC_VERSION.tar.bz2 |
pankso@449 | 194 mv glibc-ports-$GLIBC_VERSION glibc-$GLIBC_VERSION/ports |
pankso@449 | 195 libexec=/usr/lib/glibc ;; |
pankso@418 | 196 x86_64) |
pankso@449 | 197 #export CFLAGS="-march=nocona -O2 -pipe" |
pankso@449 | 198 ccflags="-m64" |
pankso@449 | 199 libexec=/usr/lib64/glibc ;; |
pankso@361 | 200 esac |
pankso@441 | 201 # Disable linking to libgcc_eh |
pankso@441 | 202 cd glibc-$GLIBC_VERSION |
pankso@441 | 203 cp Makeconfig Makeconfig.orig |
pankso@441 | 204 sed -e 's/-lgcc_eh//g' Makeconfig.orig > Makeconfig |
pankso@441 | 205 cd .. |
pankso@421 | 206 echo "CFLAGS: $CFLAGS" |
pankso@441 | 207 rm -rf glibc-build |
pankso@361 | 208 mkdir -p glibc-build && cd glibc-build |
pankso@365 | 209 BUILD_CC="gcc" \ |
pankso@418 | 210 CC="${TARGET}-gcc $ccflags" \ |
pankso@441 | 211 AR="${TARGET}-ar" \ |
pankso@441 | 212 RANLIB="${TARGET}-ranlib" \ |
pankso@361 | 213 libc_cv_forced_unwind=yes \ |
pankso@361 | 214 libc_cv_c_cleanup=yes \ |
pankso@361 | 215 ../glibc-$GLIBC_VERSION/configure \ |
pankso@441 | 216 --prefix=/usr \ |
pankso@449 | 217 --libexec=$libexec \ |
pankso@361 | 218 --host=$TARGET \ |
pankso@441 | 219 --with-headers=$sysroot/usr/include \ |
pankso@441 | 220 --with-binutils=$tools/bin \ |
pankso@425 | 221 --enable-kernel=2.6.32 \ |
pankso@442 | 222 $GLIBC_ARGS && |
pankso@361 | 223 make || exit 1 |
pankso@441 | 224 make install_root=$sysroot install |
pankso@454 | 225 # Symlink lib64 to lib |
pankso@454 | 226 case "$ARCH" in |
pankso@454 | 227 x86_64) |
pankso@454 | 228 rm -f $sysroot/lib $sysroot/usr/lib |
pankso@454 | 229 cd $sysroot && ln -s lib64 lib |
pankso@454 | 230 cd usr && ln -s lib64 lib ;; |
pankso@454 | 231 esac |
pankso@421 | 232 echo "cross: glibc compiled on: $(date)" |
pankso@361 | 233 } |
pankso@361 | 234 |
pankso@441 | 235 # 4. Eglibc: always use --prefix=/usr |
pankso@441 | 236 eglibc() { |
pankso@441 | 237 init_compile |
pankso@441 | 238 rm -rf eglibc-build eglibc-$EGLIBC_VERSION |
pankso@441 | 239 echo "Extracting: $EGLIBC_TARBALL" |
pankso@632 | 240 tar xjf $SRC/$EGLIBC_TARBALL || exit 1 |
pankso@441 | 241 # Some arch may need glibc-ports and custom CFLAGS |
pankso@441 | 242 case "$ARCH" in |
pankso@441 | 243 arm) |
pankso@441 | 244 export CFLAGS="-march=armv6 -O2" |
pankso@441 | 245 if [ ! -d "$source/eglibc-ports-$EGLIBC_VERSION" ]; then |
pankso@441 | 246 echo "Cloning $EGLIBC_WGET/ports" |
pankso@441 | 247 svn co $EGLIBC_WGET/ports eglibc-ports-$EGLIBC_VERSION >/dev/null |
pankso@441 | 248 fi |
pankso@449 | 249 cp -a eglibc-ports-$EGLIBC_VERSION eglibc-$EGLIBC_VERSION/ports |
pankso@449 | 250 libexec=/usr/lib/eglibc ;; |
pankso@441 | 251 x86_64) |
pankso@449 | 252 #export CFLAGS="-march=nocona -O2 -pipe" |
pankso@449 | 253 ccflags="-m64" |
pankso@449 | 254 libexec=/usr/lib64/eglibc ;; |
pankso@441 | 255 esac |
pankso@441 | 256 # Disable linking to libgcc_eh |
pankso@441 | 257 cd eglibc-$EGLIBC_VERSION |
pankso@441 | 258 cp Makeconfig Makeconfig.orig |
pankso@441 | 259 sed -e 's/-lgcc_eh//g' Makeconfig.orig > Makeconfig |
pankso@441 | 260 cd .. |
pankso@441 | 261 mkdir -p eglibc-build && cd eglibc-build |
pankso@441 | 262 # config.cache |
pankso@441 | 263 cat > config.cache << EOT |
pankso@441 | 264 libc_cv_forced_unwind=yes |
pankso@441 | 265 libc_cv_c_cleanup=yes |
pankso@441 | 266 libc_cv_gnu89_inline=yes |
pankso@441 | 267 EOT |
pankso@441 | 268 BUILD_CC="gcc" \ |
pankso@441 | 269 CC="${TARGET}-gcc $ccflags" \ |
pankso@441 | 270 AR="${TARGET}-ar" \ |
pankso@441 | 271 RANLIB="${TARGET}-ranlib" \ |
pankso@441 | 272 ../eglibc-$EGLIBC_VERSION/configure \ |
pankso@441 | 273 --prefix=/usr \ |
pankso@449 | 274 --libexec=$libexec \ |
pankso@441 | 275 --host=$TARGET \ |
pankso@441 | 276 --with-headers=$sysroot/usr/include \ |
pankso@441 | 277 --with-binutils=$tools/bin \ |
pankso@441 | 278 --enable-kernel=2.6.32 \ |
pankso@441 | 279 --with-__thread \ |
pankso@441 | 280 --without-gd \ |
pankso@441 | 281 --without-cvs \ |
pankso@441 | 282 --cache-file=config.cache \ |
pankso@442 | 283 $EGLIBC_ARGS && |
pankso@441 | 284 make || exit 1 |
pankso@441 | 285 make install_root=$sysroot install |
pankso@449 | 286 # The rpc headers (RPC is no longer in eglibc <2.13) |
pankso@445 | 287 # |
pankso@445 | 288 #if [ "$EGLIBC_VERSION" -gt "2.13" ]; then |
pankso@445 | 289 #rpcsvc = "bootparam_prot.x nlm_prot.x rstat.x \ |
pankso@445 | 290 #yppasswd.x klm_prot.x rex.x sm_inter.x mount.x \ |
pankso@445 | 291 #rusers.x spray.x nfs_prot.x rquota.x key_prot.x" |
pankso@445 | 292 #cd sunrpc/rpcsvc |
pankso@445 | 293 #for r in ${rpcsvc}; do |
pankso@449 | 294 #h=$(echo $r|sed -e's,\.x$,.h,') |
pankso@449 | 295 #rpcgen -h $r -o $h || echo "unable to generate header for $r" |
pankso@445 | 296 #done |
pankso@445 | 297 #fi |
pankso@441 | 298 } |
pankso@441 | 299 |
pankso@361 | 300 # 5. GCC final |
pankso@361 | 301 gcc_final() { |
pankso@408 | 302 init_compile |
pankso@361 | 303 if [ ! -d "gcc-$GCC_VERSION" ]; then |
pankso@421 | 304 echo "Extracting: $GCC_TARBALL" |
pankso@421 | 305 tar xjf $SRC/$GCC_TARBALL |
pankso@361 | 306 fi |
pankso@421 | 307 echo "Configure: $GCC_FINAL_ARGS" |
pankso@441 | 308 rm -rf gcc-build |
pankso@421 | 309 mkdir -p gcc-build && cd gcc-build |
pankso@441 | 310 AR=ar \ |
pankso@361 | 311 ../gcc-$GCC_VERSION/configure \ |
pankso@441 | 312 --prefix=$tools \ |
pankso@441 | 313 --libexec=$tools/lib \ |
pankso@361 | 314 --target=$TARGET \ |
pankso@361 | 315 --enable-shared \ |
pankso@361 | 316 --enable-c99 \ |
pankso@361 | 317 --enable-long-long \ |
pankso@361 | 318 --enable-__cxa_atexit \ |
pankso@440 | 319 --with-system-zlib \ |
pankso@440 | 320 --enable-plugin \ |
pankso@440 | 321 --disable-multilib \ |
pankso@440 | 322 --disable-libssp \ |
pankso@441 | 323 --disable-checking \ |
pankso@441 | 324 --disable-werror \ |
pankso@400 | 325 --with-pkgversion="SliTaz" \ |
pankso@440 | 326 --with-bugurl="https://bugs.slitaz.org/" \ |
pankso@442 | 327 --with-sysroot=$sysroot \ |
pankso@442 | 328 $GCC_FINAL_ARGS && |
pankso@441 | 329 make AS_FOR_TARGET="${TARGET}-as" \ |
pankso@441 | 330 LD_FOR_TARGET="${TARGET}-ld" || exit 1 |
pankso@441 | 331 make install |
pankso@421 | 332 echo "cross: GCC final compiled on: $(date)" |
pankso@361 | 333 } |
pankso@361 | 334 |
pankso@361 | 335 # |
pankso@361 | 336 # Commands |
pankso@361 | 337 # |
pankso@361 | 338 |
pankso@361 | 339 case "$1" in |
pankso@361 | 340 howto|man) |
pankso@361 | 341 doc=/usr/share/doc/cookutils/cross.txt |
pankso@361 | 342 [ -f "$doc" ] && less -E $doc ;; |
pankso@361 | 343 info) |
pankso@361 | 344 init_compile |
pankso@361 | 345 CC=${TARGET}-gcc |
paul@382 | 346 echo -e "\nCross Toolchain information" && separator |
pankso@374 | 347 [ "$config" ] && echo "Config file : $config" |
pankso@361 | 348 cat << EOT |
pankso@374 | 349 Target arch : $ARCH |
pankso@374 | 350 C Compiler : $CC |
pankso@374 | 351 Build directory : $WORK |
pankso@441 | 352 Tools prefix : $tools/bin |
pankso@441 | 353 Arch sysroot : $sysroot |
pankso@361 | 354 EOT |
pankso@361 | 355 separator && echo "" |
pankso@361 | 356 echo "GCC version" && separator |
pankso@441 | 357 if [ -x "$tools/bin/$CC" ]; then |
pankso@374 | 358 $CC -v |
pankso@374 | 359 else |
pankso@374 | 360 echo "No C compiler. To build a toolchain run: cross compile" |
pankso@441 | 361 echo "Missing: $tools/bin/$CC" |
pankso@374 | 362 fi |
pankso@361 | 363 separator && echo "" ;; |
pankso@361 | 364 testsuite) |
pankso@361 | 365 init_compile |
pankso@361 | 366 echo "[COMPILING] $TARGET-gcc -v -Wall -o test.out test.c" \ |
pankso@361 | 367 | tee $logdir/testsuite.log |
pankso@361 | 368 echo 'int main() { return 0; }' > test.c |
pankso@361 | 369 $TARGET-gcc -v -Wall -o test.out test.c 2>&1 | tee -a $logdir/testsuite.log |
pankso@361 | 370 if [ -x /usr/bin/file ]; then |
pankso@361 | 371 echo -e "\n[CHECKING] file test.out" | tee -a $logdir/testsuite.log |
pankso@361 | 372 file test.out | tee -a $logdir/testsuite.log |
pankso@361 | 373 fi |
pankso@361 | 374 echo -e "\n[CHECKING] readelf -h test.out" | tee -a $logdir/testsuite.log |
pankso@361 | 375 readelf -h test.out | tee -a $logdir/testsuite.log ;; |
pankso@421 | 376 check) |
pankso@421 | 377 echo "Checking: build system packages" |
pankso@421 | 378 for pkg in slitaz-toolchain mpfr mpfr-dev gmp gmp-dev mpc-library \ |
pankso@421 | 379 gawk autoconf; do |
pankso@361 | 380 if [ ! -d "/var/lib/tazpkg/installed/$pkg" ]; then |
pankso@361 | 381 echo "Missing packages: $pkg" |
pankso@421 | 382 if [ -x /usr/sbin/spk-add ]; then |
pankso@421 | 383 spk-add $pkg |
pankso@421 | 384 else |
pankso@421 | 385 tazpkg -gi $pkg |
pankso@421 | 386 fi |
pankso@361 | 387 fi |
pankso@421 | 388 done |
pankso@441 | 389 echo "Using: --with-sysroot=$sysroot" ;; |
pankso@361 | 390 download) |
pankso@361 | 391 download_src ;; |
pankso@361 | 392 show-log) |
pankso@361 | 393 pkg=$2 |
pankso@371 | 394 log=$logdir/$pkg.log |
pankso@371 | 395 if [ ! -f "$log" ]; then |
pankso@371 | 396 echo "No log file found for: $pkg" && exit 1 |
pankso@371 | 397 fi |
pankso@371 | 398 less -E $log ;; |
pankso@361 | 399 binutils) |
pankso@412 | 400 rm -f $logdir/binutils.log |
pankso@361 | 401 binutils 2>&1 | tee $logdir/binutils.log ;; |
pankso@447 | 402 linux-headers) |
pankso@447 | 403 linux_headers 2>&1 | tee $logdir/linux-headers.log ;; |
pankso@447 | 404 glibc-headers) |
pankso@447 | 405 glibc_headers 2>&1 | tee $logdir/glibc-headers.log ;; |
pankso@403 | 406 gcc-static) |
pankso@403 | 407 gcc_static 2>&1 | tee $logdir/gcc-static.log ;; |
pankso@361 | 408 glibc) |
pankso@361 | 409 glibc 2>&1 | tee $logdir/glibc.log ;; |
pankso@441 | 410 eglibc) |
pankso@441 | 411 eglibc 2>&1 | tee $logdir/eglibc.log ;; |
pankso@361 | 412 gcc-final) |
pankso@361 | 413 gcc_final 2>&1 | tee $logdir/gcc-final.log ;; |
pankso@361 | 414 compile) |
pankso@400 | 415 # Compile the full toolchain. |
pankso@400 | 416 time=$(date +%s) |
pankso@361 | 417 init_compile |
pankso@361 | 418 echo "Compile start: $(date)" | tee $logdir/compile.log |
pankso@361 | 419 download_src |
pankso@361 | 420 binutils 2>&1 | tee $logdir/binutils.log |
pankso@447 | 421 case "$ARCH" in |
pankso@447 | 422 x86_64) glibc_headers 2>&1 | tee $logdir/glibc-headers.log ;; |
pankso@447 | 423 esac |
pankso@403 | 424 gcc_static 2>&1 | tee $logdir/gcc-static.log |
pankso@361 | 425 linux_headers 2>&1 | tee $logdir/linux-headers.log |
pankso@441 | 426 case "$ARCH" in |
pankso@441 | 427 arm) eglibc 2>&1 | tee $logdir/eglibc.log ;; |
pankso@441 | 428 x86_64) glibc 2>&1 | tee $logdir/glibc.log ;; |
pankso@441 | 429 esac |
pankso@361 | 430 gcc_final 2>&1 | tee $logdir/gcc-final.log |
pankso@361 | 431 echo "" |
pankso@365 | 432 echo "Compile end : $(date)" | tee -a $logdir/compile.log |
pankso@400 | 433 time=$(($(date +%s) - $time)) |
pankso@400 | 434 sec=$time |
pankso@400 | 435 div=$(( ($time + 30) / 60)) |
pankso@400 | 436 [ "$div" != 0 ] && min="~ ${div}m" |
pankso@401 | 437 echo "Build time : ${sec}s $min" | tee -a $logdir/compile.log |
pankso@361 | 438 echo "" ;; |
pankso@416 | 439 clean) |
pankso@416 | 440 echo -n "Removing all source files..." |
pankso@441 | 441 rm -rf $WORK/source && status |
pankso@441 | 442 [ "$log" ] && rm -f $WORK/log/*.log ;; |
pankso@371 | 443 clean-tools) |
pankso@371 | 444 # Remove crap :-) |
pankso@371 | 445 init_compile |
pankso@441 | 446 echo "Cleaning : $tools ($(du -sh $tools | awk '{print $1}'))" |
pankso@443 | 447 for file in share/info share/man share/local |
pankso@371 | 448 do |
pankso@440 | 449 echo -n "Removing : $file" |
pankso@441 | 450 rm -rf $tools/$file && status |
pankso@371 | 451 done |
pankso@419 | 452 echo -n "Stripping : shared libs and binaries" |
pankso@443 | 453 find $tools/bin -type f -exec strip -s '{}' 2>/dev/null \; |
pankso@443 | 454 find $tools/lib -name cc1* -exec strip -s '{}' 2>/dev/null \; |
pankso@443 | 455 find $tools/lib -name lto* -exec strip -s '{}' 2>/dev/null \; |
pankso@444 | 456 find $sysroot -name "*.so*" -exec ${TARGET}-strip -s '{}' 2>/dev/null \; |
pankso@416 | 457 sleep 1 && status |
pankso@441 | 458 echo -n "Tools size : " && du -sh $tools | awk '{print $1}' ;; |
pankso@416 | 459 gen-prebuilt) |
pankso@420 | 460 # Create a prebuilt cross toolchain tarball. |
pankso@416 | 461 init_compile |
pankso@420 | 462 date=$(date "+%Y%m%d") |
pankso@443 | 463 package="slitaz-$ARCH-toolchain-$date" |
pankso@419 | 464 tarball="$package.tar.bz2" |
pankso@441 | 465 cd /cross |
pankso@443 | 466 mkdir -p $package/$ARCH || exit 1 |
pankso@419 | 467 echo "" |
pankso@419 | 468 echo -n "Copying $ARCH to: $package" |
pankso@443 | 469 cp -a $ARCH/tools $package/$ARCH |
pankso@443 | 470 cp -a $ARCH/sysroot $package/$ARCH |
pankso@419 | 471 status |
pankso@420 | 472 prebuilt_readme |
pankso@416 | 473 echo -n "Creating prebuilt $ARCH toolchain tarball..." |
pankso@419 | 474 tar cjf $tarball $package |
pankso@416 | 475 status |
pankso@419 | 476 rm -rf $package |
pankso@441 | 477 size=$(du -sh $tarball | awk '{print $1}') |
pankso@441 | 478 echo "Tarball path: $(pwd)/$tarball" |
pankso@419 | 479 echo "Tarball size: $size" |
pankso@419 | 480 echo "" ;; |
pankso@361 | 481 *) |
pankso@361 | 482 usage ;; |
pankso@361 | 483 esac |
pankso@361 | 484 |