diff -rupN octave-3.3.54.orig/acinclude.m4 octave-3.3.54.check/acinclude.m4
--- octave-3.3.54.orig/acinclude.m4	2010-09-09 00:26:50.000000000 +0200
+++ octave-3.3.54.check/acinclude.m4	2011-01-25 22:48:05.313647191 +0100
@@ -1032,10 +1032,7 @@ else
         fi
         ;;
       *)
-        save_LDFLAGS="$LDFLAGS"
-        LDFLAGS="$LDFLAGS -L/usr/X11R6/lib"
-        AC_CHECK_LIB(GL, glEnable, OPENGL_LIBS="-L/usr/X11R6/lib -lGL -lGLU")
-        LDFLAGS="$save_LDFLAGS"
+      	AC_CHECK_LIB(GL, glEnable, OPENGL_LIBS="-lGL -lGLU")
         ;;
     esac
   fi
diff -rupN octave-3.3.54.orig/common.mk octave-3.3.54.check/common.mk
--- octave-3.3.54.orig/common.mk	2010-02-25 06:07:12.000000000 +0100
+++ octave-3.3.54.check/common.mk	2011-01-25 22:48:12.779647336 +0100
@@ -92,8 +92,10 @@ F77_TOLOWER=@F77_TOLOWER@
 F77_APPEND_UNDERSCORE=@F77_TOLOWER@
 F77_APPEND_EXTRA_UNDERSCORE=@F77_TOLOWER@
 
-X11_INCFLAGS = @X11_INCFLAGS@
-X11_LIBS = @X11_LIBS@
+X_CFLAGS = @X_CFLAGS@
+X_LIBS = @X_LIBS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
 
 CARBON_LIBS = @CARBON_LIBS@
 
@@ -578,8 +580,10 @@ $(SED) < $< \
   -e "s|%OCTAVE_CONF_USE_64_BIT_IDX_T%|\"${USE_64_BIT_IDX_T}\"|" \
   -e "s|%OCTAVE_CONF_VERSION%|\"${version}\"|" \
   -e "s|%OCTAVE_CONF_ENABLE_DYNAMIC_LINKING%|\"${ENABLE_DYNAMIC_LINKING}\"|" \
-  -e "s|%OCTAVE_CONF_X11_INCFLAGS%|\"${X11_INCFLAGS}\"|" \
-  -e "s|%OCTAVE_CONF_X11_LIBS%|\"${X11_LIBS}\"|" \
+  -e "s|%OCTAVE_CONF_X_CFLAGS%|\"${X_CFLAGS}\"|" \
+  -e "s|%OCTAVE_CONF_X_LIBS%|\"${X_LIBS}\"|" \
+  -e "s|%OCTAVE_CONF_X_EXTRA_LIBS%|\"${X_EXTRA_LIBS}\"|" \
+  -e "s|%OCTAVE_CONF_X_PRE_LIBS%|\"${X_PRE_LIBS}\"|" \
   -e "s|%OCTAVE_CONF_XTRA_CFLAGS%|\"${XTRA_CFLAGS}\"|" \
   -e "s|%OCTAVE_CONF_XTRA_CXXFLAGS%|\"${XTRA_CXXFLAGS}\"|" \
   -e "s|%OCTAVE_CONF_YACC%|\"${YACC}\"|" \
diff -rupN octave-3.3.54.orig/configure.ac octave-3.3.54.check/configure.ac
--- octave-3.3.54.orig/configure.ac	2010-11-19 21:38:37.000000000 +0100
+++ octave-3.3.54.check/configure.ac	2011-01-25 22:48:19.987647243 +0100
@@ -316,23 +316,9 @@ AX_PTHREAD
 LIBS="$PTHREAD_LIBS $LIBS"
 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
 
-AC_PATH_X
-if test "$have_x" = "yes"; then
-  AC_DEFINE(HAVE_X_WINDOWS, 1, [Define if you have X11])
-
-  if test "$x_includes" != "NONE"; then
-    X11_INCFLAGS="$x_includes"
-  fi
-  AC_SUBST(X11_INCFLAGS)
-
-  if test -z $x_libraries; then
-    AC_CHECK_LIB(X11, XrmInitialize, [X11_LIBS=-lX11], [X11_LIBS=])
-  elif test $x_libraries != "NONE"; then
-    AC_CHECK_LIB(X11, XrmInitialize, 
-      [X11_LIBS="-L$x_libraries -lX11"], [X11_LIBS=], "-L$x_libraries")
-  fi
-  AC_SUBST(X11_LIBS)
-fi
+# Check for flgas, libs needed for X
+# defines X_CFLAGS, X_LIBS, X_DISPLAY_MISSING, X_EXTRA_LIBS, X_PRE_LIBS
+AC_PATH_XTRA
 
 ### On MacOSX system the Carbon framework is used to determine ScreenSize
 OCTAVE_HAVE_FRAMEWORK(Carbon, [#include <Carbon/Carbon.h>], [CGMainDisplayID ()],
@@ -2152,8 +2138,10 @@ Octave is now configured for $canonical_
   REGEX libraries:             $REGEX_LIBS
   TERM libraries:              $TERM_LIBS
   UMFPACK libraries:           $UMFPACK_LIBS
-  X11 include flags:           $X11_INCFLAGS
-  X11 libraries:               $X11_LIBS
+  X C flags:                   $X_CFLAGS
+  X libraries:                 $X_LIBS
+  X extra libs:                $X_EXTRA_LIBS
+  X pre libs:                  $X_PRE_LIBS
   Z CPPFLAGS:                  $Z_CPPFLAGS
   Z LDFLAGS:                   $Z_LDFLAGS
   Z libraries:                 $Z_LIBS
diff -rupN octave-3.3.54.orig/src/display.cc octave-3.3.54.check/src/display.cc
--- octave-3.3.54.orig/src/display.cc	2010-02-25 06:07:14.000000000 +0100
+++ octave-3.3.54.check/src/display.cc	2011-01-25 22:48:27.233647299 +0100
@@ -30,7 +30,7 @@ along with Octave; see the file COPYING.
 #include <Windows.h>
 #elif defined (HAVE_FRAMEWORK_CARBON)
 #include <Carbon/Carbon.h>
-#elif defined (HAVE_X_WINDOWS)
+#elif ! defined (X_DISPLAY_MISSING)
 #include <X11/Xlib.h>
 #endif
 
@@ -89,7 +89,7 @@ display_info::init (bool query)
       else
         warning ("no graphical display found");
 
-#elif defined (HAVE_X_WINDOWS)
+#elif ! defined (X_DISPLAY_MISSING)
 
       const char *display_name = getenv ("DISPLAY");
 
diff -rupN octave-3.3.54.orig/src/Makefile.am octave-3.3.54.check/src/Makefile.am
--- octave-3.3.54.orig/src/Makefile.am	2010-11-13 01:42:54.000000000 +0100
+++ octave-3.3.54.check/src/Makefile.am	2011-01-25 22:48:32.119834616 +0100
@@ -509,7 +509,7 @@ if AMCOND_ENABLE_DYNAMIC_LINKING
     $(GRAPHICS_LDFLAGS) $(GRAPHICS_LIBS) \
     $(FT2_LDFLAGS) $(FT2_LIBS) \
     $(HDF5_LDFLAGS) $(HDF5_LIBS) $(Z_LDFLAGS) $(Z_LIBS) \
-    $(OPENGL_LIBS) $(X11_LIBS) $(CARBON_LIBS) \
+    $(OPENGL_LIBS) $(X_PRE_LIBS) $(X_LIBS) $(X_EXTRA_LIBS) $(CARBON_LIBS) \
     $(READLINE_LIBS) $(TERM_LIBS) \
     $(LIBGLOB) \
     $(REGEX_LDFLAGS) $(REGEX_LIBS) \
@@ -539,7 +539,7 @@ else
     $(GRAPHICS_LDFLAGS) $(GRAPHICS_LIBS) \
     $(FT2_LDFLAGS) $(FT2_LIBS) \
     $(HDF5_LDFLAGS) $(HDF5_LIBS) $(Z_LDFLAGS) $(Z_LIBS) \
-    $(OPENGL_LIBS) $(X11_LIBS) $(CARBON_LIBS) \
+    $(OPENGL_LIBS) $(X_PRE_LIBS) $(X_LIBS) $(X_EXTRA_LIBS) $(CARBON_LIBS) \
     $(READLINE_LIBS) $(TERM_LIBS) \
     $(LIBGLOB) \
     $(LAPACK_LIBS) $(BLAS_LIBS) \
@@ -557,7 +557,7 @@ OCTINTERP_LINK_DEPS = \
   $(FFTW_XLDFLAGS) $(FFTW_XLIBS) \
   $(FT2_LDFLAGS) $(FT2_LIBS) \
   $(HDF5_LDFLAGS) $(HDF5_LIBS) $(Z_LDFLAGS) $(Z_LIBS) \
-  $(OPENGL_LIBS) $(X11_LIBS) $(CARBON_LIBS) \
+  $(OPENGL_LIBS) $(X_PRE_LIBS) $(X_LIBS) $(X_EXTRA_LIBS) $(CARBON_LIBS) \
   $(READLINE_LIBS) $(TERM_LIBS) \
   $(LIBGLOB) \
   $(LAPACK_LIBS) $(BLAS_LIBS) \
@@ -773,7 +773,7 @@ oct-gperf.h: octave.gperf
 	mv $@-t $@
 	rm -f $@-t1
 
-display.df display.lo: CPPFLAGS += $(X11_FLAGS)
+display.df display.lo: CPPFLAGS += $(X_CFLAGS)
 
 DLD-FUNCTIONS/__magick_read__.df: CPPFLAGS += $(MAGICK_CPPFLAGS)
 DLD_FUNCTIONS___magick_read___la_CPPFLAGS = $(AM_CPPFLAGS) $(MAGICK_CPPFLAGS)
diff -rupN octave-3.3.54.orig/src/oct-conf.h.in octave-3.3.54.check/src/oct-conf.h.in
--- octave-3.3.54.orig/src/oct-conf.h.in	2010-02-25 06:07:14.000000000 +0100
+++ octave-3.3.54.check/src/oct-conf.h.in	2011-01-25 22:48:37.314646896 +0100
@@ -517,12 +517,20 @@ along with Octave; see the file COPYING.
 #define OCTAVE_CONF_ENABLE_DYNAMIC_LINKING %OCTAVE_CONF_ENABLE_DYNAMIC_LINKING%
 #endif
 
-#ifndef OCTAVE_CONF_X11_INCFLAGS
-#define OCTAVE_CONF_X11_INCFLAGS %OCTAVE_CONF_X11_INCFLAGS%
+#ifndef OCTAVE_CONF_X_CFLAGS
+#define OCTAVE_CONF_X_CFLAGS %OCTAVE_CONF_X_CFLAGS%
 #endif
 
-#ifndef OCTAVE_CONF_X11_LIBS
-#define OCTAVE_CONF_X11_LIBS %OCTAVE_CONF_X11_LIBS%
+#ifndef OCTAVE_CONF_X_LIBS
+#define OCTAVE_CONF_X_LIBS %OCTAVE_CONF_X_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_X_EXTRA_LIBS
+#define OCTAVE_CONF_X_EXTRA_LIBS %OCTAVE_CONF_X_EXTRA_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_X_PRE_LIBS
+#define OCTAVE_CONF_X_PRE_LIBS %OCTAVE_CONF_X_PRE_LIBS%
 #endif
 
 #ifndef OCTAVE_CONF_XTRA_CFLAGS
diff -rupN octave-3.3.54.orig/src/toplev.cc octave-3.3.54.check/src/toplev.cc
--- octave-3.3.54.orig/src/toplev.cc	2010-11-17 08:50:07.000000000 +0100
+++ octave-3.3.54.check/src/toplev.cc	2011-01-25 22:48:48.616711021 +0100
@@ -1315,8 +1315,10 @@ specified option.\n\
       { false, "UMFPACK_LDFLAGS", OCTAVE_CONF_UMFPACK_LDFLAGS },
       { false, "UMFPACK_LIBS", OCTAVE_CONF_UMFPACK_LIBS },
       { false, "USE_64_BIT_IDX_T", OCTAVE_CONF_USE_64_BIT_IDX_T },
-      { false, "X11_INCFLAGS", OCTAVE_CONF_X11_INCFLAGS },
-      { false, "X11_LIBS", OCTAVE_CONF_X11_LIBS },
+      { false, "X_CFLAGS", OCTAVE_CONF_X_CFLAGS },
+      { false, "X_LIBS", OCTAVE_CONF_X_LIBS },
+      { false, "X_EXTRA_LIBS", OCTAVE_CONF_X_EXTRA_LIBS },
+      { false, "X_PRE_LIBS", OCTAVE_CONF_X_PRE_LIBS },
       { false, "XTRA_CFLAGS", OCTAVE_CONF_XTRA_CFLAGS },
       { false, "XTRA_CXXFLAGS", OCTAVE_CONF_XTRA_CXXFLAGS },
       { false, "YACC", OCTAVE_CONF_YACC },
