This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[ID 19991104.005] modified hints file for UnixWare7 ( svr5)
[perl5.git] / win32 / config_sh.PL
CommitLineData
80252599
GS
1# take a semicolon separated path list and turn it into a quoted
2# list of paths that Text::Parsewords will grok
3sub mungepath {
4 my $p = shift;
5 # remove leading/trailing semis/spaces
6 $p =~ s/^[ ;]+//;
7 $p =~ s/[ ;]+$//;
8 $p =~ s/'/"/g;
9 my @p = map { $_ = "\"$_\"" if /\s/ and !/^".*"$/; $_ } split /;/, $p;
10 return join(' ', @p);
11}
12
137443ea
PP
13my %opt;
14while (@ARGV && $ARGV[0] =~ /^([\w_]+)=(.*)$/)
15 {
16 $opt{$1}=$2;
17 shift(@ARGV);
18 }
7bac28a0 19
52b0428e
GS
20my $pl_h = '../patchlevel.h';
21
10609e9a
GS
22$opt{VERSION} = $];
23$opt{INST_VER} =~ s|~VERSION~|$]|g;
52b0428e
GS
24if (-e $pl_h) {
25 open PL, "<$pl_h" or die "Can't open $pl_h: $!";
26 while (<PL>) {
27 if (/^#\s*define\s+(PERL_\w+)\s+([\d.]+)/) {
28 $opt{$1} = $2;
29 }
30 }
31 close PL;
32}
33elsif ($] =~ /^(\d+)\.(\d\d\d)?(\d\d)?$/) { # should always be true
e1f15930
GS
34 $opt{PERL_REVISION} = $1;
35 $opt{PERL_VERSION} = int($2 || 0);
52b0428e
GS
36 $opt{PERL_SUBVERSION} = $3;
37 $opt{PERL_APIVERSION} = $];
e1f15930
GS
38}
39else {
40 die "Can't parse perl version ($])";
c90c0ff4
PP
41}
42
52b0428e
GS
43$opt{PERL_SUBVERSION} ||= '00';
44
d484a829
GS
45$opt{'cf_by'} = $ENV{USERNAME} unless $opt{'cf_by'};
46$opt{'cf_email'} = $opt{'cf_by'} . '@' . (gethostbyname('localhost'))[0]
47 unless $opt{'cf_email'};
852c2e52 48$opt{'usemymalloc'} = 'y' if $opt{'d_mymalloc'} eq 'define';
d484a829 49
80252599
GS
50$opt{libpth} = mungepath($opt{libpth}) if exists $opt{libpth};
51$opt{incpath} = mungepath($opt{incpath}) if exists $opt{incpath};
52
137443ea
PP
53while (<>)
54 {
55 s/~([\w_]+)~/$opt{$1}/g;
dc050285 56 if (/^([\w_]+)=(.*)$/) {
691c0cce 57 my($k,$v) = ($1,$2);
dc050285 58 # this depends on cf_time being empty in the template (or we'll get a loop)
691c0cce
GS
59 if ($k eq 'cf_time') {
60 $_ = "$k='" . localtime(time) . "'\n" if $v =~ /^\s*'\s*'/;
dc050285 61 }
691c0cce
GS
62 elsif (exists $opt{$k}) {
63 $_ = "$k='$opt{$k}'\n";
dc050285
GS
64 }
65 }
137443ea
PP
66 print;
67 }
68