diff --git a/Makefile.devel b/Makefile.devel
index 51698c4..efc3c35 100644
--- a/Makefile.devel
+++ b/Makefile.devel
@@ -104,7 +104,7 @@ include/iconv.h.build.in : include/iconv.h.in include/export.h
 
 lib/aliases.h lib/canonical.h lib/canonical_local.h : lib/encodings.def lib/encodings_local.def lib/genaliases.c
 	$(CC) $(CFLAGS) lib/genaliases.c -o genaliases
-	./genaliases > lib/aliases.gperf 3> canonical.sh 4> canonical_local.sh
+	./genaliases lib/aliases.gperf canonical.sh canonical_local.sh
 	$(RM) genaliases
 	$(GPERF) -m 10 lib/aliases.gperf > tmp.h
 	$(CP) tmp.h lib/aliases.h
@@ -114,7 +114,7 @@ lib/aliases.h lib/canonical.h lib/canonical_local.h : lib/encodings.def lib/enco
 
 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
+	./genaliases lib/aliases_sysaix.gperf canonical.sh canonical_local.sh
 	$(RM) genaliases
 	$(GPERF) -m 10 lib/aliases_sysaix.gperf > tmp.h
 	$(CP) tmp.h lib/aliases_sysaix.h
@@ -124,7 +124,7 @@ lib/aliases_sysaix.h lib/canonical_sysaix.h lib/canonical_local_sysaix.h : lib/e
 
 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
+	./genaliases lib/aliases_syshpux.gperf canonical.sh canonical_local.sh
 	$(RM) genaliases
 	$(GPERF) -m 10 lib/aliases_syshpux.gperf > tmp.h
 	$(CP) tmp.h lib/aliases_syshpux.h
@@ -134,7 +134,7 @@ lib/aliases_syshpux.h lib/canonical_syshpux.h lib/canonical_local_syshpux.h : li
 
 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
+	./genaliases lib/aliases_sysosf1.gperf canonical.sh canonical_local.sh
 	$(RM) genaliases
 	$(GPERF) -m 10 lib/aliases_sysosf1.gperf > tmp.h
 	$(CP) tmp.h lib/aliases_sysosf1.h
@@ -144,7 +144,7 @@ lib/aliases_sysosf1.h lib/canonical_sysosf1.h lib/canonical_local_sysosf1.h : li
 
 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
+	./genaliases lib/aliases_syssolaris.gperf canonical.sh canonical_local.sh
 	$(RM) genaliases
 	$(GPERF) -m 10 lib/aliases_syssolaris.gperf > tmp.h
 	$(CP) tmp.h lib/aliases_syssolaris.h
@@ -154,32 +154,32 @@ lib/aliases_syssolaris.h lib/canonical_syssolaris.h lib/canonical_local_syssolar
 
 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
+	./genaliases aix lib/aliases_aix.h 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
+	./genaliases aix lib/aliases_aix_sysaix.h 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
+	./genaliases osf1 lib/aliases_osf1.h 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
+	./genaliases osf1 lib/aliases_osf1_sysosf1.h 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
+	./genaliases dos lib/aliases_dos.h lib/canonical_dos.h
 	$(RM) genaliases
 
 lib/aliases_extra.h lib/canonical_extra.h : lib/encodings_extra.def lib/genaliases2.c
 	$(CC) $(CFLAGS) -DUSE_EXTRA lib/genaliases2.c -o genaliases
-	./genaliases extra > lib/aliases_extra.h 3> lib/canonical_extra.h
+	./genaliases extra lib/aliases_extra.h lib/canonical_extra.h
 	$(RM) genaliases
 
 
diff --git a/lib/genaliases.c b/lib/genaliases.c
index b54b97d..4f59c47 100644
--- a/lib/genaliases.c
+++ b/lib/genaliases.c
@@ -56,38 +56,39 @@ static void emit_encoding (FILE* out1, FILE* out2, const char* const* names, siz
     emit_alias(out1, *names, c_name);
 }
 
-int main ()
+int main (int argc, char* argv[])
 {
+  FILE* stdout1 = (argc > 1 ? fopen(argv[1], "w") : stdout);
   FILE* stdout2;
 
-  printf("struct alias { int name; unsigned int encoding_index; };\n");
-  printf("%%struct-type\n");
-  printf("%%language=ANSI-C\n");
-  printf("%%define hash-function-name aliases_hash\n");
-  printf("%%define lookup-function-name aliases_lookup\n");
-  printf("%%7bit\n");
-  printf("%%readonly-tables\n");
-  printf("%%global-table\n");
-  printf("%%define word-array-name aliases\n");
-  printf("%%pic\n");
-  printf("%%%%\n");
+  fprintf(stdout1, "struct alias { int name; unsigned int encoding_index; };\n");
+  fprintf(stdout1, "%%struct-type\n");
+  fprintf(stdout1, "%%language=ANSI-C\n");
+  fprintf(stdout1, "%%define hash-function-name aliases_hash\n");
+  fprintf(stdout1, "%%define lookup-function-name aliases_lookup\n");
+  fprintf(stdout1, "%%7bit\n");
+  fprintf(stdout1, "%%readonly-tables\n");
+  fprintf(stdout1, "%%global-table\n");
+  fprintf(stdout1, "%%define word-array-name aliases\n");
+  fprintf(stdout1, "%%pic\n");
+  fprintf(stdout1, "%%%%\n");
 
 #define DEFENCODING(xxx_names,xxx,xxx_ifuncs1,xxx_ifuncs2,xxx_ofuncs1,xxx_ofuncs2) \
   {                                                           \
     static const char* const names[] = BRACIFY xxx_names;     \
-    emit_encoding(stdout,stdout2,names,sizeof(names)/sizeof(names[0]),#xxx); \
+    emit_encoding(stdout1,stdout2,names,sizeof(names)/sizeof(names[0]),#xxx); \
   }
 #define BRACIFY(...) { __VA_ARGS__ }
-#define DEFALIAS(xxx_alias,xxx) emit_alias(stdout,xxx_alias,#xxx);
+#define DEFALIAS(xxx_alias,xxx) emit_alias(stdout1,xxx_alias,#xxx);
 
-  stdout2 = fdopen(3, "w");
+  stdout2 = (argc > 2) ? fopen(argv[2], "w") : fdopen(3, "w");
   if (stdout2 == NULL)
     exit(1);
 #include "encodings.def"
   if (fclose(stdout2))
     exit(1);
 
-  stdout2 = fdopen(4, "w");
+  stdout2 = (argc > 3) ? fopen(argv[3], "w") : fdopen(4, "w");
   if (stdout2 == NULL)
     exit(1);
 #include "encodings_local.def"
@@ -98,7 +99,7 @@ int main ()
 #undef BRACIFY
 #undef DEFENCODING
 
-  if (ferror(stdout) || fclose(stdout))
+  if (ferror(stdout1) || fclose(stdout1))
     exit(1);
   exit(0);
 }
diff --git a/lib/genaliases2.c b/lib/genaliases2.c
index 1b789ed..892e6ba 100644
--- a/lib/genaliases2.c
+++ b/lib/genaliases2.c
@@ -52,16 +52,17 @@ static void emit_encoding (FILE* out1, FILE* out2, const char* tag, const char*
 int main (int argc, char* argv[])
 {
   const char * tag = (argc > 1 ? argv[1] : "xxx");
-  FILE * stdout2 = fdopen(3, "w");
+  FILE* stdout1 = (argc > 1 ? fopen(argv[2], "w") : stdout);
+  FILE * stdout2 = (argc > 2 ? fopen(argv[3], "w") : fdopen(3, "w"));
   if (stdout2 == NULL)
     exit(1);
 #define DEFENCODING(xxx_names,xxx,xxx_ifuncs1,xxx_ifuncs2,xxx_ofuncs1,xxx_ofuncs2) \
   {                                                           \
     static const char* const names[] = BRACIFY xxx_names;     \
-    emit_encoding(stdout,stdout2,tag,names,sizeof(names)/sizeof(names[0]),#xxx); \
+    emit_encoding(stdout1,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);
+#define DEFALIAS(xxx_alias,xxx) emit_alias(stdout1,tag,xxx_alias,#xxx);
 #ifdef USE_AIX
 #include "encodings_aix.def"
 #endif
@@ -77,7 +78,7 @@ int main (int argc, char* argv[])
 #undef DEFALIAS
 #undef BRACIFY
 #undef DEFENCODING
-  if (ferror(stdout) || fclose(stdout) || ferror(stdout2) || fclose(stdout2))
+  if (ferror(stdout1) || fclose(stdout1) || ferror(stdout2) || fclose(stdout2))
     exit(1);
   exit(0);
 }
