1 # This file fills in a config_h.SH template based on the data
2 # of the file config.def and outputs a config.h.
4 # Written January 24, 2000 by Jarkko Hietaniemi [jhi@iki.fi]
5 # Modified February 2, 2000 by Paul Green [Paul_Green@stratus.com]
6 # Modified October 23, 2000 by Paul Green [Paul_Green@stratus.com]
9 # Read in the definitions file
12 if (open(CONFIG_DEF, "config.def")) {
13 while (<CONFIG_DEF>) {
14 if (/^([^=]+)='(.*)'$/) {
15 my ($var, $val) = ($1, $2);
19 warn "config.def: $.: illegal line: $_";
23 die "$0: Cannot open config.def: $!";
29 # Open the template input file.
33 unless (open(CONFIG_SH, "../config_h.SH")) {
34 die "$0: Cannot open ../config_h.SH: $!";
38 # Open the output file.
41 unless (open(CONFIG_H, ">config.h.new")) {
42 die "$0: Cannot open config.h.new for output: $!";
46 # Skip lines before the first !GROK!THIS!
50 $lineno = $lineno + 1;
51 last if /^sed <<!GROK!THIS!/;
55 # Process the rest of the file, a line at a time.
56 # Stop when the next !GROK!THIS! is found.
60 $lineno = $lineno + 1;
61 last if /^!GROK!THIS!/;
63 # The definition of SITEARCH and SITEARCH_EXP has to be commented-out.
64 # The easiest way to do this is to special-case it here.
66 if (/^#define SITEARCH*/) {
70 # The case of #$d_foo at the BOL has to be handled carefully.
71 # If $d_foo is "undef", then we must first comment out the entire line.
74 if (exists $define{$1}) {
76 s@^#(\$\w+)@("$define{$1}" eq "undef") ?
77 "/*#define":"#$define{$1}"@e;
81 # There could be multiple $variables on this line.
82 # Find and replace all of them.
85 s/(\$\w+)/(exists $define{$1}) ?
86 (($used{$1}=1),$define{$1}) :
87 ((print "Undefined keyword $1 on line $lineno\n"),$1)/ge;
91 # There are no variables, just print the line out.
98 unless (close (CONFIG_H)) {
99 die "$0: Cannot close config.h.new: $!";
104 while (($key,$value) = each %used) {
106 print "Unused keyword definition: $key\n";