summaryrefslogtreecommitdiff
path: root/vos/config.pl
blob: 33629d7081eccee09e46dcb0bd7d2cbbd4b84ea0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# This file fills in a config_h.SH template based on the data
# of the file config.def and outputs a config.sh.

if (open(CONFIG_DEF, "config.def")) {
    while (<CONFIG_DEF>) {
	if (/^([^=]+)='(.+)'$/) {
	    my ($var, $val) = ($1, $2);
	    $define{$var} = $val;
	} else {
	    warn "config.def: $.: illegal line: $_";
	}
    }
} else {
    die "$0: Cannot open config.def: $!";
}

if (open(CONFIG_SH, "config_h.SH_orig")) {
    while (<CONFIG_SH>) {
	last if /^sed <<!GROK!THIS!/;
    }
    while (<CONFIG_SH>) {
	last if /^!GROK!THIS!/;
	s/\\\$Id:/\$Id:/;
	s/\$package/perl5/;
	s/\$cf_time/localtime/e;
	s/\$myuname/$define{OSNAME}/;
        s/\$seedfunc/$define{seedfunc}/;
	if (/^#\$\w+\s+(\w+)/) {
	    if (exists $define{$1}) {
		if ($define{$1} eq 'define') {
		    print "#define $1\t/**/\n";
		} else {
		    print "#define $1 $define{$1}\n";
		}
	    } else {
		print "/*#define $1\t/**/\n";
	    }
	} elsif (/^#define\s+(\S+)/) {
	    print "#define $1 $define{$1}\n";
	} elsif (s/\$cpp_stuff/$define{cpp_stuff}/g) { 
	    print;
	} else {
	    print;
	}
    }
} else {
    die "$0: Cannot open config_h.SH_orig: $!";
}