Support system-dependent aliases.
diff --git a/ChangeLog b/ChangeLog
index f52ddbb..c66756e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,49 @@
 2008-04-06  Bruno Haible  <bruno@clisp.org>
 
+	Support all possible nl_langinfo(CODESET) results on the respective
+	platforms, according to libcharset/lib/config.charset.
+	* lib/encodings.def: Add DEFALIAS statements, conditional on
+	USE_AIX_ALIASES, USE_HPUX_ALIASES, USE_OSF1_ALIASES,
+	USE_SOLARIS_ALIASES.
+	* lib/encodings_aix.def: Add DEFALIAS statements, conditional on
+	USE_AIX_ALIASES.
+	* lib/encodings_osf1.def: Add DEFALIAS statements, conditional on
+	USE_OSF1_ALIASES.
+	* lib/genaliases.c (emit_alias): New function, extracted from
+	emit_encoding.
+	(emit_encoding): Use it.
+	(main): Define DEFALIAS.
+	* lib/genaliases2.c (counter): New variable, extracted from
+	emit_encoding.
+	(emit_alias): New function, extracted from emit_encoding.
+	(emit_encoding): Use it.
+	(main): Define DEFALIAS.
+	* lib/genflags.c (main): Define DEFALIAS.
+	* lib/iconv.c (all_encodings): Define DEFALIAS.
+	Include the system dependent variant of aliases.h on the appropriate
+	systems.
+	(all_canonical): Include the system dependent variant of canonical.h,
+	canonical_aix.h, canonical_osf1.h, canonical_local.h on the appropriate
+	systems.
+	* lib/aliases2.h: Include the system dependent variant of
+	aliases_aix.h or aliases_osf1.h on the appropriate systems.
+	* lib/Makefile.in (iconv.lo): Depend on aliases_sysaix.h,
+	aliases_syshpux.h, aliases_sysosf1.h, aliases_syssolaris.h,
+	aliases_aix_sysaix.h, lib/aliases_osf1_sysosf1.h, and also
+	aliases_extra.h, translit.h.
+	* Makefile.devel (all): Depend on lib/aliases_sysaix.h,
+	lib/aliases_syshpux.h, lib/aliases_sysosf1.h, lib/aliases_syssolaris.h,
+	lib/aliases_aix_sysaix.h, lib/aliases_osf1_sysosf1.h.
+	(lib/aliases_sysaix.h, lib/aliases_syshpux.h, lib/aliases_sysosf1.h,
+	lib/aliases_syssolaris.h): New rules.
+	(lib/aliases_aix_sysaix.h): New rule.
+	(lib/aliases_osf1_sysosf1.h): New rule.
+	* autogen.sh: Also remove lib/aliases_sysaix.h, lib/aliases_syshpux.h,
+	lib/aliases_sysosf1.h, lib/aliases_syssolaris.h,
+	lib/aliases_aix_sysaix.h, lib/aliases_osf1_sysosf1.h.
+
+2008-04-06  Bruno Haible  <bruno@clisp.org>
+
 	* build-aux/config.libpath: Remove file, brought in by gnulib-tool.
 	* build-aux/config.rpath: Remove file, brought in by gnulib-tool.
 
diff --git a/Makefile.devel b/Makefile.devel
index 479efee..2b9b066 100644
--- a/Makefile.devel
+++ b/Makefile.devel
@@ -16,7 +16,16 @@
 RM = rm -f
 
 
-all : configures config.h.in srclib/Makefile.gnulib srclib/Makefile.in include/iconv.h.build.in lib/aliases.h lib/aliases_aix.h lib/aliases_osf1.h lib/aliases_dos.h lib/aliases_extra.h lib/flags.h lib/translit.h man/iconv.1.html man/iconv.3.html man/iconv_close.3.html man/iconv_open.3.html force
+all : configures config.h.in \
+      srclib/Makefile.gnulib srclib/Makefile.in \
+      include/iconv.h.build.in \
+      lib/aliases.h lib/aliases_sysaix.h lib/aliases_syshpux.h lib/aliases_sysosf1.h lib/aliases_syssolaris.h \
+      lib/aliases_aix.h lib/aliases_aix_sysaix.h \
+      lib/aliases_osf1.h lib/aliases_osf1_sysosf1.h \
+      lib/aliases_dos.h \
+      lib/aliases_extra.h \
+      lib/flags.h lib/translit.h \
+      man/iconv.1.html man/iconv.3.html man/iconv_close.3.html man/iconv_open.3.html force
 	cd libcharset && $(MAKE) -f Makefile.devel all
 
 
@@ -98,16 +107,66 @@
 	sh canonical_local.sh > lib/canonical_local.h
 	$(RM) tmp.h canonical.sh canonical_local.sh
 
+lib/aliases_sysaix.h lib/canonical_sysaix.h lib/canonical_local_sysaix.h : lib/encodings.def lib/encodings_local.def lib/genaliases.c
+	$(CC) $(CFLAGS) -DUSE_AIX_ALIASES lib/genaliases.c -o genaliases
+	./genaliases > lib/aliases_sysaix.gperf 3> canonical.sh 4> canonical_local.sh
+	$(RM) genaliases
+	$(GPERF) -m 10 lib/aliases_sysaix.gperf > tmp.h
+	$(CP) tmp.h lib/aliases_sysaix.h
+	sh canonical.sh > lib/canonical_sysaix.h
+	sh canonical_local.sh > lib/canonical_local_sysaix.h
+	$(RM) tmp.h canonical.sh canonical_local.sh
+
+lib/aliases_syshpux.h lib/canonical_syshpux.h lib/canonical_local_syshpux.h : lib/encodings.def lib/encodings_local.def lib/genaliases.c
+	$(CC) $(CFLAGS) -DUSE_HPUX_ALIASES lib/genaliases.c -o genaliases
+	./genaliases > lib/aliases_syshpux.gperf 3> canonical.sh 4> canonical_local.sh
+	$(RM) genaliases
+	$(GPERF) -m 10 lib/aliases_syshpux.gperf > tmp.h
+	$(CP) tmp.h lib/aliases_syshpux.h
+	sh canonical.sh > lib/canonical_syshpux.h
+	sh canonical_local.sh > lib/canonical_local_syshpux.h
+	$(RM) tmp.h canonical.sh canonical_local.sh
+
+lib/aliases_sysosf1.h lib/canonical_sysosf1.h lib/canonical_local_sysosf1.h : lib/encodings.def lib/encodings_local.def lib/genaliases.c
+	$(CC) $(CFLAGS) -DUSE_OSF1_ALIASES lib/genaliases.c -o genaliases
+	./genaliases > lib/aliases_sysosf1.gperf 3> canonical.sh 4> canonical_local.sh
+	$(RM) genaliases
+	$(GPERF) -m 10 lib/aliases_sysosf1.gperf > tmp.h
+	$(CP) tmp.h lib/aliases_sysosf1.h
+	sh canonical.sh > lib/canonical_sysosf1.h
+	sh canonical_local.sh > lib/canonical_local_sysosf1.h
+	$(RM) tmp.h canonical.sh canonical_local.sh
+
+lib/aliases_syssolaris.h lib/canonical_syssolaris.h lib/canonical_local_syssolaris.h : lib/encodings.def lib/encodings_local.def lib/genaliases.c
+	$(CC) $(CFLAGS) -DUSE_SOLARIS_ALIASES lib/genaliases.c -o genaliases
+	./genaliases > lib/aliases_syssolaris.gperf 3> canonical.sh 4> canonical_local.sh
+	$(RM) genaliases
+	$(GPERF) -m 10 lib/aliases_syssolaris.gperf > tmp.h
+	$(CP) tmp.h lib/aliases_syssolaris.h
+	sh canonical.sh > lib/canonical_syssolaris.h
+	sh canonical_local.sh > lib/canonical_local_syssolaris.h
+	$(RM) tmp.h canonical.sh canonical_local.sh
+
 lib/aliases_aix.h lib/canonical_aix.h : lib/encodings_aix.def lib/genaliases2.c
 	$(CC) $(CFLAGS) -DUSE_AIX lib/genaliases2.c -o genaliases
 	./genaliases aix > lib/aliases_aix.h 3> lib/canonical_aix.h
 	$(RM) genaliases
 
+lib/aliases_aix_sysaix.h lib/canonical_aix_sysaix.h : lib/encodings_aix.def lib/genaliases2.c
+	$(CC) $(CFLAGS) -DUSE_AIX -DUSE_AIX_ALIASES lib/genaliases2.c -o genaliases
+	./genaliases aix > lib/aliases_aix_sysaix.h 3> lib/canonical_aix_sysaix.h
+	$(RM) genaliases
+
 lib/aliases_osf1.h lib/canonical_osf1.h : lib/encodings_osf1.def lib/genaliases2.c
 	$(CC) $(CFLAGS) -DUSE_OSF1 lib/genaliases2.c -o genaliases
 	./genaliases osf1 > lib/aliases_osf1.h 3> lib/canonical_osf1.h
 	$(RM) genaliases
 
+lib/aliases_osf1_sysosf1.h lib/canonical_osf1_sysosf1.h : lib/encodings_osf1.def lib/genaliases2.c
+	$(CC) $(CFLAGS) -DUSE_OSF1 -DUSE_OSF1_ALIASES lib/genaliases2.c -o genaliases
+	./genaliases osf1 > lib/aliases_osf1_sysosf1.h 3> lib/canonical_osf1_sysosf1.h
+	$(RM) genaliases
+
 lib/aliases_dos.h lib/canonical_dos.h : lib/encodings_dos.def lib/genaliases2.c
 	$(CC) $(CFLAGS) -DUSE_DOS lib/genaliases2.c -o genaliases
 	./genaliases dos > lib/aliases_dos.h 3> lib/canonical_dos.h
diff --git a/NEWS b/NEWS
index e21404b..997af69 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+New in 1.13:
+* The library and the iconv program now understand platform dependent aliases,
+  for better compatibility with the platform's own iconv_open function.
+  Examples: "646" on Solaris, "iso88591" on HP-UX, "IBM-1252" on AIX.
+
 New in 1.12:
 * The iconv program is now licensed under the GPL version 3, instead of the
   GPL version 2. The libiconv library continues to be licensed under LGPL.
diff --git a/autogen.sh b/autogen.sh
index fb70e64..0c6bf13 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -71,7 +71,11 @@
 fi
 
 rm -f configure config.h.in include/iconv.h.build.in
-rm -f lib/aliases.h lib/aliases_aix.h lib/aliases_osf1.h lib/aliases_dos.h lib/aliases_extra.h
+rm -f lib/aliases.h lib/aliases_sysaix.h lib/aliases_syshpux.h lib/aliases_sysosf1.h lib/aliases_syssolaris.h
+rm -f lib/aliases_aix.h lib/aliases_aix_sysaix.h
+rm -f lib/aliases_osf1.h lib/aliases_osf1_sysosf1.h
+rm -f lib/aliases_dos.h
+rm -f lib/aliases_extra.h
 rm -f lib/flags.h
 rm -f lib/translit.h
 rm -f man/iconv.1.html man/iconv.3.html man/iconv_close.3.html man/iconv_open.3.html
diff --git a/lib/Makefile.in b/lib/Makefile.in
index a0baa9a..ed3af95 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -99,7 +99,14 @@
 	  rm -rf objects; \
 	fi
 
-iconv.lo : $(srcdir)/iconv.c $(srcdir)/converters.h $(srcdir)/encodings.def $(srcdir)/encodings_aix.def $(srcdir)/encodings_osf1.def $(srcdir)/encodings_dos.def $(srcdir)/encodings_local.def $(srcdir)/aliases.h $(srcdir)/aliases_aix.h $(srcdir)/aliases_osf1.h $(srcdir)/aliases_dos.h $(srcdir)/flags.h
+iconv.lo : $(srcdir)/iconv.c $(srcdir)/converters.h \
+           $(srcdir)/encodings.def $(srcdir)/encodings_aix.def $(srcdir)/encodings_osf1.def $(srcdir)/encodings_dos.def $(srcdir)/encodings_local.def \
+           $(srcdir)/aliases.h $(srcdir)/aliases_sysaix.h $(srcdir)/aliases_syshpux.h $(srcdir)/aliases_sysosf1.h $(srcdir)/aliases_syssolaris.h \
+           $(srcdir)/aliases_aix.h $(srcdir)/aliases_aix_sysaix.h \
+           $(srcdir)/aliases_osf1.h $(srcdir)/aliases_osf1_sysosf1.h \
+           $(srcdir)/aliases_dos.h \
+           $(srcdir)/aliases_extra.h \
+           $(srcdir)/flags.h $(srcdir)/translit.h
 	$(LIBTOOL_COMPILE) $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(DEFS) -c $(srcdir)/iconv.c
 
 localcharset.lo : $(srcdir)/../libcharset/lib/localcharset.c $(srcdir)/relocatable.h
diff --git a/lib/aliases2.h b/lib/aliases2.h
index 72176b4..7f2dc44 100644
--- a/lib/aliases2.h
+++ b/lib/aliases2.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2003 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2003, 2008 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -19,14 +19,22 @@
  */
 
 #ifdef USE_AIX
-#include "aliases_aix.h"
+# if defined _AIX
+#  include "aliases_aix_sysaix.h"
+# else
+#  include "aliases_aix.h"
+# endif
 #endif
 #ifdef USE_OSF1
-#include "aliases_osf1.h"
+# if defined __osf__
+#  include "aliases_osf1_sysosf1.h"
+# else
+#  include "aliases_osf1.h"
+# endif
 #endif
 #ifdef USE_DOS
-#include "aliases_dos.h"
+# include "aliases_dos.h"
 #endif
 #ifdef USE_EXTRA
-#include "aliases_extra.h"
+# include "aliases_extra.h"
 #endif
diff --git a/lib/encodings.def b/lib/encodings.def
index 7a5cdbb..9c24317 100644
--- a/lib/encodings.def
+++ b/lib/encodings.def
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2007 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2008 Free Software Foundation, Inc.
    This file is part of the GNU LIBICONV Library.
 
    The GNU LIBICONV Library is free software; you can redistribute it
@@ -51,6 +51,10 @@
             ),
             ascii,
             { ascii_mbtowc, NULL },       { ascii_wctomb, NULL })
+#ifdef USE_SOLARIS_ALIASES
+DEFALIAS(     "646",                    /* Solaris */
+            ascii)
+#endif
 
 /* General multi-byte encodings */
 
@@ -60,6 +64,10 @@
             ),
             utf8,
             { utf8_mbtowc, NULL },        { utf8_wctomb, NULL })
+#ifdef USE_HPUX_ALIASES
+DEFALIAS(     "UTF8",                   /* HP-UX */
+            utf8)
+#endif
 
 DEFENCODING(( "UCS-2",                  /* glibc */
               "ISO-10646-UCS-2",        /* IANA */
@@ -182,12 +190,16 @@
               "LATIN1",                 /* IANA */
               "L1",                     /* IANA */
               "csISOLatin1",            /* IANA */
-              "ISO8859-1",              /* X11R6.4, glibc, FreeBSD */
+              "ISO8859-1",              /* X11R6.4, glibc, FreeBSD, AIX, IRIX, OSF/1, Solaris */
             /*"ISO8859_1",                 JDK 1.1 */
             /*"CP28591",                   Windows */
             ),
             iso8859_1,
             { iso8859_1_mbtowc, NULL },   { iso8859_1_wctomb, NULL })
+#ifdef USE_HPUX_ALIASES
+DEFALIAS(     "ISO88591",               /* HP-UX */
+            iso8859_1)
+#endif
 
 DEFENCODING(( "ISO-8859-2",             /* IANA */
               "ISO_8859-2",             /* IANA */
@@ -196,12 +208,16 @@
               "LATIN2",                 /* IANA */
               "L2",                     /* IANA */
               "csISOLatin2",            /* IANA */
-              "ISO8859-2",              /* X11R6.4, glibc, FreeBSD */
+              "ISO8859-2",              /* X11R6.4, glibc, FreeBSD, AIX, IRIX, OSF/1, Solaris */
             /*"ISO8859_2",                 JDK 1.1 */
             /*"CP28592",                   Windows */
             ),
             iso8859_2,
             { iso8859_2_mbtowc, NULL },   { iso8859_2_wctomb, NULL })
+#ifdef USE_HPUX_ALIASES
+DEFALIAS(     "ISO88592",               /* HP-UX */
+            iso8859_2)
+#endif
 
 DEFENCODING(( "ISO-8859-3",             /* IANA */
               "ISO_8859-3",             /* IANA */
@@ -210,7 +226,7 @@
               "LATIN3",                 /* IANA */
               "L3",                     /* IANA */
               "csISOLatin3",            /* IANA */
-              "ISO8859-3",              /* X11R6.4, glibc, FreeBSD */
+              "ISO8859-3",              /* X11R6.4, glibc, FreeBSD, Solaris */
             /*"ISO8859_3",                 JDK 1.1 */
             /*"CP28593",                   Windows */
             ),
@@ -224,7 +240,7 @@
               "LATIN4",                 /* IANA */
               "L4",                     /* IANA */
               "csISOLatin4",            /* IANA */
-              "ISO8859-4",              /* X11R6.4, glibc, FreeBSD */
+              "ISO8859-4",              /* X11R6.4, glibc, FreeBSD, OSF/1, Solaris */
             /*"ISO8859_4",                 JDK 1.1 */
             /*"CP28594",                   Windows */
             ),
@@ -237,12 +253,16 @@
               "ISO-IR-144",             /* IANA */
               "CYRILLIC",               /* IANA */
               "csISOLatinCyrillic",     /* IANA */
-              "ISO8859-5",              /* X11R6.4, glibc, FreeBSD */
+              "ISO8859-5",              /* X11R6.4, glibc, FreeBSD, AIX, IRIX, OSF/1, Solaris */
             /*"ISO8859_5",                 JDK 1.1 */
             /*"CP28595",                   Windows */
             ),
             iso8859_5,
             { iso8859_5_mbtowc, NULL },   { iso8859_5_wctomb, NULL })
+#ifdef USE_HPUX_ALIASES
+DEFALIAS(     "ISO88595",               /* HP-UX */
+            iso8859_5)
+#endif
 
 DEFENCODING(( "ISO-8859-6",             /* IANA */
               "ISO_8859-6",             /* IANA */
@@ -252,12 +272,16 @@
               "ASMO-708",               /* IANA */
               "ARABIC",                 /* IANA */
               "csISOLatinArabic",       /* IANA */
-              "ISO8859-6",              /* X11R6.4, glibc, FreeBSD */
+              "ISO8859-6",              /* X11R6.4, glibc, FreeBSD, AIX, Solaris */
             /*"ISO8859_6",                 JDK 1.1 */
             /*"CP28596",                   Windows */
             ),
             iso8859_6,
             { iso8859_6_mbtowc, NULL },   { iso8859_6_wctomb, NULL })
+#ifdef USE_HPUX_ALIASES
+DEFALIAS(     "ISO88596",               /* HP-UX */
+            iso8859_6)
+#endif
 
 DEFENCODING(( "ISO-8859-7",             /* IANA, RFC 1947 */
               "ISO_8859-7",             /* IANA */
@@ -269,12 +293,16 @@
               "GREEK8",                 /* IANA */
               "GREEK",                  /* IANA */
               "csISOLatinGreek",        /* IANA */
-              "ISO8859-7",              /* X11R6.4, glibc, FreeBSD */
+              "ISO8859-7",              /* X11R6.4, glibc, FreeBSD, AIX, IRIX, OSF/1, Solaris */
             /*"ISO8859_7",                 JDK 1.1 */
             /*"CP28597",                   Windows */
             ),
             iso8859_7,
             { iso8859_7_mbtowc, NULL },   { iso8859_7_wctomb, NULL })
+#ifdef USE_HPUX_ALIASES
+DEFALIAS(     "ISO88597",               /* HP-UX */
+            iso8859_7)
+#endif
 
 DEFENCODING(( "ISO-8859-8",             /* IANA */
               "ISO_8859-8",             /* IANA */
@@ -282,13 +310,17 @@
               "ISO-IR-138",             /* IANA */
               "HEBREW",                 /* IANA */
               "csISOLatinHebrew",       /* IANA */
-              "ISO8859-8",              /* X11R6.4, glibc, FreeBSD */
+              "ISO8859-8",              /* X11R6.4, glibc, FreeBSD, AIX, OSF/1, Solaris */
             /*"ISO8859_8",                 JDK 1.1 */
             /*"CP28598",                   Windows */
             /*"CP38598",                   Windows */
             ),
             iso8859_8,
             { iso8859_8_mbtowc, NULL },   { iso8859_8_wctomb, NULL })
+#ifdef USE_HPUX_ALIASES
+DEFALIAS(     "ISO88598",               /* HP-UX */
+            iso8859_8)
+#endif
 
 DEFENCODING(( "ISO-8859-9",             /* IANA */
               "ISO_8859-9",             /* IANA */
@@ -297,12 +329,16 @@
               "LATIN5",                 /* IANA */
               "L5",                     /* IANA */
               "csISOLatin5",            /* IANA */
-              "ISO8859-9",              /* X11R6.4, glibc, FreeBSD */
+              "ISO8859-9",              /* X11R6.4, glibc, FreeBSD, AIX, IRIX, OSF/1, Solaris */
             /*"ISO8859_9",                 JDK 1.1 */
             /*"CP28599",                   Windows */
             ),
             iso8859_9,
             { iso8859_9_mbtowc, NULL },   { iso8859_9_wctomb, NULL })
+#ifdef USE_HPUX_ALIASES
+DEFALIAS(     "ISO88599",               /* HP-UX */
+            iso8859_9)
+#endif
 
 DEFENCODING(( "ISO-8859-10",            /* IANA */
               "ISO_8859-10",
@@ -332,6 +368,10 @@
             ),
             iso8859_13,
             { iso8859_13_mbtowc, NULL },  { iso8859_13_wctomb, NULL })
+#ifdef USE_AIX_ALIASES
+DEFALIAS(     "IBM-921",                /* AIX */
+            iso8859_13)
+#endif
 
 DEFENCODING(( "ISO-8859-14",            /* IANA, glibc */
               "ISO_8859-14",            /* IANA */
@@ -350,11 +390,15 @@
               "ISO_8859-15:1998",       /* glibc */
               "ISO-IR-203",
               "LATIN-9",                /* IANA */
-              "ISO8859-15",             /* glibc, FreeBSD */
+              "ISO8859-15",             /* glibc, FreeBSD, AIX, OSF/1, Solaris */
             /*"CP28605",                   Windows */
             ),
             iso8859_15,
             { iso8859_15_mbtowc, NULL },  { iso8859_15_wctomb, NULL })
+#ifdef USE_HPUX_ALIASES
+DEFALIAS(     "ISO885915",              /* HP-UX */
+            iso8859_15)
+#endif
 
 DEFENCODING(( "ISO-8859-16",            /* IANA */
               "ISO_8859-16",            /* IANA */
@@ -399,6 +443,10 @@
             ),
             cp1251,
             { cp1251_mbtowc, NULL },      { cp1251_wctomb, NULL })
+#ifdef USE_SOLARIS_ALIASES
+DEFALIAS(     "ANSI-1251",              /* Solaris */
+            cp1251)
+#endif
 
 DEFENCODING(( "CP1252",                 /* JDK 1.1 */
               "WINDOWS-1252",           /* IANA */
@@ -406,6 +454,10 @@
             ),
             cp1252,
             { cp1252_mbtowc, NULL },      { cp1252_wctomb, NULL })
+#ifdef USE_AIX_ALIASES
+DEFALIAS(     "IBM-1252",               /* AIX */
+            cp1252)
+#endif
 
 DEFENCODING(( "CP1253",                 /* JDK 1.1 */
               "WINDOWS-1253",           /* IANA */
@@ -457,6 +509,10 @@
             ),
             cp850,
             { cp850_mbtowc, NULL },       { cp850_wctomb, NULL })
+#ifdef USE_AIX_ALIASES
+DEFALIAS(     "IBM-850",                /* AIX */
+            cp850)
+#endif
 
 DEFENCODING(( "CP862",                  /* IANA, JDK 1.1 */
               "IBM862",                 /* IANA */
@@ -619,7 +675,7 @@
             { cp1133_mbtowc, NULL },      { cp1133_wctomb, NULL })
 
 DEFENCODING(( "TIS-620",                /* IANA */
-              "TIS620",                 /* glibc */
+              "TIS620",                 /* glibc, HP-UX */
               "TIS620-0",               /* glibc */
               "TIS620.2529-1",          /* glibc */
               "TIS620.2533-0",          /* glibc */
@@ -628,6 +684,14 @@
             ),
             tis620,
             { tis620_mbtowc, NULL },      { tis620_wctomb, NULL })
+#ifdef USE_OSF1_ALIASES
+DEFALIAS(     "TACTIS",                 /* OSF/1 */
+            tis620)
+#endif
+#ifdef USE_SOLARIS_ALIASES
+DEFALIAS(     "TIS620.2533",            /* Solaris */
+            tis620)
+#endif
 
 DEFENCODING(( "CP874",                  /* JDK 1.1 */
               "WINDOWS-874",
@@ -737,7 +801,7 @@
 /* CJK encodings */
 
 DEFENCODING(( "EUC-JP",                 /* IANA */
-              "EUCJP",                  /* glibc */
+              "EUCJP",                  /* glibc, HP-UX, IRIX, OSF/1, Solaris */
               "Extended_UNIX_Code_Packed_Format_for_Japanese", /* IANA */
               "csEUCPkdFmtJapanese",    /* IANA */
             /*"EUC_JP",                    JDK 1.1 */
@@ -745,20 +809,36 @@
             ),
             euc_jp,
             { euc_jp_mbtowc, NULL },      { euc_jp_wctomb, NULL })
+#ifdef USE_AIX_ALIASES
+DEFALIAS(     "IBM-EUCJP",              /* AIX */
+            euc_jp)
+#endif
+#ifdef USE_OSF1_ALIASES
+DEFALIAS(     "SDECKANJI",              /* OSF/1 */
+            euc_jp)
+#endif
 
 DEFENCODING(( "SHIFT_JIS",              /* IANA */
               "SHIFT-JIS",              /* glibc */
-              "SJIS",                   /* JDK 1.1 */
+              "SJIS",                   /* JDK 1.1, HP-UX, OSF/1 */
               "MS_KANJI",               /* IANA */
               "csShiftJIS",             /* IANA */
             ),
             sjis,
             { sjis_mbtowc, NULL },        { sjis_wctomb, NULL })
+#ifdef USE_SOLARIS_ALIASES
+DEFALIAS(     "PCK",                    /* Solaris */
+            sjis)
+#endif
 
 DEFENCODING(( "CP932",                  /* glibc */
             ),
             cp932,
             { cp932_mbtowc, NULL },       { cp932_wctomb, NULL })
+#ifdef USE_AIX_ALIASES
+DEFALIAS(     "IBM-932",                /* AIX */
+            cp932)
+#endif
 
 DEFENCODING(( "ISO-2022-JP",            /* IANA, RFC 1468 */
               "csISO2022JP",            /* IANA */
@@ -779,7 +859,7 @@
             { iso2022_jp2_mbtowc, NULL }, { iso2022_jp2_wctomb, iso2022_jp2_reset })
 
 DEFENCODING(( "EUC-CN",                 /* glibc */
-              "EUCCN",                  /* glibc */
+              "EUCCN",                  /* glibc, IRIX */
               "GB2312",                 /* IANA */
               "CN-GB",                  /* RFC 1922 */
               "csGB2312",               /* IANA */
@@ -788,6 +868,18 @@
             ),
             euc_cn,
             { euc_cn_mbtowc, NULL },      { euc_cn_wctomb, NULL })
+#ifdef USE_AIX_ALIASES
+DEFALIAS(     "IBM-EUCCN",              /* AIX */
+            euc_cn)
+#endif
+#ifdef USE_HPUX_ALIASES
+DEFALIAS(     "HP15CN",                 /* HP-UX */
+            euc_cn)
+#endif
+#ifdef USE_OSF1_ALIASES
+DEFALIAS(     "DECHANZI",               /* OSF/1 */
+            euc_cn)
+#endif
 
 DEFENCODING(( "GBK",                    /* IANA, JDK 1.1 */
             ),
@@ -826,13 +918,21 @@
             { hz_mbtowc, NULL },          { hz_wctomb, hz_reset })
 
 DEFENCODING(( "EUC-TW",                 /* glibc */
-              "EUCTW",                  /* glibc */
+              "EUCTW",                  /* glibc, HP-UX, IRIX, OSF/1 */
               "csEUCTW",
             /*"EUC_TW",                    JDK 1.1 */
             /*"CP51950",                   Windows */
             ),
             euc_tw,
             { euc_tw_mbtowc, NULL },      { euc_tw_wctomb, NULL })
+#ifdef USE_AIX_ALIASES
+DEFALIAS(     "IBM-EUCTW",              /* AIX */
+            euc_tw)
+#endif
+#ifdef USE_SOLARIS_ALIASES
+DEFALIAS(     "CNS11643",               /* Solaris */
+            euc_tw)
+#endif
 
 DEFENCODING(( "BIG5",                   /* IANA, JDK 1.1 */
               "BIG-5",                  /* glibc */
@@ -867,25 +967,45 @@
             { big5hkscs2004_mbtowc, big5hkscs2004_flushwc }, { big5hkscs2004_wctomb, big5hkscs2004_reset })
 
 DEFENCODING(( "EUC-KR",                 /* IANA, RFC 1557 */
-              "EUCKR",                  /* glibc */
+              "EUCKR",                  /* glibc, HP-UX, IRIX, OSF/1 */
               "csEUCKR",                /* IANA */
             /*"EUC_KR",                    JDK 1.1 */
             /*"CP51949",                   Windows */
             ),
             euc_kr,
             { euc_kr_mbtowc, NULL },      { euc_kr_wctomb, NULL })
+#ifdef USE_AIX_ALIASES
+DEFALIAS(     "IBM-EUCKR",              /* AIX */
+            euc_kr)
+#endif
+#ifdef USE_OSF1_ALIASES
+DEFALIAS(     "DECKOREAN",              /* OSF/1 */
+            euc_kr)
+#endif
+#ifdef USE_SOLARIS_ALIASES
+DEFALIAS(     "5601",                   /* Solaris */
+            euc_kr)
+#endif
 
 DEFENCODING(( "CP949",                  /* JDK 1.1 */
               "UHC",                    /* glibc */
             ),
             cp949,
             { cp949_mbtowc, NULL },       { cp949_wctomb, NULL })
+#ifdef USE_OSF1_ALIASES
+DEFALIAS(     "KSC5601",                /* OSF/1 */
+            cp949)
+#endif
 
 DEFENCODING(( "JOHAB",                  /* glibc */
               "CP1361",                 /* glibc */
             ),
             johab,
             { johab_mbtowc, NULL },       { johab_wctomb, NULL })
+#ifdef USE_SOLARIS_ALIASES
+DEFALIAS(     "KO_KR.JOHAP92",          /* Solaris */
+            johab)
+#endif
 
 DEFENCODING(( "ISO-2022-KR",            /* IANA, RFC 1557 */
               "csISO2022KR",            /* IANA */
diff --git a/lib/encodings_aix.def b/lib/encodings_aix.def
index b2bb3e1..259452e 100644
--- a/lib/encodings_aix.def
+++ b/lib/encodings_aix.def
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2002 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2002, 2008 Free Software Foundation, Inc.
    This file is part of the GNU LIBICONV Library.
 
    The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,31 +22,55 @@
             ),
             cp856,
             { cp856_mbtowc, NULL },       { cp856_wctomb, NULL })
+#ifdef USE_AIX_ALIASES
+DEFALIAS(     "IBM-856",                /* AIX */
+            cp856)
+#endif
 
 DEFENCODING(( "CP922",
             ),
             cp922,
             { cp922_mbtowc, NULL },       { cp922_wctomb, NULL })
+#ifdef USE_AIX_ALIASES
+DEFALIAS(     "IBM-922",                /* AIX */
+            cp922)
+#endif
 
 DEFENCODING(( "CP943",
             ),
             cp943,
             { cp943_mbtowc, NULL },       { cp943_wctomb, NULL })
+#ifdef USE_AIX_ALIASES
+DEFALIAS(     "IBM-943",                /* AIX */
+            cp943)
+#endif
 
 DEFENCODING(( "CP1046",
             ),
             cp1046,
             { cp1046_mbtowc, NULL },      { cp1046_wctomb, NULL })
+#ifdef USE_AIX_ALIASES
+DEFALIAS(     "IBM-1046",               /* AIX */
+            cp1046)
+#endif
 
 DEFENCODING(( "CP1124",
             ),
             cp1124,
             { cp1124_mbtowc, NULL },      { cp1124_wctomb, NULL })
+#ifdef USE_AIX_ALIASES
+DEFALIAS(     "IBM-1124",               /* AIX */
+            cp1124)
+#endif
 
 DEFENCODING(( "CP1129",
             ),
             cp1129,
             { cp1129_mbtowc, NULL },      { cp1129_wctomb, NULL })
+#ifdef USE_AIX_ALIASES
+DEFALIAS(     "IBM-1129",               /* AIX */
+            cp1129)
+#endif
 
 DEFENCODING(( "CP1161",
               "IBM1161",                /* glibc */
diff --git a/lib/encodings_osf1.def b/lib/encodings_osf1.def
index 62b8ab3..7912854 100644
--- a/lib/encodings_osf1.def
+++ b/lib/encodings_osf1.def
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2008 Free Software Foundation, Inc.
    This file is part of the GNU LIBICONV Library.
 
    The GNU LIBICONV Library is free software; you can redistribute it
@@ -22,8 +22,16 @@
             ),
             dec_kanji,
             { dec_kanji_mbtowc, NULL },   { dec_kanji_wctomb, NULL })
+#ifdef USE_OSF1_ALIASES
+DEFALIAS(     "DECKANJI",               /* OSF/1 */
+            dec_kanji)
+#endif
 
 DEFENCODING(( "DEC-HANYU",
             ),
             dec_hanyu,
             { dec_hanyu_mbtowc, NULL },   { dec_hanyu_wctomb, NULL })
+#ifdef USE_OSF1_ALIASES
+DEFALIAS(     "DECHANYU",               /* OSF/1 */
+            dec_hanyu)
+#endif
diff --git a/lib/genaliases.c b/lib/genaliases.c
index ba29b96..b54b97d 100644
--- a/lib/genaliases.c
+++ b/lib/genaliases.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2001, 2003, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2001, 2003, 2005, 2008 Free Software Foundation, Inc.
    This file is part of the GNU LIBICONV Library.
 
    The GNU LIBICONV Library is free software; you can redistribute it
@@ -21,6 +21,21 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+static void emit_alias (FILE* out1, const char* alias, const char* c_name)
+{
+  /* Output alias in upper case. */
+  const char* s = alias;
+  for (; *s; s++) {
+    unsigned char c = * (unsigned char *) s;
+    if (c >= 0x80)
+      exit(1);
+    if (c >= 'a' && c <= 'z')
+      c -= 'a'-'A';
+    putc(c, out1);
+  }
+  fprintf(out1,", ei_%s\n", c_name);
+}
+
 static void emit_encoding (FILE* out1, FILE* out2, const char* const* names, size_t n, const char* c_name)
 {
   fprintf(out2,"grep 'sizeof(\"");
@@ -37,19 +52,8 @@
     }
   }
   fprintf(out2,"\")' tmp.h | sed -e 's|^.*\\(stringpool_str[0-9]*\\).*$|  (int)(long)\\&((struct stringpool_t *)0)->\\1,|'\n");
-  for (; n > 0; names++, n--) {
-    /* Output *names in upper case. */
-    const char* s = *names;
-    for (; *s; s++) {
-      unsigned char c = * (unsigned char *) s;
-      if (c >= 0x80)
-        exit(1);
-      if (c >= 'a' && c <= 'z')
-        c -= 'a'-'A';
-      putc(c, out1);
-    }
-    fprintf(out1,", ei_%s\n", c_name);
-  }
+  for (; n > 0; names++, n--)
+    emit_alias(out1, *names, c_name);
 }
 
 int main ()
@@ -74,6 +78,7 @@
     emit_encoding(stdout,stdout2,names,sizeof(names)/sizeof(names[0]),#xxx); \
   }
 #define BRACIFY(...) { __VA_ARGS__ }
+#define DEFALIAS(xxx_alias,xxx) emit_alias(stdout,xxx_alias,#xxx);
 
   stdout2 = fdopen(3, "w");
   if (stdout2 == NULL)
@@ -89,6 +94,7 @@
   if (fclose(stdout2))
     exit(1);
 
+#undef DEFALIAS
 #undef BRACIFY
 #undef DEFENCODING
 
diff --git a/lib/genaliases2.c b/lib/genaliases2.c
index 89335a1..1b789ed 100644
--- a/lib/genaliases2.c
+++ b/lib/genaliases2.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2003, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2003, 2005, 2008 Free Software Foundation, Inc.
    This file is part of the GNU LIBICONV Library.
 
    The GNU LIBICONV Library is free software; you can redistribute it
@@ -21,26 +21,32 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+static unsigned int counter = 0;
+
+static void emit_alias (FILE* out1, const char* tag, const char* alias, const char* c_name)
+{
+  fprintf(out1,"  S(%s_%u, \"",tag,counter);
+  /* Output alias in upper case. */
+  {
+    const char* s = alias;
+    for (; *s; s++) {
+      unsigned char c = * (unsigned char *) s;
+      if (c >= 0x80)
+        exit(1);
+      if (c >= 'a' && c <= 'z')
+        c -= 'a'-'A';
+      putc(c, out1);
+    }
+  }
+  fprintf(out1,"\", ei_%s )\n", c_name);
+  counter++;
+}
+
 static void emit_encoding (FILE* out1, FILE* out2, const char* tag, const char* const* names, size_t n, const char* c_name)
 {
-  static unsigned int counter = 0;
   fprintf(out2,"  (int)(long)&((struct stringpool2_t *)0)->stringpool_%s_%u,\n",tag,counter);
-  for (; n > 0; names++, n--, counter++) {
-    fprintf(out1,"  S(%s_%u, \"",tag,counter);
-    /* Output *names in upper case. */
-    {
-      const char* s = *names;
-      for (; *s; s++) {
-        unsigned char c = * (unsigned char *) s;
-        if (c >= 0x80)
-          exit(1);
-        if (c >= 'a' && c <= 'z')
-          c -= 'a'-'A';
-        putc(c, out1);
-      }
-    }
-    fprintf(out1,"\", ei_%s )\n", c_name);
-  }
+  for (; n > 0; names++, n--)
+    emit_alias(out1, tag, *names, c_name);
 }
 
 int main (int argc, char* argv[])
@@ -55,6 +61,7 @@
     emit_encoding(stdout,stdout2,tag,names,sizeof(names)/sizeof(names[0]),#xxx); \
   }
 #define BRACIFY(...) { __VA_ARGS__ }
+#define DEFALIAS(xxx_alias,xxx) emit_alias(stdout,tag,xxx_alias,#xxx);
 #ifdef USE_AIX
 #include "encodings_aix.def"
 #endif
@@ -67,6 +74,7 @@
 #ifdef USE_EXTRA
 #include "encodings_extra.def"
 #endif
+#undef DEFALIAS
 #undef BRACIFY
 #undef DEFENCODING
   if (ferror(stdout) || fclose(stdout) || ferror(stdout2) || fclose(stdout2))
diff --git a/lib/genflags.c b/lib/genflags.c
index 76fd253..026184c 100644
--- a/lib/genflags.c
+++ b/lib/genflags.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2002, 2005-2006 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2002, 2005-2006, 2008 Free Software Foundation, Inc.
    This file is part of the GNU LIBICONV Library.
 
    The GNU LIBICONV Library is free software; you can redistribute it
@@ -97,12 +97,14 @@
     struct wctomb_funcs ofuncs = xxx_ofuncs1,xxx_ofuncs2; \
     emit_encoding(&ofuncs,#xxx);                          \
   }
+#define DEFALIAS(xxx_alias,xxx) /* nothing */
 /* Consider all encodings, including the system dependent ones. */
 #include "encodings.def"
 #include "encodings_aix.def"
 #include "encodings_osf1.def"
 #include "encodings_dos.def"
 #include "encodings_extra.def"
+#undef DEFALIAS
 #undef DEFENCODING
 
   if (ferror(stdout) || fclose(stdout))
diff --git a/lib/iconv.c b/lib/iconv.c
index 6cbc846..007a700 100644
--- a/lib/iconv.c
+++ b/lib/iconv.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2007 Free Software Foundation, Inc.
+ * Copyright (C) 1999-2008 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.
  *
  * The GNU LIBICONV Library is free software; you can redistribute it
@@ -80,21 +80,22 @@
   struct wctomb_funcs ofuncs; /* conversion unicode -> multibyte */
   int oflags;                 /* flags for unicode -> multibyte conversion */
 };
+#define DEFALIAS(xxx_alias,xxx) /* nothing */
 enum {
 #define DEFENCODING(xxx_names,xxx,xxx_ifuncs1,xxx_ifuncs2,xxx_ofuncs1,xxx_ofuncs2) \
   ei_##xxx ,
 #include "encodings.def"
 #ifdef USE_AIX
-#include "encodings_aix.def"
+# include "encodings_aix.def"
 #endif
 #ifdef USE_OSF1
-#include "encodings_osf1.def"
+# include "encodings_osf1.def"
 #endif
 #ifdef USE_DOS
-#include "encodings_dos.def"
+# include "encodings_dos.def"
 #endif
 #ifdef USE_EXTRA
-#include "encodings_extra.def"
+# include "encodings_extra.def"
 #endif
 #include "encodings_local.def"
 #undef DEFENCODING
@@ -106,16 +107,16 @@
   { xxx_ifuncs1,xxx_ifuncs2, xxx_ofuncs1,xxx_ofuncs2, ei_##xxx##_oflags },
 #include "encodings.def"
 #ifdef USE_AIX
-#include "encodings_aix.def"
+# include "encodings_aix.def"
 #endif
 #ifdef USE_OSF1
-#include "encodings_osf1.def"
+# include "encodings_osf1.def"
 #endif
 #ifdef USE_DOS
-#include "encodings_dos.def"
+# include "encodings_dos.def"
 #endif
 #ifdef USE_EXTRA
-#include "encodings_extra.def"
+# include "encodings_extra.def"
 #endif
 #undef DEFENCODING
 #define DEFENCODING(xxx_names,xxx,xxx_ifuncs1,xxx_ifuncs2,xxx_ofuncs1,xxx_ofuncs2) \
@@ -123,6 +124,7 @@
 #include "encodings_local.def"
 #undef DEFENCODING
 };
+#undef DEFALIAS
 
 /*
  * Conversion loops.
@@ -136,7 +138,17 @@
  *   const struct alias * aliases_lookup (const char *str, unsigned int len);
  *   #define MAX_WORD_LENGTH ...
  */
-#include "aliases.h"
+#if defined _AIX
+# include "aliases_sysaix.h"
+#elif defined hpux || defined __hpux
+# include "aliases_syshpux.h"
+#elif defined __osf__
+# include "aliases_sysosf1.h"
+#elif defined __sun
+# include "aliases_syssolaris.h"
+#else
+# include "aliases.h"
+#endif
 
 /*
  * System dependent alias lookup function.
@@ -603,20 +615,48 @@
  * Instead of strings, it contains offsets into stringpool and stringpool2.
  */
 static const unsigned short all_canonical[] = {
-#include "canonical.h"
+#if defined _AIX
+# include "canonical_sysaix.h"
+#elif defined hpux || defined __hpux
+# include "canonical_syshpux.h"
+#elif defined __osf__
+# include "canonical_sysosf1.h"
+#elif defined __sun
+# include "canonical_syssolaris.h"
+#else
+# include "canonical.h"
+#endif
 #ifdef USE_AIX
-#include "canonical_aix.h"
+# if defined _AIX
+#  include "canonical_aix_sysaix.h"
+# else
+#  include "canonical_aix.h"
+# endif
 #endif
 #ifdef USE_OSF1
-#include "canonical_osf1.h"
+# if defined __osf__
+#  include "canonical_osf1_sysosf1.h"
+# else
+#  include "canonical_osf1.h"
+# endif
 #endif
 #ifdef USE_DOS
-#include "canonical_dos.h"
+# include "canonical_dos.h"
 #endif
 #ifdef USE_EXTRA
-#include "canonical_extra.h"
+# include "canonical_extra.h"
 #endif
-#include "canonical_local.h"
+#if defined _AIX
+# include "canonical_local_sysaix.h"
+#elif defined hpux || defined __hpux
+# include "canonical_local_syshpux.h"
+#elif defined __osf__
+# include "canonical_local_sysosf1.h"
+#elif defined __sun
+# include "canonical_local_syssolaris.h"
+#else
+# include "canonical_local.h"
+#endif
 };
 
 const char * iconv_canonicalize (const char * name)