Skip to content

Instantly share code, notes, and snippets.

@dakcarto
Created November 13, 2013 23:59
Show Gist options
  • Save dakcarto/7458788 to your computer and use it in GitHub Desktop.
Save dakcarto/7458788 to your computer and use it in GitHub Desktop.
Patch to strip all the PostgreSQL functions from PostGIS configure.ac, to allow building liblwgeom.dylib without needing PostgreSQL
diff --git a/configure.ac b/configure.ac
index 67ad482..8312847 100644
--- a/configure.ac
+++ b/configure.ac
@@ -325,160 +325,6 @@ fi
AC_SUBST([ICONV_LDFLAGS])
AC_SUBST([ICONV_CFLAGS])
-
-dnl ===========================================================================
-dnl Detect the version of PostgreSQL installed on the system
-dnl ===========================================================================
-
-AC_ARG_VAR(PG_CONFIG, [PostgreSQL configure command to determine Postgres version to bulid against.])
-AC_ARG_WITH([pgconfig],
- [AS_HELP_STRING([--with-pgconfig=FILE], [specify an alternative pg_config file])],
- [PG_CONFIG="$withval"], [])
-
-if test "x$PG_CONFIG" = "xno"; then
- dnl disabling pg_config doesn't make sense
- AC_MSG_ERROR([Cannot disable pg_config.])
-
-elif test "x$PG_CONFIG" = "x"; then
- dnl PG_CONFIG was not specified, so search within the current path
- AC_PATH_PROG([PG_CONFIG], [pg_config])
-
- dnl If we couldn't find pg_config, display an error
- if test "x$PG_CONFIG" = "x"; then
- AC_MSG_ERROR([could not find pg_config within the current path. You may need to try re-running configure with a --with-pg_config parameter.])
- fi
-else
- dnl PG_CONFIG was specified; display a message to the user
- if test "x$PG_CONFIG" = "xyes"; then
- AC_MSG_ERROR([you must specify a parameter to --with-pgconfig, e.g. --with-pgconfig=/path/to/pg_config])
- else
- if test -f $PG_CONFIG; then
- AC_MSG_RESULT([Using user-specified pg_config file: $PG_CONFIG])
- else
- AC_MSG_ERROR([the user-specified pg_config file $PG_CONFIG does not exist])
- fi
- fi
-fi
-
-
-dnl ===========================================================================
-dnl Ensure that $PG_CONFIG --pgxs points to a valid file. This is because some
-dnl distributions such as Debian also include pg_config as part of libpq-dev
-dnl packages, but don't install the Makefile it points to unless
-dnl the postgresql-server-dev packages are installed :)
-dnl ===========================================================================
-
-PGXS=`$PG_CONFIG --pgxs`
-if test ! -f $PGXS; then
- AC_MSG_ERROR([the PGXS Makefile $PGXS cannot be found. Please install the PostgreSQL server development packages and re-run configure.])
-fi
-
-AC_SUBST([PGXS])
-
-
-dnl Extract the version information from pg_config
-dnl Note: we extract the major & minor separately, ensure they are numeric, and then combine to give
-dnl the final version. This is to guard against user error...
-PGSQL_MAJOR_VERSION=`$PG_CONFIG --version | sed 's/[[^0-9]]*\([[0-9]]\)\.\([[0-9]]\).*/\1/'`
-PGSQL_MINOR_VERSION=`$PG_CONFIG --version | sed 's/[[^0-9]]*\([[0-9]]\)\.\([[0-9]]\).*/\2/'`
-PGSQL_FULL_VERSION=`$PG_CONFIG --version`
-POSTGIS_PGSQL_VERSION="$PGSQL_MAJOR_VERSION$PGSQL_MINOR_VERSION"
-
-PGSQL_PKGLIBDIR=`$PG_CONFIG --pkglibdir`
-PGSQL_LIBDIR=`$PG_CONFIG --libdir`
-PGSQL_SHAREDIR=`$PG_CONFIG --sharedir`
-
-AC_MSG_RESULT([checking PostgreSQL version... $PGSQL_FULL_VERSION])
-dnl Ensure that we are using PostgreSQL >= 9.0
-if test ! "$PGSQL_MAJOR_VERSION" -ge 9; then
- AC_MSG_ERROR([PostGIS requires PostgreSQL >= 9.0])
-fi
-
-dnl Temporary hack until minimum PostgreSQL version is 9.0:
-dnl If PostgreSQL < 9.0 is detected, trigger the inclusion of the new versioned PGXS targets
-PGXSOVERRIDE=0
-if test ! "$PGSQL_MAJOR_VERSION" -ge 9; then
- PGXSOVERRIDE=1
-fi
-
-AC_SUBST([PGXSOVERRIDE])
-
-dnl Note: We don't need the server-side LDFLAGS or CPPFLAGS because we get these from PGXS
-
-dnl Extract the linker and include flags for the frontend (for programs that use libpq)
-PGSQL_FE_LDFLAGS=-L`$PG_CONFIG --libdir`" -lpq"
-PGSQL_FE_CPPFLAGS=-I`$PG_CONFIG --includedir`
-
-AC_SUBST([PGSQL_FE_LDFLAGS])
-AC_SUBST([PGSQL_FE_CPPFLAGS])
-
-dnl Extract the include flags for the backend (libpgcommon)
-PGSRV_INC=`$PG_CONFIG --includedir-server`
-PGSQL_BE_CPPFLAGS="-I${PGSRV_INC}"
-dnl Add $PGSRV_INC/port/win32 to MinGW build to pick up netdb.h
-case $host in
- *mingw32*)
- PGSQL_BE_CPPFLAGS="${PGSQL_BE_CPPFLAGS} -I${PGSRV_INC}/port/win32"
- ;;
-esac
-
-AC_SUBST([PGSQL_BE_CPPFLAGS])
-
-dnl Extract the documentation and man page directories
-PGSQL_DOCDIR=`$PG_CONFIG --docdir`
-PGSQL_MANDIR=`$PG_CONFIG --mandir`
-
-AC_SUBST([PGSQL_DOCDIR])
-AC_SUBST([PGSQL_MANDIR])
-
-dnl Extract the locale directory
-PGSQL_LOCALEDIR=`$PG_CONFIG --localedir`
-AC_DEFINE_UNQUOTED([PGSQL_LOCALEDIR], ["$PGSQL_LOCALEDIR"], [Location of PostgreSQL locale directory])
-
-dnl Extract the executable directory
-PGSQL_BINDIR=`$PG_CONFIG --bindir`
-
-AC_SUBST([PGSQL_BINDIR])
-
-dnl Extract the share directory
-PGSQL_SHAREDIR=`$PG_CONFIG --sharedir`
-
-AC_SUBST([PGSQL_SHAREDIR])
-
-dnl Ensure that we can parse libpq-fe.h
-CPPFLAGS_SAVE="$CPPFLAGS"
-CPPFLAGS="$PGSQL_FE_CPPFLAGS"
-AC_CHECK_HEADER([libpq-fe.h], [], [AC_MSG_ERROR([could not find libpq-fe.h])])
-CPPFLAGS="$CPPFLAGS_SAVE"
-
-dnl Ensure we can link against libpq
-LIBS_SAVE="$LIBS"
-LIBS="$PGSQL_FE_LDFLAGS"
-AC_CHECK_LIB([pq], [PQserverVersion],
- [],
- [AC_MSG_ERROR([could not find libpq])],
- [])
-LIBS="$LIBS_SAVE"
-
-AC_DEFINE_UNQUOTED([POSTGIS_PGSQL_VERSION], [$POSTGIS_PGSQL_VERSION], [PostgreSQL server version])
-AC_SUBST([POSTGIS_PGSQL_VERSION])
-
-
-dnl ===========================================================================
-dnl Explain our prefix policy if necessary.
-dnl ===========================================================================
-
-if test "$prefix" != "NONE"; then
- AC_MSG_RESULT([------------------------------------------------------------------------])
- AC_MSG_RESULT([ WARNING: You have set the --prefix to '$prefix'. But we mostly ])
- AC_MSG_RESULT([ ignore the --prefix. For your info, using the values determined from ])
- AC_MSG_RESULT([ $PG_CONFIG we will be installing: ])
- AC_MSG_RESULT([ * postgis shared library in $PGSQL_LIBDIR ])
- AC_MSG_RESULT([ * postgis SQL files in $PGSQL_SHAREDIR/contrib/postgis-$POSTGIS_MAJOR_VERSION.$POSTGIS_MINOR_VERSION ])
- AC_MSG_RESULT([ * postgis executables in $PGSQL_BINDIR ])
- AC_MSG_RESULT([------------------------------------------------------------------------])
-fi
-
dnl ===========================================================================
dnl Detect libxml2 if it is installed
dnl (needed to GeomFromGML and GeomFromKML functions)
@@ -893,10 +739,10 @@ AC_DEFINE_UNQUOTED([POSTGIS_AUTOCACHE_BBOX], [1], [Enable caching of bounding bo
dnl Always enable use of ANALYZE statistics by default
AC_DEFINE_UNQUOTED([POSTGIS_USE_STATS], [1], [Enable use of ANALYZE statistics])
-CPPFLAGS="$PGSQL_CPPFLAGS $GEOS_CPPFLAGS $PROJ_CPPFLAGS $XML2_CPPFLAGS $SFCGAL_CPPFLAGS $CPPFLAGS"
+CPPFLAGS="$GEOS_CPPFLAGS $PROJ_CPPFLAGS $XML2_CPPFLAGS $SFCGAL_CPPFLAGS $CPPFLAGS"
AC_MSG_RESULT([CPPFLAGS: $CPPFLAGS])
-SHLIB_LINK="$PGSQL_LDFLAGS $GEOS_LDFLAGS $PROJ_LDFLAGS -lgeos_c -lproj $JSON_LDFLAGS $XML2_LDFLAGS $SFCGAL_LDFLAGS"
+SHLIB_LINK="$GEOS_LDFLAGS $PROJ_LDFLAGS -lgeos_c -lproj $JSON_LDFLAGS $XML2_LDFLAGS $SFCGAL_LDFLAGS"
AC_SUBST([SHLIB_LINK])
dnl AC_MSG_RESULT([SHLIB_LINK: $SHLIB_LINK])
@@ -1139,19 +985,6 @@ dnl SQL file.
dnl ===========================================================================
EXTENSIONS=""
-if test $POSTGIS_PGSQL_VERSION -ge 91; then
- if test \
- "x$XSLTPROC" != "x" -o \
- -e doc/postgis_comments.sql -a \
- -e doc/raster_comments.sql;
- then
- if test "x$RASTER" = "xraster"; then
- AC_MSG_RESULT([enabling PostgreSQL extension support...])
- EXTENSIONS=extensions
- AC_SUBST([EXTENSIONS])
- fi
- fi
-fi
dnl ===========================================================================
@@ -1208,8 +1041,6 @@ if test "x$SFCGAL" = "xsfcgal"; then
AC_MSG_RESULT([ SFCGAL config: ${SFCGAL_CONFIG}])
AC_MSG_RESULT([ SFCGAL version: ${SFCGAL_VERSION}])
fi
-AC_MSG_RESULT([ PostgreSQL config: ${PG_CONFIG}])
-AC_MSG_RESULT([ PostgreSQL version: ${PGSQL_FULL_VERSION}])
AC_MSG_RESULT([ PROJ4 version: ${POSTGIS_PROJ_VERSION}])
AC_MSG_RESULT([ Libxml2 config: ${XML2CONFIG}])
AC_MSG_RESULT([ Libxml2 version: ${POSTGIS_LIBXML2_VERSION}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment