5 # take a semicolon separated path list and turn it into a quoted
6 # list of paths that Text::Parsewords will grok
9 # remove leading/trailing semis/spaces
13 my @p = map { $_ = "\"$_\"" if /\s/ and !/^".*"$/; $_ } split /;/, $p;
17 # generate an array of option strings from command-line args
19 # -- added by BKS, 10-17-1999 to fix command-line overflow problems
21 if ($ARGV[0] =~ /--cfgsh-option-file/) {
23 my $optfile = shift @ARGV;
25 open OPTF, '<', $optfile or die "Can't open $optfile: $!\n";
27 chomp(my $line = <OPTF>);
28 my @vars = split(/\t+~\t+/, $line);
30 push(@opts, $_) unless (/^\s*$/);
42 my $optref = loadopts();
43 while (@{$optref} && $optref->[0] =~ /^([\w_]+)=(.*)$/) {
48 FindExt::scan_ext("../cpan");
49 FindExt::scan_ext("../dist");
50 FindExt::scan_ext("../ext");
51 FindExt::set_static_extensions(split ' ', $opt{static_ext});
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()) || ' ';
59 my $pl_h = '../patchlevel.h';
62 open PL, "<", $pl_h or die "Can't open $pl_h: $!";
64 if (/^#\s*define\s+(PERL_\w+)\s+([\d.]+)/) {
71 die "Can't find $pl_h: $!";
74 my $patch_file = '../.patch';
77 open my $fh, "<", $patch_file or die "Can't open $patch_file: $!";
78 chomp($opt{PERL_PATCHLEVEL} = <$fh>);
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};
86 my $ver = `ver 2>nul`;
87 $opt{osvers} = $ver =~ /\b(\d+(?:\.\d+)+)\b/ ? $1 : '4.0';
89 if (exists $opt{cc}) {
90 # cl version detection borrowed from Test::Smoke's configsmoke.pl
91 if ($opt{cc} =~ /\b(?:cl|icl)/) { #MSVC can come as clarm.exe, icl=Intel C
92 my $output = `$opt{cc} 2>&1`;
93 $opt{ccversion} = $output =~ /\b(\d+(?:\.\d+)+)\b/ ? $1 : '?';
95 elsif ($opt{cc} =~ /\bgcc\b/) {
96 chomp($opt{gccversion} = `$opt{cc} -dumpversion`);
100 $opt{cf_by} = $ENV{USERNAME} unless $opt{cf_by};
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;
107 $opt{usemymalloc} = 'y' if $opt{d_mymalloc} eq 'define';
109 $opt{libpth} = mungepath($opt{libpth}) if exists $opt{libpth};
110 $opt{incpath} = mungepath($opt{incpath}) if exists $opt{incpath};
113 if ($opt{cc} =~ /\b(?:cl|icl)/) {
116 elsif ($opt{cc} =~ /\bgcc\b/) {
117 $int64 = 'long long';
120 # set large files options
121 if ($opt{uselargefiles} eq 'define') {
123 $opt{lseektype} = $int64;
127 $opt{lseektype} = 'long';
131 if ($opt{WIN64} eq 'define') {
132 $opt{d_atoll} = 'define';
133 $opt{d_strtoll} = 'define';
134 $opt{d_strtoull} = 'define';
137 $opt{ssizetype} = $int64;
138 $opt{st_ino_size} = 8;
141 $opt{d_atoll} = 'undef';
142 $opt{d_strtoll} = 'undef';
143 $opt{d_strtoull} = 'undef';
146 $opt{ssizetype} = 'int';
147 $opt{st_ino_size} = 4;
150 # set 64-bit-int options
151 if ($opt{use64bitint} eq 'define') {
152 if ($opt{uselongdouble} eq 'define') {
153 $opt{d_nv_preserves_uv} = 'define';
154 $opt{nv_preserves_uv_bits} = 64;
157 $opt{d_nv_preserves_uv} = 'undef';
158 $opt{nv_preserves_uv_bits} = 53;
160 $opt{ivdformat} = qq{"I64d"};
162 $opt{ivtype} = $int64;
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"};
172 $opt{uvtype} = qq{unsigned $int64};
173 $opt{uvuformat} = qq{"I64u"};
174 $opt{uvxformat} = qq{"I64x"};
177 $opt{d_nv_preserves_uv} = 'define';
178 $opt{ivdformat} = '"ld"';
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"';
191 $opt{uvtype} = 'unsigned long';
192 $opt{uvuformat} = '"lu"';
193 $opt{uvxformat} = '"lx"';
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';
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';
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';
225 $opt{nvsize} = $opt{longdblsize};
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"';
234 $opt{longdblkind} = 3;
235 $opt{longdblmantbits} = 64;
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';
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"';
263 # change the s{GM|LOCAL}TIME_{min|max} for VS2005 (aka VC 8) and
264 # VS2008 (aka VC 9) or higher (presuming that later versions will have
265 # at least the range of that).
266 if ($opt{cc} =~ /\bcl/ and $opt{ccversion} =~ /^(\d+)/) {
268 if ($ccversion >= 14) {
269 $opt{sGMTIME_max} = 32535291599;
270 $opt{sLOCALTIME_max} = 32535244799;
272 if ($ccversion < 13) { #VC6
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';
283 #find out which MSVC this ICC is using
284 elsif ($opt{cc} =~ /\bicl/) {
285 my $output = `cl 2>&1`;
286 my $num_ver = $output =~ /\b(\d+(?:\.\d+)+)\b/ ? $1 : '?';
287 if ($num_ver =~ /^(\d+)/ && $1 >= 14) {
288 $opt{sGMTIME_max} = 32535291599;
289 $opt{sLOCALTIME_max} = 32535244799;
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';
301 if ($opt{useithreads} eq 'define' && $opt{ccflags} =~ /-DPERL_IMPLICIT_SYS\b/) {
302 $opt{d_pseudofork} = 'define';
305 if ($opt{usecplusplus} eq 'define') {
306 $opt{d_cplusplus} = 'define';
307 $opt{extern_C} = 'extern "C"';
310 #if the fields above are defined, they override the defaults in the premade
313 s/~([\w_]+)~/exists $opt{$1} ? $opt{$1} : ''/eg;
314 if (/^([\w_]+)=(.*)$/) {
316 # this depends on cf_time being empty in the template (or we'll
318 if ($k eq 'cf_time') {
319 $_ = "$k='" . localtime(time) . "'\n" if $v =~ /^\s*'\s*'/;
321 elsif (exists $opt{$k}) {
322 $_ = "$k='$opt{$k}'\n";