2 eval "exec perl -S $0 $*"
3 if $running_under_some_shell;
5 # $Id: makegloss.SH 1 2006-08-24 12:32:52Z rmanfredi $
7 # Copyright (c) 1991-1997, 2004-2006, 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 4.0.
15 # Original Author: Larry Wall <lwall@netlabs.com>
17 # $Log: makegloss.SH,v $
18 # Revision 3.0.1.3 1994/01/24 14:17:49 ram
19 # patch16: now understands internal-use only defined variables
21 # Revision 3.0.1.2 1993/10/16 13:50:39 ram
22 # patch12: updated to support new ?M: lines
24 # Revision 3.0.1.1 1993/08/19 06:42:21 ram
25 # patch1: leading config.sh searching was not aborting properly
27 # Revision 3.0 1993/08/18 12:10:12 ram
28 # Baseline for dist 3.0 netwide release.
31 open(G,">Glossary") || die "Can't create Glossary.\n";
33 '[This Glossary is automatically generated from the Unit files. Do not edit
34 this file or your changes will be lost. Edit the appropriate Unit instead.]
36 This file contains a listing of all the C preprocessor symbols and shell
37 variables whose value can be determined by a Configure script. For the
38 most part, any symbol in UPPERCASE is a C preprocessor symbol, and
39 will be defined in config.h. Symbols in lowercase are shell variables,
40 and are defined in config.sh.
42 If you write your shell scripts and C programs in terms of these symbols,
43 metaconfig can automatically build you a Configure script that will determine
44 the value of those symbols. See the README file for a description of how
47 In the following listing, the Unit: line indicates the name of the unit
48 where this symbol is defined, and the Wants: line indicates what other
49 symbols must be determined in order to figure out the value of this one.
50 If there is an "(Also defines ...)" entry, it indicates what other symbols
51 are defined by the Unit other than the one corresponding to the unit name.
53 Variable of the form d_* either have the value "define" or "/*define", and
54 control whether some C preprocessor symbol gets defined or not.
60 if (/^\?[\w\-]+:/) { # We may have found a control line
61 # Long lines may be escaped with a final backslash
62 $_ .= &complete_line if s/\\\s*$//;
65 ($also, $wants) = /^\?MAKE:\s*(.*):\s*(.*)/;
66 ($unit = $ARGV) =~ s|.*/(.*)\.U$|$1|;
67 @Also = split(/ /, $also);
80 @Wants = split(/ /, $wants);
94 $_ .= " (Also defines $also)" if $also;
95 $_ .= " (With private $internal)" if $internal;
102 $_ = "Optional: $option";
103 $head .= &format($_);
108 # Example of expression matched by the following pattern:
109 # ?C:symbol ~ alias (obsolete list):
110 # The main symbol (optionally aliased) can be followed by a list of
111 # obsolete symbols (the list is space separated).
113 if (/^\?[CS]:(\w+)(\s*~\s*\S+)?\s*(\(.*\))?:\s*$/) {
117 $header{$sym} .= $head;
118 if ($obsoleted =~ s/^\((.*)\)$/$1/) {
119 @obsoleted = split(' ', $obsoleted);
120 foreach $obs (@obsoleted) {
122 $header{$obs} = "\tObsoleted by $sym.\n\n";
126 elsif (s/^\?[CS]://) { # Must be inside definition
127 if (/^\.$/) { # Closing line
132 s/^(\t| ? ? ? ? ? ? ?)//;
133 $def{$sym} .= "\t" . $_;
136 elsif (/^\?M:(\w+):\s*([\w\s]*)\n$/) { # Magic mapping introduction
141 $cdep = ", needs: $cdep" if $cdep ne '';
142 $header{$sym} = "\tMagic symbol$cdep\n" . $head;
144 elsif (s/^\?M://) { # Must be a magic mapping definition
145 if (/^\.$/) { # Closing line
149 $def{$sym} .= "\t" . $_;
154 foreach $sym (sort @syms) {
156 print G $header{$sym};
161 # Format $_ to fit in 80 columns (70 + size of tabs)
162 # Long lines are split, and the all but the first are indented
163 # by two leading spaces. The whole thing is then indented by
168 local($_) = shift(@_);
169 while (length($_) > 70) {
170 $tmp = substr($_,0,70);
171 $tmp =~ s/^(.*) .*/$1/;
173 $_ = ' ' . substr($_,length($tmp),9999);
178 # The first line was escaped with a final \ character. Every following line
179 # is to be appended to it (until we found a real \n not escaped). Note that
180 # the leading spaces of the continuation line are removed, so any space should
181 # be added before the former \ if needed.
184 local($read) = ''; # Concatenation of all the continuation lines found
186 s/^\s+//; # Remove leading spaces
187 if (s/\\\s*$//) { # Still followed by a continuation line
189 } else { # We've reached the end of the continuation