[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Building armel glibc-2.5



On 2007-03-20 11:26 +0000, Wookey wrote:
> On 2007-03-19 14:29 +0100, Hector Oron wrote:
> > >Did you
> > >set the target triple correctly?
> > 
> > Well, i'm trying to do it using the Debian Way... I issue this command:
> > # env DEB_CROSS_BOOTSTRAP=yes dpkg-buildpackage -uc -us -rfakeroot -aarmel 
> > -b -d
> 
> This doesn't work for -aarm either, so I conclude that the debian
> cross bootstrap mechanism is broken. Possibly because there are slind
> patches that simply never made it into debian proper.

Answering my own post - no they aren't in debian proper, so it's no
surprise that this doesn't work :-)

The DEB_CROSS_BOOTSTRAP stuff is in glibc2.3.2.ds1 in slind sources.
Comments suggest it is also done for 2.3.6 and 2.4 in slind git
repository but my git-foo is insufficient to actually find the
relevant sources.

Attached is 

 a) the patch between slind glibc2.3.2 and debian's (with the timezone
 changes removed). Not all of this is needed as a few changes are
 runtime, but probably most of it. and 
 
 b) my version of that for 2.3.6. This seems to build the right thing,
 but there is a bit about stdio_lim.h (patches/dev-headers-fix) which
 gets different treatment for CROSS_BOOTSTRAP and normal. I don't
 understand this, but it doesn't appear in libc6-dev-headers but does
 appear in libc6-dev without this patch. Is it important? It feels
 like there out to be a nicer way...

There is also some stuff about rpcsvc headers and the
results look a bit suspicious as I think this is currently half-arsed in
my version.

For those who haven't been following this in sordid detail (which
included me till yesterday): Essentially this works by having a
libc-dev-headers package and just doing a libc-headers pass if
DEB_CROSS_BOOTSTRAP is set. This means you need to turn
--disbale-sanity-checks on too, otherwise it complains that you are
not using linuxthreads. There is also some special-casing for the
libc-headers pass in build.mk to only build minimal stuff and use the
native compiler. This is all almost identical for 2.3.2 and 2.3.6 but
I have no idea yet how much it has all changed for 2.5...

So, this is a first cut at debian-style cross-bootstrap for glibc2.3.6
which at least builds for -aarm (although probably has some vital
files missing). Now I have some headers I can try and build this bally compiler
again, and see what breaks.

Thanx to virtuoso for doing the hard work here.

Wookey
-- 
Principal hats:  Balloonz - Toby Churchill - Aleph One - Debian
http://wookware.org/

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/changelog /home/wookey/slind/glibc-2.3.2.ds1/debian/changelog
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/changelog	2007-03-20 14:42:52.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/changelog	2007-03-20 12:44:32.000000000 +0000
@@ -1,47 +1,8 @@
-glibc (2.3.2.ds1-22sarge5) stable; urgency=low
+glibc (2.3.2.ds1-22.slind1) unstable; urgency=low
 
-  * Aurelien Jarno <aurel32@debian.org>
+  * Added patches to cross-compile cleanly.
 
-   - Update debian/patches/90_glibc232-timezones.dpatch with tzdata 
-     2006p-1. This includes DST rules for West Australia and support
-     for the "Energy Policy Act 2005".
-
- -- Aurelien Jarno <aurel32@debian.org>  Tue, 28 Nov 2006 11:10:43 +0000
-
-glibc (2.3.2.ds1-22sarge4) stable; urgency=low
-
-  * Aurelien Jarno <aurel32@debian.org>
-
-   - debian/sysdeps/linux.mk: Don't build with make -j even if we have
-     multiple CPU.
-
- -- Aurelien Jarno <aurel32@debian.org>  Wed, 19 Apr 2006 14:39:15 +0200
-
-glibc (2.3.2.ds1-22sarge3) stable; urgency=low
-
-  * Aurelien Jarno <aurel32@debian.org>
-    
-   - debian/patches/90_glibc232-timezones.dpatch: still provide SystemV
-     links.
-
- -- Aurelien Jarno <aurel32@debian.org>  Sun,  2 Apr 2006 13:54:55 +0200
-
-glibc (2.3.2.ds1-22sarge2) stable; urgency=low
-
-  * Aurelien Jarno <aurel32@debian.org>
-
-   - debian/patches/nptl-pthread-amd64.dpatch: Fix pthread_rwlock_wrlock 
-     hangs with NPTL on amd64.  (Closes: #314408)
-
- -- Aurelien Jarno <aurel32@debian.org>  Thu, 23 Mar 2006 16:08:05 +0100
-
-glibc (2.3.2.ds1-22sarge1) stable; urgency=low
-
-  * Lionel Elie Mamane <lmamane@debian.org>
-  
-   - debian/patches/90_glibc232-timezones.dpatch: Update to tzdata2006b.
-
- -- Aurelien Jarno <aurel32@debian.org>  Thu, 23 Mar 2006 00:12:10 +0100
+ -- Vartan Khachaturov <vartan.khachaturov@siemens.com>  Thu,  9 Feb 2006 18:42:11 +0300
 
 glibc (2.3.2.ds1-22) unstable; urgency=medium
 
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/control /home/wookey/slind/glibc-2.3.2.ds1/debian/control
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/control	2007-03-20 14:42:52.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/control	2007-03-20 12:44:32.000000000 +0000
@@ -3,8 +3,8 @@
 Priority: required
 Build-Depends: gettext (>= 0.10.37-1), make (>= 3.80-1), dpkg-dev (>= 1.4.1.5), debianutils (>= 1.13.1), tar (>= 1.13.11), bzip2, texinfo (>= 4.0), linux-kernel-headers (>= 2.5.999-test7-bk-9) [!hurd-i386], mig (>= 1.3-2) [hurd-i386], hurd-dev (>= 20020608-1) [hurd-i386], gnumach-dev [hurd-i386], texi2html, file, gcc-3.3 [!ia64] | gcc-3.4 [!ia64], gcc-3.3 (>= 1:3.3.5-5) [ia64] | gcc-3.4 (>= 3.4.3-2) [ia64], autoconf, binutils (>= 2.14.90.0.7-5), sed (>= 4.0.5-4), gawk, debhelper (>= 4.1.76)
 Build-Depends-Indep: perl, po-debconf
-Maintainer: GNU Libc Maintainers <debian-glibc@lists.debian.org>
-Uploaders: Ben Collins <bcollins@debian.org>, GOTO Masanori <gotom@debian.org>, Philip Blundell <pb@nexus.co.uk>, Jeff Bailey <jbailey@raspberryginger.com>, Daniel Jacobowitz <dan@debian.org>
+Maintainer: Alexander Shishkin <alexander.shishkin@siemens.com>
+Uploaders: Vartan Khachaturov <vartan.khachaturov@siemens.com>
 Standards-Version: 3.6.1.0
 
 Package: glibc-doc
@@ -70,6 +70,14 @@
  Contains the symlinks, headers, and object files needed to compile
  and link programs which use the standard C library.
 
+Package: libc6-dev-headers
+Architecture: amd64 arm i386 m68k mips mipsel powerpc sparc s390 hppa sh3 sh4 sh3eb sh4eb
+Section: libdevel
+Priority: optional
+Description: GNU C Library: Header Files only
+ Contains the headers needed to bootstrap toolchains with this glibc
+ package.
+
 Package: libc6-dbg
 Architecture: amd64 arm i386 m68k mips mipsel powerpc sparc s390 hppa sh3 sh4 sh3eb sh4eb
 Section: libdevel
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/control.in/libc6 /home/wookey/slind/glibc-2.3.2.ds1/debian/control.in/libc6
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/control.in/libc6	2007-03-20 14:42:52.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/control.in/libc6	2007-03-20 12:44:32.000000000 +0000
@@ -19,6 +19,14 @@
  Contains the symlinks, headers, and object files needed to compile
  and link programs which use the standard C library.
 
+Package: libc6-dev-headers
+Architecture: amd64 arm i386 m68k mips mipsel powerpc sparc s390 hppa sh3 sh4 sh3eb sh4eb
+Section: libdevel
+Priority: optional
+Description: GNU C Library: Header Files only
+ Contains the headers needed to bootstrap toolchains with this glibc
+ package.
+
 Package: libc6-dbg
 Architecture: amd64 arm i386 m68k mips mipsel powerpc sparc s390 hppa sh3 sh4 sh3eb sh4eb
 Section: libdevel
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/control.in/main /home/wookey/slind/glibc-2.3.2.ds1/debian/control.in/main
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/control.in/main	2007-03-20 14:42:52.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/control.in/main	2007-03-20 12:44:32.000000000 +0000
@@ -3,8 +3,8 @@
 Priority: required
 Build-Depends: gettext (>= 0.10.37-1), make (>= 3.80-1), dpkg-dev (>= 1.4.1.5), debianutils (>= 1.13.1), tar (>= 1.13.11), bzip2, texinfo (>= 4.0), linux-kernel-headers (>= 2.5.999-test7-bk-9) [!hurd-i386], mig (>= 1.3-2) [hurd-i386], hurd-dev (>= 20020608-1) [hurd-i386], gnumach-dev [hurd-i386], texi2html, file, gcc-3.3 [!ia64] | gcc-3.4 [!ia64], gcc-3.3 (>= 1:3.3.5-5) [ia64] | gcc-3.4 (>= 3.4.3-2) [ia64], autoconf, binutils (>= 2.14.90.0.7-5), sed (>= 4.0.5-4), gawk, debhelper (>= 4.1.76)
 Build-Depends-Indep: perl, po-debconf
-Maintainer: GNU Libc Maintainers <debian-glibc@lists.debian.org>
-Uploaders: Ben Collins <bcollins@debian.org>, GOTO Masanori <gotom@debian.org>, Philip Blundell <pb@nexus.co.uk>, Jeff Bailey <jbailey@raspberryginger.com>, Daniel Jacobowitz <dan@debian.org>
+Maintainer: Alexander Shishkin <alexander.shishkin@siemens.com>
+Uploaders: Vartan Khachaturov <vartan.khachaturov@siemens.com>
 Standards-Version: 3.6.1.0
 
 Package: @glibc@-doc
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/copyright /home/wookey/slind/glibc-2.3.2.ds1/debian/copyright
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/copyright	2007-03-20 14:42:52.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/copyright	2007-03-20 12:44:32.000000000 +0000
@@ -7,6 +7,10 @@
   <ftp://sources.redhat.com/pub/glibc/releases/glibc-2.3.x.tar.bz2>
   <ftp://sources.redhat.com/pub/glibc/releases/glibc-linuxthreads-2.3.x.tar.gz>
 
+This version of the package includes Slind-specific cross-compilation
+patches which are:
+   Copyright (C) 2005, 2006 Siemens AG.
+
 Copyright (C) 1991,92,93,94,95,96,97,98,99,2000,2001,2002,2003 Free Software Foundation, Inc.
 
    The GNU C Library is free software; you can redistribute it and/or
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/debhelper.in/libc-dev-headers.install /home/wookey/slind/glibc-2.3.2.ds1/debian/debhelper.in/libc-dev-headers.install
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/debhelper.in/libc-dev-headers.install	1970-01-01 00:00:00.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/debhelper.in/libc-dev-headers.install	2007-03-20 12:44:32.000000000 +0000
@@ -0,0 +1 @@
+debian/tmp-libc-headers/usr/include/* usr/include
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/debhelper.in/libc.postinst /home/wookey/slind/glibc-2.3.2.ds1/debian/debhelper.in/libc.postinst
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/debhelper.in/libc.postinst	2007-03-20 14:42:52.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/debhelper.in/libc.postinst	2007-03-20 12:44:32.000000000 +0000
@@ -1,10 +1,11 @@
-#!/bin/bash
+#!/bin/sh
 set -e
 export LC_ALL=C
 
+package=LIBC
 package_name()
 {
-    echo LIBC
+    echo $package
 }
 
 zone_banner() {
@@ -19,66 +20,9 @@
 }
 
 set_timezone() {
-    frontend=`echo "$DEBIAN_FRONTEND" | tr '[:upper:]' '[:lower:]'`
-    if [ "$frontend" = noninteractive ]; then
-        echo "Non-interactive mode, setting timezone to UTC.  Run tzconfig to change."
-        echo "UTC" >/etc/timezone
-        ln -sf /usr/share/zoneinfo/UTC /etc/localtime
-    else
-        echo "Running 'tzconfig' to set this system's timezone."
-        /usr/sbin/tzconfig
-    fi
-}
-
-# Borrowed from sysvinit's postinst.
-#	Function like update-rc.d but simpler & faster.
-#	Usage: updatercd basename start|stop NN runlevel .
-#
-#	Now we use the real update-rc.d, so now this function should
-#	be equivalent to /usr/sbin/update-rc.d.
-#
-updatercd() {
-
-	if [ ! -f /etc/init.d/$1 ]
-	then
-		return
-	fi
-
-	if [ -x /usr/sbin/update-rc.d ]
-	then
-		update-rc.d "$@" > /dev/null
-		return $?
-	fi
-
-	base=$1
-	shift
-	while [ "$1" != "" ]
-	do
-		if [ "$1" = stop ]
-		then
-			tlet=K
-		else
-			tlet=S
-		fi
-		lev=$2
-		shift 2
-		while [ "$1" != "." ]
-		do
-			cd /etc/rc$1.d
-			tmp="`echo $tlet??$base`"
-			case "$tmp" in
-				"$tlet??$base")
-					# Not present yet.
-					ln -s ../init.d/$base $tlet$lev$base
-					;;
-				*)
-					# Already present.
-					;;
-			esac
-			shift
-		done
-		shift
-	done
+    echo "Non-interactive mode, setting timezone to UTC.  Run tzconfig to change."
+    echo "UTC" >/etc/timezone
+    ln -sf /usr/share/zoneinfo/UTC /etc/localtime
 }
 
 realpath()
@@ -100,54 +44,8 @@
     echo $fname
 }
 
-# element() is a helper function for file-rc:
-element() {
-    local element list IFS
-
-    element="$1"
-
-    [ "$2" = "in" ] && shift
-    list="$2"
-    [ "$list" = "-" ] && return 1
-    [ "$list" = "*" ] && return 0
-
-    IFS=","
-    set -- $list
-    case $element in
-	"$1"|"$2"|"$3"|"$4"|"$5"|"$6"|"$7"|"$8"|"$9")
-	    return 0
-    esac
-    return 1
-}
-
-# filerc (runlevel, service) returns /etc/init.d/service, if service is
-# running in $runlevel:
-filerc() {
-    local runlevel basename
-    runlevel=$1
-    basename=$2
-    while read LINE
-    do
-	case $LINE in
-	    \#*|"") continue
-	esac
-
-	set -- $LINE
-	SORT_NO="$1"; STOP="$2"; START="$3"; CMD="$4"
-	[ "$CMD" = "/etc/init.d/$basename" ] || continue
-
-	if element "$runlevel" in "$START" || element "S" in "$START"
-	then
-	    echo "/etc/init.d/$basename"
-	    return 0
-	fi
-    done < /etc/runlevel.conf
-    echo ""
-}
-
 # We remove a relic of the past /usr/doc/<package> symlinks.
 # This script should keep at least until sarge release.
-package=LIBC
 if [ -L "/usr/doc/$package" ]; then
     rm -f "/usr/doc/$package"
 fi
@@ -217,11 +115,7 @@
 	    check="$check inetd"
 	    rl=$(runlevel | awk '{print $2}')
 	    for service in $check; do
-		if [ -f /usr/share/file-rc/rc -o -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
-		    idl=$(filerc $rl $service)
-		else
-		    idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -1)
-		fi
+		idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -1)
 		if [ -n "$idl" ] && [ -x $idl ]; then
 		    services="$service $services"
 		fi
@@ -243,29 +137,14 @@
 		echo "probably necessary to restart them too.  We recommend you to reboot your"
 		echo "machine after the upgrade to avoid the NSS related trouble."
 		echo
-		frontend=`echo "$DEBIAN_FRONTEND" | tr '[:upper:]' '[:lower:]'`
-		if [ "$frontend" = noninteractive ]; then
-		    echo "Non-interactive mode, restarting services"
-		    answer=yes
-		else
-		    echo -n "Do you wish to restart services? [Y/n] "
-		    read answer
-		    case $answer in
-			Y*|y*) answer=yes ;;
-			N*|n*) answer=no ;;
-			*) answer=yes ;;
-		    esac
-		fi
+		echo "Restarting services"
+		answer=yes
 		echo
 		if [ "$answer" = yes ] && [ "$services" != "" ]; then
 		    echo "Restarting services possibly affected by the upgrade:"
 		    failed=""
 		    for service in $services; do
-			if [ -f /usr/share/file-rc/rc -o -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
-			    idl=$(filerc $rl $service)
-			else
-			    idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -1)
-			fi
+			idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -1)
 			echo -n "  $service: stopping..."
 			$idl stop > /dev/null 2>&1 || true
 			sleep 2
@@ -285,11 +164,6 @@
 			echo "You will need to start these manually by running \`/etc/init.d/<service> start'"
 			echo "If the service still fails to start, you may need to file a bug on"
 			echo "$(package_name) or the service involved."
-			if [ "$DEBIAN_FRONTEND" != noninteractive ]; then
-			    echo
-			    echo -n "Press ENTER to continue: "
-			    read foo
-			fi
 		    else
 			echo "Services restarted successfully."
 		    fi
@@ -337,13 +211,6 @@
     if [ "$(date +%Z)" = "/etc/localtime" ]; then
 	set_timezone
     fi
-#    # DO NOT FOLLOW THIS EXAMPLE IN OTHER PACKAGES
-#    updatercd mountkernfs start 35 S .
-#    if [ -x /usr/sbin/invoke-rc.d ]; then
-#	invoke-rc.d mountkernfs start
-#    else
-#	/etc/init.d/mountkernfs 2>/dev/null || true
-#    fi
 fi
 
 if [ "`uname -s`" = Linux ]; then
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/debhelper.in/libc.preinst /home/wookey/slind/glibc-2.3.2.ds1/debian/debhelper.in/libc.preinst
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/debhelper.in/libc.preinst	2007-03-20 14:42:52.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/debhelper.in/libc.preinst	2007-03-20 12:44:32.000000000 +0000
@@ -1,8 +1,10 @@
-#!/bin/bash
+#!/bin/sh
 set -e
 export LC_ALL=C
 
-dpkg --assert-support-predepends
+# Nothing to do here for slind
+#dpkg --assert-support-predepends
+exit 0
 
 if [ "$1" = upgrade ]
 then
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/patches/00list /home/wookey/slind/glibc-2.3.2.ds1/debian/patches/00list
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/patches/00list	2007-03-20 14:42:52.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/patches/00list	2007-03-20 12:44:32.000000000 +0000
@@ -125,4 +125,5 @@
 glibc232-clock_settime
 glibc23-mips-lazy-eval
 rtld-vdso-assertion
-nptl-pthread-amd64
+fix-gcc-eh
+fix-arm-mcount-internal
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/patches/dev-headers-fix.dpatch /home/wookey/slind/glibc-2.3.2.ds1/debian/patches/dev-headers-fix.dpatch
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/patches/dev-headers-fix.dpatch	1970-01-01 00:00:00.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/patches/dev-headers-fix.dpatch	2007-03-20 12:44:32.000000000 +0000
@@ -0,0 +1,58 @@
+#! /bin/sh -e
+
+# All lines beginning with `# DP:' are a description of the patch.
+# DP: Description: @DESCRIPTION@
+# DP: Related bugs: 
+# DP: Dpatch author: 
+# DP: Patch author: 
+# DP: Upstream status: [In CVS | Debian-Specific | Pending | Not submitted ]
+# DP: Status Details: 
+# DP: Date: @DATE@
+
+PATCHLEVEL=0
+
+if [ $# -ne 2 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+case "$1" in
+    -patch) patch -d "$2" -f --no-backup-if-mismatch -p$PATCHLEVEL < $0;;
+    -unpatch) patch -d "$2" -f --no-backup-if-mismatch -R -p$PATCHLEVEL < $0;;
+    *)
+	echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+	exit 1
+esac
+exit 0
+
+# append the patch here and adjust the -p? flag in the patch calls.
+--- stdio-common/Makefile	10 Aug 2004 18:01:29 -0000	1.90
++++ stdio-common/Makefile	26 Sep 2004 19:54:08 -0000
+@@ -21,7 +21,7 @@
+ #
+ subdir	:= stdio-common
+ 
+-headers	:= printf.h stdio_ext.h
++headers	:= printf.h stdio_ext.h bits/stdio_lim.h
+ 
+ routines	:=							      \
+ 	ctermid cuserid							      \
+@@ -36,8 +36,6 @@ routines	:=							      \
+ 	remove rename							      \
+ 	flockfile ftrylockfile funlockfile
+ 
+-install-others = $(inst_includedir)/bits/stdio_lim.h
+-
+ include ../Makeconfig
+ 
+ aux	:= errlist siglist printf-parsemb printf-parsewc
+@@ -59,9 +57,6 @@ test-srcs = tst-unbputc tst-printf
+ 
+ include ../Rules
+ 
+-$(inst_includedir)/bits/stdio_lim.h: $(common-objpfx)bits/stdio_lim.h $(+force)
+-	$(do-install)
+-
+ ifeq ($(cross-compiling),no)
+ .PHONY: do-tst-unbputc do-tst-printf
+ tests: do-tst-unbputc do-tst-printf
+
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/patches/fix-arm-mcount-internal.dpatch /home/wookey/slind/glibc-2.3.2.ds1/debian/patches/fix-arm-mcount-internal.dpatch
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/patches/fix-arm-mcount-internal.dpatch	1970-01-01 00:00:00.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/patches/fix-arm-mcount-internal.dpatch	2007-03-20 12:44:32.000000000 +0000
@@ -0,0 +1,48 @@
+#! /bin/sh -e
+
+# All lines beginning with `# DP:' are a description of the patch.
+# DP: Make ldd handle non-executable shared objects
+
+if [ $# -ne 2 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+case "$1" in
+    -patch) patch -d "$2" -f --no-backup-if-mismatch -p0 < $0;;
+    -unpatch) patch -d "$2" -f --no-backup-if-mismatch -R -p0 < $0;;
+    *)
+	echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+	exit 1
+esac
+exit 0
+
+#
+# Submitted:
+# 
+# Robert Schwebel, 2003-12-22
+#  
+# Error:
+# 
+# ... undefined reference to mcount_internal ...
+# 
+# Description: 
+#
+# State:
+# 
+# unknown
+#
+
+--- sysdeps/arm/machine-gmon.h.orig	2001-07-07 21:21:19.000000000 +0200
++++ sysdeps/arm/machine-gmon.h	2003-12-21 23:58:26.000000000 +0100
+@@ -32,10 +32,8 @@
+ weak_alias (_mcount, mcount)
+ #endif
+ 
+-static void mcount_internal (u_long frompc, u_long selfpc);
+-
+ #define _MCOUNT_DECL(frompc, selfpc) \
+-static void mcount_internal (u_long frompc, u_long selfpc)
++void mcount_internal (u_long frompc, u_long selfpc)
+ 
+ /* This macro/func MUST save r0, r1 because the compiler inserts
+ 	blind calls to _mount(), ignoring the fact that _mcount may
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/patches/fix-gcc-eh.dpatch /home/wookey/slind/glibc-2.3.2.ds1/debian/patches/fix-gcc-eh.dpatch
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/patches/fix-gcc-eh.dpatch	1970-01-01 00:00:00.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/patches/fix-gcc-eh.dpatch	2007-03-20 12:44:32.000000000 +0000
@@ -0,0 +1,31 @@
+#! /bin/sh -e
+
+# All lines beginning with `# DP:' are a description of the patch.
+# DP: Make ldd handle non-executable shared objects
+
+if [ $# -ne 2 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+case "$1" in
+    -patch) patch -d "$2" -f --no-backup-if-mismatch -p0 < $0;;
+    -unpatch) patch -d "$2" -f --no-backup-if-mismatch -R -p0 < $0;;
+    *)
+	echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+	exit 1
+esac
+exit 0
+
+--- ./Makeconfig.orig	2005-03-05 14:29:56.000000000 +0300
++++ ./Makeconfig	2005-03-05 14:30:17.000000000 +0300
+@@ -524,8 +524,8 @@
+ else
+  libgcc_eh := -Wl,--as-needed -lgcc_s$(libgcc_s_suffix) $(libunwind) -Wl,--no-as-needed
+ endif
+-gnulib := -lgcc $(libgcc_eh)
+-static-gnulib := -lgcc -lgcc_eh $(libunwind)
++gnulib := -lgcc
++static-gnulib := -lgcc $(libunwind)
+ libc.so-gnulib := -lgcc
+ endif
+ ifeq ($(elf),yes)
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/patches/nptl-pthread-amd64.dpatch /home/wookey/slind/glibc-2.3.2.ds1/debian/patches/nptl-pthread-amd64.dpatch
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/patches/nptl-pthread-amd64.dpatch	2007-03-20 14:42:52.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/patches/nptl-pthread-amd64.dpatch	1970-01-01 00:00:00.000000000 +0000
@@ -1,43 +0,0 @@
-#! /bin/sh -e
-
-# DP: Description: Fix pthread_rwlock_wrlock hangs with NPTL on amd64.
-# DP: Related bugs: 314408
-# DP: Author: Jakub Jelinek <jakub@redhat.com>
-# DP: Upstream status: Fixed
-
-if [ $# -ne 2 ]; then
-    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
-    exit 1
-fi
-case "$1" in
-    -patch) patch -d "$2" -f --no-backup-if-mismatch -p1 < $0;;
-    -unpatch) patch -d "$2" -f --no-backup-if-mismatch -R -p1 < $0;;
-    *)
-	echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
-	exit 1
-esac
-exit 0
-
-2004-02-18  Jakub Jelinek  <jakub@redhat.com>
-
-	* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
-	(__pthread_rwlock_unlock): Access WRITER as 32-bit value.
-
---- libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S.jj	2003-09-22 06:40:52.000000000 +0200
-+++ libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S	2004-02-18 13:22:16.620462840 +0100
-@@ -49,12 +49,12 @@ __pthread_rwlock_unlock:
- #endif
- 	jnz	1f
- 
--2:	cmpq	$0, WRITER(%rdi)
-+2:	cmpl	$0, WRITER(%rdi)
- 	jne	5f
- 	decl	NR_READERS(%rdi)
- 	jnz	6f
- 
--5:	movq	$0, WRITER(%rdi)
-+5:	movl	$0, WRITER(%rdi)
- 
- 	movq	$1, %rsi
- 	leaq	WRITERS_WAKEUP(%rdi), %r10
-
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/rules /home/wookey/slind/glibc-2.3.2.ds1/debian/rules
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/rules	2007-03-20 14:42:52.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/rules	2007-03-20 12:50:24.000000000 +0000
@@ -112,7 +112,7 @@
 # Which build pass are we on?
 curpass = $(filter-out %_,$(subst _,_ ,$@))
 
-DEB_ARCH_REGULAR_PACKAGES = $(libc) $(libc)-dev $(libc)-dbg $(libc)-prof $(libc)-pic
+DEB_ARCH_REGULAR_PACKAGES = $(libc) $(libc)-dev $(libc)-dev-headers $(libc)-dbg $(libc)-prof $(libc)-pic
 DEB_INDEP_REGULAR_PACKAGES = glibc-doc locales
 DEB_UDEB_PACKAGES = $(libc)-udeb libnss-dns-udeb libnss-files-udeb
 
@@ -137,11 +137,22 @@
 DEB_ARCH_REGULAR_PACKAGES += nscd
 endif
 
+# Now that we included all the arch-dependent stuff, let's check if we're
+# building bootstrap headers package, and only go through libc-headers
+# pass, if DEB_CROSS_BOOTSTRAP is defined.
+ifeq ($(DEB_CROSS_BOOTSTRAP),yes)
+GLIBC_PASSES := libc-headers
+DEB_ARCH_REGULAR_PACKAGES = $(libc)-dev-headers
+DEB_INDEP_REGULAR_PACKAGES = 
+DEB_UDEB_PACKAGES = 
+endif
+
 # And now the rules...
 include debian/rules.d/*.mk
 
 clean:: debhelper-clean
 	rm -rf $(patsubst %,debian/tmp-%,$(GLIBC_PASSES))
+	rm -rf debian/tmp-libc-headers
 	rm -rf $(build-tree)
 	rm -rf $(stamp)
 	rm -f log-*
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/rules.d/build.mk /home/wookey/slind/glibc-2.3.2.ds1/debian/rules.d/build.mk
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/rules.d/build.mk	2007-03-20 14:42:52.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/rules.d/build.mk	2007-03-20 12:44:32.000000000 +0000
@@ -42,21 +42,38 @@
 	    echo "No.  Forcing cross-compile by setting build to $$configure_build."; \
 	  fi; \
 	fi; \
-	cd $(DEB_BUILDDIR) && \
-		CC="$(call xx,CC)" \
-		AUTOCONF=false \
-		$(CURDIR)/$(DEB_SRCDIR)/configure \
-		--host=$(call xx,configure_target) \
-		--build=$$configure_build --prefix=/usr --without-cvs \
-		--enable-add-ons="$(call xx,add-ons)" \
-		$(call xx,with_headers) $(call xx,extra_config_options) 2>&1 | tee -a $(log_build)
+	if [ $(curpass) = libc-headers ]; then \
+	  cd $(DEB_BUILDDIR) && \
+	  	  unset AS CXX CC CPP MAKEFLAGS GCC IMAKEFLAGS LD IMAKECPP && \
+		  export -n AS CXX CC CPP MAKEFLAGS GCC IMAKEFLAGS LD IMAKECPP && \
+		  CC="$(call xx,BUILD_CC)" \
+		  BUILD_CC="$(call xx,BUILD_CC)" \
+		  $(CURDIR)/$(DEB_SRCDIR)/configure \
+		  --host=$(call xx,configure_target) \
+		  --build=$$configure_build --prefix=/usr --without-cvs \
+		  --enable-hacker-mode \
+		  --disable-sanity-checks \
+		  $(call xx,with_headers) $(call xx,extra_config_options) 2>&1 | tee -a $(log_build); \
+	else \
+	  cd $(DEB_BUILDDIR) && \
+		  CC="$(call xx,CC)" \
+		  AUTOCONF=false \
+		  $(CURDIR)/$(DEB_SRCDIR)/configure \
+		  --host=$(call xx,configure_target) \
+		  --build=$$configure_build --prefix=/usr --without-cvs \
+		  --enable-add-ons="$(call xx,add-ons)" \
+		  $(call xx,with_headers) $(call xx,extra_config_options) 2>&1 | tee -a $(log_build); \
+	 ( cd $(DEB_BUILDDIR); mkdir -p dlfcn; cd dlfcn; ln -sf libdl.so libdl.so.2 ); \
+	fi
 
 	touch $@
 
 $(patsubst %,build_%,$(GLIBC_PASSES)) :: build_% : $(stamp)build_%
 $(stamp)build_%: $(stamp)configure_%
 	@echo Building $(curpass)
-	$(MAKE) -C $(DEB_BUILDDIR) -j $(NJOBS) 2>&1 | tee -a $(log_build)
+	if [ $(curpass) != libc-headers ]; then \
+	 $(MAKE) -C $(DEB_BUILDDIR) -j $(NJOBS) in 2>&1 | tee -a $(log_build); \
+	fi
 	touch $@
 
 $(patsubst %,check_%,$(GLIBC_PASSES)) :: check_% : $(stamp)check_%
@@ -69,7 +86,9 @@
 	  echo "Kernel too old, skipping tests."; \
 	else \
 	  echo Testing $(curpass); \
-	  $(MAKE) -C $(DEB_BUILDDIR) -j $(NJOBS) -k check 2>&1 | tee -a $(log_test); \
+	  if [ $(curpass) != libc-headers ]; then \
+	   $(MAKE) -C $(DEB_BUILDDIR) -j $(NJOBS) -k check 2>&1 | tee -a $(log_test); \
+	  fi; \
 	fi
 	touch $@
 
@@ -77,8 +96,47 @@
 $(stamp)install_%: $(stamp)check_%
 	@echo Installing $(curpass)
 	rm -rf $(CURDIR)/debian/tmp-$(curpass)
-	$(MAKE) -C $(DEB_BUILDDIR) -j $(NJOBS) \
-	  install_root=$(CURDIR)/debian/tmp-$(curpass) install
+	if [ $(curpass) = libc-headers ]; then \
+	 unset AS CXX CC CPP MAKEFLAGS GCC IMAKEFLAGS LD &&  \
+	 export -n AS CXX CC CPP MAKEFLAGS GCC IMAKEFLAGS LD IMAKECPP && \
+	 CC="$(call xx,BUILD_CC)" \
+	 $(MAKE) -C $(DEB_BUILDDIR) -j $(NJOBS) \
+	   CC="$(call xx,BUILD_CC)" \
+	   $(DEB_BUILDDIR)/sysdeps/gnu/errlist.c 2>&1; \
+	 mkdir -p $(DEB_BUILDDIR)/stdio-common; \
+	 touch $(DEB_BUILDDIR)/stdio-common/errlist-compat.c; \
+	 mkdir $(DEB_BUILDDIR)/rpcsvc; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/bootparam.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/bootparam_prot.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/key_prot.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/klm_prot.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/mount.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/nfs_prot.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/nis_callback.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/nis.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/nislib.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/nis_tags.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/nlm_prot.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/rex.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/rquota.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/rstat.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/rusers.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/sm_inter.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/spray.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/ypclnt.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/yp.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/yppasswd.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/yp_prot.h; \
+	 touch $(DEB_BUILDDIR)/rpcsvc/ypupd.h; \
+	 unset AS CXX CC CPP MAKEFLAGS GCC IMAKEFLAGS LD &&  \
+	 export -n AS CXX CC CPP MAKEFLAGS GCC IMAKEFLAGS LD IMAKECPP && \
+	 $(MAKE) -C $(DEB_BUILDDIR) -j $(NJOBS) \
+	   CC="$(call xx,BUILD_CC)" \
+	   install_root=$(CURDIR)/debian/tmp-$(curpass) prefix=/usr install-headers; \
+	else \
+	 $(MAKE) -C $(DEB_BUILDDIR) -j $(NJOBS) \
+	   install_root=$(CURDIR)/debian/tmp-$(curpass) install; \
+	fi
 
 	if [ $(curpass) = libc ]; then \
 	  $(MAKE) -f debian/generate-supported.mk IN=$(DEB_SRCDIR)/localedata/SUPPORTED \
@@ -87,6 +145,17 @@
 	  install --mode=0644 $(DEB_SRCDIR)/manual/dir-add.info \
 	    debian/tmp-$(curpass)/usr/share/info/libc-dir-add.info; \
 	fi
+	  #cp $(DEB_SRCDIR)/bits/stdio_lim.h \
+	  # $(CURDIR)/debian/tmp-$(curpass)/usr/include/bits/stdio_lim.h; \
+	  #cp $(DEB_SRCDIR)/misc/syscall-list.h \
+	  #$(CURDIR)/debian/tmp-$(curpass)/usr/include/bits/syscall.h; \
+
+	if [ $(curpass) = libc-headers ]; then \
+	  mkdir -p $(CURDIR)/debian/tmp-$(curpass)/usr/include/gnu; \
+	  touch $(CURDIR)/debian/tmp-$(curpass)/usr/include/gnu/stubs.h; \
+	  cp $(DEB_SRCDIR)/include/features.h \
+	   $(CURDIR)/debian/tmp-$(curpass)/usr/include/features.h; \
+	fi
 
 	$(call xx,extra_install)
 	touch $@
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/rules.d/debhelper.mk /home/wookey/slind/glibc-2.3.2.ds1/debian/rules.d/debhelper.mk
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/rules.d/debhelper.mk	2007-03-20 14:42:52.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/rules.d/debhelper.mk	2007-03-20 12:44:32.000000000 +0000
@@ -55,7 +55,14 @@
 	@echo Running debhelper for $(curpass)
 	dh_testroot
 	dh_installdirs -p$(curpass)
+
+ifneq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
+	# Cross-compiling, rpcsvc missing. FIXME!
+	dh_install -Xrpcsvc -p$(curpass)
+else
 	dh_install -p$(curpass)
+endif
+
 	dh_installman -p$(curpass)
 	dh_installinfo -p$(curpass)
 	dh_installdebconf -p$(curpass)
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/rules.d/dpatch.mk /home/wookey/slind/glibc-2.3.2.ds1/debian/rules.d/dpatch.mk
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/rules.d/dpatch.mk	2007-03-20 14:42:52.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/rules.d/dpatch.mk	2007-03-20 12:44:32.000000000 +0000
@@ -12,9 +12,13 @@
 PATCHLIST_ALL	 = $(shell test -f debian/patches/00list && grep -v ^\# debian/patches/00list)
 PATCHLIST_ARCH	 = $(shell test -f debian/patches/00list.${DPATCH_ARCH} && grep -v ^\# debian/patches/00list.${DPATCH_ARCH})
 PATCHLIST	?= $(shell echo ${PATCHLIST_ALL} ${PATCHLIST_ARCH})
+ifeq ($(DEB_CROSS_BOOTSTRAP),yes)
+  PATCHLIST += dev-headers-fix
+endif
 
 UNPATCHLIST	 = $(shell echo ${PATCHLIST} | tr ' ' '\n' | tac)
 
+
 # Expand them right now
 PATCHLIST	:= ${PATCHLIST}
 UNPATCHLIST	:= ${UNPATCHLIST}
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/sysdeps/linux-gnu.mk /home/wookey/slind/glibc-2.3.2.ds1/debian/sysdeps/linux-gnu.mk
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/sysdeps/linux-gnu.mk	1970-01-01 00:00:00.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/sysdeps/linux-gnu.mk	2007-03-20 12:44:32.000000000 +0000
@@ -0,0 +1,68 @@
+GLIBC_OVERLAYS ?= $(shell ls nptl* glibc-linuxthreads*)
+MIN_KERNEL_SUPPORTED := 2.2.0
+libc = libc6
+
+# Support multiple makes at once based on number of processors
+# Common wisdom says parallel make can be up to 2n+1.
+# Should we do that to get faster builds?
+NJOBS:=$(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
+ifeq ($(NJOBS),-1)
+ NJOBS:=1
+endif
+
+ifeq ($(NJOBS),0)
+ NJOBS=1
+endif
+
+# Linuxthreads Config
+threads = yes
+libc_add-ons = linuxthreads $(add-ons)
+
+ifndef LINUX_SOURCE
+  LINUX_HEADERS := /usr/include
+else
+  LINUX_HEADERS := $(LINUX_SOURCE)/include
+endif
+
+# Minimum Kernel supported
+with_headers = --with-headers=$(shell pwd)/debian/include --enable-kernel=$(call xx,MIN_KERNEL_SUPPORTED)
+
+# libc-headers
+libc-headers_extra_config_options = $(extra_config_options) --disable-sanity-checks
+
+# NPTL Config
+nptl_add-ons = nptl $(add-ons)
+nptl_extra_config_options = $(extra_config_options) --with-tls --with-__thread --disable-profile
+nptl_extra_cflags = -g1 -O3
+nptl_MIN_KERNEL_SUPPORTED = 2.6.0
+nptl_LIBDIR = /tls
+
+LINUX_HEADER_DIR = $(stamp)mkincludedir
+$(stamp)mkincludedir:
+	rm -rf debian/include
+	mkdir debian/include
+	ln -s $(LINUX_HEADERS)/linux debian/include
+	# Link all asm directories.  We can't just link asm and asm-generic
+	# because of explicit references to <asm-sparc/*> and
+	# <asm-sparc64/*>.
+	find $(LINUX_HEADERS) -maxdepth 1 -xtype d -name asm\* \
+	  -exec ln -s '{}' debian/include ';'
+
+	# To make configure happy if libc6-dev is not installed.
+	touch debian/include/assert.h
+
+	touch $@
+
+# Also to make configure happy.
+export CPPFLAGS = -isystem $(shell pwd)/debian/include
+
+# This round of ugliness decomposes the Linux kernel version number
+# into an integer so it can be easily compared and then does so.
+CURRENT_KERNEL_VERSION=$(shell uname -r)
+define kernel_check
+(minimum=$$((`echo $(1) | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`)); \
+current=$$((`echo $(CURRENT_KERNEL_VERSION) | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`)); \
+if [ $$current -lt $$minimum ]; then \
+  false; \
+fi)
+endef
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/sysdeps/linux.mk /home/wookey/slind/glibc-2.3.2.ds1/debian/sysdeps/linux.mk
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/sysdeps/linux.mk	2007-03-20 14:42:52.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/sysdeps/linux.mk	1970-01-01 00:00:00.000000000 +0000
@@ -1,68 +0,0 @@
-GLIBC_OVERLAYS ?= $(shell ls nptl* glibc-linuxthreads*)
-MIN_KERNEL_SUPPORTED := 2.2.0
-libc = libc6
-
-# Support multiple makes at once based on number of processors
-# Common wisdom says parallel make can be up to 2n+1.
-# Should we do that to get faster builds?
-NJOBS:=$(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
-ifeq ($(NJOBS),-1)
- NJOBS:=1
-endif
-
-ifeq ($(NJOBS),0)
- NJOBS=1
-endif
-
-# It looks like the timezone part is not SMP safe
-NJOBS:=1
-
-# Linuxthreads Config
-threads = yes
-libc_add-ons = linuxthreads $(add-ons)
-
-ifndef LINUX_SOURCE
-  LINUX_HEADERS := /usr/include
-else
-  LINUX_HEADERS := $(LINUX_SOURCE)/include
-endif
-
-# Minimum Kernel supported
-with_headers = --with-headers=$(shell pwd)/debian/include --enable-kernel=$(call xx,MIN_KERNEL_SUPPORTED)
-
-# NPTL Config
-nptl_add-ons = nptl $(add-ons)
-nptl_extra_config_options = $(extra_config_options) --with-tls --with-__thread --disable-profile
-nptl_extra_cflags = -g1 -O3
-nptl_MIN_KERNEL_SUPPORTED = 2.6.0
-nptl_LIBDIR = /tls
-
-LINUX_HEADER_DIR = $(stamp)mkincludedir
-$(stamp)mkincludedir:
-	rm -rf debian/include
-	mkdir debian/include
-	ln -s $(LINUX_HEADERS)/linux debian/include
-	# Link all asm directories.  We can't just link asm and asm-generic
-	# because of explicit references to <asm-sparc/*> and
-	# <asm-sparc64/*>.
-	find $(LINUX_HEADERS) -maxdepth 1 -xtype d -name asm\* \
-	  -exec ln -s '{}' debian/include ';'
-
-	# To make configure happy if libc6-dev is not installed.
-	touch debian/include/assert.h
-
-	touch $@
-
-# Also to make configure happy.
-export CPPFLAGS = -isystem $(shell pwd)/debian/include
-
-# This round of ugliness decomposes the Linux kernel version number
-# into an integer so it can be easily compared and then does so.
-CURRENT_KERNEL_VERSION=$(shell uname -r)
-define kernel_check
-(minimum=$$((`echo $(1) | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`)); \
-current=$$((`echo $(CURRENT_KERNEL_VERSION) | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`)); \
-if [ $$current -lt $$minimum ]; then \
-  false; \
-fi)
-endef
diff -urN /home/wookey/armel/glibc-2.3.2.ds1/debian/wrapper/objcopy /home/wookey/slind/glibc-2.3.2.ds1/debian/wrapper/objcopy
--- /home/wookey/armel/glibc-2.3.2.ds1/debian/wrapper/objcopy	2007-03-20 14:42:52.000000000 +0000
+++ /home/wookey/slind/glibc-2.3.2.ds1/debian/wrapper/objcopy	2007-03-20 12:44:32.000000000 +0000
@@ -1,11 +1,16 @@
 #!/bin/sh
 
+if [ "x$DEB_HOST_GNU_TYPE" != "x$DEB_BUILD_GNU_TYPE" ]; then
+    # Cross-compiling, set the prefix.
+    CROSSPREFIX=${DEB_HOST_GNU_TYPE}-
+fi
+
 case " $* " in
   *" --only-keep-debug "*)
-    exec /usr/bin/objcopy -R .debug_info -R .debug_aranges -R .debug_pubnames \
+    exec ${CROSSPREFIX}objcopy -R .debug_info -R .debug_aranges -R .debug_pubnames \
 	-R .debug_abbrev -R .debug_line -R .debug_str -R .debug_ranges \
 	-R .comment -R .note "$@"
     ;;
 esac
 
-exec /usr/bin/objcopy "$@"
+exec ${CROSSPREFIX}objcopy "$@"
diff -urN glibc-2.3.6.ds1.orig/debian/control.in/libc glibc-2.3.6.ds1/debian/control.in/libc
--- glibc-2.3.6.ds1.orig/debian/control.in/libc	2007-03-20 17:28:26.000000000 +0000
+++ glibc-2.3.6.ds1/debian/control.in/libc	2007-03-20 15:18:27.000000000 +0000
@@ -19,6 +19,14 @@
  Contains the symlinks, headers, and object files needed to compile
  and link programs which use the standard C library.
 
+Package: @libc@-dev-headers
+Architecture: @archs@
+Section: libdevel
+Priority: optional
+Description: GNU C Library: Header Files only
+ Contains the headers needed to bootstrap toolchains with this glibc
+ package.
+
 Package: @libc@-dbg
 Architecture: @archs@
 Section: libdevel
diff -urN glibc-2.3.6.ds1.orig/debian/debhelper.in/libc-dev-headers.install glibc-2.3.6.ds1/debian/debhelper.in/libc-dev-headers.install
--- glibc-2.3.6.ds1.orig/debian/debhelper.in/libc-dev-headers.install	1970-01-01 00:00:00.000000000 +0000
+++ glibc-2.3.6.ds1/debian/debhelper.in/libc-dev-headers.install	2007-03-20 17:03:38.000000000 +0000
@@ -0,0 +1 @@
+debian/tmp-libc-headers/usr/include/* usr/include
diff -urN glibc-2.3.6.ds1.orig/debian/rules glibc-2.3.6.ds1/debian/rules
--- glibc-2.3.6.ds1.orig/debian/rules	2007-03-20 17:28:26.000000000 +0000
+++ glibc-2.3.6.ds1/debian/rules	2007-03-20 17:30:28.000000000 +0000
@@ -159,11 +159,22 @@
 DEB_ARCH_REGULAR_PACKAGES += nscd
 endif
 
+# Now that we included all the arch-dependent stuff, let's check if we're
+# building bootstrap headers package, and only go through libc-headers
+# pass, if DEB_CROSS_BOOTSTRAP is defined.
+ifeq ($(DEB_CROSS_BOOTSTRAP),yes)
+GLIBC_PASSES := libc-headers
+DEB_ARCH_REGULAR_PACKAGES = $(libc)-dev-headers
+DEB_INDEP_REGULAR_PACKAGES = 
+DEB_UDEB_PACKAGES = 
+endif
+
 # And now the rules...
 include debian/rules.d/*.mk
 
 clean:: debhelper-clean
 	rm -rf $(patsubst %,debian/tmp-%,$(GLIBC_PASSES))
+	rm -rf debian/tmp-libc-headers
 	rm -rf $(build-tree)
 	rm -rf $(stamp)
 	rm -f log-*
diff -urN glibc-2.3.6.ds1.orig/debian/rules.d/build.mk glibc-2.3.6.ds1/debian/rules.d/build.mk
--- glibc-2.3.6.ds1.orig/debian/rules.d/build.mk	2007-03-20 17:28:26.000000000 +0000
+++ glibc-2.3.6.ds1/debian/rules.d/build.mk	2007-03-20 16:44:12.000000000 +0000
@@ -59,24 +59,42 @@
 	  fi; \
 	fi; \
 	$(call logme, -a $(log_build), echo -n "Build started: " ; date --rfc-2822 ; echo "---------------") ; \
-	$(call logme, -a $(log_build), \
-		cd $(DEB_BUILDDIR) && \
-		CC="$(call xx,CC)" \
-		AUTOCONF=false \
-		MAKEINFO=: \
-		$(CURDIR)/$(DEB_SRCDIR)/configure \
-		--host=$(call xx,configure_target) \
-		--build=$$configure_build --prefix=/usr --without-cvs \
-		--enable-add-ons=$(standard-add-ons)"$(call xx,add-ons)" \
-		--without-selinux \
-		$(call xx,with_headers) $(call xx,extra_config_options))
+	if [ $(curpass) = libc-headers ]; then \
+		$(call logme, -a $(log_build), \
+			cd $(DEB_BUILDDIR) && \
+	  		unset AS CXX CC CPP MAKEFLAGS GCC IMAKEFLAGS LD IMAKECPP && \
+			export -n AS CXX CC CPP MAKEFLAGS GCC IMAKEFLAGS LD IMAKECPP && \
+			CC="$(call xx,BUILD_CC)" \
+			BUILD_CC="$(call xx,BUILD_CC)" \
+			$(CURDIR)/$(DEB_SRCDIR)/configure \
+			--host=$(call xx,configure_target) \
+			--build=$$configure_build --prefix=/usr --without-cvs \
+			--enable-hacker-mode \
+			--disable-sanity-checks \
+			--without-selinux \
+			$(call xx,with_headers) $(call xx,extra_config_options)); \
+	else \
+		$(call logme, -a $(log_build), \
+			cd $(DEB_BUILDDIR) && \
+			CC="$(call xx,CC)" \
+			AUTOCONF=false \
+			MAKEINFO=: \
+			$(CURDIR)/$(DEB_SRCDIR)/configure \
+			--host=$(call xx,configure_target) \
+			--build=$$configure_build --prefix=/usr --without-cvs \
+			--enable-add-ons=$(standard-add-ons)"$(call xx,add-ons)" \
+			--without-selinux \
+			$(call xx,with_headers) $(call xx,extra_config_options)); \
+	fi
 	touch $@
 
 $(patsubst %,build_%,$(GLIBC_PASSES)) :: build_% : $(stamp)build_%
 $(stamp)build_%: $(stamp)configure_%
 	@echo Building $(curpass)
-	$(call logme, -a $(log_build), $(MAKE) -C $(DEB_BUILDDIR) -j $(NJOBS))
-	$(call logme, -a $(log_build), echo "---------------" ; echo -n "Build ended: " ; date --rfc-2822)
+	if [ $(curpass) != libc-headers ]; then \
+		$(call logme, -a $(log_build), $(MAKE) -C $(DEB_BUILDDIR) -j $(NJOBS)); \
+		$(call logme, -a $(log_build), echo "---------------" ; echo -n "Build ended: " ; date --rfc-2822); \
+	fi
 	touch $@
 
 $(patsubst %,check_%,$(GLIBC_PASSES)) :: check_% : $(stamp)check_%
@@ -110,9 +128,48 @@
 $(stamp)install_%: $(stamp)check_%
 	@echo Installing $(curpass)
 	rm -rf $(CURDIR)/debian/tmp-$(curpass)
-	$(MAKE) -C $(DEB_BUILDDIR) \
-	  install_root=$(CURDIR)/debian/tmp-$(curpass) install
-
+	if [ $(curpass) = libc-headers ]; then \
+	  unset AS CXX CC CPP MAKEFLAGS GCC IMAKEFLAGS LD &&  \
+	  export -n AS CXX CC CPP MAKEFLAGS GCC IMAKEFLAGS LD IMAKECPP && \
+	  CC="$(call xx,BUILD_CC)" \
+	  $(MAKE) -C $(DEB_BUILDDIR) -j $(NJOBS) \
+	    CC="$(call xx,BUILD_CC)" \
+	    $(DEB_BUILDDIR)/sysdeps/gnu/errlist.c 2>&1; \
+	  mkdir -p $(DEB_BUILDDIR)/stdio-common; \
+	  touch $(DEB_BUILDDIR)/stdio-common/errlist-compat.c; \
+	  mkdir $(DEB_BUILDDIR)/rpcsvc; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/bootparam.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/bootparam_prot.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/key_prot.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/klm_prot.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/mount.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/nfs_prot.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/nis_callback.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/nis.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/nislib.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/nis_tags.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/nlm_prot.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/rex.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/rquota.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/rstat.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/rusers.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/sm_inter.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/spray.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/ypclnt.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/yp.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/yppasswd.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/yp_prot.h; \
+	  touch $(DEB_BUILDDIR)/rpcsvc/ypupd.h; \
+	  unset AS CXX CC CPP MAKEFLAGS GCC IMAKEFLAGS LD &&  \
+	  export -n AS CXX CC CPP MAKEFLAGS GCC IMAKEFLAGS LD IMAKECPP && \
+	  $(MAKE) -C $(DEB_BUILDDIR) -j $(NJOBS) \
+	    CC="$(call xx,BUILD_CC)" \
+	    install_root=$(CURDIR)/debian/tmp-$(curpass) prefix=/usr install-headers; \
+	else \
+	  $(MAKE) -C $(DEB_BUILDDIR)\
+	    install_root=$(CURDIR)/debian/tmp-$(curpass) install; \
+	fi
+	
 	if [ $(curpass) = libc ]; then \
 	  $(MAKE) -f debian/generate-supported.mk IN=$(DEB_SRCDIR)/localedata/SUPPORTED \
 	    OUT=debian/tmp-$(curpass)/usr/share/i18n/SUPPORTED; \
@@ -164,6 +221,13 @@
 	  echo /lib/$$triplet >> $$conffile; \
 	  echo /usr/lib/$$triplet >> $$conffile; \
 	fi
-	 
+      
+	if [ $(curpass) = libc-headers ]; then \
+	  mkdir -p $(CURDIR)/debian/tmp-$(curpass)/usr/include/gnu; \
+	  touch $(CURDIR)/debian/tmp-$(curpass)/usr/include/gnu/stubs.h; \
+	  cp $(DEB_SRCDIR)/include/features.h \
+	   $(CURDIR)/debian/tmp-$(curpass)/usr/include/features.h; \
+	fi
+ 
 	$(call xx,extra_install)
 	touch $@
diff -urN glibc-2.3.6.ds1.orig/debian/sysdeps/linux.mk glibc-2.3.6.ds1/debian/sysdeps/linux.mk
--- glibc-2.3.6.ds1.orig/debian/sysdeps/linux.mk	2007-03-20 17:28:26.000000000 +0000
+++ glibc-2.3.6.ds1/debian/sysdeps/linux.mk	2007-03-20 14:29:16.000000000 +0000
@@ -19,6 +19,9 @@
 # Minimum Kernel supported
 with_headers = --with-headers=$(shell pwd)/debian/include --enable-kernel=$(call xx,MIN_KERNEL_SUPPORTED)
 
+# libc-headers
+libc-headers_extra_config_options = $(extra_config_options) --disable-sanity-checks
+
 # NPTL Config
 nptl_add-ons = nptl $(add-ons)
 nptl_extra_config_options = $(extra_config_options) --disable-profile

Reply to: