--- x11.SlackBuild	2007-04-20 14:37:46.000000000 -0400
+++ x11.SlackBuild.s390x	2009-07-01 21:27:10.000000000 -0400
@@ -11,7 +11,7 @@
   SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
 elif [ "$ARCH" = "i486" ]; then
   SLKCFLAGS="-O2 -march=i486 -mtune=i686"
-elif [ "$ARCH" = "s390" ]; then
+elif [ "$ARCH" = "s390x" ]; then
   SLKCFLAGS="-O2"
 elif [ "$ARCH" = "x86_64" ]; then
   SLKCFLAGS="-O2"
@@ -154,16 +154,29 @@
 # pkgconfig files (like alocal files) are best placed in a single location, like /usr/lib/pkgconfig.
 # First make sure the pkgconfig directories exist:
 mkdir -p /usr/lib/pkgconfig /usr/X11R6/lib/pkgconfig
+mkdir -p /usr/lib64/pkgconfig /usr/X11R6/lib64/pkgconfig
 # Then, move any existing files.  This may (and probably will) produce an error if
 # /usr/X11R6/lib/pkgconfig is empty, so we'll silence stderr:
 mv /usr/X11R6/lib/pkgconfig/* /usr/lib/pkgconfig 2> /dev/null
+mv /usr/X11R6/lib64/pkgconfig/* /usr/lib/pkgconfig 2> /dev/null
+mv /usr/lib64/pkgconfig/* /usr/lib/pkgconfig 2> /dev/null
 # Finally, make a link from the old location to the system-wide one:
 ( cd /usr/X11R6/lib ; rm -rf pkgconfig )
 ( cd /usr/X11R6/lib ; ln -sf ../../lib/pkgconfig . )
+( cd /usr/X11R6/lib64 ; rm -rf pkgconfig )
+( cd /usr/X11R6/lib64 ; ln -sf ../../lib/pkgconfig . )
+( cd /usr/lib64 ; rm -rf pkgconfig )
+( cd /usr/lib64 ; ln -sf ../lib/pkgconfig . )
 # Now set up the same structure in the target install location:
 mkdir -p $PKG/usr/lib/pkgconfig $PKG/usr/X11R6/lib
+mkdir -p $PKG/usr/lib64/pkgconfig $PKG/usr/X11R6/lib64
 ( cd $PKG/usr/X11R6/lib ; rm -rf pkgconfig )
 ( cd $PKG/usr/X11R6/lib ; ln -sf ../../lib/pkgconfig . )
+( cd $PKG/usr/X11R6/lib64 ; rm -rf pkgconfig )
+( cd $PKG/usr/X11R6/lib64 ; ln -sf ../../lib/pkgconfig . )
+# We only need this for the freetype2 piece.  We'll remove it later
+( cd $PKG/usr/lib64 ; rm -rf pkgconfig )
+( cd $PKG/usr/lib64 ; ln -sf ../lib/pkgconfig . )
 
 # It's VERY important to build freetype2 ourselves first (or some functions are left
 # out), but also to use the X supplied sources.
@@ -173,7 +186,9 @@
        /usr/X11R6/include/freetype2 \
        /usr/X11R6/include/ft2build.h \
        /usr/lib/libfreetype.* \
-       /usr/X11R6/lib/libfreetype.*
+       /usr/lib64/libfreetype.* \
+       /usr/X11R6/lib/libfreetype.* \
+       /usr/X11R6/lib64/libfreetype.*
 # It seems prudent to move this into /usr rather than /usr/X11R6, as *many* source bits
 # won't find ft2build.h in /usr/X11R6/include without some patching.
 # Therefore, --prefix=/usr must be the ad-hoc standard.  Another
@@ -183,10 +198,11 @@
 # with X on a 386 in the year 2002.  If there are, maybe they can get away with running an
 # earlier version of X.  :-) 
 ( cd extras/freetype2
-  CFLAGS="$SLKCFLAGS" make setup CFG="--prefix=/usr $ARCH-slackware-linux"
-  make
+  CFLAGS="$SLKCFLAGS" make setup CFG="--prefix=/usr --libdir=/usr/lib64 $ARCH-slackware-linux"
+  make -j3
   # This only needs to go to the main system for now
-  make install
+echo LOGGING: ready to do make -i install for initial freetype2 into live file system
+  make -i install
 )
 ldconfig
 
@@ -200,8 +216,9 @@
 )
 
 # Build and install X:
-make World -j2 -i CDEBUGFLAGS="$SLKCFLAGS" || exit 1
-make install DESTDIR=$PKG || exit 1
+make World -j3 -i CDEBUGFLAGS="$SLKCFLAGS" || exit 1
+echo LOGGING: ready to do make -i install DESTDIR for main X code
+make install -i DESTDIR=$PKG || exit 1
 
 # Here, enjoy this old cruft and some never-used build script.
 
@@ -241,7 +258,7 @@
 ## Then build.  :-)
 ##
 ## Oh -- more stuff to uncomment near the bottom of this script as well.
-## Search for x11-sdk and you'll finf it easily.
+## Search for x11-sdk and you'll find it easily.
 ##
 #PKG13=$BLOC/package-x11-sdk
 #mkdir -p $PKG13/install
@@ -257,15 +274,17 @@
 # the compile, and besides, that's what a development box is for.  It should
 # be disposable.  :-)
 
-make install
+echo LOGGING: ready to do make install of main X code into the live file system
+make -i install || exit 1
 ldconfig
 
 # Install man pages:
+echo LOGGING: ready to do make install.man into PKG dir
 make install.man DESTDIR=$PKG
 
 # More useless Xprint clutter.  Great to see new cruft.
 rm -rf $PKG/usr/X11R6/include/X11/Xprint*
-rm -f $PKG/usr/X11R6/lib/libXprint*.a
+rm -f $PKG/usr/X11R6/lib64/libXprint*.a
 rm -f $PKG/usr/X11R6/man/man7/Xprint*
 
 ## *** If this is still a problem, report it to X.Org ***
@@ -331,8 +350,8 @@
 zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
 
 # Cruft.
-rm -f /usr/X11R6/lib/libz.a
-rm -f $PKG/usr/X11R6/lib/libz.a
+rm -vf /usr/X11R6/lib64/libz.a
+rm -vf $PKG/usr/X11R6/lib64/libz.a
 
 # We'll use the encodings on the system, so hopefully they are the right ones...
 ( cd $PKG/usr/X11R6/lib/X11/fonts/misc
@@ -400,16 +419,20 @@
 
 # Replace freetype2:
 ( cd $CWD/../../l/freetype
-  ./freetype2.build
+echo LOGGING: ready to build freetype2 in live file system
+  ./freetype2.build64
   ldconfig
-  DESTDIR=$PKG ./freetype2.build
+echo LOGGING: ready to build freetype2 with DESTDIR=PKG
+  DESTDIR=$PKG ./freetype2.build64
 )
 
 # Replace fontconfig:
 ( cd $CWD/../fontconfig
-  ./fontconfig.build
+echo LOGGING: ready to build fontconfig in live file system
+  ./fontconfig.build64
   ldconfig
-  DESTDIR=$PKG ./fontconfig.build
+echo LOGGING: ready to build fontconfig with DESTDIR=PKG
+  DESTDIR=$PKG ./fontconfig.build64
 )
 
 # crud removal:
@@ -417,6 +440,9 @@
 # We don't ship fonts.cache-1 files, we create them later.
 find $PKG/usr -type f -name fonts.cache-1 -exec rm {} \;
 
+# We're done with this now, so it can be removed.
+( cd $PKG/usr/lib64 ; rm -rf pkgconfig )
+
 # Strip binaries:
 ( cd $PKG
   find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
@@ -440,18 +466,47 @@
   ( cd etc/X11/xkb/rules ; ln -sf xorg xfree86 )
 )
 
+echo LOGGING: ready to copy xbm and xpm files to package directory
+# These files aren't copied over by the make install for Linux/390.  I suspect
+# they are only needed by xf86cfg or xf86config, but why not include them.
+( cd $BLOC/xc
+  mkdir -p $PKG/usr/X11R6/include/X11/bitmaps $PKG/usr/X11R6/include/X11/pixmaps
+  cp -a programs/Xserver/hw/xfree86/xf86cfg/*.xbm  \
+        $PKG/usr/X11R6/include/X11/bitmaps/
+  cp -a programs/Xserver/hw/xfree86/xf86cfg/*.xpm \
+        $PKG/usr/X11R6/include/X11/pixmaps/
+  chmod 444 $PKG/usr/X11R6/include/X11/bitmaps/*.xbm $PKG/usr/X11R6/include/X11/pixmaps/*.xpm
+)
+( cd $BLOC/xc/programs/Xserver/hw/xfree86/etc/
+  cp Xinstall.sh $PKG/usr/X11R6/lib/X11/etc/
+  cp xmodmap.std $PKG/usr/X11R6/lib/X11/etc/
+  chmod 444 $PKG/usr/X11R6/lib/X11/etc/Xinstall.sh $PKG/usr/X11R6/lib/X11/etc/xmodmap.std
+  cp sun.tcap $PKG//usr/X11R6/lib/X11/etc/sun.termcap
+  cp sun.tinfo $PKG/usr/X11R6/lib/X11/etc/sun.terminfo
+  chmod 444 $PKG//usr/X11R6/lib/X11/etc/sun.termcap $PKG/usr/X11R6/lib/X11/etc/sun.terminfo
+)
+( cd $BLOC/xc/programs/Xserver/hw/xfree86/doc
+  cp -a BUILD DESIGN Install LICENSE OS2.Notes README README.XKB-Config README.XKB-Enhancing \
+        README.dps README.fonts RELNOTES Versions \
+      $PKG/usr/X11R6/lib/X11/doc
+  sed -e 's%XF86_VERSION%$VERSION%' BugReport.cpp > $PKG/usr/X11R6/lib/X11/doc/BugReport
+  find $PKG/usr/X11R6/lib/X11/doc/ -type f | xargs chmod 444
+)
+
 # Clean out any freetype/fontconfig "residue":
 rm --verbose -rf \
       $PKG/usr/X11R6/bin/freetype-config \
       $PKG/usr/X11R6/include/freetype2 \
       $PKG/usr/X11R6/include/ft2build.h \
       $PKG/usr/X11R6/lib/libfreetype.* \
+      $PKG/usr/X11R6/lib64/libfreetype.* \
       $PKG/usr/X11R6/lib/X11/doc/freetype* \
       $PKG/usr/X11R6/lib/pkgconfig/freetype.pc \
       $PKG/usr/bin/freetype-config \
       $PKG/usr/include/freetype2 \
       $PKG/usr/include/ft2build.h \
       $PKG/usr/lib/libfreetype.* \
+      $PKG/usr/lib64/libfreetype.* \
       $PKG/usr/doc/freetype* \
       $PKG/usr/lib/pkgconfig/freetype.pc \
       $PKG/usr/share/aclocal/freetype2.m4
@@ -463,6 +518,7 @@
       $PKG/usr/X11R6/include/fontconfig \
       $PKG/usr/X11R6/lib/pkgconfig/fontconfig.pc \
       $PKG/usr/X11R6/lib/libfontconfig.* \
+      $PKG/usr/X11R6/lib64/libfontconfig.* \
       $PKG/usr/X11R6/lib/X11/doc/fontconfig* \
       $PKG/usr/X11R6/man/man?/fc-* \
       $PKG/usr/X11R6/man/man3/Fc* \
@@ -558,13 +614,14 @@
 
 # x11-devel package:
 PKG11=$BLOC/package-x11-devel
-mkdir -p $PKG11/usr/X11R6/lib/X11 $PKG11/usr/lib $PKG11/usr/X11R6/man $PKG11/install
+mkdir -p $PKG11/usr/X11R6/lib/X11 $PKG11/usr/X11R6/lib64/X11 $PKG11/usr/lib $PKG11/usr/lib64 $PKG11/usr/X11R6/man $PKG11/install
 mv $PKG/usr/lib/pkgconfig $PKG11/usr/lib
 chmod 644 $PKG11/usr/lib/pkgconfig/*
 mv $PKG/usr/X11R6/lib/pkgconfig $PKG11/usr/X11R6/lib
+mv $PKG/usr/X11R6/lib64/pkgconfig $PKG11/usr/X11R6/lib64
 mv $PKG/usr/X11R6/lib/X11/config $PKG11/usr/X11R6/lib/X11
-mv $PKG/usr/X11R6/lib/*.a $PKG11/usr/X11R6/lib
-mv $PKG/usr/lib/*.a $PKG11/usr/lib
+mv $PKG/usr/X11R6/lib64/*.a $PKG11/usr/X11R6/lib64
+mv $PKG/usr/lib64/*.a $PKG11/usr/lib64
 mv $PKG/usr/X11R6/man/man3 $PKG11/usr/X11R6/man
 mv $PKG/usr/share $PKG11/usr
 mv $PKG/usr/include $PKG11/usr
@@ -590,7 +647,8 @@
 
 # Clean up leftover stuff:
 rm -f $PKG/install/doinst.sh.fonts \
-      $PKG/install/slack-desc.x11-drm
+      $PKG/install/slack-desc.x11-drm \
+      $PKG/install/slack-desc.x11-sdk
 
 # Don't ship anything in here:
 rm -f $PKG/usr/X11R6/lib/X11/fonts/local/*
