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])
AC_SUBST([XSLBASE])
+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
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])
#include <unistd.h>
#include <errno.h>
#include "getopt.h"
-#ifdef HAVE_ICONV_H
+#ifdef HAVE_ICONV
#include <iconv.h>
#endif
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;
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);
char *ptr, *optr;
int toescape = 0;
size_t size;
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
char *utf8str=NULL;
if ( encoding )
}
*optr='\0';
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
if ( encoding ) free(str);
#endif
char *ptr, *optr;
int toescape = 0;
size_t size;
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
char *utf8str=NULL;
if ( encoding )
}
*optr='\0';
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
if ( encoding ) free(str);
#endif
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
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
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");
char name[MAXFIELDNAMELEN];
char name2[MAXFIELDNAMELEN];
DBFFieldType type = -1;
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
char *utf8str;
#endif
widths[j] = field_width;
precisions[j] = field_precision;
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
if ( encoding )
{
utf8str = utf8(encoding, name);
strcat(col_names, ")");
}
-#ifdef USE_ICONV
+#ifdef HAVE_ICONV
char *
utf8 (const char *fromcode, char *inputbuf)
return outputbuf;
}
-#endif /* defined USE_ICONV */
+#endif /* defined HAVE_ICONV */
/**********************************************************************
* $Log$