1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # cross-lfs cross glibc full build
|
---|
4 | # --------------------------------
|
---|
5 | # $LastChangedBy$
|
---|
6 | # $LastChangedDate$
|
---|
7 | # $LastChangedRevision$
|
---|
8 | # $HeadURL$
|
---|
9 | #
|
---|
10 |
|
---|
11 | cd ${SRC}
|
---|
12 |
|
---|
13 | LOG="glibc-cross.log"
|
---|
14 | libdirname=lib
|
---|
15 |
|
---|
16 | # Test how this script has been called.
|
---|
17 | # This should only really get called during bi-arch/multi-lib builds
|
---|
18 | SELF=`basename ${0}`
|
---|
19 | set_buildenv
|
---|
20 | set_libdirname
|
---|
21 | setup_multiarch
|
---|
22 |
|
---|
23 | if [ -z ${ALT_TGT} ]; then ALT_TGT="${TARGET}" ; fi
|
---|
24 |
|
---|
25 | # if target = build, modify build slightly to
|
---|
26 | # trick configure to believing we are cross compiling
|
---|
27 | if [ "${TARGET}" = "${BUILD}" -o "${ALT_TGT}" = "${BUILD}" ]; then
|
---|
28 | BUILD=`echo ${BUILD} | sed 's@\([_a-zA-Z0-9]*\)\(-[_a-zA-Z0-9]*\)\(.*\)@\1\2x\3@'`
|
---|
29 | fi
|
---|
30 |
|
---|
31 | if [ "${USE_SYSROOT}" = "Y" ]; then
|
---|
32 | BUILD_PREFIX=/usr
|
---|
33 | INSTALL_PREFIX="${LFS}${BUILD_PREFIX}"
|
---|
34 | INSTALL_OPTIONS="install_root=${LFS}"
|
---|
35 | else
|
---|
36 | BUILD_PREFIX=${TGT_TOOLS}
|
---|
37 | INSTALL_PREFIX="${TGT_TOOLS}"
|
---|
38 | INSTALL_OPTIONS=""
|
---|
39 | fi
|
---|
40 |
|
---|
41 | if [ "${USE_SANITISED_HEADERS}" = "Y" ]; then
|
---|
42 | KERN_HDR_DIR="${INSTALL_PREFIX}/kernel-hdrs"
|
---|
43 | else
|
---|
44 | KERN_HDR_DIR="${INSTALL_PREFIX}/include"
|
---|
45 | fi
|
---|
46 |
|
---|
47 | unpack_tarball glibc-${GLIBC_VER}
|
---|
48 | cd ${PKGDIR}
|
---|
49 |
|
---|
50 | # Gather package version information
|
---|
51 | #-----------------------------------
|
---|
52 | target_glibc_ver=`grep VERSION version.h | \
|
---|
53 | sed 's@.*\"\([0-9.]*\)\"@\1@'`
|
---|
54 | export target_glibc_ver
|
---|
55 |
|
---|
56 | # Retrieve target_gcc_ver from gcc -v output
|
---|
57 | target_gcc_ver=`${TARGET}-gcc -v 2>&1 | grep " version " | \
|
---|
58 | sed 's@.*version \([0-9.]*\).*@\1@g'`
|
---|
59 |
|
---|
60 | # check kernel headers for version
|
---|
61 | kernver=`grep UTS_RELEASE ${KERN_HDR_DIR}/linux/version.h | \
|
---|
62 | sed 's@.*\"\([0-9.]*\).*\"@\1@g' `
|
---|
63 |
|
---|
64 | # if we don't have linuxthreads dirs (ie: a glibc release), then
|
---|
65 | # unpack the linuxthreads tarball
|
---|
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 | # unpack libidn add-on if required (should be supplied with cvs versions)
|
---|
72 | case ${target_glibc_ver} in
|
---|
73 | 2.3.[4-9]* | 2.4* )
|
---|
74 | cd ${SRC}/${PKGDIR}
|
---|
75 | if [ ! -d libidn ]; then
|
---|
76 | OLDPKGDIR=${PKGDIR} ; unpack_tarball glibc-libidn-${GLIBC_VER}
|
---|
77 | PKGDIR=${OLDPKGDIR}
|
---|
78 | fi
|
---|
79 | ;;
|
---|
80 | esac
|
---|
81 |
|
---|
82 | # apply glibc patches as required depending on the above gcc/kernel versions
|
---|
83 | # see funcs/glibc_funcs.sh
|
---|
84 | apply_glibc_patches
|
---|
85 |
|
---|
86 | # HACK: nptl for sparc64 wont build
|
---|
87 | case ${TGT_ARCH} in
|
---|
88 | sparc64 )
|
---|
89 | USE_NPTL=N
|
---|
90 | ;;
|
---|
91 | esac
|
---|
92 |
|
---|
93 | if [ "Y" = "${USE_NPTL}" ]; then
|
---|
94 | # remove linuxthreads dirs if they exist
|
---|
95 | # (CVS source contains linuxthreads)
|
---|
96 | if [ -d linuxthreads ]; then rm -rf linuxthreads* ; fi
|
---|
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
|
---|
104 | fname="${SRC}/${PKGDIR}/nptl/Makefile"
|
---|
105 | grep tst-cancelx7-ARGS ${fname} > /dev/null 2>&1 ||
|
---|
106 | {
|
---|
107 | echo " - patching ${fname}"
|
---|
108 | mv ${fname} ${fname}-ORIG
|
---|
109 | sed -e '/tst-cancel7-ARGS = --command "$(built-program-cmd)"/a\
|
---|
110 | tst-cancelx7-ARGS = --command "$(built-program-cmd)"' \
|
---|
111 | ${fname}-ORIG > ${fname}
|
---|
112 | }
|
---|
113 |
|
---|
114 | extra_conf="${extra_conf} --with-tls --with-__thread"
|
---|
115 | else
|
---|
116 | if [ -d nptl ]; then rm -rf nptl* ; fi
|
---|
117 | fi
|
---|
118 |
|
---|
119 | # set without-fp if target has no floating point unit
|
---|
120 | if [ "${WITHOUT_FPU}" = "Y" ]; then
|
---|
121 | extra_conf="${extra_conf} --without-fp"
|
---|
122 | fi
|
---|
123 |
|
---|
124 | # set --enable-kernel to match the kernel version
|
---|
125 | # of the kernel headers glibc is to be built against
|
---|
126 | #-------------------------------------------------
|
---|
127 | # HACK: hack around 2.6.8.1 release
|
---|
128 | case ${kernver} in 2.6.8.* ) kernver=2.6.8 ;; esac
|
---|
129 | extra_conf="${extra_conf} --enable-kernel=${kernver}"
|
---|
130 |
|
---|
131 | test -d ${SRC}/glibc-${GLIBC_VER}-cross${suffix} &&
|
---|
132 | rm -rf ${SRC}/glibc-${GLIBC_VER}-cross${suffix}
|
---|
133 |
|
---|
134 | mkdir -p ${SRC}/glibc-${GLIBC_VER}-cross${suffix}
|
---|
135 | cd ${SRC}/glibc-${GLIBC_VER}-cross${suffix}
|
---|
136 |
|
---|
137 |
|
---|
138 | if [ "${USE_NPTL}" = "Y" ]; then
|
---|
139 | echo "libc_cv_forced_unwind=yes" > config.cache
|
---|
140 | echo "libc_cv_c_cleanup=yes" >> config.cache
|
---|
141 | case ${TGT_ARCH} in
|
---|
142 | sparc64 )
|
---|
143 | echo "libc_cv_sparc64_tls=yes" >> config.cache
|
---|
144 | ;;
|
---|
145 | esac
|
---|
146 | extra_conf="${extra_conf} --cache-file=config.cache"
|
---|
147 | fi
|
---|
148 |
|
---|
149 | # Are libs to be installed into a non-standard place?
|
---|
150 | if [ ! "${libdirname}" = "lib" ]; then
|
---|
151 | extra_conf="${extra_conf} --libdir=${BUILD_PREFIX}/${libdirname}"
|
---|
152 | # Also create a configparms file setting slibdir to */${libdirname}
|
---|
153 | if [ "${USE_SYSROOT}" = "Y" ]; then
|
---|
154 | echo "slibdir=/${libdirname}" >> configparms
|
---|
155 | else
|
---|
156 | echo "slibdir=${TGT_TOOLS}/${libdirname}" >> configparms
|
---|
157 | fi
|
---|
158 | fi
|
---|
159 |
|
---|
160 | max_log_init Glibc ${GLIBC_VER} Cross ${CONFLOGS} ${LOG}
|
---|
161 | BUILD_CC=gcc BUILD_CFLAGS="-O2 ${HOST_CFLAGS} -pipe" CFLAGS="-O2 -pipe" \
|
---|
162 | CC="${TARGET}-gcc ${ARCH_CFLAGS} ${TGT_CFLAGS}" \
|
---|
163 | AR="${TARGET}-ar" RANLIB="${TARGET}-ranlib" \
|
---|
164 | ../${PKGDIR}/configure --prefix=${BUILD_PREFIX} \
|
---|
165 | --host=${ALT_TGT} --build=${BUILD} \
|
---|
166 | --without-cvs --disable-profile --enable-add-ons \
|
---|
167 | --with-headers=${KERN_HDR_DIR} ${extra_conf} \
|
---|
168 | --with-binutils=${HST_TOOLS}/bin --without-gd \
|
---|
169 | --mandir=${BUILD_PREFIX}/share/man \
|
---|
170 | --infodir=${BUILD_PREFIX}/share/info \
|
---|
171 | --libexecdir=${BUILD_PREFIX}/${libdirname}/glibc \
|
---|
172 | >> ${LOGFILE} 2>&1 &&
|
---|
173 | echo " o Configure OK" || barf
|
---|
174 |
|
---|
175 | min_log_init ${BUILDLOGS} &&
|
---|
176 | make SHELL="bash" PARALLELMFLAGS="${PMFLAGS}" \
|
---|
177 | >> ${LOGFILE} 2>&1 &&
|
---|
178 | echo " o Build OK" || barf
|
---|
179 |
|
---|
180 | min_log_init ${INSTLOGS} &&
|
---|
181 | make ${INSTALL_OPTIONS} install \
|
---|
182 | >> ${LOGFILE} 2>&1 &&
|
---|
183 | echo " o install OK"
|
---|
184 |
|
---|