source: trunk/essentials/dev-lang/perl/win32/config_sh.PL

Last change on this file was 3181, checked in by bird, 18 years ago

perl 5.8.8

File size: 3.7 KB
Line 
1use FindExt;
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
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
37my %opt;
38
39my $optref = loadopts();
40while (@{$optref} && $optref->[0] =~ /^([\w_]+)=(.*)$/) {
41 $opt{$1}=$2;
42 shift(@{$optref});
43}
44
45FindExt::scan_ext("../ext");
46FindExt::set_static_extensions(split ' ', $opt{'static_ext'});
47
48my @dynamic_ext = FindExt::dynamic_ext();
49my @extensions = FindExt::extensions();
50if (!$opt{'use5005threads'} || $opt{'use5005threads'} eq 'undef')
51 {
52 @dynamic_ext = grep(!/Thread/,@dynamic_ext);
53 @extensions = grep(!/Thread/,@extensions);
54 }
55$opt{'nonxs_ext'} = join(' ',FindExt::nonxs_ext()) || ' ';
56$opt{'static_ext'} = join(' ',FindExt::static_ext()) || ' ';
57$opt{'dynamic_ext'} = join(' ',@dynamic_ext) || ' ';
58$opt{'extensions'} = join(' ',@extensions) || ' ';
59$opt{'known_extensions'} = join(' ',FindExt::known_extensions()) || ' ';
60
61my $pl_h = '../patchlevel.h';
62
63if (-e $pl_h) {
64 open PL, "<$pl_h" or die "Can't open $pl_h: $!";
65 while (<PL>) {
66 if (/^#\s*define\s+(PERL_\w+)\s+([\d.]+)/) {
67 $opt{$1} = $2;
68 }
69 }
70 close PL;
71}
72else {
73 die "Can't find $pl_h: $!";
74}
75$opt{VERSION} = "$opt{PERL_REVISION}.$opt{PERL_VERSION}.$opt{PERL_SUBVERSION}";
76$opt{INST_VER} =~ s|~VERSION~|$opt{VERSION}|g;
77$opt{'version_patchlevel_string'} = "version $opt{PERL_VERSION} subversion $opt{PERL_SUBVERSION}";
78$opt{'version_patchlevel_string'} .= " patchlevel $opt{PERL_PATCHLEVEL}" if exists $opt{PERL_PATCHLEVEL};
79
80$opt{'osvers'} = join '.', (Win32::GetOSVersion())[1,2];
81
82if (exists $opt{cc}) {
83 # cl and bcc32 version detection borrowed from Test::Smoke's configsmoke.pl
84 if ($opt{cc} eq 'cl') {
85 my $output = `cl --version 2>&1`;
86 $opt{ccversion} = $output =~ /^.*Version\s+([\d.]+)/ ? $1 : '?';
87 }
88 elsif ($opt{cc} eq 'bcc32') {
89 my $output = `bcc32 --version 2>&1`;
90 $opt{ccversion} = $output =~ /([\d.]+)/ ? $1 : '?';
91 }
92 elsif ($opt{cc} eq 'gcc') {
93 chomp($opt{gccversion} = `gcc -dumpversion`);
94 }
95}
96
97$opt{'cf_by'} = $ENV{USERNAME} unless $opt{'cf_by'};
98$opt{'cf_email'} = $opt{'cf_by'} . '@' . (gethostbyname('localhost'))[0]
99 unless $opt{'cf_email'};
100$opt{'usemymalloc'} = 'y' if $opt{'d_mymalloc'} eq 'define';
101
102$opt{libpth} = mungepath($opt{libpth}) if exists $opt{libpth};
103$opt{incpath} = mungepath($opt{incpath}) if exists $opt{incpath};
104
105# some functions are not available on Win9x
106if (defined(&Win32::IsWin95) && Win32::IsWin95()) {
107 $opt{d_flock} = 'undef';
108 $opt{d_link} = 'undef';
109}
110
111if ($opt{uselargefiles} ne 'define') {
112 $opt{lseeksize} = 4;
113 $opt{lseektype} = 'off_t';
114}
115
116while (<>) {
117 s/~([\w_]+)~/$opt{$1}/g;
118 if (/^([\w_]+)=(.*)$/) {
119 my($k,$v) = ($1,$2);
120 # this depends on cf_time being empty in the template (or we'll
121 # get a loop)
122 if ($k eq 'cf_time') {
123 $_ = "$k='" . localtime(time) . "'\n" if $v =~ /^\s*'\s*'/;
124 }
125 elsif (exists $opt{$k}) {
126 $_ = "$k='$opt{$k}'\n";
127 }
128 }
129 print;
130}
Note: See TracBrowser for help on using the repository browser.