This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
integrate cfgperl contents into mainline; merge conflicts
[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
10609e9a
GS
20$opt{VERSION} = $];
21$opt{INST_VER} =~ s|~VERSION~|$]|g;
e1f15930
GS
22if ($] =~ /^(\d+)\.(\d\d\d)?(\d\d)?$/) { # should always be true
23 $opt{PERL_REVISION} = $1;
24 $opt{PERL_VERSION} = int($2 || 0);
25 $opt{PERL_SUBVERSION} = $3 || '00';
26}
27else {
28 die "Can't parse perl version ($])";
c90c0ff4
PP
29}
30
d484a829
GS
31$opt{'cf_by'} = $ENV{USERNAME} unless $opt{'cf_by'};
32$opt{'cf_email'} = $opt{'cf_by'} . '@' . (gethostbyname('localhost'))[0]
33 unless $opt{'cf_email'};
852c2e52 34$opt{'usemymalloc'} = 'y' if $opt{'d_mymalloc'} eq 'define';
d484a829 35
80252599
GS
36$opt{libpth} = mungepath($opt{libpth}) if exists $opt{libpth};
37$opt{incpath} = mungepath($opt{incpath}) if exists $opt{incpath};
38
137443ea
PP
39while (<>)
40 {
41 s/~([\w_]+)~/$opt{$1}/g;
dc050285 42 if (/^([\w_]+)=(.*)$/) {
691c0cce 43 my($k,$v) = ($1,$2);
dc050285 44 # this depends on cf_time being empty in the template (or we'll get a loop)
691c0cce
GS
45 if ($k eq 'cf_time') {
46 $_ = "$k='" . localtime(time) . "'\n" if $v =~ /^\s*'\s*'/;
dc050285 47 }
691c0cce
GS
48 elsif (exists $opt{$k}) {
49 $_ = "$k='$opt{$k}'\n";
dc050285
GS
50 }
51 }
137443ea
PP
52 print;
53 }
54