From aa7a44a031fa8efba1a014a215f1eb03ea2607fb Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 4 Jul 2010 11:23:28 +0200 Subject: [PATCH] Use a perl script to create error2.h This is *much* faster than the shell code in configure. Perl is required anyway for help2man, so this patch does not introduce additional requirements on the build system. --- configure.ac | 49 +++++--------------------------------------- error2.pl | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 44 deletions(-) create mode 100755 error2.pl diff --git a/configure.ac b/configure.ac index d8f55ce2..f0c27872 100644 --- a/configure.ac +++ b/configure.ac @@ -652,53 +652,14 @@ AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)]) AC_DEFUN([add_para],[$(for i in $@; do printf "para_$i "; done)]) AC_DEFUN([objlist_to_errlist],[$(for i in $@; do printf "DEFINE_ERRLIST($(echo $i| tr 'a-z' 'A-Z'));"; done) [const char **para_errlist[[]]] = {$(for i in $@; do printf "PARA_ERRLIST($(echo $i | tr 'a-z' 'A-Z')), "; done) }]) ############################################################# error2.h -AC_DEFUN([define_safe_error_enums], -[ - exe="" - for i in $executables; do -# eval echo checking if $1 is linked into $i - for j in $(eval echo \$${i}_errlist_objs); do - if test $j = $1; then - exe="$exe $i" - break; - fi - done - done - #echo "$1 gets linked into $exe" - safe_errlists="" - for i in $all_errlist_objs; do - for j in $exe; do - found=0 - for k in $(eval echo \$${j}_errlist_objs); do - if test $k = $i; then - found=1 - break; - fi - done - if test $found -eq 0; then - break; - fi - done - if test $found -eq 1; then - safe_errlists="$safe_errlists $i" - fi - done - #echo "safe errlists for $1: $safe_errlists" - ss_defs="" - for i in $safe_errlists; do - echo "SS_ENUM($(echo $i | tr 'a-z' 'A-Z'));" - done -] -) - - AC_MSG_NOTICE(creating error2.h) +for i in $executables; do + echo "$i: " + eval echo \$${i}_errlist_objs +done | ./error2.pl > error2.h for obj in $all_errlist_objs; do SS="$SS SS_$(echo $obj | tr 'a-z' 'A-Z')," - echo "#ifdef MAIN_INPUT_FILE_IS_$obj" - define_safe_error_enums($obj) - echo "#endif" -done > error2.h +done AC_DEFINE_UNQUOTED(DEFINE_ERRLIST_OBJECT_ENUM, [enum {$SS NUM_SS}], [list of all objects that use paraslash's error facility] diff --git a/error2.pl b/error2.pl new file mode 100755 index 00000000..78ff2c56 --- /dev/null +++ b/error2.pl @@ -0,0 +1,58 @@ +#!/usr/bin/env perl + +use warnings; +use strict; + +my %matrix; +my @executables; +my %objects; + +sub make_matrix +{ + my ($line, $e, @fields, $field); + + while (defined($line = <>)) { + chomp($line); + if ($line =~ "^ *\$") { + next; + } + @fields = split(" ", $line); + while (defined(($field = shift(@fields)))) { + if ($field =~ ":\$") { + $field =~ s/://; + $e = $field; + push(@executables, $e); + next; + } + $matrix{$e . ">" . $field} = 1; + $objects{$field} = 1; + } + } +} + +sub print_safe_objects +{ + my @objs = keys(%objects); + my ($o1, $o2, $e); + + foreach $o1 (@objs) { + print("#ifdef MAIN_INPUT_FILE_IS_$o1\n"); + O2: foreach $o2 (@objs) { + foreach $e (@executables) { + if (!defined($matrix{$e . ">" . $o1})) { + next; + } + if (defined($matrix{$e . ">" . $o2})) { + next; + } + next O2; + } + $_ = $o2; + tr/a-z/A-Z/; + printf("SS_ENUM(%s);\n", $_); + } + print("#endif\n"); + } +} +make_matrix; +print_safe_objects; -- 2.30.2