--- php.SlackBuild.s390x	2008-09-03 20:23:06.000000000 -0400
+++ php.SlackBuild.s390x	2009-06-30 18:31:09.000000000 -0400
@@ -20,7 +20,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"
@@ -33,9 +33,9 @@
   ls -l $IMAPLIBDIR/lib/c-client.a
   sleep 5
 else
-  ( cd $CWD/../pine ; ./pine.SlackBuild )
+  ( cd $CWD/../pine ; EXTRACFLAGS="-fPIC" ./pine.SlackBuild.s390x.php )
   ( cd $TMP/pine${PINE}/imap/c-client
-    strip -g c-client.a
+echo NOT    strip -g c-client.a
     mkdir -p $IMAPLIBDIR/lib
     cp c-client.a $IMAPLIBDIR/lib
     mkdir -p $IMAPLIBDIR/include
@@ -44,10 +44,11 @@
 fi
 
 php_configure() {
-EXTENSION_DIR=/usr/lib/php/extensions \
+EXTENSION_DIR=/usr/lib64/php/extensions \
 CFLAGS="$SLKCFLAGS" \
 ./configure --prefix=/usr \
   $* \
+  --libdir=/usr/lib64 \
   --sysconfdir=/etc \
   --with-config-file-path=/etc/apache \
   --enable-safe-mode \
@@ -60,7 +61,7 @@
   --enable-calendar \
   --enable-ctype \
   --with-gdbm \
-  --with-db4 \
+  --with-db4=/usr/lib64 \
   --with-imap-ssl=$IMAPLIBDIR \
   --with-imap=$IMAPLIBDIR \
   --enable-dbase \
@@ -75,7 +76,7 @@
   --with-png \
   --with-ttf \
   --with-freetype-dir=/usr \
-  --with-gmp \
+  --with-gmp=/usr/lib64 \
   --enable-mbstring \
   --with-curl=/usr \
   --with-pcre-regex=/usr \
@@ -131,6 +132,9 @@
 # Sometimes they ship a few of these:
 find . -name "*.orig" -exec rm {} \;
 
+cat $CWD/configure.diff | patch -p0 --verbose --backup --suffix=.orig || exit 1
+# Patch the memory limit to be 16M.  The default of 8M isn't enough (apparently) on a 64-bit system
+#cat $CWD/php.main.c.diff | patch -p1 --verbose --backup --suffix=.orig || exit 1
 # Patch ini files:
 zcat $CWD/php.ini.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit 1
 
@@ -143,7 +147,7 @@
 # --with-freetype-dir=foo  Something for later maybe?  any requests?
 
 make -j6 || exit 1
-make install INSTALL_ROOT=$PKG
+make install INSTALL_ROOT=$PKG || exit 1
 make distclean
 
 # PHP likes to install Pear with some strange permissions.
@@ -157,20 +161,26 @@
   --enable-sigchild
 
 make -j3 || exit 1
-make install-cli INSTALL_ROOT=$PKG
+make install-cli INSTALL_ROOT=$PKG || exit 1
 chmod 755 $PKG/usr/bin/php
+#chown root:bin $PKG/usr/bin/php
 
 # Install the CGI/FastCGI interpreter:
 cat sapi/cgi/php > $PKG/usr/bin/php-cgi
 chmod 755 $PKG/usr/bin/php-cgi
 
+# Move the build files
+( cd $PKG/usr/lib64
+  mv build php/
+)
+
 # PHP 4.4.2 seems to be throwing some junk in the root directory:
 ( cd $PKG
   rm -rf .channels .depdb .depdblock .filemap .lock .registry
 )
 
-# Fix $PKG/usr/lib/php perms:
-( cd $PKG/usr/lib/php
+# Fix $PKG/usr/lib64/php perms:
+( cd $PKG/usr/lib64/php
   find . -perm 666 -exec chmod 644 {} \;
   find . -perm 664 -exec chmod 644 {} \;
   find . -perm 600 -exec chmod 644 {} \;
