| 1 | #!/bin/bash
|
|---|
| 2 |
|
|---|
| 3 | # cross-lfs native glibc build
|
|---|
| 4 | # ----------------------------
|
|---|
| 5 | # $LastChangedBy$
|
|---|
| 6 | # $LastChangedDate$
|
|---|
| 7 | # $LastChangedRevision$
|
|---|
| 8 | # $HeadURL$
|
|---|
| 9 | #
|
|---|
| 10 |
|
|---|
| 11 | cd ${SRC}
|
|---|
| 12 | LOG="glibc-native.log"
|
|---|
| 13 |
|
|---|
| 14 | # Test if the 64 script has been called.
|
|---|
| 15 | # This should only really get called during bi-arch builds
|
|---|
| 16 | SELF=`basename ${0}`
|
|---|
| 17 | set_buildenv
|
|---|
| 18 | set_libdirname
|
|---|
| 19 | setup_multiarch
|
|---|
| 20 |
|
|---|
| 21 | # Only add --build=foo ( and probably should set --host=foo )
|
|---|
| 22 | # if we are doing a multi-arch build.
|
|---|
| 23 | # By rights --host should be inferred from --build, and CC will
|
|---|
| 24 | # be set for the correct emulation ( via -m32/-m64 etc ) anyway
|
|---|
| 25 | if [ "Y" = "${MULTIARCH}" ]; then
|
|---|
| 26 | if [ -z "${ALT_TGT}" ]; then ALT_TGT="${TARGET}" ; fi
|
|---|
| 27 | extra_conf="--build=${ALT_TGT}"
|
|---|
| 28 | fi
|
|---|
| 29 |
|
|---|
| 30 | if [ "${USE_SYSROOT}" = "Y" ]; then
|
|---|
| 31 | KERN_HDR_PREFIX=/usr
|
|---|
| 32 | else
|
|---|
| 33 | KERN_HDR_PREFIX="${TGT_TOOLS}"
|
|---|
| 34 | fi
|
|---|
| 35 |
|
|---|
| 36 | # point at the correct kernel headers
|
|---|
| 37 | #------------------------------------
|
|---|
| 38 | if [ "Y" = "${USE_SANITISED_HEADERS}" ]; then
|
|---|
| 39 | KERN_HDR_DIR="${KERN_HDR_PREFIX}/kernel-hdrs"
|
|---|
| 40 | else
|
|---|
| 41 | KERN_HDR_DIR="${KERN_HDR_PREFIX}/include"
|
|---|
| 42 | fi
|
|---|
| 43 |
|
|---|
| 44 | unpack_tarball glibc-${GLIBC_VER} &&
|
|---|
| 45 | cd ${PKGDIR}
|
|---|
| 46 |
|
|---|
| 47 | # Gather package version information
|
|---|
| 48 | #-----------------------------------
|
|---|
| 49 | target_glibc_ver=`grep VERSION version.h | \
|
|---|
| 50 | sed 's@.*\"\([0-9.]*\)\"@\1@'`
|
|---|
| 51 | export target_glibc_ver
|
|---|
| 52 |
|
|---|
| 53 | # Retrieve target_gcc_ver from gcc -v output
|
|---|
| 54 | target_gcc_ver=`${CC-gcc} -v 2>&1 | grep " version " | \
|
|---|
| 55 | sed 's@.*version \([0-9.]*\).*@\1@g'`
|
|---|
| 56 |
|
|---|
| 57 | # get kernel version from kernel headers
|
|---|
| 58 | kernver=`grep UTS_RELEASE ${KERN_HDR_DIR}/linux/version.h | \
|
|---|
| 59 | sed 's@.*\"\([0-9.]*\).*\"@\1@g' `
|
|---|
| 60 |
|
|---|
| 61 | # if we don't have linuxthreads dirs (ie: a glibc release), then
|
|---|
| 62 | # unpack the linuxthreads tarball
|
|---|
| 63 | case ${GLIBC_VER} in
|
|---|
| 64 | 2.4 | 2.4.* ) ;;
|
|---|
| 65 | * )
|
|---|
| 66 | if [ ! -d linuxthreads -o ! -d linuxthreads_db ]; then
|
|---|
| 67 | OLDPKGDIR=${PKGDIR} ; unpack_tarball glibc-linuxthreads-${GLIBC_VER}
|
|---|
| 68 | PKGDIR=${OLDPKGDIR}
|
|---|
| 69 | fi
|
|---|
| 70 | ;;
|
|---|
| 71 | esac
|
|---|
| 72 |
|
|---|
| 73 | # unpack libidn add-on if required (should be supplied with cvs versions)
|
|---|
| 74 | if [ "${USE_LIBIDN}" = "Y" ]; then
|
|---|
| 75 | case ${target_glibc_ver} in
|
|---|
| 76 | 2.3.[4-9]* | 2.4* )
|
|---|
| 77 | cd ${SRC}/${PKGDIR}
|
|---|
| 78 | if [ ! -d libidn ]; then
|
|---|
| 79 | OLDPKGDIR=${PKGDIR} ; unpack_tarball glibc-libidn-${GLIBC_VER}
|
|---|
| 80 | PKGDIR=${OLDPKGDIR}
|
|---|
| 81 | fi
|
|---|
| 82 | ;;
|
|---|
| 83 | esac
|
|---|
| 84 | fi
|
|---|
| 85 |
|
|---|
| 86 | # apply glibc patches as required depending on the above gcc/kernel versions
|
|---|
| 87 | # see funcs/glibc_funcs.sh
|
|---|
| 88 | apply_glibc_patches
|
|---|
| 89 |
|
|---|
| 90 | # Ensure sanity check uses correct glibc
|
|---|
| 91 | cd ${SRC}/${PKGDIR}
|
|---|
| 92 | ld_so=`gcc ${ARCH_CFLAGS} -dumpspecs | grep dynamic-linker | \
|
|---|
| 93 | sed -e "s@.*-dynamic-linker \([-._a-zA-Z0-9/]*/${libdirname}/[-._a-zA-Z0-9/]*\).*@\1@g" \
|
|---|
| 94 | -e 's@^.*/\(.*\)@\1@g'`
|
|---|
| 95 | sed -i "s@link_libs -o@link_libs -L/usr/${libdirname} -Wl,-dynamic-linker=/${libdirname}/${ld_so} -o@" \
|
|---|
| 96 | scripts/test-installation.pl
|
|---|
| 97 |
|
|---|
| 98 | # configuration for pthread type
|
|---|
| 99 | #-------------------------------
|
|---|
| 100 | # HACK: nptl for sparc64 wont build
|
|---|
| 101 | case ${TGT_ARCH} in
|
|---|
| 102 | sparc64 )
|
|---|
| 103 | USE_NPTL=N
|
|---|
| 104 | ;;
|
|---|
| 105 | esac
|
|---|
| 106 |
|
|---|
| 107 | if [ "Y" = "${USE_NPTL}" ]; then
|
|---|
| 108 | # remove linuxthreads dirs if they exist
|
|---|
| 109 | # (CVS source contains linuxthreads)
|
|---|
| 110 | test -d linuxthreads &&
|
|---|
| 111 | rm -rf linuxthreads*
|
|---|
| 112 |
|
|---|
| 113 | # As of ~2003-10-06 nptl is included in glibc cvs
|
|---|
| 114 | #test -d ./nptl &&
|
|---|
| 115 | #test -d ./nptl_db ||
|
|---|
| 116 | #unpack_tarball nptl-${NPTL_VER}
|
|---|
| 117 |
|
|---|
| 118 | # fix tst-cancelx7 test (if needed)
|
|---|
| 119 | fname="${SRC}/${PKGDIR}/nptl/Makefile"
|
|---|
| 120 | grep tst-cancelx7-ARGS ${fname} > /dev/null 2>&1 || {
|
|---|
| 121 | echo " - patching ${fname}"
|
|---|
| 122 | mv ${fname} ${fname}-ORIG
|
|---|
| 123 | sed -e '/tst-cancel7-ARGS = --command "$(built-program-cmd)"/a\
|
|---|
| 124 | tst-cancelx7-ARGS = --command "$(built-program-cmd)"' \
|
|---|
| 125 | ${fname}-ORIG > ${fname}
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | extra_conf="${extra_conf} --with-tls --with-__thread"
|
|---|
| 129 | else
|
|---|
| 130 | if [ -d ./nptl ]; then rm -rf nptl* ; fi
|
|---|
| 131 | fi
|
|---|
| 132 |
|
|---|
| 133 | # set without-fp if target has no floating point unit
|
|---|
| 134 | if [ "${WITHOUT_FPU}" = "Y" ]; then
|
|---|
| 135 | extra_conf="${extra_conf} --without-fp"
|
|---|
| 136 | fi
|
|---|
| 137 |
|
|---|
| 138 | # set --enable-kernel to match the kernel version
|
|---|
| 139 | # of the kernel headers glibc is to be built against
|
|---|
| 140 | #-------------------------------------------------
|
|---|
| 141 | # HACK: hack around 2.6.8.1 release
|
|---|
| 142 | case ${kernver} in 2.6.8.* ) kernver=2.6.8 ;; esac
|
|---|
| 143 | extra_conf="${extra_conf} --enable-kernel=${kernver}"
|
|---|
| 144 |
|
|---|
| 145 | # End prep
|
|---|
| 146 | #--------------------------------
|
|---|
| 147 | touch /etc/ld.so.conf
|
|---|
| 148 |
|
|---|
| 149 | test -d ${SRC}/glibc-${GLIBC_VER}-native${suffix} &&
|
|---|
| 150 | rm -rf ${SRC}/glibc-${GLIBC_VER}-native${suffix}
|
|---|
| 151 |
|
|---|
| 152 | mkdir ${SRC}/glibc-${GLIBC_VER}-native${suffix}
|
|---|
| 153 | cd ${SRC}/glibc-${GLIBC_VER}-native${suffix}
|
|---|
| 154 |
|
|---|
| 155 | if [ ! "${libdirname}" = "lib" ]; then
|
|---|
| 156 | extra_conf="${extra_conf} --libdir=/usr/${libdirname}"
|
|---|
| 157 | # Also create a configparms file setting slibdir to */libdirname
|
|---|
| 158 | echo "slibdir=/${libdirname}" >> configparms
|
|---|
| 159 | fi
|
|---|
| 160 |
|
|---|
| 161 | max_log_init Glibc ${GLIBC_VER} native ${CONFLOGS} ${LOG}
|
|---|
| 162 | CFLAGS="-O2 -pipe" PARALLELMFLAGS="${PMFLAGS}" \
|
|---|
| 163 | CC="${CC-gcc} ${ARCH_CFLAGS} ${TGT_CFLAGS}" \
|
|---|
| 164 | CXX="${CXX-g++} ${ARCH_CFLAGS} ${TGT_CFLAGS}" \
|
|---|
| 165 | ../${PKGDIR}/configure --prefix=/usr \
|
|---|
| 166 | --without-cvs --disable-profile --enable-add-ons \
|
|---|
| 167 | --with-headers=${KERN_HDR_DIR} ${extra_conf} \
|
|---|
| 168 | --mandir=/usr/share/man --infodir=/usr/share/info \
|
|---|
| 169 | --libexecdir=/usr/${libdirname}/glibc \
|
|---|
| 170 | >> ${LOGFILE} 2>&1 &&
|
|---|
| 171 | echo " o Configure OK" &&
|
|---|
| 172 |
|
|---|
| 173 | min_log_init ${BUILDLOGS} &&
|
|---|
| 174 | make PARALLELMFLAGS="${PMFLAGS}" \
|
|---|
| 175 | >> ${LOGFILE} 2>&1 &&
|
|---|
| 176 | echo " o Build OK" || barf
|
|---|
| 177 |
|
|---|
| 178 | # Tests moved after install, during glibc tests
|
|---|
| 179 | # at times librt will be rebuilt... incorrectly.
|
|---|
| 180 | # Better to install first and not have to worry
|
|---|
| 181 | # about anything built correctly being replaced
|
|---|
| 182 | # by something broken...
|
|---|
| 183 |
|
|---|
| 184 | echo "-Installing Glibc" &&
|
|---|
| 185 | min_log_init ${INSTLOGS} &&
|
|---|
| 186 | make install \
|
|---|
| 187 | >> ${LOGFILE} 2>&1 &&
|
|---|
| 188 | echo " o install OK" || barf
|
|---|
| 189 |
|
|---|
| 190 | make localedata/install-locales \
|
|---|
| 191 | >> ${LOGFILE} 2>&1 &&
|
|---|
| 192 | echo " o install-locales OK" || barf
|
|---|
| 193 | ln -sf ../usr/share/zoneinfo/${TZ} /etc/localtime &&
|
|---|
| 194 |
|
|---|
| 195 | # Use make -k check... will have to revisit this
|
|---|
| 196 | min_log_init ${TESTLOGS} &&
|
|---|
| 197 | make -k check \
|
|---|
| 198 | >> ${LOGFILE} 2>&1 &&
|
|---|
| 199 | echo " o Test OK" || errmsg
|
|---|
| 200 |
|
|---|
| 201 | # install sample nscd.conf
|
|---|
| 202 | if [ ! -f /etc/nscd.conf ]; then
|
|---|
| 203 | echo -n " o Creating /etc/nscd.conf - "
|
|---|
| 204 | cp ${SRC}/${PKGDIR}/nscd/nscd.conf /etc/nscd.conf &&
|
|---|
| 205 | echo "OK" || echo "FAIL"
|
|---|
| 206 | fi
|
|---|
| 207 |
|
|---|
| 208 | if [ ! -d /var/run/nscd ]; then
|
|---|
| 209 | mkdir -p /var/run/nscd
|
|---|
| 210 | fi
|
|---|