[617118d] | 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 | if [ ! -d linuxthreads -o ! -d linuxthreads_db ]; then |
---|
| 64 | OLDPKGDIR=${PKGDIR} ; unpack_tarball glibc-linuxthreads-${GLIBC_VER} |
---|
| 65 | PKGDIR=${OLDPKGDIR} |
---|
| 66 | fi |
---|
| 67 | |
---|
| 68 | # unpack libidn add-on if required (should be supplied with cvs versions) |
---|
| 69 | case ${target_glibc_ver} in |
---|
| 70 | 2.3.[4-9]* | 2.4* ) |
---|
| 71 | cd ${SRC}/${PKGDIR} |
---|
| 72 | if [ ! -d libidn ]; then |
---|
| 73 | OLDPKGDIR=${PKGDIR} ; unpack_tarball glibc-libidn-${GLIBC_VER} |
---|
| 74 | PKGDIR=${OLDPKGDIR} |
---|
| 75 | fi |
---|
| 76 | ;; |
---|
| 77 | esac |
---|
| 78 | |
---|
| 79 | # apply glibc patches as required depending on the above gcc/kernel versions |
---|
| 80 | # see funcs/glibc_funcs.sh |
---|
| 81 | apply_glibc_patches |
---|
| 82 | |
---|
| 83 | # configuration for pthread type |
---|
| 84 | #------------------------------- |
---|
| 85 | # HACK: nptl for sparc64 wont build |
---|
| 86 | case ${TGT_ARCH} in |
---|
| 87 | sparc64 ) |
---|
| 88 | USE_NPTL=N |
---|
| 89 | ;; |
---|
| 90 | esac |
---|
| 91 | |
---|
| 92 | if [ "Y" = "${USE_NPTL}" ]; then |
---|
| 93 | # remove linuxthreads dirs if they exist |
---|
| 94 | # (CVS source contains linuxthreads) |
---|
| 95 | test -d linuxthreads && |
---|
| 96 | rm -rf linuxthreads* |
---|
| 97 | |
---|
| 98 | # As of ~2003-10-06 nptl is included in glibc cvs |
---|
| 99 | #test -d ./nptl && |
---|
| 100 | #test -d ./nptl_db || |
---|
| 101 | #unpack_tarball nptl-${NPTL_VER} |
---|
| 102 | |
---|
| 103 | # fix tst-cancelx7 test (if needed) |
---|
| 104 | fname="${SRC}/${PKGDIR}/nptl/Makefile" |
---|
| 105 | grep tst-cancelx7-ARGS ${fname} > /dev/null 2>&1 || { |
---|
| 106 | echo " - patching ${fname}" |
---|
| 107 | mv ${fname} ${fname}-ORIG |
---|
| 108 | sed -e '/tst-cancel7-ARGS = --command "$(built-program-cmd)"/a\ |
---|
| 109 | tst-cancelx7-ARGS = --command "$(built-program-cmd)"' \ |
---|
| 110 | ${fname}-ORIG > ${fname} |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | extra_conf="${extra_conf} --with-tls --with-__thread" |
---|
| 114 | else |
---|
| 115 | if [ -d ./nptl ]; then rm -rf nptl* ; fi |
---|
| 116 | fi |
---|
| 117 | |
---|
| 118 | # set without-fp if target has no floating point unit |
---|
| 119 | if [ "${WITHOUT_FPU}" = "Y" ]; then |
---|
| 120 | extra_conf="${extra_conf} --without-fp" |
---|
| 121 | fi |
---|
| 122 | |
---|
| 123 | # set --enable-kernel to match the kernel version |
---|
| 124 | # of the kernel headers glibc is to be built against |
---|
| 125 | #------------------------------------------------- |
---|
| 126 | # HACK: hack around 2.6.8.1 release |
---|
| 127 | case ${kernver} in 2.6.8.* ) kernver=2.6.8 ;; esac |
---|
| 128 | extra_conf="${extra_conf} --enable-kernel=${kernver}" |
---|
| 129 | |
---|
| 130 | # End prep |
---|
| 131 | #-------------------------------- |
---|
| 132 | touch /etc/ld.so.conf |
---|
| 133 | |
---|
| 134 | test -d ${SRC}/glibc-${GLIBC_VER}-native${suffix} && |
---|
| 135 | rm -rf ${SRC}/glibc-${GLIBC_VER}-native${suffix} |
---|
| 136 | |
---|
| 137 | mkdir ${SRC}/glibc-${GLIBC_VER}-native${suffix} |
---|
| 138 | cd ${SRC}/glibc-${GLIBC_VER}-native${suffix} |
---|
| 139 | |
---|
| 140 | if [ ! "${libdirname}" = "lib" ]; then |
---|
| 141 | extra_conf="${extra_conf} --libdir=/usr/${libdirname}" |
---|
| 142 | # Also create a configparms file setting slibdir to */libdirname |
---|
| 143 | echo "slibdir=/${libdirname}" >> configparms |
---|
| 144 | fi |
---|
| 145 | |
---|
| 146 | max_log_init Glibc ${GLIBC_VER} native ${CONFLOGS} ${LOG} |
---|
| 147 | CFLAGS="-O2 -pipe" PARALLELMFLAGS="${PMFLAGS}" \ |
---|
| 148 | CC="${CC-gcc} ${ARCH_CFLAGS} ${TGT_CFLAGS}" \ |
---|
| 149 | CXX="${CXX-g++} ${ARCH_CFLAGS} ${TGT_CFLAGS}" \ |
---|
| 150 | ../${PKGDIR}/configure --prefix=/usr \ |
---|
| 151 | --without-cvs --disable-profile --enable-add-ons \ |
---|
| 152 | --with-headers=${KERN_HDR_DIR} ${extra_conf} \ |
---|
| 153 | --mandir=/usr/share/man --infodir=/usr/share/info \ |
---|
| 154 | --libexecdir=/usr/${libdirname}/glibc \ |
---|
| 155 | >> ${LOGFILE} 2>&1 && |
---|
| 156 | echo " o Configure OK" && |
---|
| 157 | |
---|
| 158 | min_log_init ${BUILDLOGS} && |
---|
| 159 | make PARALLELMFLAGS="${PMFLAGS}" \ |
---|
| 160 | >> ${LOGFILE} 2>&1 && |
---|
| 161 | echo " o Build OK" || barf |
---|
| 162 | |
---|
| 163 | # Tests moved after install, during glibc tests |
---|
| 164 | # at times librt will be rebuilt... incorrectly. |
---|
| 165 | # Better to install first and not have to worry |
---|
| 166 | # about anything built correctly being replaced |
---|
| 167 | # by something broken... |
---|
| 168 | |
---|
| 169 | echo "-Installing Glibc" && |
---|
| 170 | min_log_init ${INSTLOGS} && |
---|
| 171 | make install \ |
---|
| 172 | >> ${LOGFILE} 2>&1 && |
---|
| 173 | echo " o install OK" || barf |
---|
| 174 | |
---|
| 175 | make localedata/install-locales \ |
---|
| 176 | >> ${LOGFILE} 2>&1 && |
---|
| 177 | echo " o install-locales OK" || barf |
---|
| 178 | ln -sf ../usr/share/zoneinfo/${TZ} /etc/localtime && |
---|
| 179 | |
---|
| 180 | # Use make -k check... will have to revisit this |
---|
| 181 | min_log_init ${TESTLOGS} && |
---|
| 182 | make -k check \ |
---|
| 183 | >> ${LOGFILE} 2>&1 && |
---|
| 184 | echo " o Test OK" || errmsg |
---|
| 185 | |
---|
| 186 | # install sample nscd.conf |
---|
| 187 | if [ ! -f /etc/nscd.conf ]; then |
---|
| 188 | echo -n " o Creating /etc/nscd.conf - " |
---|
| 189 | cp ${SRC}/${PKGDIR}/nscd/nscd.conf /etc/nscd.conf && |
---|
| 190 | echo "OK" || echo "FAIL" |
---|
| 191 | fi |
---|
| 192 | |
---|
| 193 | if [ ! -d /var/run/nscd ]; then |
---|
| 194 | mkdir -p /var/run/nscd |
---|
| 195 | fi |
---|