Commit 88f90fa7 authored by Paul Ramsey's avatar Paul Ramsey

First attempt at i18n for the loader/dumper.


git-svn-id: http://svn.osgeo.org/postgis/trunk@6239 b70326c6-7e19-0410-871a-916f4a2858ee
parent 5d996dd6
......@@ -516,6 +516,40 @@ AC_DEFINE_UNQUOTED([POSTGIS_GEOS_VERSION], [$POSTGIS_GEOS_VERSION], [GEOS librar
AC_SUBST([POSTGIS_GEOS_VERSION])
dnl ===========================================================================
dnl Detect gettext
dnl ===========================================================================
GETTEXT_CFLAGS=""
GETTEXT_LDFLAGS=""
AC_ARG_WITH([gettext],
[AS_HELP_STRING([--with-gettext=PATH], [specify a path to non-default gettext installation])],
[GETTEXT_PATH="$withval"], [GETTEXT_PATH=""])
LDFLAGS_SAVE="$LDFLAGS"
CFLAGS_SAVE="$CFLAGS"
if test "x$GETTEXT_PATH" != "x"; then
AC_MSG_RESULT([checking user-specified gettext location: $GETTEXT_PATH])
GETTEXT_CFLAGS="-I$GETTEXT_PATH/include"
GETTEXT_LDFLAGS="-L$GETTEXT_PATH/lib"
LDFLAGS="$GETTEXT_LDFLAGS $LDFLAGS"
CFLAGS="$GETTEXT_CFLAGS $CFLAGS"
fi
AM_GNU_GETTEXT([external], [], [])
if test "x$LIBINTL" = "x"; then
USE_NLS=no
fi
AC_SUBST([GETTEXT_CFLAGS])
AC_SUBST([GETTEXT_LDFLAGS])
LDFLAGS="$LDFLAGS_SAVE"
CFLAGS="$CFLAGS_SAVE"
dnl ===========================================================================
dnl Detect the version of PROJ.4 installed
dnl ===========================================================================
......
......@@ -23,7 +23,7 @@ include $(PGXS)
# Set CFLAGS afer PGXS, otherwise it will get overwritten with the PGXS
# version which is not what we want.
CC=@CC@
CFLAGS=@CFLAGS@ @PICFLAGS@ @WARNFLAGS@
CFLAGS=@CFLAGS@ @PICFLAGS@ @WARNFLAGS@
# Filenames with extension as determined by the OS
PGSQL2SHP-CLI=pgsql2shp@EXESUFFIX@
......@@ -41,12 +41,26 @@ ICONV_CFLAGS=@ICONV_CFLAGS@
# liblwgeom
LIBLWGEOM=../liblwgeom/liblwgeom.a
LIBICONV=@LIBICONV@
LTLIBICONV=@LTLIBICONV@
# GTK includes and libraries
GTK_CFLAGS = @GTK_CFLAGS@ @IGE_MAC_CFLAGS@
GTK_LIBS = @GTK_LIBS@ @IGE_MAC_LIBS@
GTK_WIN32_FLAGS = @GTK_WIN32_FLAGS@
GTK_WIN32_RES = @GTK_WIN32_RES@
# GetText includes and libraries
GETTEXT_CFLAGS = @GETTEXT_CFLAGS@
GETTEXT_LDFLAGS = @GETTEXT_LDFLAGS@ @LIBINTL@
nls_build = @USE_NLS@
ifdef nls_build
localedir = $(shell $(PG_CONFIG) --localedir)
CFLAGS += -DUSE_NLS
CFLAGS += -DLOCALEDIR=\"$(localedir)\"
LANGUAGES = fr
endif
# If REGRESS=1 passed as a parameter, change the default install paths
# so that no prefix is included. This allows us to relocate to a temporary
# directory for regression testing.
......@@ -73,7 +87,7 @@ $(LIBLWGEOM):
make -C ../liblwgeom
shp2pgsql-core.o: shp2pgsql-core.c
$(CC) $(CFLAGS) $(ICONV_CFLAGS) -c $<
$(CC) $(CFLAGS) $(GETTEXT_CFLAGS) $(ICONV_CFLAGS) -c $<
pgsql2shp-core.o: pgsql2shp-core.c
$(CC) $(CFLAGS) $(ICONV_CFLAGS) $(PGSQL_FE_CPPFLAGS) -c $<
......@@ -82,19 +96,19 @@ pgsql2shp-cli.o: pgsql2shp-cli.c
$(CC) $(CFLAGS) $(ICONV_CFLAGS) $(PGSQL_FE_CPPFLAGS) -c $<
$(PGSQL2SHP-CLI): shpopen.o dbfopen.o getopt.o pgsql2shp-core.o shpcommon.o pgsql2shp-cli.o safileio.o $(LIBLWGEOM)
$(CC) $(CFLAGS) $^ $(PGSQL_FE_CPPFLAGS) $(ICONV_LDFLAGS) $(PGSQL_FE_LDFLAGS) -lm -o $@
$(CC) $(CFLAGS) $^ $(ICONV_LDFLAGS) $(PGSQL_FE_LDFLAGS) -lm -o $@
$(SHP2PGSQL-CLI): shpopen.o dbfopen.o getopt.o shp2pgsql-core.o shpcommon.o shp2pgsql-cli.o safileio.o $(LIBLWGEOM)
$(CC) $(CFLAGS) $^ -o $@ $(ICONV_LDFLAGS) -lm
$(CC) $(CFLAGS) $^ -o $@ $(GETTEXT_LDFLAGS) $(ICONV_LDFLAGS) -lm
structure.o: structure.c
$(CC) $(CFLAGS) $(GTK_CFLAGS) -o $@ -c structure.c
shp2pgsql-gui.o: shp2pgsql-gui.c
$(CC) $(CFLAGS) $(PGSQL_FE_CPPFLAGS) $(GTK_CFLAGS) -o $@ -c shp2pgsql-gui.c
$(CC) $(CFLAGS) $(GTK_CFLAGS) $(PGSQL_FE_CPPFLAGS) -o $@ -c shp2pgsql-gui.c
$(SHP2PGSQL-GUI): shpopen.o dbfopen.o shp2pgsql-core.o shpcommon.o shp2pgsql-gui.o getopt.o structure.o safileio.o $(LIBLWGEOM) $(GTK_WIN32_RES)
$(CC) $(CFLAGS) $(GTK_WIN32_FLAGS) $^ -o $@ $(GTK_LIBS) $(ICONV_LDFLAGS) $(PGSQL_FE_LDFLAGS) -lm
$(CC) $(CFLAGS) $(GTK_WIN32_FLAGS) $^ -o $@ $(GTK_LIBS) $(ICONV_LDFLAGS) $(PGSQL_FE_LDFLAGS) $(GETTEXT_LDFLAGS) -lm
installdir:
@mkdir -p $(DESTDIR)$(bindir)
......@@ -116,3 +130,23 @@ check:
clean:
@rm -f *.o $(SHP2PGSQL-CLI) $(PGSQL2SHP-CLI) $(GTK_WIN32_RES)
#
# Internationalization targets. These are going to need some work and
# love to land the files in the right places in all platforms.
#
pot:
xgettext -k_ shp2pgsql-core.c shp2pgsql-cli.c shp2pgsql-gui.c -o po/shp2pgsql.pot
xgettext -k_ pgsql2shp-core.c pgsql2shp-cli.c -o po/pgsql2shp.pot
mo:
for lang in $(LANGUAGES); do \
msgfmt -o po/shp2pgsql-$$lang.mo po/shp2pgsql.$$lang ; \
done
install-mo:
ifneq (,$(LANGUAGES))
for lang in $(LANGUAGES); do \
$(INSTALL_DATA) po/shp2pgsql-$$lang.mo '$(localedir)'/$$lang/LC_MESSAGES/shp2pgsql.mo || exit 1; \
done
endif
Translating these Applications
------------------------------
You will need the gettext utilities to work with the translation files.
Ensure you have the following utilities available:
xgettext
msgfmt
First, update the translation template ("pot") file
make pot
This will create fresh template files in "po/", "shp2pgsql.pot" and
"pgsql2shp.pot"
Second, copy a template to a translation file. For example,
for a French translation:
cp shp2pgsql.pot shp2pgsql.fr
cp pgsql2shp.pot pgsql2shp.fr
Finally, prepare your translations. There is header information in the
translation file to identify yourself as the translator -- fill it in.
Important, set the CHARSET value in the header to the text character set
you are using for your text file. We'd prefer you use UTF-8, if you can.
When your translation file is complete, commit your changes, or
mail it to the postgis-devel list, and we'll commit it for you.
This directory contains the loader and dumper utility programs.
The loader can convert shape files to an SQL dump suitable for loading into a PostGIS enabled
PostgreSQL database server. The dumper does the opposite, creates a shape file out of an PostGIS
table or arbitrary query.
The loader can convert shape files to an SQL dump suitable for loading into a
PostGIS enabled PostgreSQL database server. The dumper does the opposite,
creates a shape file out of an PostGIS table or arbitrary query.
To compile the program from source, simply run "make" in the source directory. Then copy the
binary into your command search path (or wherever you like).
To compile the program from source, simply run "make" in the source directory.
Then copy the binary into your command search path (or wherever you like).
For usage information, simply run the programs without any arguments, that will display a
help screen, and look into the ../doc/man/ directory, there are manpages ready for copying
into the manual search path on unixoid systems.
For usage information, simply run the programs without any arguments, that
will display a help screen, and look into the ../doc/man/ directory,
there are manpages ready for copying into the manual search path on
unixoid systems.
......@@ -19,31 +19,33 @@
static void
usage()
{
printf("RCSID: %s RELEASE: %s\n", RCSID, POSTGIS_VERSION);
printf("USAGE: shp2pgsql [<options>] <shapefile> [<schema>.]<table>\n");
printf("OPTIONS:\n");
printf(" -s <srid> Set the SRID field. Defaults to -1.\n");
printf(" (-d|a|c|p) These are mutually exclusive options:\n");
printf(" -d Drops the table, then recreates it and populates\n");
printf(" it with current shape file data.\n");
printf(" -a Appends shape file into current table, must be\n");
printf(" exactly the same table schema.\n");
printf(" -c Creates a new table and populates it, this is the\n");
printf(" default if you do not specify any options.\n");
printf(" -p Prepare mode, only creates the table.\n");
printf(" -g <geocolumn> Specify the name of the geometry/geography column\n");
printf(" (mostly useful in append mode).\n");
printf(" -D Use postgresql dump format (defaults to SQL insert statments.\n");
printf(" -G Use geography type (requires lon/lat data).\n");
printf(" -k Keep postgresql identifiers case.\n");
printf(" -i Use int4 type for all integer dbf fields.\n");
printf(" -I Create a spatial index on the geocolumn.\n");
printf(" -S Generate simple geometries instead of MULTI geometries.\n");
printf(" -W <encoding> Specify the character encoding of Shape's\n");
printf(" attribute column. (default : \""ENCODING_DEFAULT"\")\n");
printf(" -N <policy> NULL geometries handling policy (insert*,skip,abort)\n");
printf(" -n Only import DBF file.\n");
printf(" -? Display this help screen.\n");
printf("RELEASE: %s (r%s)\n", POSTGIS_VERSION, RCSID);
printf(_(
"USAGE: shp2pgsql [<options>] <shapefile> [<schema>.]<table>\n"
"OPTIONS:\n"
" -s <srid> Set the SRID field. Defaults to -1.\n"
" (-d|a|c|p) These are mutually exclusive options:\n"
" -d Drops the table, then recreates it and populates\n"
" it with current shape file data.\n"
" -a Appends shape file into current table, must be\n"
" exactly the same table schema.\n"
" -c Creates a new table and populates it, this is the\n"
" default if you do not specify any options.\n"
" -p Prepare mode, only creates the table.\n"
" -g <geocolumn> Specify the name of the geometry/geography column\n"
" (mostly useful in append mode).\n"
" -D Use postgresql dump format (defaults to SQL insert statments.\n"
" -G Use geography type (requires lon/lat data).\n"
" -k Keep postgresql identifiers case.\n"
" -i Use int4 type for all integer dbf fields.\n"
" -I Create a spatial index on the geocolumn.\n"
" -S Generate simple geometries instead of MULTI geometries.\n"
" -W <encoding> Specify the character encoding of Shape's\n"
" attribute column. (default: \"UTF-8\")\n"
" -N <policy> NULL geometries handling policy (insert*,skip,abort)\n"
" -n Only import DBF file.\n"
" -? Display this help screen.\n"
));
}
......@@ -56,6 +58,11 @@ main (int argc, char **argv)
char c;
int ret, i;
#ifdef USE_NLS
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
#endif
/* If no options are specified, display usage */
if (argc == 1)
......
......@@ -14,6 +14,7 @@
#include "shp2pgsql-core.h"
/* Internal ring/point structures */
typedef struct struct_point
{
......@@ -385,7 +386,7 @@ GenerateLineStringGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometr
if (state->config->simple_geometries == 1 && obj->nParts > 1)
{
snprintf(state->message, SHPLOADERMSGLEN, "We have a Multilinestring with %d parts, can't use -S switch!", obj->nParts);
snprintf(state->message, SHPLOADERMSGLEN, _("We have a Multilinestring with %d parts, can't use -S switch!"), obj->nParts);
return SHPLOADERERR;
}
......@@ -725,7 +726,7 @@ GeneratePolygonGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry)
if (state->config->simple_geometries == 1 && polygon_total != 1) /* We write Non-MULTI geometries, but have several parts: */
{
snprintf(state->message, SHPLOADERMSGLEN, "We have a Multipolygon with %d parts, can't use -S switch!", polygon_total);
snprintf(state->message, SHPLOADERMSGLEN, _("We have a Multipolygon with %d parts, can't use -S switch!"), polygon_total);
return SHPLOADERERR;
}
......@@ -943,7 +944,7 @@ ShpLoaderOpenShape(SHPLOADERSTATE *state)
if (state->hSHPHandle == NULL)
{
snprintf(state->message, SHPLOADERMSGLEN, "%s: shape (.shp) or index files (.shx) can not be opened, will just import attribute data.", state->config->shp_file);
snprintf(state->message, SHPLOADERMSGLEN, _("%s: shape (.shp) or index files (.shx) can not be opened, will just import attribute data."), state->config->shp_file);
state->config->readshape = 0;
ret = SHPLOADERWARN;
......@@ -954,7 +955,7 @@ ShpLoaderOpenShape(SHPLOADERSTATE *state)
state->hDBFHandle = DBFOpen(state->config->shp_file, "rb");
if ((state->hSHPHandle == NULL && state->config->readshape == 1) || state->hDBFHandle == NULL)
{
snprintf(state->message, SHPLOADERMSGLEN, "%s: dbf file (.dbf) can not be opened.", state->config->shp_file);
snprintf(state->message, SHPLOADERMSGLEN, _("%s: dbf file (.dbf) can not be opened."), state->config->shp_file);
return SHPLOADERERR;
}
......@@ -974,13 +975,13 @@ ShpLoaderOpenShape(SHPLOADERSTATE *state)
if (!obj)
{
snprintf(state->message, SHPLOADERMSGLEN, "Error reading shape object %d", j);
snprintf(state->message, SHPLOADERMSGLEN, _("Error reading shape object %d"), j);
return SHPLOADERERR;
}
if (obj->nVertices == 0)
{
snprintf(state->message, SHPLOADERMSGLEN, "Empty geometries found, aborted.");
snprintf(state->message, SHPLOADERMSGLEN, _("Empty geometries found, aborted.)"));
return SHPLOADERERR;
}
......@@ -1140,7 +1141,7 @@ ShpLoaderOpenShape(SHPLOADERSTATE *state)
state->wkbtype = COLLECTIONTYPE | WKBZOFFSET | WKBMOFFSET;
state->pgdims = 4;
snprintf(state->message, SHPLOADERMSGLEN, "Unknown geometry type: %d\n", state->shpfiletype);
snprintf(state->message, SHPLOADERMSGLEN, _("Unknown geometry type: %d\n"), state->shpfiletype);
return SHPLOADERERR;
break;
......@@ -1189,18 +1190,18 @@ ShpLoaderOpenShape(SHPLOADERSTATE *state)
if (state->config->encoding)
{
static char *encoding_msg = "Try \"LATIN1\" (Western European), or one of the values described at http://www.postgresql.org/docs/current/static/multibyte.html.";
char *encoding_msg = _("Try \"LATIN1\" (Western European), or one of the values described at http://www.postgresql.org/docs/current/static/multibyte.html.");
int rv = utf8(state->config->encoding, name, &utf8str);
if (rv != UTF8_GOOD_RESULT)
{
if ( rv == UTF8_BAD_RESULT )
snprintf(state->message, SHPLOADERMSGLEN, "Unable to convert field name \"%s\" to UTF-8 (iconv reports \"%s\"). Current encoding is \"%s\". %s", utf8str, strerror(errno), state->config->encoding, encoding_msg);
snprintf(state->message, SHPLOADERMSGLEN, _("Unable to convert field name \"%s\" to UTF-8 (iconv reports \"%s\"). Current encoding is \"%s\". %s"), utf8str, strerror(errno), state->config->encoding, encoding_msg);
else if ( rv == UTF8_NO_RESULT )
snprintf(state->message, SHPLOADERMSGLEN, "Unable to convert field name to UTF-8 (iconv reports \"%s\"). Current encoding is \"%s\". %s", strerror(errno), state->config->encoding, encoding_msg);
snprintf(state->message, SHPLOADERMSGLEN, _("Unable to convert field name to UTF-8 (iconv reports \"%s\"). Current encoding is \"%s\". %s"), strerror(errno), state->config->encoding, encoding_msg);
else
snprintf(state->message, SHPLOADERMSGLEN, "Unexpected return value from utf8()");
snprintf(state->message, SHPLOADERMSGLEN, _("Unexpected return value from utf8()"));
if ( rv == UTF8_BAD_RESULT )
free(utf8str);
......@@ -1410,7 +1411,7 @@ ShpLoaderGetSQLHeader(SHPLOADERSTATE *state, char **strheader)
break;
default:
snprintf(state->message, SHPLOADERMSGLEN, "Invalid type %x in DBF file", state->types[j]);
snprintf(state->message, SHPLOADERMSGLEN, _("Invalid type %x in DBF file"), state->types[j]);
stringbuffer_destroy(sb);
return SHPLOADERERR;
}
......@@ -1427,7 +1428,7 @@ ShpLoaderGetSQLHeader(SHPLOADERSTATE *state, char **strheader)
dimschar = "";
if (state->config->sr_id != -1 && state->config->sr_id != 4326)
{
snprintf(state->message, SHPLOADERMSGLEN, "Invalid SRID for geography type: %x", state->config->sr_id);
snprintf(state->message, SHPLOADERMSGLEN, _("Invalid SRID for geography type: %x"), state->config->sr_id);
stringbuffer_destroy(sb);
return SHPLOADERERR;
}
......@@ -1495,7 +1496,7 @@ ShpLoaderGetSQLCopyStatement(SHPLOADERSTATE *state, char **strheader)
else
{
/* Flag an error as something has gone horribly wrong */
snprintf(state->message, SHPLOADERMSGLEN, "Internal error: attempt to generate a COPY statement for data that hasn't been requested in COPY format");
snprintf(state->message, SHPLOADERMSGLEN, _("Internal error: attempt to generate a COPY statement for data that hasn't been requested in COPY format"));
return SHPLOADERERR;
}
......@@ -1542,7 +1543,7 @@ ShpLoaderGenerateSQLRowStatement(SHPLOADERSTATE *state, int item, char **strreco
obj = SHPReadObject(state->hSHPHandle, item);
if (!obj)
{
snprintf(state->message, SHPLOADERMSGLEN, "Error reading shape object %d", item);
snprintf(state->message, SHPLOADERMSGLEN, _("Error reading shape object %d"), item);
return SHPLOADERERR;
}
......@@ -1619,7 +1620,7 @@ ShpLoaderGenerateSQLRowStatement(SHPLOADERSTATE *state, int item, char **strreco
break;
default:
snprintf(state->message, SHPLOADERMSGLEN, "Error: field %d has invalid or unknown field type (%d)", i, state->types[i]);
snprintf(state->message, SHPLOADERMSGLEN, _("Error: field %d has invalid or unknown field type (%d)"), i, state->types[i]);
SHPDestroyObject(obj);
stringbuffer_destroy(sbwarn);
......@@ -1630,18 +1631,18 @@ ShpLoaderGenerateSQLRowStatement(SHPLOADERSTATE *state, int item, char **strreco
if (state->config->encoding)
{
static char *encoding_msg = "Try \"LATIN1\" (Western European), or one of the values described at http://www.postgresql.org/docs/current/static/multibyte.html.";
char *encoding_msg = _("Try \"LATIN1\" (Western European), or one of the values described at http://www.postgresql.org/docs/current/static/multibyte.html.");
int rv = utf8(state->config->encoding, val, &utf8str);
if (rv != UTF8_GOOD_RESULT)
{
if ( rv == UTF8_BAD_RESULT )
snprintf(state->message, SHPLOADERMSGLEN, "Unable to convert data value \"%s\" to UTF-8 (iconv reports \"%s\"). Current encoding is \"%s\". %s", utf8str, strerror(errno), state->config->encoding, encoding_msg);
snprintf(state->message, SHPLOADERMSGLEN, _("Unable to convert data value \"%s\" to UTF-8 (iconv reports \"%s\"). Current encoding is \"%s\". %s"), utf8str, strerror(errno), state->config->encoding, encoding_msg);
else if ( rv == UTF8_NO_RESULT )
snprintf(state->message, SHPLOADERMSGLEN, "Unable to convert data value to UTF-8 (iconv reports \"%s\"). Current encoding is \"%s\". %s", strerror(errno), state->config->encoding, encoding_msg);
snprintf(state->message, SHPLOADERMSGLEN, _("Unable to convert data value to UTF-8 (iconv reports \"%s\"). Current encoding is \"%s\". %s"), strerror(errno), state->config->encoding, encoding_msg);
else
snprintf(state->message, SHPLOADERMSGLEN, "Unexpected return value from utf8()");
snprintf(state->message, SHPLOADERMSGLEN, _("Unexpected return value from utf8()"));
if ( rv == UTF8_BAD_RESULT )
free(utf8str);
......@@ -1745,7 +1746,7 @@ ShpLoaderGenerateSQLRowStatement(SHPLOADERSTATE *state, int item, char **strreco
break;
default:
snprintf(state->message, SHPLOADERMSGLEN, "Shape type is NOT SUPPORTED, type id = %d", obj->nSHPType);
snprintf(state->message, SHPLOADERMSGLEN, _("Shape type is not supported, type id = %d"), obj->nSHPType);
SHPDestroyObject(obj);
stringbuffer_destroy(sbwarn);
......
......@@ -12,6 +12,17 @@
*
**********************************************************************/
/* For internationalization */
#ifdef USE_NLS
#include <libintl.h>
#include <locale.h>
#define _(String) gettext(String)
#define PACKAGE "shp2pgsql"
#else
#define _(String) String
#endif
/* Standard headers */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
......@@ -26,30 +37,27 @@
#include "shpcommon.h"
#include "getopt.h"
#include "../liblwgeom/liblwgeom.h"
#define RCSID "$Id$"
/*
* Loader policy constants
*/
/* Loader policy constants */
#define POLICY_NULL_ABORT 0x0
#define POLICY_NULL_INSERT 0x1
#define POLICY_NULL_SKIP 0x2
/*
* Error message handling
*/
/* Error message handling */
#define SHPLOADERMSGLEN 1024
/* Error status codes */
#define SHPLOADEROK -1
#define SHPLOADERERR 0
#define SHPLOADERWARN 1
/* Record status codes */
#define SHPLOADERRECDELETED 2
#define SHPLOADERRECISNULL 3
......@@ -74,7 +82,6 @@
/*
* Structure to hold the loader configuration options
*/
typedef struct shp_loader_config
{
/* load mode: c = create, d = delete, a = append, p = prepare */
......@@ -131,7 +138,6 @@ typedef struct shp_loader_config
/*
* Structure to holder the current loader state
*/
typedef struct shp_loader_state
{
/* Configuration for this state */
......
This diff is collapsed.
This diff is collapsed.
# iconv.m4 serial AM6 (gettext-0.17)
dnl Copyright (C) 2000-2002, 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
[
dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
dnl accordingly.
AC_LIB_LINKFLAGS_BODY([iconv])
])
AC_DEFUN([AM_ICONV_LINK],
[
dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
dnl those with the standalone portable GNU libiconv installed).
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
dnl accordingly.
AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
dnl Add $INCICONV to CPPFLAGS before performing the following checks,
dnl because if the user has installed libiconv and not disabled its use
dnl via --without-libiconv-prefix, he wants to use it. The first
dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
am_save_CPPFLAGS="$CPPFLAGS"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
AC_CACHE_CHECK([for iconv], am_cv_func_iconv, [
am_cv_func_iconv="no, consider installing GNU libiconv"
am_cv_lib_iconv=no
AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
am_cv_func_iconv=yes)
if test "$am_cv_func_iconv" != yes; then
am_save_LIBS="$LIBS"
LIBS="$LIBS $LIBICONV"
AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
am_cv_lib_iconv=yes
am_cv_func_iconv=yes)
LIBS="$am_save_LIBS"
fi
])
if test "$am_cv_func_iconv" = yes; then
AC_CACHE_CHECK([for working iconv], am_cv_func_iconv_works, [
dnl This tests against bugs in AIX 5.1 and HP-UX 11.11.
am_save_LIBS="$LIBS"
if test $am_cv_lib_iconv = yes; then
LIBS="$LIBS $LIBICONV"
fi
AC_TRY_RUN([
#include <iconv.h>
#include <string.h>
int main ()
{
/* Test against AIX 5.1 bug: Failures are not distinguishable from successful
returns. */
{
iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
if (cd_utf8_to_88591 != (iconv_t)(-1))
{
static const char input[] = "\342\202\254"; /* EURO SIGN */
char buf[10];
const char *inptr = input;
size_t inbytesleft = strlen (input);
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
size_t res = iconv (cd_utf8_to_88591,
(char **) &inptr, &inbytesleft,
&outptr, &outbytesleft);
if (res == 0)
return 1;
}
}
#if 0 /* This bug could be worked around by the caller. */
/* Test against HP-UX 11.11 bug: Positive return value instead of 0. */
{
iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
if (cd_88591_to_utf8 != (iconv_t)(-1))
{
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
char buf[50];
const char *inptr = input;
size_t inbytesleft = strlen (input);
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
size_t res = iconv (cd_88591_to_utf8,
(char **) &inptr, &inbytesleft,
&outptr, &outbytesleft);
if ((int)res > 0)
return 1;
}
}
#endif
/* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
provided. */
if (/* Try standardized names. */
iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
/* Try IRIX, OSF/1 names. */
&& iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
/* Try AIX names. */
&& iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
/* Try HP-UX names. */
&& iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
return 1;
return 0;
}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no],
[case "$host_os" in
aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
*) am_cv_func_iconv_works="guessing yes" ;;
esac])
LIBS="$am_save_LIBS"
])
case "$am_cv_func_iconv_works" in
*no) am_func_iconv=no am_cv_lib_iconv=no ;;
*) am_func_iconv=yes ;;
esac
else
am_func_iconv=no am_cv_lib_iconv=no
fi
if test "$am_func_iconv" = yes; then
AC_DEFINE(HAVE_ICONV, 1,
[Define if you have the iconv() function and it works.])
fi
if test "$am_cv_lib_iconv" = yes; then
AC_MSG_CHECKING([how to link with libiconv])
AC_MSG_RESULT([$LIBICONV])
else
dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
dnl either.
CPPFLAGS="$am_save_CPPFLAGS"
LIBICONV=
LTLIBICONV=
fi
AC_SUBST(LIBICONV)
AC_SUBST(LTLIBICONV)
])
AC_DEFUN([AM_ICONV],
[
AM_ICONV_LINK
if test "$am_cv_func_iconv" = yes; then
AC_MSG_CHECKING([for iconv declaration])
AC_CACHE_VAL(am_cv_proto_iconv, [
AC_TRY_COMPILE([
#include <stdlib.h>
#include <iconv.h>
extern
#ifdef __cplusplus
"C"
#endif
#if defined(__STDC__) || defined(__cplusplus)
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
#else
size_t iconv();
#endif
], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
AC_MSG_RESULT([$]{ac_t:-
}[$]am_cv_proto_iconv)
AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
[Define as const if the declaration of iconv() needs const.])
fi
])
This diff is collapsed.
# intldir.m4 serial 1 (gettext-0.16)
dnl Copyright (C) 2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl
dnl This file can can be used in projects which are not available under
dnl the GNU General Public License or the GNU Library General Public
dnl License but which still want to provide support for the GNU gettext
dnl functionality.
dnl Please note that the actual code of the GNU gettext library is covered
dnl by the GNU Library General Public License, and the rest of the GNU
dnl gettext package package is covered by the GNU General Public License.
dnl They are *not* in the public domain.
AC_PREREQ(2.52)
dnl Tells the AM_GNU_GETTEXT macro to consider an intl/ directory.
AC_DEFUN([AM_GNU_GETTEXT_INTL_SUBDIR], [])
# intlmacosx.m4 serial 1 (gettext-0.17)
dnl Copyright (C) 2004-2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl
dnl This file can can be used in projects which are not available under
dnl the GNU General Public License or the GNU Library General Public
dnl License but which still want to provide support for the GNU gettext
dnl functionality.
dnl Please note that the actual code of the GNU gettext library is covered
dnl by the GNU Library General Public License, and the rest of the GNU
dnl gettext package package is covered by the GNU General Public License.
dnl They are *not* in the public domain.
dnl Checks for special options needed on MacOS X.
dnl Defines INTL_MACOSX_LIBS.
AC_DEFUN([gt_INTL_MACOSX],
[
dnl Check for API introduced in MacOS X 10.2.
AC_CACHE_CHECK([for CFPreferencesCopyAppValue],
gt_cv_func_CFPreferencesCopyAppValue,
[gt_save_LIBS="$LIBS"
LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
AC_TRY_LINK([#include <CoreFoundation/CFPreferences.h>],
[CFPreferencesCopyAppValue(NULL, NULL)],
[gt_cv_func_CFPreferencesCopyAppValue=yes],
[gt_cv_func_CFPreferencesCopyAppValue=no])
LIBS="$gt_save_LIBS"])
if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then
AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], 1,
[Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.])
fi
dnl Check for API introduced in MacOS X 10.3.
AC_CACHE_CHECK([for CFLocaleCopyCurrent], gt_cv_func_CFLocaleCopyCurrent,
[gt_save_LIBS="$LIBS"
LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
AC_TRY_LINK([#include <CoreFoundation/CFLocale.h>], [CFLocaleCopyCurrent();],
[gt_cv_func_CFLocaleCopyCurrent=yes],
[gt_cv_func_CFLocaleCopyCurrent=no])
LIBS="$gt_save_LIBS"])
if test $gt_cv_func_CFLocaleCopyCurrent = yes; then
AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], 1,
[Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.])
fi
INTL_MACOSX_LIBS=
if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then
INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation"
fi
AC_SUBST([INTL_MACOSX_LIBS])
])
This diff is collapsed.
# nls.m4 serial 3 (gettext-0.15)
dnl Copyright (C) 1995-2003, 2005-2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,