Commit | Line | Data |
8e232993 |
1 | use FindExt; |
80252599 |
2 | # take a semicolon separated path list and turn it into a quoted |
3 | # list of paths that Text::Parsewords will grok |
4 | sub 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 |
17 | sub 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 | |
137443ea |
37 | my %opt; |
8e232993 |
38 | |
7a958ec3 |
39 | my $optref = loadopts(); |
40 | while (@{$optref} && $optref->[0] =~ /^([\w_]+)=(.*)$/) { |
41 | $opt{$1}=$2; |
42 | shift(@{$optref}); |
43 | } |
7bac28a0 |
44 | |
ca58f2ae |
45 | FindExt::scan_ext("../ext"); |
78ff2d7b |
46 | FindExt::scan_ext("ext") if -d 'ext'; # also look in win32/ext/ if it exists |
ca58f2ae |
47 | FindExt::set_static_extensions(split ' ', $opt{'static_ext'}); |
1076f1fd |
48 | |
ca58f2ae |
49 | $opt{'nonxs_ext'} = join(' ',FindExt::nonxs_ext()) || ' '; |
50 | $opt{'static_ext'} = join(' ',FindExt::static_ext()) || ' '; |
47f9f84c |
51 | $opt{'dynamic_ext'} = join(' ',FindExt::dynamic_ext()) || ' '; |
52 | $opt{'extensions'} = join(' ',FindExt::extensions()) || ' '; |
ca58f2ae |
53 | $opt{'known_extensions'} = join(' ',FindExt::known_extensions()) || ' '; |
8e232993 |
54 | |
52b0428e |
55 | my $pl_h = '../patchlevel.h'; |
56 | |
52b0428e |
57 | if (-e $pl_h) { |
58 | open PL, "<$pl_h" or die "Can't open $pl_h: $!"; |
59 | while (<PL>) { |
60 | if (/^#\s*define\s+(PERL_\w+)\s+([\d.]+)/) { |
61 | $opt{$1} = $2; |
62 | } |
63 | } |
64 | close PL; |
65 | } |
e1f15930 |
66 | else { |
273cf8d1 |
67 | die "Can't find $pl_h: $!"; |
c90c0ff4 |
68 | } |
a9277f44 |
69 | |
70 | my $patch_file = '../.patch'; |
71 | |
72 | if (-e $patch_file) { |
73 | open my $fh, "<", $patch_file or die "Can't open $patch_file: $!"; |
74 | chomp($opt{PERL_PATCHLEVEL} = <$fh>); |
75 | close $fh; |
76 | } |
77 | |
273cf8d1 |
78 | $opt{VERSION} = "$opt{PERL_REVISION}.$opt{PERL_VERSION}.$opt{PERL_SUBVERSION}"; |
79 | $opt{INST_VER} =~ s|~VERSION~|$opt{VERSION}|g; |
fd390a00 |
80 | $opt{'version_patchlevel_string'} = "version $opt{PERL_VERSION} subversion $opt{PERL_SUBVERSION}"; |
79a3ac15 |
81 | $opt{'version_patchlevel_string'} .= " patch $opt{PERL_PATCHLEVEL}" if exists $opt{PERL_PATCHLEVEL}; |
52b0428e |
82 | |
d51fa99c |
83 | my $ver = `ver 2>nul`; |
84 | if ($ver =~ /Version (\d+\.\d+)/) { |
85 | $opt{'osvers'} = $1; |
86 | } |
87 | else { |
88 | $opt{'osvers'} = '4.0'; |
89 | } |
dbd14d13 |
90 | |
2018b347 |
91 | if (exists $opt{cc}) { |
92 | # cl and bcc32 version detection borrowed from Test::Smoke's configsmoke.pl |
93 | if ($opt{cc} eq 'cl') { |
94 | my $output = `cl --version 2>&1`; |
95 | $opt{ccversion} = $output =~ /^.*Version\s+([\d.]+)/ ? $1 : '?'; |
96 | } |
97 | elsif ($opt{cc} eq 'bcc32') { |
98 | my $output = `bcc32 --version 2>&1`; |
645ff3cb |
99 | $opt{ccversion} = $output =~ /([\d.]+)/ ? $1 : '?'; |
2018b347 |
100 | } |
101 | elsif ($opt{cc} eq 'gcc') { |
102 | chomp($opt{gccversion} = `gcc -dumpversion`); |
103 | } |
104 | } |
105 | |
d484a829 |
106 | $opt{'cf_by'} = $ENV{USERNAME} unless $opt{'cf_by'}; |
107 | $opt{'cf_email'} = $opt{'cf_by'} . '@' . (gethostbyname('localhost'))[0] |
108 | unless $opt{'cf_email'}; |
852c2e52 |
109 | $opt{'usemymalloc'} = 'y' if $opt{'d_mymalloc'} eq 'define'; |
d484a829 |
110 | |
80252599 |
111 | $opt{libpth} = mungepath($opt{libpth}) if exists $opt{libpth}; |
112 | $opt{incpath} = mungepath($opt{incpath}) if exists $opt{incpath}; |
113 | |
108967c2 |
114 | # some functions are not available on Win9x |
cf2f24a4 |
115 | unless (defined $ENV{SYSTEMROOT}) { # SystemRoot has been introduced by WinNT |
108967c2 |
116 | $opt{d_flock} = 'undef'; |
117 | $opt{d_link} = 'undef'; |
118 | } |
119 | |
f7e8b52a |
120 | # change the lseeksize and lseektype from their canned default values (which |
121 | # are set-up for a non-uselargefiles build) if we are building with |
122 | # uselargefiles. don't do this for bcc32: the code contains special handling |
123 | # for bcc32 and the lseeksize and lseektype should not be changed. |
124 | if ($opt{uselargefiles} eq 'define' and $opt{cc} ne 'bcc32') { |
125 | $opt{lseeksize} = 8; |
126 | if ($opt{cc} eq 'cl') { |
127 | $opt{lseektype} = '__int64'; |
128 | } |
129 | elsif ($opt{cc} eq 'gcc') { |
130 | $opt{lseektype} = 'long long'; |
131 | } |
4a9d6100 |
132 | } |
133 | |
4b7e285e |
134 | # change the sGMTIME_min and sGMTIME_max for VS2005 (aka VC 8) and |
135 | # VS2008 (aka VC 9) or higher (presuming that later versions will have |
136 | # at least the range of that). |
137 | if ($opt{cc} eq 'cl' and $opt{ccversion} =~ /^(\d+)/) { |
138 | my $ccversion = $1; |
139 | if ($ccversion == 14) { |
140 | $opt{sGMTIME_max} = 32535244799; |
73e6e416 |
141 | $opt{sLOCALTIME_max} = 32535244799; |
4b7e285e |
142 | } |
143 | elsif ($ccversion >= 15) { |
144 | $opt{sGMTIME_min} = -43200; |
145 | $opt{sGMTIME_max} = 32535291599; |
73e6e416 |
146 | $opt{sLOCALTIME_min} = -43200; |
147 | $opt{sLOCALTIME_max} = 32535291599; |
4b7e285e |
148 | } |
149 | } |
150 | |
1fd1213a |
151 | if ($opt{useithreads} eq 'define' && $opt{ccflags} =~ /-DPERL_IMPLICIT_SYS\b/) { |
27bdbd07 |
152 | $opt{d_pseudofork} = 'define'; |
153 | } |
154 | |
7a958ec3 |
155 | while (<>) { |
156 | s/~([\w_]+)~/$opt{$1}/g; |
157 | if (/^([\w_]+)=(.*)$/) { |
158 | my($k,$v) = ($1,$2); |
159 | # this depends on cf_time being empty in the template (or we'll |
160 | # get a loop) |
161 | if ($k eq 'cf_time') { |
162 | $_ = "$k='" . localtime(time) . "'\n" if $v =~ /^\s*'\s*'/; |
163 | } |
164 | elsif (exists $opt{$k}) { |
165 | $_ = "$k='$opt{$k}'\n"; |
166 | } |
dc050285 |
167 | } |
7a958ec3 |
168 | print; |
169 | } |