Contents of /branches/magellan-next/core/glibc-nptl/glibc-nptl-2.12.1-r2.smage2
Parent Directory | Revision Log
Revision 5842 -
(show annotations)
(download)
Tue Aug 17 01:40:51 2010 UTC (14 years, 1 month ago) by niro
File size: 11293 byte(s)
Tue Aug 17 01:40:51 2010 UTC (14 years, 1 month ago) by niro
File size: 11293 byte(s)
-enabled bind-now and added fixes for i686 and some memory issues
1 | # $Id: glibc-nptl-2.10.1-r1.smage2 3009 2009-10-06 19:20:40Z niro $ |
2 | |
3 | PNAME="glibc-nptl" |
4 | PVER="2.12.1" |
5 | PBUILD="r2" |
6 | |
7 | PCATEGORIE="sys-libs" |
8 | STATE="unstable" |
9 | |
10 | DESCRIPTION="GNU libc6 (also called glibc2) C library with NPTL Threads." |
11 | HOMEPAGE="http://www.gnu.org/software/libc/libc.html" |
12 | |
13 | DEPEND=">= sys-libs/libstdc++-4.5 |
14 | >= sys-apps/base-files-0.1" |
15 | |
16 | # we force headers to one specific version |
17 | # (for x86_64 2.6.12.0-r2 bi-arch headers are needed!) |
18 | SDEPEND="== sys-kernel/linux-libc-headers-2.6.35" |
19 | PROVIDE="virtual/glibc" |
20 | |
21 | # functions to include in the mage file |
22 | SPECIAL_FUNCTIONS="fix_db_files" |
23 | |
24 | SRCFILE="glibc-${PVER/.0/}.tar.bz2" |
25 | SRCDIR="${BUILDDIR}/glibc-${PVER/.0/}" |
26 | |
27 | # locale.gen CVS revision |
28 | LOCALEGEN_CVS_REV=1.3 |
29 | |
30 | sminclude mtools |
31 | |
32 | SRC_URI=( |
33 | ftp://sources.redhat.com/pub/glibc/releases/${SRCFILE} |
34 | ftp://sources.redhat.com/pub/glibc/snapshots/${SRCFILE} |
35 | gnu://glibc/${SRCFILE} |
36 | mirror://glibc/${SRCFILE} |
37 | mirror://glibc/nsswitch.conf |
38 | mirror://glibc/nscd.conf |
39 | mirror://glibc/glibc.envd |
40 | mirror://glibc/locale-gen |
41 | mirror://glibc/locale.gen-${LOCALEGEN_CVS_REV} |
42 | mirror://glibc/glibc-2.3.5-localedef_segfault-1.patch |
43 | mirror://glibc/glibc-${PVER}-bz4781.patch |
44 | mirror://glibc/glibc-${PVER}-i686.patch |
45 | ) |
46 | |
47 | # sed line: on 2 digits add an zero: 2.7 -> 2.7.0 |
48 | UP2DATE="updatecmd_gnu ${PNAME/-nptl/} | sed 's/^\([0-9]\.[0-9]\$\)/\1.0/'" |
49 | |
50 | # glibc don't like strong CFLAGS |
51 | export CFLAGS="${CFLAGS//-O?} -O2" |
52 | # glibc -> nptl thread don't like striping |
53 | NOSTRIP=true |
54 | # gcc 3.0 - 3.3 needs this: |
55 | export CFLAGS="${CFLAGS} -finline-limit=2000" |
56 | export CXXFLAGS="${CFLAGS}" |
57 | export LDFLAGS="${LDFLAGS//-Wl,--relax}" |
58 | |
59 | # hack to fix NPTL issues with xen, only required on 32bit arches |
60 | if [[ ${ARCH} = i*86 ]] |
61 | then |
62 | export CFLAGS="${CFLAGS} -mno-tls-direct-seg-refs" |
63 | fi |
64 | |
65 | # glibc-2.6.1 and above needs march CFLAGS: -march=${ARCH} -mtune=generic |
66 | # first filter -mtune and -march from flags |
67 | for flag in ${CFLAGS} |
68 | do |
69 | case ${flag} in |
70 | -mtune=*) continue ;; |
71 | -march=*) continue ;; |
72 | esac |
73 | newflags="${newflags} ${flag}" |
74 | done |
75 | # than add our defaults for glibc |
76 | [[ ${ARCH} = i*86 ]] && export CFLAGS="${CFLAGS} -march=${ARCH}" # only i*86 |
77 | export CFLAGS="${CFLAGS} -mtune=generic" # all arches |
78 | export CXXFLAGS="${CFLAGS}" |
79 | |
80 | # use other linux-headers |
81 | [[ -z ${ALT_HEADERS} ]] && export ALT_HEADERS="/usr/include" |
82 | |
83 | # kernel support |
84 | export ENABLE_KERNEL=2.6.18 |
85 | |
86 | src_prepare() |
87 | { |
88 | munpack ${SRCFILE} || die |
89 | cd ${SRCDIR} |
90 | |
91 | # disable binutils -as-needed |
92 | sed -i 's/^have-as-needed.*/have-as-needed = no/' ${SRCDIR}/config.make.in || die |
93 | |
94 | # fix segfault of localdef on arches beside x86-32 |
95 | mpatch glibc-2.3.5-localedef_segfault-1.patch || die |
96 | |
97 | # http://sources.redhat.com/bugzilla/show_bug.cgi?id=4781 |
98 | mpatch glibc-${PVER}-bz4781.patch || die |
99 | |
100 | # http://sources.redhat.com/bugzilla/show_bug.cgi?id=411 |
101 | # http://sourceware.org/ml/libc-alpha/2009-07/msg00072.html |
102 | mpatch glibc-${PVER}-i686.patch || die |
103 | |
104 | # fix permissions on some of the scripts |
105 | chmod u+x ${SRCDIR}/scripts/*.sh || die |
106 | |
107 | install -d ${SRCDIR}/build || die |
108 | cd ${SRCDIR}/build |
109 | |
110 | if [ ! -f /etc/ld.so.conf ] |
111 | then |
112 | touch /etc/ld.so.conf || die |
113 | fi |
114 | } |
115 | |
116 | src_compile() |
117 | { |
118 | # support multilib lib64 dir (x86_64 only) |
119 | if [[ ${ARCH} = x86_64 ]] |
120 | then |
121 | # first build a -m32 version |
122 | install -d ${SRCDIR}/build-m32 |
123 | cd ${SRCDIR}/build-m32 |
124 | |
125 | CC="gcc -m32" CXX="g++ -m32" \ |
126 | CFLAGS="${CFLAGS//-march=${ARCH}} -march=i686" \ |
127 | CXXFLAGS="${CXXFLAGS//-march=${ARCH}} -march=i686" \ |
128 | ../configure \ |
129 | --build=${CHOST} \ |
130 | --host=i686-pc-linux-gnu \ |
131 | --prefix=/usr \ |
132 | --mandir=/usr/share/man \ |
133 | --infodir=/usr/share/info \ |
134 | --disable-profile \ |
135 | --enable-add-ons=nptl,libidn \ |
136 | --with-tls \ |
137 | --with-__thread \ |
138 | --enable-kernel=${ENABLE_KERNEL} \ |
139 | --without-cvs \ |
140 | --without-gd \ |
141 | --libdir=/usr/lib \ |
142 | --libexecdir=/usr/lib/glibc \ |
143 | --with-headers=${ALT_HEADERS} \ |
144 | --enable-bind-now \ |
145 | || die |
146 | |
147 | make PARALLELMFLAGS="${MAKEOPTS}" || die |
148 | fi |
149 | |
150 | cd ${SRCDIR}/build |
151 | |
152 | if [[ ${ARCH} = x86_64 ]]; then |
153 | # make sure the -m64 libs goes really to /lib64 |
154 | echo "slibdir=/$(mlibdir)" >> ${SRCDIR}/build/configparms || die |
155 | fi |
156 | |
157 | # kernel-2.6 with nptl needs this |
158 | ../configure \ |
159 | --build=${CHOST} \ |
160 | --host=${CHOST} \ |
161 | --prefix=/usr \ |
162 | --mandir=/usr/share/man \ |
163 | --infodir=/usr/share/info \ |
164 | --disable-profile \ |
165 | --enable-add-ons=nptl,libidn \ |
166 | --with-tls \ |
167 | --with-__thread \ |
168 | --enable-kernel=${ENABLE_KERNEL} \ |
169 | --without-cvs \ |
170 | --without-gd \ |
171 | --libdir=/usr/$(mlibdir) \ |
172 | --libexecdir=/usr/$(mlibdir)/glibc \ |
173 | --with-headers=${ALT_HEADERS} \ |
174 | --enable-bind-now \ |
175 | || die |
176 | |
177 | make PARALLELMFLAGS="${MAKEOPTS}" || die |
178 | } |
179 | |
180 | src_install() |
181 | { |
182 | if [[ ${ARCH} = x86_64 ]] |
183 | then |
184 | # install -m32 libs |
185 | cd ${SRCDIR}/build-m32 |
186 | make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die |
187 | fi |
188 | |
189 | cd ${SRCDIR}/build |
190 | make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die |
191 | |
192 | # do not generate the locales here, let it the user do with the locale-gen tool |
193 | # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die |
194 | |
195 | # install locales list and generate tools |
196 | # to generate this listing see the glibc-2.5/localedata/SUPPORTED file |
197 | minstalletc locale.gen-${LOCALEGEN_CVS_REV} locale.gen || die |
198 | minstalldir /usr/sbin || die |
199 | minstallexec -s locale-gen /usr/sbin || die |
200 | |
201 | # nsswitch configuration file |
202 | minstalletc nsswitch.conf || die |
203 | |
204 | # nscd configuration file |
205 | minstalletc nscd.conf || die |
206 | |
207 | # we use Berlin as default |
208 | cp --remove-destination ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die |
209 | [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; } |
210 | [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; } |
211 | |
212 | # base environment |
213 | minstallenv glibc.envd 00glibc || die |
214 | if [[ ${ARCH} = x86_64 ]] |
215 | then |
216 | echo "LDPATH=\"/usr/local/$(mlibdir)\"" >> ${BINDIR}/etc/env.d/00glibc || die |
217 | echo "LDPATH=\"/opt/$(mlibdir)\"" >> ${BINDIR}/etc/env.d/00glibc || die |
218 | fi |
219 | |
220 | # move some libs and tools to proper locations |
221 | # will suppress some ldconfig errors too |
222 | mv ${BINDIR}/$(mlibdir)/libmemusage.so ${BINDIR}/usr/$(mlibdir) || die |
223 | mv ${BINDIR}/$(mlibdir)/libpcprofile.so ${BINDIR}/usr/$(mlibdir) || die |
224 | mlink ../usr/$(mlibdir)/libmemusage.so /$(mlibdir)/libmemusage.so || die |
225 | mlink ../usr/$(mlibdir)/libpcprofile.so /$(mlibdir)/libpcprofile.so || die |
226 | |
227 | # strip all binaries |
228 | find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die |
229 | |
230 | # strip all libraries |
231 | # want to be safe here; --strip-unneeded seems to cause pthread problems |
232 | # strip all but libpthread |
233 | install -d ${BUILDDIR}/thread-backup || die |
234 | mv ${BINDIR}/$(mlibdir)/lib{pthread,thread_db}* ${BUILDDIR}/thread-backup/ || die |
235 | |
236 | # now strip |
237 | find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die |
238 | mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/$(mlibdir)/ || die |
239 | # remove stale directory |
240 | rm -rf ${BUILDDIR}/thread-backup || die |
241 | |
242 | # prepare glibc for installation; slackware method |
243 | minstalldir /incoming || die |
244 | mv ${BINDIR}/$(mlibdir)/* ${BINDIR}/incoming || die |
245 | mv ${BINDIR}/incoming ${BINDIR}/$(mlibdir)/incoming || die |
246 | mv ${BINDIR}/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/$(mlibdir) || die |
247 | } |
248 | |
249 | fix_db_files() |
250 | { |
251 | local i |
252 | local DB_ENTRY="${BUILDDIR}/${PKGNAME}" |
253 | |
254 | for i in .files .symlinks .dirs |
255 | do |
256 | [ ! -f ${DB_ENTRY}/${i} ] && continue |
257 | [[ -z $(< ${DB_ENTRY}/${i}) ]] && continue |
258 | |
259 | echo " fixing /$(mlibdir)/incoming from db-entry '${i}' ..." |
260 | |
261 | # /lib/incoming -> empty line; sed2 removes all empty lines |
262 | #sed -i -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i} |
263 | # do not simply emtpy the line, but change it the the correct path, |
264 | # so no stale libs are around if the package gets updated! |
265 | sed -i -e "s:/$(mlibdir)/incoming:/$(mlibdir):g" \ |
266 | -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i} |
267 | done |
268 | } |
269 | |
270 | preinstall() |
271 | { |
272 | # remove libmemusage and libpcprofile as these libs now |
273 | # resides in /usr/lib and are symlinked to /lib |
274 | if [[ -f ${MROOT}/$(mlibdir)/libmemusage.so ]] |
275 | then |
276 | rm ${MROOT}/$(mlibdir)/libmemusage.so |
277 | fi |
278 | |
279 | if [[ -f ${MROOT}/$(mlibdir)/libpcprofile.so ]] |
280 | then |
281 | rm ${MROOT}/$(mlibdir)/libpcprofile.so |
282 | fi |
283 | } |
284 | |
285 | postinstall() |
286 | { |
287 | # first save the old libpthread.so.0; |
288 | # it will later used to determinate that there are no stale |
289 | # libpthreads that breaks ldconfig |
290 | local OLD_PTHREAD |
291 | OLD_PTHREAD="$(readlink ${MROOT}/$(mlibdir)/libpthread.so.0)" |
292 | |
293 | # slackware install method |
294 | |
295 | # we cannot easily install the glibc libs, |
296 | # because our tools for cp etc needs them to run |
297 | |
298 | local file |
299 | |
300 | echo " Switching to new glibc ..." |
301 | # swap libraries on the fly: |
302 | if [ -x /sbin/ldconfig -a -d /$(mlibdir)/incoming ] && [[ -z ${MROOT} ]] |
303 | then |
304 | # first create copies of the incoming libraries: |
305 | cd /$(mlibdir)/incoming |
306 | for file in $(find /$(mlibdir)/incoming -type f) |
307 | do |
308 | if [ ! -r "../$(basename ${file}).incoming" ] |
309 | then |
310 | cp -a ${file} ../$(basename ${file}).incoming |
311 | fi |
312 | done |
313 | |
314 | # then switch to them all at once: |
315 | /sbin/ldconfig -l /$(mlibdir)/*.incoming 2> /dev/null |
316 | |
317 | # finally, rename them and clean up: |
318 | cd /$(mlibdir) |
319 | for file in *.incoming |
320 | do |
321 | rm -f $(basename ${file} .incoming) |
322 | cp -a ${file} $(basename ${file} .incoming) |
323 | /sbin/ldconfig -l $(basename ${file} .incoming) |
324 | rm -f ${file} |
325 | done |
326 | |
327 | # no ldconfig? |
328 | # good, it's safe to just jam it on home (and make links below): |
329 | else |
330 | ( |
331 | cd ${MROOT}/$(mlibdir)/incoming |
332 | for file in * |
333 | do |
334 | cp -a ${file} .. |
335 | done |
336 | |
337 | local my_sym |
338 | local my_dest |
339 | |
340 | # rebuild symlinks |
341 | echo " Recreating Symlinks:" |
342 | for i in $(find ${MROOT}/$(mlibdir)/incoming -type l) |
343 | do |
344 | my_sym="$(readlink ${i})" |
345 | my_dest="$(basename ${i})" |
346 | |
347 | echo " ${my_dest} -> ${my_dest}" |
348 | |
349 | # assure to remove the old ones; |
350 | [ -L ${MROOT}/$(mlibdir)/"${my_dest}" ] && \ |
351 | rm ${MROOT}/$(mlibdir)/"${my_dest}" |
352 | |
353 | ln -snf "${my_sym}" ${MROOT}/$(mlibdir)/"${my_dest}" |
354 | done |
355 | ) |
356 | fi |
357 | |
358 | # now, get rid of the temporary directory: |
359 | rm -rf ${MROOT}/$(mlibdir)/incoming |
360 | |
361 | # remove stale nptl libpthread-2.?.?.so, |
362 | # fix only needed for glibc with linuxthreads; |
363 | # prevent reloc errors such as: |
364 | # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory |
365 | |
366 | # get our new libpthread.so.0 |
367 | local NEW_PTHREAD |
368 | NEW_PTHREAD="$(readlink ${MROOT}/$(mlibdir)/libpthread.so.0)" |
369 | |
370 | if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ] |
371 | then |
372 | echo " Removing stale libpthread libraries ..." |
373 | for file in ${MROOT}/$(mlibdir)/libpthread-* |
374 | do |
375 | if [ "$(basename ${file})" != "${NEW_PTHREAD}" ] |
376 | then |
377 | rm -f ${file} |
378 | fi |
379 | done |
380 | |
381 | #rm -f /lib/${OLD_PTHREAD} |
382 | |
383 | ln -snf ${NEW_PTHREAD} ${MROOT}/$(mlibdir)/libpthread.so.0 |
384 | fi |
385 | |
386 | if [ -x /usr/sbin/iconvconfig ] |
387 | then |
388 | # generate fastloading iconv module configuration file. |
389 | echo " Generate iconv module config ..." |
390 | /usr/sbin/iconvconfig --prefix=${MROOT}/ |
391 | fi |
392 | |
393 | # reloading init |
394 | echo " Reloading init ..." |
395 | [[ -z ${MROOT} ]] && /sbin/init U &> /dev/null |
396 | |
397 | # generating user def locales |
398 | echo " Generating user defined locales ..." |
399 | [[ -z ${MROOT} ]] && /usr/sbin/locale-gen |
400 | |
401 | # now we must fix the mage db files |
402 | # to stop the annoying errors messages |
403 | fix_db_files |
404 | } |