--- ext/gd/config.m4.orig	2009-08-08 15:47:36.000000000 +0200
+++ ext/gd/config.m4	2009-08-08 15:52:11.000000000 +0200
@@ -51,7 +51,7 @@
   if test "$PHP_JPEG_DIR" != "no"; then
 
     for i in $PHP_JPEG_DIR /usr/local /usr; do
-      test -f $i/lib/libjpeg.$SHLIB_SUFFIX_NAME -o -f $i/lib/libjpeg.a && GD_JPEG_DIR=$i && break
+      test -f $i/lib64/libjpeg.$SHLIB_SUFFIX_NAME -o -f $i/lib64/libjpeg.a && GD_JPEG_DIR=$i && break
     done
 
     if test -z "$GD_JPEG_DIR"; then
@@ -61,11 +61,11 @@
     PHP_CHECK_LIBRARY(jpeg,jpeg_read_header,
     [
       PHP_ADD_INCLUDE($GD_JPEG_DIR/include)
-      PHP_ADD_LIBRARY_WITH_PATH(jpeg, $GD_JPEG_DIR/lib, GD_SHARED_LIBADD)
+      PHP_ADD_LIBRARY_WITH_PATH(jpeg, $GD_JPEG_DIR/lib64, GD_SHARED_LIBADD)
     ],[
       AC_MSG_ERROR([Problem with libjpeg.(a|so). Please check config.log for more information.]) 
     ],[
-      -L$GD_JPEG_DIR/lib
+      -L$GD_JPEG_DIR/lib64
     ])
   else 
     AC_MSG_RESULT([If configure fails try --with-jpeg-dir=<DIR>])
@@ -76,7 +76,7 @@
   if test "$PHP_PNG_DIR" != "no"; then
 
     for i in $PHP_PNG_DIR /usr/local /usr; do
-      test -f $i/lib/libpng.$SHLIB_SUFFIX_NAME -o -f $i/lib/libpng.a && GD_PNG_DIR=$i && break
+      test -f $i/lib64/libpng.$SHLIB_SUFFIX_NAME -o -f $i/lib64/libpng.a && GD_PNG_DIR=$i && break
     done
 
     if test -z "$GD_PNG_DIR"; then
@@ -94,12 +94,12 @@
     PHP_CHECK_LIBRARY(png,png_write_image,
     [
       PHP_ADD_INCLUDE($GD_PNG_DIR/include)
-      PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/lib, GD_SHARED_LIBADD)
-      PHP_ADD_LIBRARY_WITH_PATH(png, $GD_PNG_DIR/lib, GD_SHARED_LIBADD)
+      PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/lib64, GD_SHARED_LIBADD)
+      PHP_ADD_LIBRARY_WITH_PATH(png, $GD_PNG_DIR/lib64, GD_SHARED_LIBADD)
     ],[
       AC_MSG_ERROR([Problem with libpng.(a|so) or libz.(a|so). Please check config.log for more information.]) 
     ],[
-      -L$PHP_ZLIB_DIR/lib -lz -L$GD_PNG_DIR/lib
+      -L$PHP_ZLIB_DIR/lib -lz -L$GD_PNG_DIR/lib64
     ])
 
   else 
@@ -111,7 +111,7 @@
   if test "$PHP_XPM_DIR" != "no"; then
 
     for i in $PHP_XPM_DIR /usr/local /usr/X11R6 /usr; do
-      test -f $i/lib/libXpm.$SHLIB_SUFFIX_NAME -o -f $i/lib/libXpm.a && GD_XPM_DIR=$i && break
+      test -f $i/lib64/libXpm.$SHLIB_SUFFIX_NAME -o -f $i/lib64/libXpm.a && GD_XPM_DIR=$i && break
     done
 
     if test -z "$GD_XPM_DIR"; then
@@ -129,12 +129,12 @@
     PHP_CHECK_LIBRARY(Xpm,XpmFreeXpmImage, 
     [
       PHP_ADD_INCLUDE($GD_XPM_INC)
-      PHP_ADD_LIBRARY_WITH_PATH(Xpm, $GD_XPM_DIR/lib, GD_SHARED_LIBADD)
-      PHP_ADD_LIBRARY_WITH_PATH(X11, $GD_XPM_DIR/lib, GD_SHARED_LIBADD)
+      PHP_ADD_LIBRARY_WITH_PATH(Xpm, $GD_XPM_DIR/lib64, GD_SHARED_LIBADD)
+      PHP_ADD_LIBRARY_WITH_PATH(X11, $GD_XPM_DIR/lib64, GD_SHARED_LIBADD)
     ],[
       AC_MSG_ERROR([Problem with libXpm.(a|so) or libX11.(a|so). Please check config.log for more information.]) 
     ],[
-      -L$GD_XPM_DIR/lib -lX11
+      -L$GD_XPM_DIR/lib64 -lX11
     ])
   else 
     AC_MSG_RESULT(If configure fails try --with-xpm-dir=<DIR>)
@@ -163,7 +163,7 @@
       fi
       if test -n "$TTF_DIR" ; then
         AC_DEFINE(HAVE_LIBTTF,1,[ ])
-        PHP_ADD_LIBRARY_WITH_PATH(ttf, $TTF_DIR/lib, GD_SHARED_LIBADD)
+        PHP_ADD_LIBRARY_WITH_PATH(ttf, $TTF_DIR/lib64, GD_SHARED_LIBADD)
       fi
       if test -z "$TTF_INC_DIR"; then
         TTF_INC_DIR=$TTF_DIR/include
@@ -187,7 +187,7 @@
     done
     
     if test -n "$FREETYPE2_DIR" ; then
-      PHP_ADD_LIBRARY_WITH_PATH(freetype, $FREETYPE2_DIR/lib, GD_SHARED_LIBADD)
+      PHP_ADD_LIBRARY_WITH_PATH(freetype, $FREETYPE2_DIR/lib64, GD_SHARED_LIBADD)
       PHP_ADD_INCLUDE($FREETYPE2_DIR/include)
       PHP_ADD_INCLUDE($FREETYPE2_INC_DIR)
       AC_DEFINE(USE_GD_IMGSTRTTF, 1, [ ])
@@ -215,11 +215,11 @@
     [
       AC_DEFINE(HAVE_LIBT1,1,[ ])
       PHP_ADD_INCLUDE($GD_T1_DIR/include)
-      PHP_ADD_LIBRARY_WITH_PATH(t1, $GD_T1_DIR/lib, GD_SHARED_LIBADD)
+      PHP_ADD_LIBRARY_WITH_PATH(t1, $GD_T1_DIR/lib64, GD_SHARED_LIBADD)
     ],[
       AC_MSG_ERROR([Problem with libt1.(a|so). Please check config.log for more information.]) 
     ],[
-      -L$GD_T1_DIR/lib
+      -L$GD_T1_DIR/lib64
     ])
   fi
 ])
@@ -365,7 +365,7 @@
   done
 
 dnl Library path
-  for i in lib/gd1.3 lib/gd lib gd1.3 gd ""; do
+  for i in lib64/gd1.3 lib64/gd lib64 gd1.3 gd ""; do
     test -f "$PHP_GD/$i/libgd.$SHLIB_SUFFIX_NAME" -o -f "$PHP_GD/$i/libgd.a" && GD_LIB="$PHP_GD/$i"
   done
 
