diff options
author | Mike Frysinger <vapier@gentoo.org> | 2022-01-18 06:00:26 +0300 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2022-01-20 03:59:16 +0300 |
commit | b86dc2dab4981ba92d683b866badc0b32be39120 (patch) | |
tree | 73fb7b2142531a24018626c464a584d183a48dd1 /newlib/libc | |
parent | 15c091ad7326129a3a4ddf04c67fffbc62d002ae (diff) |
newlib: iconv: autogenerate iconv define list
The list of iconv to/from defines is hand maintained in newlib.hin.
Lets leverage mkdeps.pl to generate this list automatically from the
list of known encodings. The newlib.hin list is up-to-date, so the
list in iconv.m4 matches the list already generated.
Diffstat (limited to 'newlib/libc')
-rwxr-xr-x | newlib/libc/iconv/ces/mkdeps.pl | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/newlib/libc/iconv/ces/mkdeps.pl b/newlib/libc/iconv/ces/mkdeps.pl index 4e648694a..b279fd4e8 100755 --- a/newlib/libc/iconv/ces/mkdeps.pl +++ b/newlib/libc/iconv/ces/mkdeps.pl @@ -334,6 +334,9 @@ sub process_section_encodings($) # Generate ccsnames.h header file generate_ccsnames_h (\%ccsenc); + # Generate iconv.m4 file + my @encodings = sort keys %encalias; + generate_iconv_m4 (\@encodings); } # ============================================================================== @@ -928,3 +931,39 @@ sub generate_ccsnames_h($) print CCSNAMES_H "\n#endif /* !__CCSNAMES_H__ */\n\n"; close CCSNAMES_H or err "Error while closing ../ccs/ccsnames.h file."; } + +# ============================================================================== +# +# Generate iconv.m4 file. +# +# Parameter 1 (input): array reference with encoding names +# +# ============================================================================== +sub generate_iconv_m4($) +{ + my @encodings = @{$_[0]}; + + print "Debug: create \"../../../iconv.m4\" file.\n" if $verbose; + open (ICONV_M4, '>', "../../../iconv.m4") + or err "Can't create \"../../../iconv.m4\" file for writing.\nSystem error message: $!.\n"; + + print ICONV_M4 "$comment_automatic\n"; + print ICONV_M4 "AC_DEFUN([NEWLIB_ICONV_DEFINES],[dnl\n"; + foreach my $encoding (@encodings) + { + my $ucencoding = uc $encoding; + + my $tovar = "_ICONV_TO_ENCODING_$ucencoding"; + print ICONV_M4 " if test \"\$$tovar\" = 1; then\n"; + print ICONV_M4 " AC_DEFINE($tovar, 1, [Support $encoding output encoding.])\n"; + print ICONV_M4 " fi\n"; + + my $fromvar = "_ICONV_FROM_ENCODING_$ucencoding"; + print ICONV_M4 " if test \"\$$fromvar\" = 1; then\n"; + print ICONV_M4 " AC_DEFINE($fromvar, 1, [Support $encoding input encoding.])\n"; + print ICONV_M4 " fi\n"; + } + print ICONV_M4 "])\n"; + + close ICONV_M4 or err "Error while closing ../../../iconv.m4 file."; +} |