Commit | Line | Data |
c287c78d |
1 | # This file fills in a config_h.SH template based on the data |
2 | # of the file config.def and outputs a config.sh. |
3 | |
4 | if (open(CONFIG_DEF, "config.def")) { |
5 | while (<CONFIG_DEF>) { |
6 | if (/^([^=]+)='(.+)'$/) { |
7 | my ($var, $val) = ($1, $2); |
8 | $define{$var} = $val; |
9 | } else { |
10 | warn "config.def: $.: illegal line: $_"; |
11 | } |
12 | } |
13 | } else { |
14 | die "$0: Cannot open config.def: $!"; |
15 | } |
16 | |
17 | if (open(CONFIG_SH, "config_h.SH_orig")) { |
18 | while (<CONFIG_SH>) { |
19 | last if /^sed <<!GROK!THIS!/; |
20 | } |
21 | while (<CONFIG_SH>) { |
22 | last if /^!GROK!THIS!/; |
23 | s/\\\$Id:/\$Id:/; |
24 | s/\$package/perl5/; |
25 | s/\$cf_time/localtime/e; |
26 | s/\$myuname/$define{OSNAME}/; |
27 | s/\$seedfunc/$define{seedfunc}/; |
28 | if (/^#\$\w+\s+(\w+)/) { |
29 | if (exists $define{$1}) { |
30 | if ($define{$1} eq 'define') { |
31 | print "#define $1\t/**/\n"; |
32 | } else { |
33 | print "#define $1 $define{$1}\n"; |
34 | } |
35 | } else { |
36 | print "/*#define $1\t/**/\n"; |
37 | } |
38 | } elsif (/^#define\s+(\S+)/) { |
39 | print "#define $1 $define{$1}\n"; |
40 | } elsif (s/\$cpp_stuff/$define{cpp_stuff}/g) { |
41 | print; |
42 | } else { |
43 | print; |
44 | } |
45 | } |
46 | } else { |
47 | die "$0: Cannot open config_h.SH_orig: $!"; |
48 | } |