Integrate mainline (new test scheme now ok on Linux).
[p5sagit/p5-mst-13.2.git] / win32 / config_sh.PL
CommitLineData
8e232993 1use FindExt;
80252599 2# take a semicolon separated path list and turn it into a quoted
3# list of paths that Text::Parsewords will grok
4sub mungepath {
5 my $p = shift;
6 # remove leading/trailing semis/spaces
7 $p =~ s/^[ ;]+//;
8 $p =~ s/[ ;]+$//;
9 $p =~ s/'/"/g;
10 my @p = map { $_ = "\"$_\"" if /\s/ and !/^".*"$/; $_ } split /;/, $p;
11 return join(' ', @p);
12}
13
7a958ec3 14# generate an array of option strings from command-line args
15# or an option file
16# -- added by BKS, 10-17-1999 to fix command-line overflow problems
17sub loadopts {
18 if ($ARGV[0] =~ /--cfgsh-option-file/) {
19 shift @ARGV;
20 my $optfile = shift @ARGV;
21 local (*F);
22 open OPTF, $optfile or die "Can't open $optfile: $!\n";
23 my @opts;
24 chomp(my $line = <OPTF>);
25 my @vars = split(/\t+~\t+/, $line);
26 for (@vars) {
27 push(@opts, $_) unless (/^\s*$/);
28 }
29 close OPTF;
30 return \@opts;
31 }
32 else {
33 return \@ARGV;
34 }
35}
36
8e232993 37FindExt::scan_ext("../ext");
38
137443ea 39my %opt;
8e232993 40
7a958ec3 41my $optref = loadopts();
42while (@{$optref} && $optref->[0] =~ /^([\w_]+)=(.*)$/) {
43 $opt{$1}=$2;
44 shift(@{$optref});
45}
7bac28a0 46
8e232993 47$opt{'dynamic_ext'} = join(' ',FindExt::dynamic_extensions());
48$opt{'nonxs_ext'} = join(' ',FindExt::noxs_extensions());
49
52b0428e 50my $pl_h = '../patchlevel.h';
51
52b0428e 52if (-e $pl_h) {
53 open PL, "<$pl_h" or die "Can't open $pl_h: $!";
54 while (<PL>) {
55 if (/^#\s*define\s+(PERL_\w+)\s+([\d.]+)/) {
56 $opt{$1} = $2;
57 }
58 }
59 close PL;
60}
e1f15930 61else {
273cf8d1 62 die "Can't find $pl_h: $!";
c90c0ff4 63}
273cf8d1 64$opt{VERSION} = "$opt{PERL_REVISION}.$opt{PERL_VERSION}.$opt{PERL_SUBVERSION}";
65$opt{INST_VER} =~ s|~VERSION~|$opt{VERSION}|g;
52b0428e 66
d484a829 67$opt{'cf_by'} = $ENV{USERNAME} unless $opt{'cf_by'};
68$opt{'cf_email'} = $opt{'cf_by'} . '@' . (gethostbyname('localhost'))[0]
69 unless $opt{'cf_email'};
852c2e52 70$opt{'usemymalloc'} = 'y' if $opt{'d_mymalloc'} eq 'define';
d484a829 71
80252599 72$opt{libpth} = mungepath($opt{libpth}) if exists $opt{libpth};
73$opt{incpath} = mungepath($opt{incpath}) if exists $opt{incpath};
74
7a958ec3 75while (<>) {
76 s/~([\w_]+)~/$opt{$1}/g;
77 if (/^([\w_]+)=(.*)$/) {
78 my($k,$v) = ($1,$2);
79 # this depends on cf_time being empty in the template (or we'll
80 # get a loop)
81 if ($k eq 'cf_time') {
82 $_ = "$k='" . localtime(time) . "'\n" if $v =~ /^\s*'\s*'/;
83 }
84 elsif (exists $opt{$k}) {
85 $_ = "$k='$opt{$k}'\n";
86 }
dc050285 87 }
7a958ec3 88 print;
89}
137443ea 90