This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Bring win32/config.* into line with win32/config_H.*
[perl5.git] / win32 / config_sh.PL
CommitLineData
8e232993 1use FindExt;
80252599
GS
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
BS
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
NIS
37FindExt::scan_ext("../ext");
38
137443ea 39my %opt;
8e232993 40
7a958ec3
BS
41my $optref = loadopts();
42while (@{$optref} && $optref->[0] =~ /^([\w_]+)=(.*)$/) {
43 $opt{$1}=$2;
44 shift(@{$optref});
45}
7bac28a0 46
1076f1fd
NIS
47my @dynamic = FindExt::dynamic_extensions();
48my @noxs = FindExt::noxs_extensions();
49my @known = sort(@dynamic,split(/\s+/,$opt{'staticext'}),@noxs);
50$opt{'known_extensions'} = join(' ',@known);
51
3db8f154
MB
52@dynamic = grep(!/Thread/,@dynamic);
53@known = grep(!/Thread/,@dynamic);
1076f1fd
NIS
54
55$opt{'dynamic_ext'} = join(' ',@dynamic);
56$opt{'nonxs_ext'} = join(' ',@noxs);
57
58$opt{'extensions'} = join(' ',@known);
8e232993 59
52b0428e
GS
60my $pl_h = '../patchlevel.h';
61
52b0428e
GS
62if (-e $pl_h) {
63 open PL, "<$pl_h" or die "Can't open $pl_h: $!";
64 while (<PL>) {
65 if (/^#\s*define\s+(PERL_\w+)\s+([\d.]+)/) {
66 $opt{$1} = $2;
67 }
68 }
69 close PL;
70}
e1f15930 71else {
273cf8d1 72 die "Can't find $pl_h: $!";
c90c0ff4 73}
273cf8d1
GS
74$opt{VERSION} = "$opt{PERL_REVISION}.$opt{PERL_VERSION}.$opt{PERL_SUBVERSION}";
75$opt{INST_VER} =~ s|~VERSION~|$opt{VERSION}|g;
fd390a00
JH
76$opt{'version_patchlevel_string'} = "version $opt{PERL_VERSION} subversion $opt{PERL_SUBVERSION}";
77$opt{'version_patchlevel_string'} .= " patchlevel $opt{PERL_PATCHLEVEL}" if exists $opt{PERL_PATCHLEVEL};
52b0428e 78
d484a829
GS
79$opt{'cf_by'} = $ENV{USERNAME} unless $opt{'cf_by'};
80$opt{'cf_email'} = $opt{'cf_by'} . '@' . (gethostbyname('localhost'))[0]
81 unless $opt{'cf_email'};
852c2e52 82$opt{'usemymalloc'} = 'y' if $opt{'d_mymalloc'} eq 'define';
d484a829 83
80252599
GS
84$opt{libpth} = mungepath($opt{libpth}) if exists $opt{libpth};
85$opt{incpath} = mungepath($opt{incpath}) if exists $opt{incpath};
86
108967c2
GS
87# some functions are not available on Win9x
88if (defined(&Win32::IsWin95) && Win32::IsWin95()) {
89 $opt{d_flock} = 'undef';
90 $opt{d_link} = 'undef';
91}
92
4a9d6100
GS
93if ($opt{uselargefiles} ne 'define') {
94 $opt{lseeksize} = 4;
95 $opt{lseektype} = 'off_t';
96}
97
7a958ec3
BS
98while (<>) {
99 s/~([\w_]+)~/$opt{$1}/g;
100 if (/^([\w_]+)=(.*)$/) {
101 my($k,$v) = ($1,$2);
102 # this depends on cf_time being empty in the template (or we'll
103 # get a loop)
104 if ($k eq 'cf_time') {
105 $_ = "$k='" . localtime(time) . "'\n" if $v =~ /^\s*'\s*'/;
106 }
107 elsif (exists $opt{$k}) {
108 $_ = "$k='$opt{$k}'\n";
109 }
dc050285 110 }
7a958ec3
BS
111 print;
112}