[postgis-commits] svn - r2784 - in trunk: . loader
postgis-commits at postgis.refractions.net
postgis-commits at postgis.refractions.net
Tue May 27 07:47:06 PDT 2008
Author: mcayland
Date: 2008-05-27 07:47:06 -0700 (Tue, 27 May 2008)
New Revision: 2784
Added:
trunk/loader/Makefile.shp2pgsql.in
Removed:
trunk/loader/Makefile.shp2pgsql
Modified:
trunk/configure.in
trunk/loader/shp2pgsql.c
trunk/postgis_config.h.in
Log:
Update new build system to include iconv detection for shp2pgsql
Modified: trunk/configure.in
===================================================================
--- trunk/configure.in 2008-05-27 03:00:12 UTC (rev 2783)
+++ trunk/configure.in 2008-05-27 14:47:06 UTC (rev 2784)
@@ -54,6 +54,7 @@
done
fi
+
dnl For XSLBASE, make sure the directory exists and that it contains html/docbook.xsl
if test ! -d "$XSLBASE"; then
AC_MSG_ERROR([the docbook stylesheet directory specified using --with-xsldir does not exist])
@@ -67,6 +68,49 @@
dnl
+dnl Detect iconv if it is installed (used for shp2pgsql encoding conversion if available)
+dnl
+
+LIBS_SAVE="$LIBS"
+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
+ dnl Check for iconv includes as part of libc
+ AC_CHECK_LIB([c], [iconv_open], [HAVE_ICONV=1], [])
+ if test "x$HAVE_ICONV" = "x"; then
+ dnl If not found, check for iconv included as part of libiconv
+ AC_CHECK_LIB([iconv], [iconv_open], [HAVE_ICONV=1], [])
+ if test "x$HAVE_ICONV" = "x"; then
+ dnl If not found, check for Win32 iconv (some of them use a lib prefix for functions within the iconv DLLs)
+ AC_CHECK_LIB([iconv], [libiconv_open], [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])
+ else
+ ICONV_LDFLAGS="$LIBS"
+ fi
+ else
+ ICONV_LDFLAGS="$LIBS"
+ fi
+ fi
+else
+ dnl No iconv header was found; issue a warning to the console
+ AC_MSG_WARN([could not find iconv.h header: no support for encoding conversion will be included])
+fi
+
+LIBS="$LIBS_SAVE"
+
+dnl Only define HAVE_ICONV in postgis_config.h if we detect iconv sucessfully
+if test "x$HAVE_ICONV" != "x"; then
+ AC_DEFINE_UNQUOTED([HAVE_ICONV], [$HAVE_ICONV], [Defined if libiconv headers and library are present])
+fi
+
+AC_SUBST([ICONV_LDFLAGS])
+
+
+dnl
dnl Detect the version of PostgreSQL installed on the system
dnl
@@ -295,5 +339,5 @@
dnl AC_MSG_RESULT([SHLIB_LINK: $SHLIB_LINK])
dnl Output the relevant files
-AC_OUTPUT([lwgeom/Makefile lwgeom/sqldefines.h loader/Makefile.pgsql2shp regress/Makefile doc/Makefile])
+AC_OUTPUT([lwgeom/Makefile lwgeom/sqldefines.h loader/Makefile.pgsql2shp loader/Makefile.shp2pgsql regress/Makefile doc/Makefile])
Deleted: trunk/loader/Makefile.shp2pgsql
===================================================================
--- trunk/loader/Makefile.shp2pgsql 2008-05-27 03:00:12 UTC (rev 2783)
+++ trunk/loader/Makefile.shp2pgsql 2008-05-27 14:47:06 UTC (rev 2784)
@@ -1,16 +0,0 @@
-#
-# PostGIS PGXS build system
-#
-PROGRAM=shp2pgsql
-
-# List of objects to build
-OBJS= shpopen.o \
- dbfopen.o \
- getopt.o \
- shp2pgsql.o
-
-# PGXS information
-PG_CONFIG = pg_config
-PGXS := $(shell $(PG_CONFIG) --pgxs)
-include $(PGXS)
-
Added: trunk/loader/Makefile.shp2pgsql.in
===================================================================
--- trunk/loader/Makefile.shp2pgsql.in 2008-05-27 03:00:12 UTC (rev 2783)
+++ trunk/loader/Makefile.shp2pgsql.in 2008-05-27 14:47:06 UTC (rev 2784)
@@ -0,0 +1,19 @@
+#
+# PostGIS PGXS build system
+#
+PROGRAM=shp2pgsql
+
+# List of objects to build
+OBJS= shpopen.o \
+ dbfopen.o \
+ getopt.o \
+ shp2pgsql.o
+
+# Link against libiconv where available
+PG_LIBS=@ICONV_LDFLAGS@
+
+# PGXS information
+PG_CONFIG = pg_config
+PGXS := $(shell $(PG_CONFIG) --pgxs)
+include $(PGXS)
+
Modified: trunk/loader/shp2pgsql.c
===================================================================
--- trunk/loader/shp2pgsql.c 2008-05-27 03:00:12 UTC (rev 2783)
+++ trunk/loader/shp2pgsql.c 2008-05-27 14:47:06 UTC (rev 2784)
@@ -33,7 +33,7 @@
#include <unistd.h>
#include <errno.h>
#include "getopt.h"
-#ifdef HAVE_ICONV_H
+#ifdef HAVE_ICONV
#include <iconv.h>
#endif
@@ -82,7 +82,7 @@
unsigned int wkbtype;
char *shp_file = NULL;
int hwgeom = 0; /* old (hwgeom) mode */
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
char *encoding=NULL;
#endif
int null_policy = insert_null;
@@ -118,7 +118,7 @@
int ParseCmdline(int ARGC, char **ARGV);
void SetPgType(void);
char *dump_ring(Ring *ring);
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
char *utf8(const char *fromcode, char *inputbuf);
#endif
int FindPolygons(SHPObject *obj, Ring ***Out);
@@ -170,7 +170,7 @@
char *ptr, *optr;
int toescape = 0;
size_t size;
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
char *utf8str=NULL;
if ( encoding )
@@ -202,7 +202,7 @@
}
*optr='\0';
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
if ( encoding ) free(str);
#endif
@@ -225,7 +225,7 @@
char *ptr, *optr;
int toescape = 0;
size_t size;
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
char *utf8str=NULL;
if ( encoding )
@@ -258,7 +258,7 @@
}
*optr='\0';
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
if ( encoding ) free(str);
#endif
@@ -412,12 +412,12 @@
fprintf(stderr, "Postgis type: %s[%d]\n", pgtype, pgdims);
}
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
if ( encoding )
{
printf("SET CLIENT_ENCODING TO UTF8;\n");
}
-#endif /* defined USE_ICONV */
+#endif /* defined HAVE_ICONV */
/*
* Drop table if requested
@@ -802,7 +802,7 @@
fprintf(out, " -I Create a GiST index on the geometry column.\n");
fprintf(out, " -S Generate simple geometries instead of MULTI geometries.\n");
fprintf(out, " -w Use wkt format (for postgis-0.x support - drops M - drifts coordinates).\n");
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
fprintf(out, " -W <encoding> Specify the character encoding of Shape's\n");
fprintf(out, " attribute column. (default : \"ASCII\")\n");
#endif
@@ -1376,7 +1376,7 @@
readshape = 0;
break;
case 'W':
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
encoding = optarg;
#else
fprintf(stderr, "WARNING: the -W switch will have no effect. UTF8 disabled at compile time\n");
@@ -1681,7 +1681,7 @@
char name[MAXFIELDNAMELEN];
char name2[MAXFIELDNAMELEN];
DBFFieldType type = -1;
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
char *utf8str;
#endif
@@ -1710,7 +1710,7 @@
widths[j] = field_width;
precisions[j] = field_precision;
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
if ( encoding )
{
utf8str = utf8(encoding, name);
@@ -1778,7 +1778,7 @@
strcat(col_names, ")");
}
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
char *
utf8 (const char *fromcode, char *inputbuf)
@@ -1820,7 +1820,7 @@
return outputbuf;
}
-#endif /* defined USE_ICONV */
+#endif /* defined HAVE_ICONV */
/**********************************************************************
* $Log$
Modified: trunk/postgis_config.h.in
===================================================================
--- trunk/postgis_config.h.in 2008-05-27 03:00:12 UTC (rev 2783)
+++ trunk/postgis_config.h.in 2008-05-27 14:47:06 UTC (rev 2784)
@@ -1,5 +1,8 @@
/* postgis_config.h.in. Generated from configure.in by autoheader. */
+/* Defined if libiconv headers and library are present */
+#undef HAVE_ICONV
+
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
More information about the postgis-commits
mailing list