Commit | Line | Data |
---|---|---|
2d7ad1b1 SH |
1 | #!perl -w |
2 | use strict; | |
8e232993 | 3 | use FindExt; |
2d7ad1b1 | 4 | |
80252599 GS |
5 | # take a semicolon separated path list and turn it into a quoted |
6 | # list of paths that Text::Parsewords will grok | |
7 | sub mungepath { | |
8 | my $p = shift; | |
9 | # remove leading/trailing semis/spaces | |
10 | $p =~ s/^[ ;]+//; | |
11 | $p =~ s/[ ;]+$//; | |
12 | $p =~ s/'/"/g; | |
13 | my @p = map { $_ = "\"$_\"" if /\s/ and !/^".*"$/; $_ } split /;/, $p; | |
14 | return join(' ', @p); | |
15 | } | |
16 | ||
7a958ec3 BS |
17 | # generate an array of option strings from command-line args |
18 | # or an option file | |
19 | # -- added by BKS, 10-17-1999 to fix command-line overflow problems | |
20 | sub loadopts { | |
21 | if ($ARGV[0] =~ /--cfgsh-option-file/) { | |
22 | shift @ARGV; | |
23 | my $optfile = shift @ARGV; | |
2d7ad1b1 | 24 | local (*OPTF); |
1ae6ead9 | 25 | open OPTF, '<', $optfile or die "Can't open $optfile: $!\n"; |
7a958ec3 BS |
26 | my @opts; |
27 | chomp(my $line = <OPTF>); | |
28 | my @vars = split(/\t+~\t+/, $line); | |
29 | for (@vars) { | |
30 | push(@opts, $_) unless (/^\s*$/); | |
31 | } | |
32 | close OPTF; | |
33 | return \@opts; | |
34 | } | |
35 | else { | |
36 | return \@ARGV; | |
37 | } | |
38 | } | |
39 | ||
137443ea | 40 | my %opt; |
8e232993 | 41 | |
7a958ec3 BS |
42 | my $optref = loadopts(); |
43 | while (@{$optref} && $optref->[0] =~ /^([\w_]+)=(.*)$/) { | |
44 | $opt{$1}=$2; | |
45 | shift(@{$optref}); | |
46 | } | |
7bac28a0 | 47 | |
338584c0 | 48 | FindExt::scan_ext("../cpan"); |
d284e2f9 | 49 | FindExt::scan_ext("../dist"); |
ca58f2ae | 50 | FindExt::scan_ext("../ext"); |
6f062036 | 51 | FindExt::set_static_extensions(split ' ', $opt{static_ext}); |
1076f1fd | 52 | |
6f062036 SH |
53 | $opt{nonxs_ext} = join(' ',FindExt::nonxs_ext()) || ' '; |
54 | $opt{static_ext} = join(' ',FindExt::static_ext()) || ' '; | |
55 | $opt{dynamic_ext} = join(' ',FindExt::dynamic_ext()) || ' '; | |
56 | $opt{extensions} = join(' ',FindExt::extensions()) || ' '; | |
57 | $opt{known_extensions} = join(' ',FindExt::known_extensions()) || ' '; | |
8e232993 | 58 | |
52b0428e GS |
59 | my $pl_h = '../patchlevel.h'; |
60 | ||
52b0428e | 61 | if (-e $pl_h) { |
1ae6ead9 | 62 | open PL, "<", $pl_h or die "Can't open $pl_h: $!"; |
52b0428e GS |
63 | while (<PL>) { |
64 | if (/^#\s*define\s+(PERL_\w+)\s+([\d.]+)/) { | |
65 | $opt{$1} = $2; | |
66 | } | |
67 | } | |
68 | close PL; | |
69 | } | |
e1f15930 | 70 | else { |
273cf8d1 | 71 | die "Can't find $pl_h: $!"; |
c90c0ff4 | 72 | } |
a9277f44 SH |
73 | |
74 | my $patch_file = '../.patch'; | |
75 | ||
76 | if (-e $patch_file) { | |
77 | open my $fh, "<", $patch_file or die "Can't open $patch_file: $!"; | |
78 | chomp($opt{PERL_PATCHLEVEL} = <$fh>); | |
79 | close $fh; | |
80 | } | |
81 | ||
6f062036 SH |
82 | $opt{version} = "$opt{PERL_REVISION}.$opt{PERL_VERSION}.$opt{PERL_SUBVERSION}"; |
83 | $opt{version_patchlevel_string} = "version $opt{PERL_VERSION} subversion $opt{PERL_SUBVERSION}"; | |
84 | $opt{version_patchlevel_string} .= " patch $opt{PERL_PATCHLEVEL}" if exists $opt{PERL_PATCHLEVEL}; | |
52b0428e | 85 | |
d51fa99c | 86 | my $ver = `ver 2>nul`; |
43b354f1 | 87 | $opt{osvers} = $ver =~ /\b(\d+(?:\.\d+)+)\b/ ? $1 : '4.0'; |
dbd14d13 | 88 | |
2018b347 | 89 | if (exists $opt{cc}) { |
378eeda7 | 90 | # cl version detection borrowed from Test::Smoke's configsmoke.pl |
a48cc4c4 | 91 | if ($opt{cc} =~ /\b(?:cl|icl)/) { #MSVC can come as clarm.exe, icl=Intel C |
43b354f1 SH |
92 | my $output = `$opt{cc} 2>&1`; |
93 | $opt{ccversion} = $output =~ /\b(\d+(?:\.\d+)+)\b/ ? $1 : '?'; | |
2018b347 | 94 | } |
e08b586c S |
95 | elsif ($opt{cc} =~ /\bgcc\b/) { |
96 | chomp($opt{gccversion} = `$opt{cc} -dumpversion`); | |
2018b347 SH |
97 | } |
98 | } | |
99 | ||
6f062036 | 100 | $opt{cf_by} = $ENV{USERNAME} unless $opt{cf_by}; |
19253ae6 DD |
101 | if (!$opt{cf_email}) { |
102 | my $computername = eval{(gethostbyname('localhost'))[0]}; | |
103 | # gethostbyname might not be implemented in miniperl | |
104 | $computername = $ENV{COMPUTERNAME} if $@; | |
105 | $opt{cf_email} = $opt{cf_by} . '@' . $computername; | |
106 | } | |
6f062036 | 107 | $opt{usemymalloc} = 'y' if $opt{d_mymalloc} eq 'define'; |
d484a829 | 108 | |
80252599 GS |
109 | $opt{libpth} = mungepath($opt{libpth}) if exists $opt{libpth}; |
110 | $opt{incpath} = mungepath($opt{incpath}) if exists $opt{incpath}; | |
111 | ||
683f916d | 112 | my $int64; |
a48cc4c4 | 113 | if ($opt{cc} =~ /\b(?:cl|icl)/) { |
1f64ae15 | 114 | $int64 = '__int64'; |
1f64ae15 SH |
115 | } |
116 | elsif ($opt{cc} =~ /\bgcc\b/) { | |
117 | $int64 = 'long long'; | |
1f64ae15 SH |
118 | } |
119 | ||
120 | # set large files options | |
378eeda7 | 121 | if ($opt{uselargefiles} eq 'define') { |
f7e8b52a | 122 | $opt{lseeksize} = 8; |
1f64ae15 SH |
123 | $opt{lseektype} = $int64; |
124 | } | |
125 | else { | |
126 | $opt{lseeksize} = 4; | |
127 | $opt{lseektype} = 'long'; | |
128 | } | |
129 | ||
130 | # set 64-bit options | |
131 | if ($opt{WIN64} eq 'define') { | |
132 | $opt{d_atoll} = 'define'; | |
133 | $opt{d_strtoll} = 'define'; | |
134 | $opt{d_strtoull} = 'define'; | |
135 | $opt{ptrsize} = 8; | |
136 | $opt{sizesize} = 8; | |
137 | $opt{ssizetype} = $int64; | |
138 | $opt{st_ino_size} = 8; | |
139 | } | |
140 | else { | |
141 | $opt{d_atoll} = 'undef'; | |
142 | $opt{d_strtoll} = 'undef'; | |
143 | $opt{d_strtoull} = 'undef'; | |
144 | $opt{ptrsize} = 4; | |
145 | $opt{sizesize} = 4; | |
146 | $opt{ssizetype} = 'int'; | |
147 | $opt{st_ino_size} = 4; | |
148 | } | |
890b5089 SH |
149 | |
150 | # set 64-bit-int options | |
1f64ae15 | 151 | if ($opt{use64bitint} eq 'define') { |
890b5089 SH |
152 | if ($opt{uselongdouble} eq 'define') { |
153 | $opt{d_nv_preserves_uv} = 'define'; | |
154 | $opt{nv_preserves_uv_bits} = 64; | |
155 | } | |
156 | else { | |
157 | $opt{d_nv_preserves_uv} = 'undef'; | |
158 | $opt{nv_preserves_uv_bits} = 53; | |
159 | } | |
683f916d | 160 | $opt{ivdformat} = qq{"I64d"}; |
1f64ae15 SH |
161 | $opt{ivsize} = 8; |
162 | $opt{ivtype} = $int64; | |
683f916d SH |
163 | $opt{sPRIXU64} = qq{"I64X"}; |
164 | $opt{sPRId64} = qq{"I64d"}; | |
165 | $opt{sPRIi64} = qq{"I64i"}; | |
166 | $opt{sPRIo64} = qq{"I64o"}; | |
167 | $opt{sPRIu64} = qq{"I64u"}; | |
168 | $opt{sPRIx64} = qq{"I64x"}; | |
169 | $opt{uvXUformat} = qq{"I64X"}; | |
170 | $opt{uvoformat} = qq{"I64o"}; | |
1f64ae15 SH |
171 | $opt{uvsize} = 8; |
172 | $opt{uvtype} = qq{unsigned $int64}; | |
683f916d SH |
173 | $opt{uvuformat} = qq{"I64u"}; |
174 | $opt{uvxformat} = qq{"I64x"}; | |
1f64ae15 SH |
175 | } |
176 | else { | |
177 | $opt{d_nv_preserves_uv} = 'define'; | |
178 | $opt{ivdformat} = '"ld"'; | |
179 | $opt{ivsize} = 4; | |
180 | $opt{ivtype} = 'long'; | |
181 | $opt{nv_preserves_uv_bits} = 32; | |
182 | $opt{sPRIXU64} = '"lX"'; | |
183 | $opt{sPRId64} = '"ld"'; | |
184 | $opt{sPRIi64} = '"li"'; | |
185 | $opt{sPRIo64} = '"lo"'; | |
186 | $opt{sPRIu64} = '"lu"'; | |
187 | $opt{sPRIx64} = '"lx"'; | |
188 | $opt{uvXUformat} = '"lX"'; | |
189 | $opt{uvoformat} = '"lo"'; | |
190 | $opt{uvsize} = 4; | |
191 | $opt{uvtype} = 'unsigned long'; | |
192 | $opt{uvuformat} = '"lu"'; | |
193 | $opt{uvxformat} = '"lx"'; | |
4a9d6100 GS |
194 | } |
195 | ||
c0bf9074 TC |
196 | unless ($opt{cc} =~ /\bcl/) { |
197 | if ($opt{WIN64} eq 'define') { | |
198 | $opt{longdblsize} = 16; | |
199 | $opt{longdblinfbytes} = '0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'; | |
200 | $opt{longdblnanbytes} = '0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'; | |
201 | } | |
202 | else { | |
203 | $opt{longdblsize} = 12; | |
204 | $opt{longdblinfbytes} = '0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00'; | |
205 | $opt{longdblnanbytes} = '0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x00, 0x00'; | |
206 | } | |
207 | } | |
208 | ||
890b5089 SH |
209 | # set long double options |
210 | if ($opt{uselongdouble} eq 'define') { | |
211 | $opt{d_Gconvert} = 'sprintf((b),"%.*""Lg",(n),(x))'; | |
212 | $opt{d_PRIEUldbl} = 'define'; | |
213 | $opt{d_PRIFUldbl} = 'define'; | |
214 | $opt{d_PRIGUldbl} = 'define'; | |
215 | $opt{d_frexpl} = 'define'; | |
216 | $opt{d_isnanl} = 'define'; | |
217 | $opt{d_modfl} = 'define'; | |
218 | $opt{d_modflproto} = 'define'; | |
219 | $opt{d_sqrtl} = 'define'; | |
220 | $opt{d_strtold} = 'define'; | |
221 | $opt{d_PRIeldbl} = 'define'; | |
222 | $opt{d_PRIfldbl} = 'define'; | |
223 | $opt{d_PRIgldbl} = 'define'; | |
224 | $opt{d_SCNfldbl} = 'define'; | |
c0bf9074 | 225 | $opt{nvsize} = $opt{longdblsize}; |
890b5089 SH |
226 | $opt{nvtype} = 'long double'; |
227 | $opt{nv_overflows_integers_at} = '256.0*256.0*256.0*256.0*256.0*256.0*256.0*2.0*2.0*2.0*2.0*2.0*2.0*2.0*2.0'; | |
228 | $opt{nvEUformat} = '"LE"'; | |
229 | $opt{nvFUformat} = '"LF"'; | |
230 | $opt{nvGUformat} = '"LG"'; | |
231 | $opt{nveformat} = '"Le"'; | |
232 | $opt{nvfformat} = '"Lf"'; | |
233 | $opt{nvgformat} = '"Lg"'; | |
c0bf9074 TC |
234 | $opt{longdblkind} = 3; |
235 | $opt{longdblmantbits} = 64; | |
890b5089 SH |
236 | } |
237 | else { | |
238 | $opt{d_Gconvert} = 'sprintf((b),"%.*g",(n),(x))'; | |
239 | $opt{d_PRIEUldbl} = 'undef'; | |
240 | $opt{d_PRIFUldbl} = 'undef'; | |
241 | $opt{d_PRIGUldbl} = 'undef'; | |
242 | $opt{d_frexpl} = 'undef'; | |
243 | $opt{d_isnanl} = 'undef'; | |
244 | $opt{d_modfl} = 'undef'; | |
245 | $opt{d_modflproto} = 'undef'; | |
246 | $opt{d_sqrtl} = 'undef'; | |
247 | $opt{d_strtold} = 'undef'; | |
248 | $opt{d_PRIeldbl} = 'undef'; | |
249 | $opt{d_PRIfldbl} = 'undef'; | |
250 | $opt{d_PRIgldbl} = 'undef'; | |
251 | $opt{d_SCNfldbl} = 'undef'; | |
252 | $opt{nvsize} = 8; | |
253 | $opt{nvtype} = 'double'; | |
254 | $opt{nv_overflows_integers_at} = '256.0*256.0*256.0*256.0*256.0*256.0*2.0*2.0*2.0*2.0*2.0'; | |
255 | $opt{nvEUformat} = '"E"'; | |
256 | $opt{nvFUformat} = '"F"'; | |
257 | $opt{nvGUformat} = '"G"'; | |
258 | $opt{nveformat} = '"e"'; | |
259 | $opt{nvfformat} = '"f"'; | |
260 | $opt{nvgformat} = '"g"'; | |
261 | } | |
262 | ||
049aaf37 | 263 | # change the s{GM|LOCAL}TIME_{min|max} for VS2005 (aka VC 8) and |
4b7e285e JD |
264 | # VS2008 (aka VC 9) or higher (presuming that later versions will have |
265 | # at least the range of that). | |
58ff4bd0 | 266 | if ($opt{cc} =~ /\bcl/ and $opt{ccversion} =~ /^(\d+)/) { |
4b7e285e | 267 | my $ccversion = $1; |
92e71c91 | 268 | if ($ccversion >= 14) { |
4b7e285e | 269 | $opt{sGMTIME_max} = 32535291599; |
049aaf37 | 270 | $opt{sLOCALTIME_max} = 32535244799; |
4b7e285e | 271 | } |
43b354f1 | 272 | if ($ccversion < 13) { #VC6 |
a9e3f359 DD |
273 | $opt{ar} ='lib'; |
274 | } | |
1f664ef5 SH |
275 | if ($ccversion >= 19) { # VC14 |
276 | $opt{stdio_base} = 'PERLIO_FILE_base(fp)'; | |
277 | $opt{stdio_bufsiz} = '(PERLIO_FILE_cnt(fp) + PERLIO_FILE_ptr(fp) - PERLIO_FILE_base(fp))'; | |
278 | $opt{stdio_cnt} = 'PERLIO_FILE_cnt(fp)'; | |
279 | $opt{stdio_ptr} = 'PERLIO_FILE_ptr(fp)'; | |
280 | $opt{i_stdbool} = 'define'; | |
281 | } | |
4b7e285e | 282 | } |
a48cc4c4 DD |
283 | #find out which MSVC this ICC is using |
284 | elsif ($opt{cc} =~ /\bicl/) { | |
43b354f1 SH |
285 | my $output = `cl 2>&1`; |
286 | my $num_ver = $output =~ /\b(\d+(?:\.\d+)+)\b/ ? $1 : '?'; | |
287 | if ($num_ver =~ /^(\d+)/ && $1 >= 14) { | |
a48cc4c4 DD |
288 | $opt{sGMTIME_max} = 32535291599; |
289 | $opt{sLOCALTIME_max} = 32535244799; | |
290 | } | |
1f664ef5 SH |
291 | if ($num_ver =~ /^(\d+)/ && $1 >= 19) { # VC14 |
292 | $opt{stdio_base} = 'PERLIO_FILE_base(fp)'; | |
293 | $opt{stdio_bufsiz} = '(PERLIO_FILE_cnt(fp) + PERLIO_FILE_ptr(fp) - PERLIO_FILE_base(fp))'; | |
294 | $opt{stdio_cnt} = 'PERLIO_FILE_cnt(fp)'; | |
295 | $opt{stdio_ptr} = 'PERLIO_FILE_ptr(fp)'; | |
296 | $opt{i_stdbool} = 'define'; | |
297 | } | |
a48cc4c4 DD |
298 | $opt{ar} ='xilib'; |
299 | } | |
4b7e285e | 300 | |
1fd1213a | 301 | if ($opt{useithreads} eq 'define' && $opt{ccflags} =~ /-DPERL_IMPLICIT_SYS\b/) { |
27bdbd07 SH |
302 | $opt{d_pseudofork} = 'define'; |
303 | } | |
304 | ||
f9bbfafd SH |
305 | if ($opt{usecplusplus} eq 'define') { |
306 | $opt{d_cplusplus} = 'define'; | |
307 | $opt{extern_C} = 'extern "C"'; | |
308 | } | |
309 | ||
a9e3f359 DD |
310 | #if the fields above are defined, they override the defaults in the premade |
311 | #config file | |
7a958ec3 | 312 | while (<>) { |
2d7ad1b1 | 313 | s/~([\w_]+)~/exists $opt{$1} ? $opt{$1} : ''/eg; |
7a958ec3 BS |
314 | if (/^([\w_]+)=(.*)$/) { |
315 | my($k,$v) = ($1,$2); | |
316 | # this depends on cf_time being empty in the template (or we'll | |
317 | # get a loop) | |
318 | if ($k eq 'cf_time') { | |
319 | $_ = "$k='" . localtime(time) . "'\n" if $v =~ /^\s*'\s*'/; | |
320 | } | |
321 | elsif (exists $opt{$k}) { | |
322 | $_ = "$k='$opt{$k}'\n"; | |
323 | } | |
dc050285 | 324 | } |
7a958ec3 BS |
325 | print; |
326 | } |