Package-Name: glibc
Gentoo-Package: sys-libs/glibc
Compile-Requires: gcc binutils make
Homepage: http://www.gnu.org/software/glibc/
# FIXME: 2.6 malloc is broken, avoid it for now
Source: gnu:///glibc/glibc-(\d+.[0-57-9]\d*(.\d+)?).tar.gz $1
#More-Source-1: gnu:///glibc/glibc-linuxthreads-$1.tar.gz
# No auto update, as the devs seem to release broken code a lot
Explicit-Only: 1
Repack:
	tar xzvfp "$(SOURCE)"
#	tar Cxzvfp glibc-"$(VERSION)" "$(SOURCE1)"
Compile:
	mv -f BUGS CONFORMANCE COPYING* ChangeLog* FAQ NAMESPACE NEWS NOTES PROJECTS README* "$(PREFIX)/"
	mkdir ../build
# FIXME: --enable-omitfp causes thread crashes, e.g.:
#	#include <pthread.h>
#	void* func(void *arg) { return arg; }
#	int main(void) { pthread_t tid; return pthread_create (&tid, 0, func, 0) == 0 ? 0 : 1; }
# dies with a segfault in __pthread_internal_tsd_get.
	if test -d /usr/src/linux/include ; then WITH_HEADERS="--with-headers=/usr/src/linux/include" ; else WITH_HEADERS="" ; fi ; \
# FIXME: compiling with -fstack-protector gives undefined symbol errors on __stack_chk_guard
	cd ../build && libc_cv_ssp=no $(MAKE) -f ../Makefile configure CONFIGURE="../glibc-$(VERSION)/configure" CONFIGURE_OPTS="--sysconfdir=/etc $$WITH_HEADERS --without-gd --disable-omitfp --disable-profile --enable-kernel=2.2.0 --disable-rpath --enable-add-ons=nptl --with-tls"
	cd ../build && $(MAKE) inst_sysconfdir="$(PREFIX)/etc"
# Avoid problems with overwriting shared libraries
	rm -f "$(PREFIX)"/lib/*.so*
	/sbin/ldconfig
	cd ../build && $(MAKE) install inst_sysconfdir="$(PREFIX)/etc"
	/sbin/ldconfig /lib
	umask 022 ; mkdir -p "$(PREFIX)"/man/man3
#	$(MAKE) -C linuxthreads/man all install MANDIR="$(PREFIX)/man/man3"
	/sbin/ldconfig /lib
	rm -f "$(PREFIX)"/sbin/{nscd*,sln}
	ln -fs /etc/ld.so.conf /etc/ld.so.cache /etc/localtime "$(PREFIX)"/etc/
	umask 022 ; mkdir -p "$(PREFIX)"/lib/locale
#	rm -rf /tmp/zxbb /tmp/zxgg ; cp -a ../build /tmp/zxbb ; cp -a /pkg/glibc /tmp/zxgg
	rm -rf ../build
Install:
	chmod 4711 "$(PREFIX)"/libexec/pt_chown
	mv -f "$(PREFIX)"/sbin/ldconfig /sbin/
	-chattr -i /lib/{ld,libc}-*.so
	@set -e ; set -x ; \
		cd "$(PREFIX)"/lib ; \
		ff="" ; \
		for i in ld libBrokenLocale libanl libc libcrypt libdl libm libnsl libnss_compat libnss_dns libnss_files libnss_hesiod libnss_nis libnss_nisplus libpthread libresolv librt libthread_db libutil ; do \
			f=`/bin/ls $$i-*.so | tail -1` ; \
			chattr -i /lib/"$$f" || true ; \
			ff="$$ff $$f" ; \
		done ; \
		mv -f $$ff /lib/ ; \
		/sbin/ldconfig /lib ; \
		cd /lib ; \
		chmod a-w $$ff ; \
		chattr +i $$ff
	cp -p /lib/ld-"$(VERSION)".so "$(PREFIX)"/lib/
	rm -f "$(PREFIX)"/lib/*.so.*
	for i in libc libpthread ; do \
		mv -f "$(PREFIX)"/lib/$$i.so . ; \
		sed 's,$(PREFIX)/lib/'$$i'\.so,/lib/'$$i'.so,g' <$$i.so >"$(PREFIX)"/lib/$$i.so ; \
		chmod 644 "$(PREFIX)"/lib/$$i.so ; \
	done
	cd "$(PREFIX)"/lib ; for i in *.so ; do \
		if [ ! -f "$$i" ] ; then \
			target=`ls -l "$$i" | sed 's/.* -> //'` ; \
			ln -vfs "/lib/$$target" "$$i" ; \
		fi ; \
	done
	$(MAKE) instbin BIN="catchsegv gencat getconf getent glibcbug iconv ldd lddlibc4 locale localedef mtrace pcprofiledump rpcgen sprof tzselect xtrace"
	$(MAKE) instsbin SBIN="iconvconfig rpcinfo zdump zic"
	ln -fs "$(PREFIX)"/lib/{Mcrt1,Scrt1,crt1,crti,crtn,gcrt1}.o /usr/lib/
	rm -rf /usr/lib/{gconv,locale}
	ln -s "$(PREFIX)"/lib/{gconv,locale} /usr/lib/
	$(MAKE) instlib LIB="BrokenLocale SegFault anl bsd-compat c c_nonshared crypt dl g ieee m mcheck memusage nsl nss_compat nss_dns nss_files nss_hesiod nss_nis nss_nisplus pcprofile pthread resolv rpcsvc rt thread_db util"
	if [ ! "$(STRIPLIB)" ] ; then \
		$(MAKE) instlib LIB="BrokenLocale_g anl_g c_g crypt_g dl_g m_g nsl_g pthread_g resolv_g rpcsvc_g rt_g util_g" ; \
	else \
		rm -f /usr/lib/lib{BrokenLocale,anl,c,crypt,dl,m,nsl,pthread,resolv,rpcsvc,rt,util}_g.a ; \
	fi
	grep -q '^/lib$$' /etc/ld.so.conf || echo /lib >>/etc/ld.so.conf
	grep -q '^/usr/lib$$' /etc/ld.so.conf || echo /usr/lib >>/etc/ld.so.conf
	$(MAKE) addldso
	rm -rf /usr/include/{arpa,bits,gnu,net,netash,netatalk,netax25,neteconet,netinet,netipx,netpacket,netrom,netrose,nfs,protocols,rpc,rpcsvc,sys}
	$(MAKE) instinc INC="_G_config.h a.out.h aio.h aliases.h alloca.h ar.h argp.h argz.h arpa assert.h bits byteswap.h complex.h cpio.h crypt.h ctype.h dirent.h dlfcn.h elf.h endian.h envz.h err.h errno.h error.h execinfo.h fcntl.h features.h fenv.h fmtmsg.h fnmatch.h fpu_control.h fstab.h fts.h ftw.h gconv.h getopt.h glob.h gnu gnu-versions.h grp.h iconv.h ieee754.h ifaddrs.h inttypes.h langinfo.h lastlog.h libgen.h libintl.h libio.h limits.h link.h locale.h malloc.h math.h mcheck.h memory.h mntent.h monetary.h net netash netatalk netax25 netdb.h neteconet netinet netipx netpacket netrom netrose nfs nl_types.h nss.h obstack.h paths.h poll.h printf.h protocols pthread.h pty.h pwd.h re_comp.h regex.h regexp.h resolv.h rpc rpcsvc sched.h search.h semaphore.h setjmp.h sgtty.h shadow.h signal.h spawn.h stab.h stdint.h stdio.h stdio_ext.h stdlib.h string.h strings.h stropts.h sys syscall.h sysexits.h syslog.h tar.h termio.h termios.h tgmath.h thread_db.h time.h ttyent.h ucontext.h ulimit.h unistd.h ustat.h utime.h utmp.h utmpx.h values.h wait.h wchar.h wctype.h wordexp.h xlocale.h"
	umask 022 ; mkdir -p /usr/share/locale
	mv -f "$(PREFIX)"/share/locale/locale.alias /usr/share/locale/
	$(MAKE) instlocale FILE=libc
	$(MAKE) instinfo INFO=libc
	$(MAKE) instman SECTION=3 SUFFIX=thr MAN="*"
	mv -f "$(PREFIX)"/etc/rpc /etc/
	rm -rf /usr/share/{i18n,zoneinfo}
	ln -s "$(PREFIX)"/share/{i18n,zoneinfo} /usr/share/
# Create the ja_JP locale
#	localedef -i ja_JP -f EUC-JP ja_JP.EUC-JP
#	localedef -i ja_JP -f UTF-8 ja_JP.UTF-8
Patch: <<EOT
######## begin no solarXX patch
--- timezone/Makefile.old	2002-08-05 04:25:49 +0900
+++ timezone/Makefile	2002-11-25 06:37:33 +0900
@@ -31,8 +31,7 @@
 tests	:= test-tz tst-timezone
 
 tzbases := africa antarctica asia australasia europe northamerica \
-	   southamerica etcetera factory \
-	   solar87 solar88 solar89
+	   southamerica etcetera factory
 tzlinks := backward systemv
 tzfiles := $(tzbases) $(tzlinks)
 # pacificnew doesn't compile; if it is to be used, it should be included in
######## end no solarXX patch
######## begin UTF-8 wcwidth patch
--- localedata/charmaps/UTF-8.old	2002-05-15 13:45:11 +0900
+++ localedata/charmaps/UTF-8	2007-06-26 02:51:00 +0900
@@ -28394,11 +28394,23 @@
 <U180B>...<U180E>	0
 <U18A9>			0
 <U200B>...<U200F>	0
+<U2014>...<U2015>	2
+<U2025>...<U2026>	2
 <U202A>...<U202E>	0
+<U203B>			2
 <U2060>...<U2063>	0
 <U206A>...<U206F>	0
 <U20D0>...<U20EA>	0
+<U2103>			2
+<U2109>			2
+<U2116>			2
+<U2121>			2
+<U2160>...<U2183>	2
+<U2190>...<U22FF>	2
+<U2312>			2
 <U2329>...<U232A>	2
+<U2460>...<U2473>	2
+<U2500>...<U2689>	2
 <U2E80>...<U3029>	2
 <U302A>...<U302F>	0
 <U3030>...<U303E>	2
######## end UTF-8 wcwidth patch
EOT
NoPatch: <<EOT
######## begin pthread fix (FIXME: still needed?)
--- ../glibc-2.3.4-orig/linuxthreads/manager.c	2004-05-04 06:41:23 +0900
+++ linuxthreads/manager.c	2005-02-14 22:11:00 +0900
@@ -972,13 +972,18 @@
   int status;
 
   while ((pid = waitpid_not_cancel(-1, &status, WNOHANG | __WCLONE)) > 0) {
-    pthread_exited(pid);
+    /*
+     * check the status of the thread before cleaning up after it -
+     * if the thread has exited holding a lock (e.g. in malloc)
+     * it may not be possible to clean up
+     */
     if (WIFSIGNALED(status)) {
       /* If a thread died due to a signal, send the same signal to
          all other threads, including the main thread. */
       pthread_kill_all_threads(WTERMSIG(status), 1);
       _exit(0);
     }
+    pthread_exited(pid);
   }
 }
 
--- ../glibc-2.3.4-orig/linuxthreads/pthread.c	2004-10-06 17:04:43 +0900
+++ linuxthreads/pthread.c	2005-02-14 22:09:57 +0900
@@ -735,18 +735,18 @@
 	  pid = __clone2(__pthread_manager_event,
 			 (void **) __pthread_manager_thread_bos,
 			 THREAD_MANAGER_STACK_SIZE,
-			 CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND,
-			 mgr);
+			 CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
+			 SIGCHLD, mgr);
 #elif _STACK_GROWS_UP
 	  pid = __clone(__pthread_manager_event,
 			(void **) __pthread_manager_thread_bos,
-			CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND,
-			mgr);
+			CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
+			SIGCHLD, mgr);
 #else
 	  pid = __clone(__pthread_manager_event,
 			(void **) __pthread_manager_thread_tos,
-			CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND,
-			mgr);
+			CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
+			SIGCHLD, mgr);
 #endif
 
 	  if (pid != -1)
@@ -775,13 +775,16 @@
 #ifdef NEED_SEPARATE_REGISTER_STACK
       pid = __clone2(__pthread_manager, (void **) __pthread_manager_thread_bos,
 		     THREAD_MANAGER_STACK_SIZE,
-		     CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND, mgr);
+		     CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
+		     SIGCHLD, mgr);
 #elif _STACK_GROWS_UP
       pid = __clone(__pthread_manager, (void **) __pthread_manager_thread_bos,
-		    CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND, mgr);
+		    CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
+		    SIGCHLD, mgr);
 #else
       pid = __clone(__pthread_manager, (void **) __pthread_manager_thread_tos,
-		    CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND, mgr);
+		    CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
+		    SIGCHLD, mgr);
 #endif
     }
   if (__builtin_expect (pid, 0) == -1) {
######## end pthread fix
######## begin gcc/binutils(?) bug fix: "missing symbol" output in middle of link script from --verbose
--- Makerules.old	2003-02-23 08:23:31 +0900
+++ Makerules	2003-11-23 01:05:10 +0900
@@ -512,7 +512,7 @@
 define build-shlib
 $(build-shlib-helper) \
 	  -o $@.new $(csu-objpfx)abi-note.o -Wl,--verbose \
-	  $(LDLIBS-$(@F:lib%.so=%).so) 2>&1 | \
+	  $(LDLIBS-$(@F:lib%.so=%).so) -lc 2>&1 | \
 	  sed -e '/^=========/,/^=========/!d;/^=========/d' \
 	      -e 's/^.*\.hash[ 	]*:.*$$/  .note.ABI-tag : { *(.note.ABI-tag) } &/' \
 	      $(LDSEDCMD-$(@F:lib%.so=%).so) > $@.lds
@@ -561,7 +561,7 @@
 define build-module
 $(build-module-helper) \
 	  -o $@.new $(csu-objpfx)abi-note.o -Wl,--verbose \
-	  $(LDLIBS-$(@F:lib%.so=%).so) 2>&1 | \
+	  $(LDLIBS-$(@F:lib%.so=%).so) -lc 2>&1 | \
 	  sed -e '/^=========/,/^=========/!d;/^=========/d' \
 	      -e 's/^.*\.hash[ 	]*:.*$$/  .note.ABI-tag : { *(.note.ABI-tag) } &/' \
 	  > $@.lds
######## end gcc/binutils(?) bug fix
EOT

-/etc/host.conf
-/etc/hosts
-/etc/ld.so.conf
-/etc/localtime
-/etc/networks
-/etc/nsswitch.conf
-/etc/resolv.conf
/etc/host.conf
/etc/hosts
/etc/ld.so.cache
/etc/ld.so.conf
/etc/localtime
/etc/networks
/etc/nsswitch.conf
/etc/resolv.conf
/etc/utmp
/etc/wtmp
/lib/ld-*.so
/lib/ld-linux.so.[0-9]*
/lib/libBrokenLocale-[0-9]*.so
/lib/libBrokenLocale.so.*
/lib/libanl-[0-9]*.so
/lib/libanl.so.*
/lib/libc-[0-9]*.so
/lib/libc.so.*
/lib/libcrypt-[0-9]*.so
/lib/libcrypt.so.*
/lib/libdl-[0-9]*.so
/lib/libdl.so.*
/lib/libm-[0-9]*.so
/lib/libm.so.*
/lib/libnsl-[0-9]*.so
/lib/libnsl.so.*
/lib/libnss_compat-[0-9]*.so
/lib/libnss_compat.so.*
/lib/libnss_dns-[0-9]*.so
/lib/libnss_dns.so.*
/lib/libnss_files-[0-9]*.so
/lib/libnss_files.so.*
/lib/libnss_hesiod-[0-9]*.so
/lib/libnss_hesiod.so.*
/lib/libnss_nis-[0-9]*.so
/lib/libnss_nis.so.*
/lib/libnss_nisplus-[0-9]*.so
/lib/libnss_nisplus.so.*
/lib/libpthread-[0-9]*.so
/lib/libpthread.so.*
/lib/libresolv-[0-9]*.so
/lib/libresolv.so.*
/lib/librt-[0-9]*.so
/lib/librt.so.*
/lib/libthread_db-[0-9]*.so
/lib/libthread_db.so.*
/lib/libutil-[0-9]*.so
/lib/libutil.so.*
/pkg/glibc/
/sbin/ldconfig
/usr/bin/catchsegv
/usr/bin/gencat
/usr/bin/getconf
/usr/bin/getent
/usr/bin/glibcbug
/usr/bin/iconv
/usr/bin/ldd
/usr/bin/lddlibc4
/usr/bin/locale
/usr/bin/localedef
/usr/bin/mtrace
/usr/bin/pcprofiledump
/usr/bin/rpcgen
/usr/bin/sprof
/usr/bin/tzselect
/usr/bin/xtrace
/usr/include/_G_config.h
/usr/include/a.out.h
/usr/include/aio.h
/usr/include/aliases.h
/usr/include/alloca.h
/usr/include/ar.h
/usr/include/argp.h
/usr/include/argz.h
/usr/include/arpa
/usr/include/assert.h
/usr/include/bits
/usr/include/byteswap.h
/usr/include/complex.h
/usr/include/cpio.h
/usr/include/crypt.h
/usr/include/ctype.h
/usr/include/dirent.h
/usr/include/dlfcn.h
/usr/include/elf.h
/usr/include/endian.h
/usr/include/envz.h
/usr/include/err.h
/usr/include/errno.h
/usr/include/error.h
/usr/include/execinfo.h
/usr/include/fcntl.h
/usr/include/features.h
/usr/include/fenv.h
/usr/include/fmtmsg.h
/usr/include/fnmatch.h
/usr/include/fpu_control.h
/usr/include/fstab.h
/usr/include/fts.h
/usr/include/ftw.h
/usr/include/gconv.h
/usr/include/getopt.h
/usr/include/glob.h
/usr/include/gnu
/usr/include/gnu-versions.h
/usr/include/grp.h
/usr/include/iconv.h
/usr/include/ieee754.h
/usr/include/ifaddrs.h
/usr/include/inttypes.h
/usr/include/langinfo.h
/usr/include/lastlog.h
/usr/include/libgen.h
/usr/include/libintl.h
/usr/include/libio.h
/usr/include/limits.h
/usr/include/link.h
/usr/include/locale.h
/usr/include/malloc.h
/usr/include/math.h
/usr/include/mcheck.h
/usr/include/memory.h
/usr/include/mntent.h
/usr/include/monetary.h
/usr/include/net
/usr/include/netash
/usr/include/netatalk
/usr/include/netax25
/usr/include/netdb.h
/usr/include/neteconet
/usr/include/netinet
/usr/include/netipx
/usr/include/netpacket
/usr/include/netrom
/usr/include/netrose
/usr/include/nfs
/usr/include/nl_types.h
/usr/include/nss.h
/usr/include/obstack.h
/usr/include/paths.h
/usr/include/poll.h
/usr/include/printf.h
/usr/include/protocols
/usr/include/pthread.h
/usr/include/pty.h
/usr/include/pwd.h
/usr/include/re_comp.h
/usr/include/regex.h
/usr/include/regexp.h
/usr/include/resolv.h
/usr/include/rpc
/usr/include/rpcsvc
/usr/include/sched.h
/usr/include/search.h
/usr/include/semaphore.h
/usr/include/setjmp.h
/usr/include/sgtty.h
/usr/include/shadow.h
/usr/include/signal.h
/usr/include/spawn.h
/usr/include/stab.h
/usr/include/stdint.h
/usr/include/stdio.h
/usr/include/stdio_ext.h
/usr/include/stdlib.h
/usr/include/string.h
/usr/include/strings.h
/usr/include/stropts.h
/usr/include/sys
/usr/include/syscall.h
/usr/include/sysexits.h
/usr/include/syslog.h
/usr/include/tar.h
/usr/include/termio.h
/usr/include/termios.h
/usr/include/tgmath.h
/usr/include/thread_db.h
/usr/include/time.h
/usr/include/ttyent.h
/usr/include/ucontext.h
/usr/include/ulimit.h
/usr/include/unistd.h
/usr/include/ustat.h
/usr/include/utime.h
/usr/include/utmp.h
/usr/include/utmpx.h
/usr/include/values.h
/usr/include/wait.h
/usr/include/wchar.h
/usr/include/wctype.h
/usr/include/wordexp.h
/usr/include/xlocale.h
/usr/info/libc.info*
/usr/lib/Mcrt1.o
/usr/lib/crt1.o
/usr/lib/crti.o
/usr/lib/crtn.o
/usr/lib/gconv
/usr/lib/gcrt1.o
/usr/lib/libBrokenLocale.*
/usr/lib/libBrokenLocale_g.*
/usr/lib/libSegFault.*
/usr/lib/libanl.*
/usr/lib/libanl_g.*
/usr/lib/libbsd-compat.*
/usr/lib/libc.*
/usr/lib/libc_g.*
/usr/lib/libc_nonshared.*
/usr/lib/libcrypt.*
/usr/lib/libcrypt_g.*
/usr/lib/libdl.*
/usr/lib/libdl_g.*
/usr/lib/libg.*
/usr/lib/libieee.*
/usr/lib/libm.*
/usr/lib/libm_g.*
/usr/lib/libmcheck.*
/usr/lib/libmemusage.*
/usr/lib/libnsl.*
/usr/lib/libnsl_g.*
/usr/lib/libnss_compat.*
/usr/lib/libnss_dns.*
/usr/lib/libnss_files.*
/usr/lib/libnss_hesiod.*
/usr/lib/libnss_nis.*
/usr/lib/libnss_nisplus.*
/usr/lib/libpcprofile.*
/usr/lib/libpthread.*
/usr/lib/libpthread_g.*
/usr/lib/libresolv.*
/usr/lib/libresolv_g.*
/usr/lib/librpcsvc.*
/usr/lib/librpcsvc_g.*
/usr/lib/librt.*
/usr/lib/librt_g.*
/usr/lib/libthread_db.*
/usr/lib/libutil.*
/usr/lib/libutil_g.*
/usr/lib/locale
/usr/man/man3/*.3thr.gz
/usr/sbin/iconvconfig
/usr/sbin/rpcinfo
/usr/sbin/zdump
/usr/sbin/zic
/usr/share/i18n
/usr/share/locale
/usr/share/zoneinfo
/var/log/wtmp
