--- glibc.SlackBuild	2006-09-20 01:51:23.000000000 -0400
+++ glibc.SlackBuild.s390x	2007-01-22 23:34:04.000000000 -0500
@@ -5,7 +5,7 @@
 
 # Temporary build location.  This should not be a directory
 # path a non-root user could create later...
-TMP=${TMP:-/glibc-tmp-`mcookie`}
+TMP=${TMP:-/glibc-tmp}
 if [ ! -d $TMP ]; then
   mkdir -p $TMP
 fi
@@ -30,10 +30,10 @@
 # $ARCH may be preset, otherwise i486 compatibility with i686 binary
 # structuring is the Slackware default now, since this is what gcc-3.2+
 # requires for binary compatibility with previous releases.
-ARCH=${ARCH:-i486}
+ARCH=${ARCH:-s390x}
 
 # This should be i486 for all 32-bit x86 arch:
-TARGET=${TARGET:-i486}
+TARGET=${TARGET:-s390x}
 
 BUILD=${BUILD:-6}
 
@@ -48,6 +48,16 @@
   zcat $CWD/glibc.tls.crashfix.diff.gz | patch -p1 --verbose || exit 1
   # Fix NIS netgroups:
   zcat $CWD/glibc.nis-netgroups.diff.gz | patch -p1 --verbose || exit 1
+
+  # Fix some mainframe-specific issues
+# cat $CWD/tls.h.diff | patch -p1 --verbose || exit 1
+  cat $CWD/user.h.diff | patch -p1 --verbose || exit 1
+  ( cd /usr/src/linux-$HEADERSTWOSIX
+    if [ -f include/asm-s390/sigcontext.h.orig ]; then
+         cp -vp include/asm-s390/sigcontext.h.orig include/asm-s390/sigcontext.h
+    fi
+    cat $CWD/sigcontext.h.diff | patch -p1 --verbose --backup --suffix=.orig || exit 1
+  )
   # Evidently glibc never expected Linux kernel versions to be in the
   # format 1.2.3.4.  This patch makes glibc consider the kernel version
   # to be only the first three digit groups found, and drops any
@@ -89,7 +99,7 @@
   OPTIMIZ="-O3 -march=i686"
 elif [ "$ARCH" = "athlon" ]; then
   OPTIMIZ="-O3 -march=athlon"
-elif [ "$ARCH" = "s390" ]; then
+elif [ "$ARCH" = "s390x" ]; then
   OPTIMIZ="-O3"
 elif [ "$ARCH" = "x86_64" ]; then
   OPTIMIZ="-O3"
@@ -122,9 +132,11 @@
 
 # Create an incoming directory structure for glibc to be built into:
 mkdir -p $PKG/lib
+mkdir -p $PKG/lib64
 mkdir -p $PKG/sbin
 mkdir -p $PKG/usr/bin
 mkdir -p $PKG/usr/lib
+mkdir -p $PKG/usr/lib64
 mkdir -p $PKG/usr/sbin
 mkdir -p $PKG/usr/include
 mkdir -p $PKG/usr/doc
@@ -134,16 +146,18 @@
 mkdir -p $PKG/var/run/nscd
 # And for $PNPTL:
 mkdir -p $PNPTL/lib
+mkdir -p $PNPTL/lib64
 mkdir -p $PNPTL/sbin
 mkdir -p $PNPTL/usr/bin
 mkdir -p $PNPTL/usr/lib
+mkdir -p $PNPTL/usr/lib64
 mkdir -p $PNPTL/usr/sbin
 mkdir -p $PNPTL/usr/include
 mkdir -p $PNPTL/usr/doc
 mkdir -p $PNPTL/usr/man
 mkdir -p $PNPTL/usr/share
-mkdir -p $PKG/var/db/nscd
-mkdir -p $PKG/var/run/nscd
+mkdir -p $PNPTL/var/db/nscd
+mkdir -p $PNPTL/var/run/nscd
 
 cd $TMP
 rm -rf $CWD/glibc-$CVSVER
@@ -230,23 +244,24 @@
 #make localedata/install-locales install_root=$PNPTL
 
 # Relocate the NPTL libraries in /lib/tls/incoming:
-( cd $PNPTL/lib
-  mkdir -p $PKG/lib/tls/incoming
-  mv * $PKG/lib/tls/incoming
-  mv $PKG/lib/tls/incoming/libSegFault.so $PKG/lib/tls
+( cd $PNPTL/lib64
+  mkdir -p $PKG/lib64/tls/incoming
+  mv * $PKG/lib64/tls/incoming
+  mv $PKG/lib64/tls/incoming/libSegFault.so $PKG/lib64/tls
 )
 
-# Put some of the NPTL versions of the libraries into /usr/lib/nptl/
+# Put some of the NPTL versions of the libraries into /usr/lib64/nptl/
 # in case something needs to links against them:
-( cd $PNPTL/usr/lib
-  mkdir -p $PKG/usr/lib/nptl
-  cp -a libc.a libpthread.a libpthread_nonshared.a librt.a $PKG/usr/lib/nptl
-  cp -a $CWD/nptl-so/* $PKG/usr/lib/nptl
-  chown root:root $PKG/usr/lib/nptl/*.so
-  chmod 644 $PKG/usr/lib/nptl/*.so
-  ( cd $PKG/usr/lib/nptl
+( cd $PNPTL/usr/lib64
+  mkdir -p $PKG/usr/lib64/nptl
+  cp -a libc.a libpthread.a libpthread_nonshared.a librt.a $PKG/usr/lib64/nptl
+  cp -a $CWD/nptl-so/libc.so.s390x  $PKG/usr/lib64/nptl/libc.so
+  cp -a $CWD/nptl-so/libpthread.so.s390x $PKG/usr/lib64/nptl/libpthread.so
+  chown root:root $PKG/usr/lib64/nptl/*.so
+  chmod 644 $PKG/usr/lib64/nptl/*.so
+  ( cd $PKG/usr/lib64/nptl
     strip -g *
-    ln -sf /lib/tls/librt-${VERSION}.so librt.so
+    ln -sf /lib64/tls/librt-${VERSION}.so librt.so
   )
 )
 
@@ -283,11 +298,11 @@
 # The prevailing standard seems to be putting unstripped libraries in
 # /usr/lib/debug/ and stripping the debugging symbols from all the other
 # libraries.  Only linuxthreads versions are provided.
-mkdir -p $PKG/usr/lib/debug
-cp -a $PKG/lib/l*.so* $PKG/usr/lib/debug
-cp -a $PKG/usr/lib/*.a $PKG/usr/lib/debug
+mkdir -p $PKG/usr/lib64/debug
+cp -a $PKG/lib64/l*.so* $PKG/usr/lib64/debug
+cp -a $PKG/usr/lib64/*.a $PKG/usr/lib64/debug
 # Don't need debug+profile:
-( cd $PKG/usr/lib/debug ; rm -f *_p.* )
+( cd $PKG/usr/lib64/debug ; rm -f *_p.* )
 # NOTE:  Is there really a reason for the glibc-debug package?
 # If you're debugging glibc, you can also compile it, right?
 
@@ -297,10 +312,10 @@
 # It might be best to put the unstripped and profiling libraries in glibc-debug and glibc-profile.
 
 # I don't think "strip -g" causes the pthread problems.  It's --strip-unneeded that does.
-strip -g $PKG/lib/l*.so*
-strip -g $PKG/lib/tls/l*.so*
-strip -g $PKG/usr/lib/l*.so*
-strip -g $PKG/usr/lib/lib*.a
+strip -g $PKG/lib64/l*.so*
+strip -g $PKG/lib64/tls/l*.so*
+strip -g $PKG/usr/lib64/l*.so*
+strip -g $PKG/usr/lib64/lib*.a
 
 # Back to the sources dir to add some files/docs:
 cd $TMP/glibc-$CVSVER
@@ -403,11 +418,11 @@
 
 # glibc-profile:
 cd $PPROFILE
-mkdir -p usr/lib
+mkdir -p usr/lib64
 # Might as well just grab these with 'mv' to simplify things later:
-mv $PKG/usr/lib/lib*_p.a usr/lib
+mv $PKG/usr/lib64/lib*_p.a usr/lib64
 # Profile libs should be stripped.  Use the debug libs to debug...
-( cd usr/lib ; strip -g *.a )
+( cd usr/lib64 ; strip -g *.a )
 mkdir install
 cp -a $CWD/slack-desc.glibc-profile install/slack-desc
 makepkg -l y -c n $TMP/glibc-profile-$VERSION-$ARCH-$BUILD.tgz
@@ -415,9 +430,9 @@
 # THIS IS NO LONGER PACKAGED (or is it?  might be better to let it be made, and then ship it or not...)
 # glibc-debug:
 cd $PDEBUG
-mkdir -p usr/lib
+mkdir -p usr/lib64
 # Might as well just grab these with 'mv' to simplify things later:
-mv $PKG/usr/lib/debug usr/lib
+mv $PKG/usr/lib64/debug usr/lib64
 mkdir install
 cp -a $CWD/slack-desc.glibc-debug install/slack-desc
 makepkg -l y -c n $TMP/glibc-debug-$VERSION-$ARCH-$BUILD.tgz
@@ -442,14 +457,14 @@
 cp -a $CWD/profile.d/* etc/profile.d
 chown -R root:root etc
 chmod 755 etc/profile.d/*
-mkdir -p lib
-cp -a $PKG/lib/* lib
-( cd lib
+mkdir -p lib64
+cp -a $PKG/lib64/* lib64
+( cd lib64
   mkdir incoming
   mv *so* incoming
   mv incoming/libSegFault.so .
 )
-( cd lib/tls
+( cd lib64/tls
   mkdir incoming
   mv *so* incoming
   mv incoming/libSegFault.so .
@@ -459,10 +474,10 @@
 mv usr/bin/ldd .
 rm usr/bin/*
 mv ldd usr/bin
-mkdir -p usr/lib
+mkdir -p usr/lib64
 # The gconv directory has a lot of stuff, but including it here will save some problems.
 # Seems standard elsewhere.
-cp -a $PKG/usr/lib/gconv usr/lib
+cp -a $PKG/usr/lib64/gconv usr/lib64
 # Another manpage abandoned by GNU...
 #mkdir -p usr/man/man1
 #cp -a $PKG/usr/man/man1/ldd.1.gz usr/man/man1
@@ -475,7 +490,7 @@
 mv ldconfig sbin
 mkdir install
 cp -a $CWD/slack-desc.glibc-solibs install/slack-desc
-cp -a $CWD/doinst.sh-glibc-solibs install/doinst.sh
+cp -a $CWD/doinst.sh-glibc-solibs.s390x install/doinst.sh
 # Ditch links:
 find . -type l -exec rm {} \;
 # Build the package:
@@ -493,13 +508,13 @@
 find . -type l -exec rm {} \;
 mkdir install
 cp -a $CWD/slack-desc.glibc install/slack-desc
-cp -a $CWD/doinst.sh-glibc install/doinst.sh
-( cd lib
+cp -a $CWD/doinst.sh-glibc.s390x install/doinst.sh
+( cd lib64
   mkdir incoming
   mv *so* incoming
   mv incoming/libSegFault.so .
 )
-( cd lib/tls
+( cd lib64/tls
   mkdir incoming
   mv *so* incoming
   mv incoming/libSegFault.so .
