wok view glibc/receipt @ rev 10031

glibc: make it cross compilable
author Christophe Lincoln <pankso@slitaz.org>
date Fri May 20 02:51:43 2011 +0200 (2011-05-20)
parents 0fc448aca6fe
children 6cb60b6aa19f
line source
1 # SliTaz package receipt.
3 PACKAGE="glibc"
4 VERSION="2.13"
5 CATEGORY="meta"
6 SHORT_DESC="The GNU C libraries. This package is used to compile the libc."
7 MAINTAINER="pankso@slitaz.org"
8 TARBALL="$PACKAGE-$VERSION.tar.gz"
9 WEB_SITE="http://www.gnu.org/software/libc/"
10 WGET_URL="$GNU_MIRROR/$PACKAGE/$TARBALL"
12 DEPENDS="glibc-base glibc-locale glibc-dev"
13 BUILD_DEPENDS="linux-api-headers gawk"
15 # Genpkg order for tazwok.
16 COOK_OPT="genpkg=glibc-base:glibc-extra-samba:glib-locale:glibc-dev"
18 # Rules to compile & install the temporary toolchain.
19 cook_tmp_toolchain()
20 {
21 cd $src
23 # Fix a bug that prevents Glibc from building with GCC-4.5.2:
24 patch -Np1 -i $stuff/glibc-2.13-gcc_fix-1.patch
26 # Build in a separate directory.
27 mkdir ../glibc-build && cd ../glibc-build
29 # glibc no longer support i386, so use -march=i486 for better compatibility.
30 # If i686 ???
31 case $ARCH in
32 i?86) echo "CFLAGS += -march=i486 -mtune=native" > configparms ;;
33 esac
35 { $src/configure \
36 --host=$BUILD_HOST \
37 --build=$($src/scripts/config.guess) \
38 --disable-profile --enable-add-ons \
39 --enable-kernel=2.6.22.5 --with-headers=/tools/include \
40 libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes &&
41 make &&
42 make install
43 } || return 1
45 # Link compiler to this new glibc.
46 SPECS=`dirname $($BUILD_HOST-gcc -print-libgcc-file-name)`/specs
47 $BUILD_HOST-gcc -dumpspecs | sed \
48 -e 's@/lib\(64\)\?/ld@/tools&@g' \
49 -e "/^\*cpp:$/{n;s,$, -isystem /tools/include,}" > $SPECS
50 unset SPECS
51 }
53 # Rules to configure and make the package.
54 compile_rules()
55 {
56 cd $src
57 # Following patches and sed fixes comes from LFS development book:
58 # http://www.linuxfromscratch.org/lfs/view/development/chapter06/glibc.html
59 DL=$(readelf -l /bin/sh | sed -n 's@.*interpret.*/tools\(.*\)]$@\1@p')
60 sed -i "s|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=$DL -o|" \
61 scripts/test-installation.pl
62 unset DL
63 sed -i -e 's/"db1"/& \&\& $name ne "nss_test1"/' scripts/test-installation.pl
64 sed -i 's|@BASH@|/bin/bash|' elf/ldd.bash.in
66 # Fix a bug that prevents Glibc from building with GCC-4.5.2:
67 patch -Np1 -i $stuff/glibc-2.13-gcc_fix-1.patch
69 # Fix a stack imbalance that occurs under some conditions:
70 sed -i '195,213 s/PRIVATE_FUTEX/FUTEX_CLOCK_REALTIME/' \
71 nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S \
72 nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
74 # Glibc needs ld.so.conf in the install destdir.
75 mkdir -p $WOK/$PACKAGE/install/etc
76 touch $WOK/$PACKAGE/install/etc/ld.so.conf
77 mkdir ../glibc-build && cd ../glibc-build
79 # Read the INSTALL file in glibc. Also Glibc dont build with -Os flag.
80 # --enale-kernel use latest SliTaz Kernel version. From Glibc INSTALL:
81 # "The higher the VERSION number is, the less compatibility code is
82 # added, and the faster the code gets."
83 unset CFLAGS CXXFLAGS
84 case "$ARCH" in
85 i386|i486)
86 echo "CFLAGS += -O2 -march=i486 -mtune=native" > configparms ;;
87 *)
88 echo "CFLAGS += -O2 -march=$ARCH -mtune=native" > configparms ;;
89 esac
90 { $src/configure \
91 --disable-profile \
92 --enable-add-ons \
93 --enable-kernel=2.6.37 \
94 --libexecdir=/usr/lib/glibc \
95 $CONFIGURE_ARGS &&
96 make && make install_root=$DESTDIR install
97 } || return 1
99 # If temporary toolchain was previously used, switch to regular toolchain.
100 [ -d /tools ] || return
101 mv /tools/bin/ld /tools/bin/ld-old
102 mv /tools/$(gcc -dumpmachine)/bin/ld /tools/$(gcc -dumpmachine)/bin/ld-old
103 mv /tools/bin/ld-new /tools/bin/ld
104 ln -s /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld
105 gcc -dumpspecs | sed -e 's@/tools@@g' \
106 -e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \
107 -e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' > \
108 `dirname $(gcc --print-libgcc-file-name)`/specs
109 }
111 # Rules to gen a SliTaz package suitable for Tazpkg.
112 genpkg_rules()
113 {
114 LOCALE=""
115 mkdir -p $fs/var
117 # Remove build directory.
118 rm -rf $WOK/$PACKAGE/source/$PACKAGE-build
119 rm -rf $WOK/$PACKAGE/$PACKAGE-build
120 }