1 ;# $Id: depend.pl,v 3.0.1.3 1995/09/25 09:18:56 ram Exp $
3 ;# Copyright (c) 1991-1993, Raphael Manfredi
5 ;# You may redistribute only under the terms of the Artistic Licence,
6 ;# as specified in the README file that comes with the distribution.
7 ;# You may reuse parts of this distribution only within the terms of
8 ;# that same Artistic Licence; a copy of which may be found at the root
9 ;# of the source tree for dist 3.0.
11 ;# $Log: depend.pl,v $
12 ;# Revision 3.0.1.3 1995/09/25 09:18:56 ram
13 ;# patch59: new ?Y: directive to change unit layout
15 ;# Revision 3.0.1.2 1994/10/29 16:35:23 ram
16 ;# patch36: added various escapes in strings for perl5 support
18 ;# Revision 3.0.1.1 1993/10/16 13:54:35 ram
19 ;# patch12: added minimal support for ?P: lines (not ready yet)
21 ;# Revision 3.0 1993/08/18 12:10:21 ram
22 ;# Baseline for dist 3.0 netwide release.
24 ;# Metaconfig-dependent part of the dependency extraction.
26 # Process the ?W: lines
28 # Syntax is ?W:<shell symbols>:<C symbols>
29 local($active) = $_[0] =~ /^([^:]*):/; # Symbols to activate
30 local($look_symbols) = $_[0] =~ /:(.*)/; # When those are used
31 local(@syms) = split(/ /, $look_symbols); # Keep original spacing info
32 $active =~ s/\s+/\n/g; # One symbol per line
34 # Concatenate quoted strings, so saying something like 'two words' will
35 # be introduced as one single symbol "two words".
36 local(@symbols); # Concatenated symbols to look for
37 local($concat) = ''; # Concatenation buffer
42 push(@symbols, $concat . ' ' . $_);
45 push(@symbols, $_) unless $concat;
46 $concat .= ' ' . $_ if $concat;
50 # Now record symbols in master and wanted tables
52 $cmaster{$_} = undef; # Asks for look-up in C files
53 $cwanted{$_} = "$active" if $active; # Shell symbols to activate
57 # Process the ?INIT: lines
60 print INIT "?$unit:", $_; # Wanted only if unit is loaded
63 # Process the ?D: lines
66 s/^([A-Za-z_]+)=(.*)/\@if !$1\n%$1:$1=$2\n\@define $1\n\@end/
67 && ($hasdefault{$1}++, print INIT $_);
70 # Process the ?P: lines
73 local($csym); # C symbol(s) we're trying to look at
74 local($nosym); # List of symbol(s) which mustn't be wanted
75 local($cfile); # Name of file implementing csym (no .ext)
76 ($csym, $nosym, $cfile) = /([^()]+)\s*(\(.*\))\s*:\s*(\S+)/;
77 unless ($csym eq '' || $cfile eq '') {
78 # Add dependencies for each C symbol, of the form:
79 # -pick public <sym> <file> <notdef symbols list>
80 # and the file will be added to config.c whenever sym is wanted and
81 # none of the notdef symbols is wanted.
82 foreach $sym (split(' ', $csym)) {
83 $dependencies .= "\t-pick public $sym $cfile $nosym\n";
88 # Process the ?Y: lines
89 # Valid layouts are for now are: top, bottom, default.
92 # This routine relies on the $defined variable, a global variable set
93 # during the ?MAKE: processing, which lists all the defined symbols in
94 # the unit (the optional leading '+' for internal symbols has been removed
97 # The routine fills up a %Layout table, indexed by symbol, yielding the
98 # layout imposed to this unit. That table will then be used later on when
99 # we sort wanted symbols for the Makefile.
102 local($layout) = /^\s*(\w+)/;
103 $layout =~ tr/A-Z/a-z/; # Case is not significant for layouts
104 unless (defined $Lcmp{$layout}) {
105 warn "\"$file\", line $.: unknown layout directive '$layout'.\n";
108 foreach $sym (split(' ', $defined)) {
109 $Layout{$sym} = $Lcmp{$layout};
113 # Process the ?L: lines
114 # There should not be any '-l' in front of the library name
119 # Process the ?I: lines
124 # Write out line in file Extern.U. The information recorded there has the
125 # following prototypical format:
127 # If 'symbol' is wanted, then 'inet bsd' will be added to $libswanted.
130 local($target) = $defined; # By default, applies to defined symbols
131 $target = $1 if s/^(.*)://; # List is qualified "?L:target:symbols"
132 local(@target) = split(' ', $target);
134 foreach $key (@target) {
135 print EXTERN "?$key:$_\n"; # EXTERN file defined in xref.pl