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]
--- /dev/null
+#!/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;