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 | |
---|
87 | # HACK: nptl for sparc64 wont build |
---|
88 | case ${TGT_ARCH} in |
---|
89 | sparc64 ) |
---|
90 | USE_NPTL=N |
---|
91 | ;; |
---|
92 | esac |
---|
93 | |
---|
94 | if [ "Y" = "${NO_GCC_EH}" ]; then |
---|
95 | cd ${SRC}/${PKGDIR} |
---|
96 | if [ ! -f Makeconfig-ORIG ]; then cp -p Makeconfig Makeconfig-ORIG ; fi |
---|
97 | sed 's/-lgcc_eh//g' Makeconfig-ORIG > Makeconfig |
---|
98 | fi |
---|
99 | |
---|
100 | if [ "Y" = "${USE_NPTL}" ]; then |
---|
101 | # remove linuxthreads dirs if they exist |
---|
102 | # (CVS source contains linuxthreads) |
---|
103 | if [ -d linuxthreads ]; then rm -rf linuxthreads* ; fi |
---|
104 | |
---|
105 | # As of ~2003-10-06 nptl is included in glibc cvs |
---|
106 | #test -d ./nptl && |
---|
107 | #test -d ./nptl_db || |
---|
108 | #unpack_tarball nptl-${NPTL_VER} |
---|
109 | |
---|
110 | # fix tst-cancelx7 test |
---|
111 | fname="${SRC}/${PKGDIR}/nptl/Makefile" |
---|
112 | grep tst-cancelx7-ARGS ${fname} > /dev/null 2>&1 || |
---|
113 | { |
---|
114 | echo " - patching ${fname}" |
---|
115 | mv ${fname} ${fname}-ORIG |
---|
116 | sed -e '/tst-cancel7-ARGS = --command "$(built-program-cmd)"/a\ |
---|
117 | tst-cancelx7-ARGS = --command "$(built-program-cmd)"' \ |
---|
118 | ${fname}-ORIG > ${fname} |
---|
119 | } |
---|
120 | |
---|
121 | extra_conf="${extra_conf} --with-tls --with-__thread" |
---|
122 | else |
---|
123 | if [ -d nptl ]; then rm -rf nptl* ; fi |
---|
124 | fi |
---|
125 | |
---|
126 | # set without-fp if target has no floating point unit |
---|
127 | if [ "${WITHOUT_FPU}" = "Y" ]; then |
---|
128 | extra_conf="${extra_conf} --without-fp" |
---|
129 | fi |
---|
130 | |
---|
131 | # set --enable-kernel to match the kernel version |
---|
132 | # of the kernel headers glibc is to be built against |
---|
133 | #------------------------------------------------- |
---|
134 | # HACK: hack around 2.6.8.1 release |
---|
135 | case ${kernver} in 2.6.8.* ) kernver=2.6.8 ;; esac |
---|
136 | extra_conf="${extra_conf} --enable-kernel=${kernver}" |
---|
137 | |
---|
138 | test -d ${SRC}/glibc-${GLIBC_VER}-cross${suffix} && |
---|
139 | rm -rf ${SRC}/glibc-${GLIBC_VER}-cross${suffix} |
---|
140 | |
---|
141 | mkdir -p ${SRC}/glibc-${GLIBC_VER}-cross${suffix} |
---|
142 | cd ${SRC}/glibc-${GLIBC_VER}-cross${suffix} |
---|
143 | |
---|
144 | |
---|
145 | if [ "${USE_NPTL}" = "Y" ]; then |
---|
146 | echo "libc_cv_forced_unwind=yes" > config.cache |
---|
147 | echo "libc_cv_c_cleanup=yes" >> config.cache |
---|
148 | case ${TGT_ARCH} in |
---|
149 | sparc64 ) |
---|
150 | echo "libc_cv_sparc64_tls=yes" >> config.cache |
---|
151 | ;; |
---|
152 | esac |
---|
153 | extra_conf="${extra_conf} --cache-file=config.cache" |
---|
154 | fi |
---|
155 | |
---|
156 | # Are libs to be installed into a non-standard place? |
---|
157 | if [ ! "${libdirname}" = "lib" ]; then |
---|
158 | extra_conf="${extra_conf} --libdir=${BUILD_PREFIX}/${libdirname}" |
---|
159 | # Also create a configparms file setting slibdir to */${libdirname} |
---|
160 | if [ "${USE_SYSROOT}" = "Y" ]; then |
---|
161 | echo "slibdir=/${libdirname}" >> configparms |
---|
162 | else |
---|
163 | echo "slibdir=${TGT_TOOLS}/${libdirname}" >> configparms |
---|
164 | fi |
---|
165 | fi |
---|
166 | |
---|
167 | max_log_init Glibc ${GLIBC_VER} Cross ${CONFLOGS} ${LOG} |
---|
168 | BUILD_CC=gcc BUILD_CFLAGS="-O2 ${HOST_CFLAGS} -pipe" CFLAGS="-O2 -pipe" \ |
---|
169 | CC="${TARGET}-gcc ${ARCH_CFLAGS} ${TGT_CFLAGS}" \ |
---|
170 | AR="${TARGET}-ar" RANLIB="${TARGET}-ranlib" \ |
---|
171 | ../${PKGDIR}/configure --prefix=${BUILD_PREFIX} \ |
---|
172 | --host=${ALT_TGT} --build=${BUILD} \ |
---|
173 | --without-cvs --disable-profile --enable-add-ons \ |
---|
174 | --with-headers=${KERN_HDR_DIR} ${extra_conf} \ |
---|
175 | --with-binutils=${HST_TOOLS}/bin --without-gd \ |
---|
176 | --mandir=${BUILD_PREFIX}/share/man \ |
---|
177 | --infodir=${BUILD_PREFIX}/share/info \ |
---|
178 | --libexecdir=${BUILD_PREFIX}/${libdirname}/glibc \ |
---|
179 | >> ${LOGFILE} 2>&1 && |
---|
180 | echo " o Configure OK" || barf |
---|
181 | |
---|
182 | min_log_init ${BUILDLOGS} && |
---|
183 | make SHELL="bash" PARALLELMFLAGS="${PMFLAGS}" \ |
---|
184 | >> ${LOGFILE} 2>&1 && |
---|
185 | echo " o Build OK" || barf |
---|
186 | |
---|
187 | min_log_init ${INSTLOGS} && |
---|
188 | make ${INSTALL_OPTIONS} install \ |
---|
189 | >> ${LOGFILE} 2>&1 && |
---|
190 | echo " o install OK" |
---|
191 | |
---|