From a2e2a58e0b5da4c008c70228ff4424a594f1aece Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Tue, 15 Dec 2009 18:44:09 +0000 Subject: [PATCH] Add --with-libiconv argument to configure, to allow third-party iconv libraries to be used instead of system iconv, if so desired. Necessary to work around an OS/X Snow Leopard issue (iconv_open only available as a 32 bit call!) git-svn-id: http://svn.osgeo.org/postgis/trunk@5004 b70326c6-7e19-0410-871a-916f4a2858ee --- configure.ac | 31 ++++++++++++++++++++++++++----- loader/Makefile.in | 8 ++++++-- loader/shp2pgsql-gui.c | 1 - 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 48ca952dd..3f57e1b9e 100644 --- a/configure.ac +++ b/configure.ac @@ -189,19 +189,37 @@ dnl Detect iconv if it is installed (used for shp2pgsql encoding conversion dnl if available) dnl =========================================================================== +ICONV_CFLAGS="" +ICONV_LDFLAGS="" + +AC_ARG_WITH([libiconv], + [AS_HELP_STRING([--with-libiconv=PATH], [specify a path to non-default libiconv installation])], + [LIBICONV_PATH="$withval"], [LIBICONV_PATH=""]) + +LDFLAGS_SAVE="$LDFLAGS" +CFLAGS_SAVE="$CFLAGS" + +if test "x$LIBICONV_PATH" != "x"; then + AC_MSG_RESULT([checking user-specified libiconv location: $LIBICONV_PATH]) + ICONV_CFLAGS="-I$LIBICONV_PATH/include" + ICONV_LDFLAGS="-L$LIBICONV_PATH/lib" + LDFLAGS="$ICONV_LDFLAGS $LDFLAGS" + CFLAGS="$ICONV_CFLAGS $CFLAGS" +fi + HAVE_ICONV_H=0 AC_CHECK_HEADER([iconv.h], [HAVE_ICONV_H=1], []) dnl If we find the header file, try and link against the library -if test "x$HAVE_ICONV_H" != "x0"; then +if test "x$HAVE_ICONV_H" = "x1"; then dnl libconv defines iconv_open to libiconv_open, so we'll check that directly - AC_CHECK_LIB([iconv], [libiconv_open], [ICONV_LDFLAGS=-liconv HAVE_ICONV=1], []) + AC_CHECK_LIB([iconv], [libiconv_open], [ICONV_LDFLAGS="$ICONV_LDFLAGS -liconv" HAVE_ICONV=1], []) if test "x$HAVE_ICONV" = "x"; then dnl Check for iconv included as part of libc, using iconv_open - AC_CHECK_LIB([c], [iconv_open], [ICONV_LDFLAGS=-lc HAVE_ICONV=1], []) + AC_CHECK_LIB([c], [iconv_open], [ICONV_LDFLAGS="$ICONV_LDFLAGS -lc" HAVE_ICONV=1], []) if test "x$HAVE_ICONV" = "x"; then dnl But it's possible this implementation of libiconv doesn't have a libiconv_* define - AC_CHECK_LIB([iconv], [iconv_open], [ICONV_LDFLAGS=-liconv HAVE_ICONV=1], []) + AC_CHECK_LIB([iconv], [iconv_open], [ICONV_LDFLAGS="$ICONV_LDFLAGS -liconv" HAVE_ICONV=1], []) if test "x$HAVE_ICONV" = "x"; then dnl No iconv library was found; issue a warning to the console AC_MSG_WARN([could not find iconv library: no support for encoding conversion will be included]) @@ -213,6 +231,8 @@ else AC_MSG_WARN([could not find iconv.h header: no support for encoding conversion will be included]) fi +LDFLAGS="$LDFLAGS_SAVE" +CFLAGS="$CFLAGS_SAVE" dnl Only define HAVE_ICONV in postgis_config.h if we detect iconv sucessfully if test "x$HAVE_ICONV" != "x"; then @@ -220,6 +240,7 @@ if test "x$HAVE_ICONV" != "x"; then fi AC_SUBST([ICONV_LDFLAGS]) +AC_SUBST([ICONV_CFLAGS]) dnl =========================================================================== @@ -528,7 +549,7 @@ AC_ARG_WITH([gui], if test "x$GUI" = "xyes"; then AC_MSG_RESULT([GUI: Build requested, checking for dependencies (GKT+2.0)]) case $host in - *apple*) + *darwin10.1*) for frmwrk [ in Cairo GLib Gtk ]; do if test -d /Library/Frameworks/${frmwrk}.framework; then GTK_CFLAGS="$GTK_CFLAGS -I/Library/Frameworks/${frmwrk}.framework/Headers" diff --git a/loader/Makefile.in b/loader/Makefile.in index deaeab013..17a7466a7 100644 --- a/loader/Makefile.in +++ b/loader/Makefile.in @@ -36,6 +36,7 @@ PGSQL_FE_LDFLAGS=@PGSQL_FE_LDFLAGS@ # iconv flags ICONV_LDFLAGS=@ICONV_LDFLAGS@ +ICONV_CFLAGS=@ICONV_CFLAGS@ # liblwgeom LIBLWGEOM=../liblwgeom/liblwgeom.a @@ -64,8 +65,11 @@ gui: $(SHP2PGSQL-GUI) $(SHP2PGSQL-CLI) $(LIBLWGEOM): make -C ../liblwgeom +shp2pgsql-core.o: shp2pgsql-core.c + $(CC) $(CFLAGS) $(ICONV_CFLAGS) -c $< + pgsql2shp.o: pgsql2shp.c - $(CC) $(CFLAGS) $(PGSQL_FE_CPPFLAGS) -c $< + $(CC) $(CFLAGS) $(ICONV_CFLAGS) $(PGSQL_FE_CPPFLAGS) -c $< $(PGSQL2SHP): shpopen.o dbfopen.o getopt.o pgsql2shp.o $(LIBLWGEOM) $(CC) $(CFLAGS) $^ $(ICONV_LDFLAGS) $(PGSQL_FE_LDFLAGS) -lm -o $@ @@ -74,7 +78,7 @@ $(SHP2PGSQL-CLI): stringbuffer.o shpopen.o dbfopen.o getopt.o shp2pgsql-core.o s $(CC) $(CFLAGS) $^ -o $@ $(ICONV_LDFLAGS) -lm shp2pgsql-gui.o: shp2pgsql-gui.c - $(CC) $(PGSQL_FE_CPPFLAGS) $(CFLAGS) $(GTK_CFLAGS) -o $@ -c shp2pgsql-gui.c + $(CC) $(CFLAGS) $(PGSQL_FE_CPPFLAGS) $(GTK_CFLAGS) -o $@ -c shp2pgsql-gui.c $(SHP2PGSQL-GUI): stringbuffer.o shpopen.o dbfopen.o shp2pgsql-core.o shp2pgsql-gui.o $(LIBLWGEOM) $(CC) $(CFLAGS) $^ -o $@ $(GTK_LIBS) $(ICONV_LDFLAGS) $(PGSQL_FE_LDFLAGS) -lm diff --git a/loader/shp2pgsql-gui.c b/loader/shp2pgsql-gui.c index cba9a1313..5e7863062 100644 --- a/loader/shp2pgsql-gui.c +++ b/loader/shp2pgsql-gui.c @@ -353,7 +353,6 @@ pgui_copy_write(const char *line) } return 1; - } /* -- 2.40.0