summaryrefslogtreecommitdiff
path: root/vos/config.pl
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2000-01-24 09:39:01 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2000-01-24 09:39:01 +0000
commitc287c78ddec0173e5310e046c5e6d595abe24407 (patch)
treecea947f553a00580c6d0c87932b212578fb9205d /vos/config.pl
parent43371e5a94ecbd01114258baefd24ec247812ad9 (diff)
downloadperl-c287c78ddec0173e5310e046c5e6d595abe24407.tar.gz
Create a tool for converting a config_h.SH into a VOS config.h.
p4raw-id: //depot/cfgperl@4872
Diffstat (limited to 'vos/config.pl')
-rw-r--r--vos/config.pl48
1 files changed, 48 insertions, 0 deletions
diff --git a/vos/config.pl b/vos/config.pl
new file mode 100644
index 0000000000..33629d7081
--- /dev/null
+++ b/vos/config.pl
@@ -0,0 +1,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: $!";
+}