diff --git a/Makefile.am b/Makefile.am
index 4ee6151..677ec5c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -80,4 +80,7 @@ style:
 
 # Create HTML docs
 doc:
-	cd $(top_srcdir)/docs/en_US && make html
+if SPHINX_BUILD
+	cd $(top_srcdir)/docs/en_US && make -f Makefile.sphinx SPHINXBUILD=${SPHINX_BUILD} html
+endif
+
diff --git a/acinclude.m4 b/acinclude.m4
index 771d38f..f81a681 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -287,6 +287,43 @@ AC_DEFUN([LOCATE_POSTGRESQL],
 	])
 ])
 
+#################
+# Locate Sphinx #
+#################
+AC_DEFUN([LOCATE_SPHINX],
+[
+        AC_ARG_WITH(sphinx-build, [  --with-sphinx-build=FILE sphinx-build executable to build the docs with],
+        [
+                if test "$withval" != no
+                then
+                        SPHINX_BUILD="$withval"
+                        if test ! -f "${SPHINX_BUILD}"
+                        then
+                                AC_MSG_ERROR([Could not find your sphinx-build executable ${SPHINX_BUILD}])
+                        fi
+
+                fi
+        ],
+        [
+                SPHINX_BUILD=/usr/local/bin/sphinx-build
+                if test ! -f "${SPHINX_BUILD}"
+                then
+                        SPHINX_BUILD=/usr/bin/sphinx-build
+                        if test ! -f "${SPHINX_BUILD}"
+                        then
+                                # Search the path
+				SPHINX_BUILD=""
+                                AC_PATH_PROGS(SPHINX_BUILD, sphinx-build sphinx-build-2.7 sphinx-build-2.6, "")
+                                if test ! -f "${SPHINX_BUILD}"
+                                then
+                                        AC_MSG_WARN([Could not find your sphinx-build executable. You might need to use the --with-sphinx-build=FILE configure option])
+                                fi
+                        fi
+                fi
+        ])
+])
+AC_SUBST(SPHINX_BUILD)
+
 ###########################
 # Debug build of pgAdmin3 #
 ###########################
@@ -840,7 +877,13 @@ AC_DEFUN([SUMMARY],
 		echo "Building a Mac OS X appbundle:		No"
 	fi
 	echo
-
+        if test "$SPHINX_BUILD" = ""
+        then
+                echo "sphinx-build executable:                <not found>"
+        else
+                echo "sphinx-build executable:                ${SPHINX_BUILD}"
+        fi
+	echo
 	echo "pgAdmin configuration is now complete. You can now compile and"
 	echo "install pgAdmin using 'make; make install'."
 	echo
diff --git a/configure.ac.in b/configure.ac.in
index 571fa46..50463e7 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -62,6 +62,9 @@ CHECK_LIBXML2
 LOCATE_LIBXSLT
 SETUP_LIBXSLT
 
+LOCATE_SPHINX
+AM_CONDITIONAL([SPHINX_BUILD], [test x$SPHINX_BUILD != x])
+
 AC_CONFIG_FILES([Makefile
 		 branding/Makefile
 		 i18n/Makefile
