2 eval 'exec perl -S $0 "$@"'
3 if $runnning_under_some_shell;
5 # $Id: bindex.SH,v 3.0.1.1 1993/08/19 06:42:12 ram Exp $
7 # Copyright (c) 1991-1993, Raphael Manfredi
9 # You may redistribute only under the terms of the Artistic Licence,
10 # as specified in the README file that comes with the distribution.
11 # You may reuse parts of this distribution only within the terms of
12 # that same Artistic Licence; a copy of which may be found at the root
13 # of the source tree for dist 3.0.
16 # Revision 3.0.1.1 1993/08/19 06:42:12 ram
17 # patch1: leading config.sh searching was not aborting properly
19 # Revision 3.0 1993/08/18 12:04:13 ram
20 # Baseline for dist 3.0 netwide release.
23 $file = "files/Jmake.rules";
25 open(INDEX, ">Index") || die "Cannot create Index.\n";
26 open(RULES, "$file") || die "Cannot open $file.\n";
29 "[This Index is automatically generated from Jmake.rules file. Do not
30 edit this file or your changes will be lost. Edit Jmake.rules instead.]
32 This file contains a listing of all the macros that can be used in a
33 Jmakefile. Only a few of these should be used in the Jmakefile (they
34 are the top-level macros). However, some low-level ones may be useful,
35 but it is up to you to make that decision. This explains why this file
36 holds all the available macros for jmake.
38 In the following listing, the macros are separated by a line of dashes.
39 The signature of the macro is given, then a small comment of what it
40 does precedes the actual definition.
42 Lines preceded by '->' show the set of symbols defined when the macro is
43 used. Initialization lines are shown as-is, i.e. have the form SYM = val
44 while concatenation is shown by SYM += val (which means val is added to
47 Conditional lines are preceded by tests like (if SYM). This means the line
48 is to be kept if and only if the symbol SYM is defined. Other internal
49 requests are not formatted yet.
52 $inrule = 0; # Not inside a rule at the beginning
53 $incomment = 0; # Not inside a comment
54 $last_was_text = 0; # Last line was not a rule text
56 $inrule || next unless /^\s\*\s(\w+)\s*:/;
57 if ($inrule) { # We are already in a rule
59 if (m|^\s*\*/|) { # End of comment
61 $Comment{$current} .= "\n";
63 s/^\s*\*\s*//; # Remove leading comment sign
64 $Comment{$current} .= " $_";
66 next; # Anyway, go to next line
68 if (/^\s*$/) { # Empty line = end of rule
72 # Here, we have to print the body of the rule, after some cleaning
73 s/(@#|@@|@!)\\$//; # Remove final continuations
74 s/^(#define.*)\\/$1/; # Remove single '\' on first rule line
76 s/\|rule:\s+/ /; # Remove rule markers
78 s/%(\w+):\|skip/#ifdef $1/; # Deal with ugly skip syntax
79 s/\?(\w+):\|skip/#ifndef $1/; # Deal with ugly skip syntax
81 s/\?(\w+):/(if $1) /; # Simple '?' test
82 s/%(\w+):/(not $1) /; # Simple '%' test
83 s/\|suffix/.SUFFIXES:/; # Make suffix command explicit
84 s/\t/ /g; # Expand all tabs to 4 chars
85 s/\s*$/\n/; # Remove any trailing space
86 s|\^\^|/**/|; # Restore ^^ to the more visual /**/
87 if (/^$/) { # If empty line
88 $Index{$current} .= "\n" if $last_was_text;
92 if (/^[>+]/) { # Special commands
93 if (s/^>\s*//) { # Wanted symbol
95 $Wants{$current} .= " $_";
96 } elsif (/^\+\+\s*(\S+)\s*(.*)/) { # Added symbol
97 $Added{$current} .= "\t$1 += $2\n";
100 $Init{$current} .= "\t$1\n";
104 if (s/^#define\s+//) { # Definition of the rule
106 $Sig{$current} = $_; # Signature of rule
108 $Index{$current} .= " $_"; # Rule's body
111 } else { # We've just entered a rule
113 next if $current =~ /patch\d/; # Skip RCS log messages
115 $incomment = 1; # We're still in the leading comment
122 # Now sort the rules in alphabetical order
124 print INDEX '-' x 72, "\n";
125 foreach $rule (sort(keys %Seen)) {
126 print INDEX "$Sig{$rule}:\n";
127 print INDEX $Comment{$rule};
128 $line = $Wants{$rule};
131 $line = do format($line);
132 print INDEX "$line\n";
134 $line = $Init{$rule};
135 print INDEX "$line\n" if length($line);
136 $line = $Added{$rule};
137 print INDEX "$line\n" if length($line);
138 $line = $Index{$rule};
140 print INDEX "\n" if (length($line));
141 print INDEX '-' x 72, "\n";
146 # Format $_ to fit in 80 columns (70 + size of tabs)
147 # Long lines are split, and the all but the first are indented
148 # by two leading spaces. The whole thing is then indented by
153 local($_) = shift(@_);
154 while (length($_) > 70) {
155 $tmp = substr($_,0,70);
156 $tmp =~ s/^(.*) .*/$1/;
158 $_ = ' ' . substr($_,length($tmp),9999);