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*$/);
40 my $prebuilt; # are we making the prebuilt config used to bootstrap?
41 if (@ARGV && $ARGV[0] eq '--prebuilt') {
48 my $optref = loadopts();
49 while (@{$optref} && $optref->[0] =~ /^([\w_]+)=(.*)$/) {
54 FindExt::scan_ext("../cpan");
55 FindExt::scan_ext("../dist");
56 FindExt::scan_ext("../ext");
57 FindExt::set_static_extensions(split ' ', $opt{static_ext});
59 $opt{nonxs_ext} = join(' ',FindExt::nonxs_ext()) || ' ';
60 $opt{static_ext} = join(' ',FindExt::static_ext()) || ' ';
61 $opt{dynamic_ext} = join(' ',FindExt::dynamic_ext()) || ' ';
62 $opt{extensions} = join(' ',FindExt::extensions()) || ' ';
63 $opt{known_extensions} = join(' ',FindExt::known_extensions()) || ' ';
65 my $pl_h = '../patchlevel.h';
68 open PL, "<", $pl_h or die "Can't open $pl_h: $!";
70 if (/^#\s*define\s+(PERL_\w+)\s+([\d.]+)/) {
77 die "Can't find $pl_h: $!";
80 my $patch_file = '../.patch';
83 open my $fh, "<", $patch_file or die "Can't open $patch_file: $!";
84 chomp($opt{PERL_PATCHLEVEL} = <$fh>);
88 $opt{version} = "$opt{PERL_REVISION}.$opt{PERL_VERSION}.$opt{PERL_SUBVERSION}";
89 $opt{version_patchlevel_string} = "version $opt{PERL_VERSION} subversion $opt{PERL_SUBVERSION}";
90 $opt{version_patchlevel_string} .= " patch $opt{PERL_PATCHLEVEL}" if exists $opt{PERL_PATCHLEVEL};
92 my $ver = `ver 2>nul`;
93 $opt{osvers} = $ver =~ /\b(\d+(?:\.\d+)+)\b/ ? $1 : '4.0';
95 if (exists $opt{cc}) {
96 # cl version detection borrowed from Test::Smoke's configsmoke.pl
97 if ($opt{cc} =~ /\b(?:cl|icl)/) { #MSVC can come as clarm.exe, icl=Intel C
98 my $output = `$opt{cc} 2>&1`;
99 $opt{ccversion} = $output =~ /\b(\d+(?:\.\d+)+)\b/ ? $1 : '?';
101 elsif ($opt{cc} =~ /\bgcc\b/) {
102 chomp($opt{gccversion} = `$opt{cc} -dumpversion`);
106 $opt{cf_by} = $ENV{USERNAME} unless $opt{cf_by};
107 if (!$opt{cf_email}) {
108 my $computername = eval{(gethostbyname('localhost'))[0]};
109 # gethostbyname might not be implemented in miniperl
110 $computername = $ENV{COMPUTERNAME} if $@;
111 $opt{cf_email} = $opt{cf_by} . '@' . $computername;
113 $opt{usemymalloc} = 'y' if $opt{d_mymalloc} eq 'define';
115 $opt{libpth} = mungepath($opt{libpth}) if exists $opt{libpth};
116 $opt{incpath} = mungepath($opt{incpath}) if exists $opt{incpath};
119 if ($opt{cc} =~ /\b(?:cl|icl)/) {
122 elsif ($opt{cc} =~ /\bgcc\b/) {
123 $int64 = 'long long';
127 if ($opt{WIN64} eq 'define') {
128 $opt{d_atoll} = 'define';
129 $opt{d_strtoll} = 'define';
130 $opt{d_strtoull} = 'define';
133 $opt{ssizetype} = $int64;
134 $opt{st_ino_size} = 8;
137 $opt{d_atoll} = 'undef';
138 $opt{d_strtoll} = 'undef';
139 $opt{d_strtoull} = 'undef';
142 $opt{ssizetype} = 'int';
143 $opt{st_ino_size} = 4;
146 # set 64-bit-int options
147 if ($opt{use64bitint} eq 'define') {
148 if ($opt{uselongdouble} eq 'define') {
149 $opt{d_nv_preserves_uv} = 'define';
150 $opt{nv_preserves_uv_bits} = 64;
153 $opt{d_nv_preserves_uv} = 'undef';
154 $opt{nv_preserves_uv_bits} = 53;
156 $opt{ivdformat} = qq{"I64d"};
158 $opt{ivtype} = $int64;
159 $opt{sPRIXU64} = qq{"I64X"};
160 $opt{sPRId64} = qq{"I64d"};
161 $opt{sPRIi64} = qq{"I64i"};
162 $opt{sPRIo64} = qq{"I64o"};
163 $opt{sPRIu64} = qq{"I64u"};
164 $opt{sPRIx64} = qq{"I64x"};
165 $opt{uvXUformat} = qq{"I64X"};
166 $opt{uvoformat} = qq{"I64o"};
168 $opt{uvtype} = qq{unsigned $int64};
169 $opt{uvuformat} = qq{"I64u"};
170 $opt{uvxformat} = qq{"I64x"};
173 $opt{d_nv_preserves_uv} = 'define';
174 $opt{ivdformat} = '"ld"';
176 $opt{ivtype} = 'long';
177 $opt{nv_preserves_uv_bits} = 32;
178 $opt{sPRIXU64} = '"lX"';
179 $opt{sPRId64} = '"ld"';
180 $opt{sPRIi64} = '"li"';
181 $opt{sPRIo64} = '"lo"';
182 $opt{sPRIu64} = '"lu"';
183 $opt{sPRIx64} = '"lx"';
184 $opt{uvXUformat} = '"lX"';
185 $opt{uvoformat} = '"lo"';
187 $opt{uvtype} = 'unsigned long';
188 $opt{uvuformat} = '"lu"';
189 $opt{uvxformat} = '"lx"';
192 unless ($opt{cc} =~ /\bcl/) {
193 if ($opt{WIN64} eq 'define') {
194 $opt{longdblsize} = 16;
195 $opt{longdblinfbytes} = '0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00';
196 $opt{longdblnanbytes} = '0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00';
199 $opt{longdblsize} = 12;
200 $opt{longdblinfbytes} = '0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00';
201 $opt{longdblnanbytes} = '0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x00, 0x00';
205 # set long double options
206 if ($opt{uselongdouble} eq 'define') {
207 $opt{d_Gconvert} = 'sprintf((b),"%.*""Lg",(n),(x))';
208 $opt{d_PRIEUldbl} = 'define';
209 $opt{d_PRIFUldbl} = 'define';
210 $opt{d_PRIGUldbl} = 'define';
211 $opt{d_modflproto} = 'define';
212 $opt{d_strtold} = 'define';
213 $opt{d_PRIeldbl} = 'define';
214 $opt{d_PRIfldbl} = 'define';
215 $opt{d_PRIgldbl} = 'define';
216 $opt{d_SCNfldbl} = 'define';
217 $opt{nvsize} = $opt{longdblsize};
218 $opt{nvtype} = 'long double';
219 $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';
220 $opt{nvEUformat} = '"LE"';
221 $opt{nvFUformat} = '"LF"';
222 $opt{nvGUformat} = '"LG"';
223 $opt{nveformat} = '"Le"';
224 $opt{nvfformat} = '"Lf"';
225 $opt{nvgformat} = '"Lg"';
226 $opt{nvmantbits} = 64;
227 $opt{longdblkind} = 3;
228 $opt{longdblmantbits} = 64;
231 $opt{d_Gconvert} = 'sprintf((b),"%.*g",(n),(x))';
232 $opt{d_PRIEUldbl} = 'undef';
233 $opt{d_PRIFUldbl} = 'undef';
234 $opt{d_PRIGUldbl} = 'undef';
236 if($opt{cc} =~ /\b(?:cl|icl)/) {
237 $opt{d_modflproto} = 'undef';
240 $opt{d_modflproto} = 'define';
243 $opt{d_strtold} = 'undef';
244 $opt{d_PRIeldbl} = 'undef';
245 $opt{d_PRIfldbl} = 'undef';
246 $opt{d_PRIgldbl} = 'undef';
247 $opt{d_SCNfldbl} = 'undef';
249 $opt{nvtype} = 'double';
250 $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';
251 $opt{nvEUformat} = '"E"';
252 $opt{nvFUformat} = '"F"';
253 $opt{nvGUformat} = '"G"';
254 $opt{nveformat} = '"e"';
255 $opt{nvfformat} = '"f"';
256 $opt{nvgformat} = '"g"';
259 # change some configuration variables based on compiler version
260 if ($opt{cc} =~ /\bcl/ and $opt{ccversion} =~ /^(\d+)/) {
262 if ($ccversion >= 14) { # VC8+
263 $opt{sGMTIME_max} = 32535291599;
264 $opt{sLOCALTIME_max} = 32535244799;
266 if ($ccversion >= 16 && !$prebuilt) { # VC10+
267 $opt{i_stdint} = 'define';
269 if ($ccversion >= 19) { # VC14+
270 $opt{stdio_base} = 'PERLIO_FILE_base(fp)';
271 $opt{stdio_bufsiz} = '(PERLIO_FILE_cnt(fp) + PERLIO_FILE_ptr(fp) - PERLIO_FILE_base(fp))';
272 $opt{stdio_cnt} = 'PERLIO_FILE_cnt(fp)';
273 $opt{stdio_ptr} = 'PERLIO_FILE_ptr(fp)';
274 $opt{i_stdbool} = 'define' unless $prebuilt;
277 # find out which MSVC this ICC is using
278 elsif ($opt{cc} =~ /\bicl/) {
279 my $output = `cl 2>&1`;
280 my $num_ver = $output =~ /\b(\d+(?:\.\d+)+)\b/ ? $1 : '?';
281 if ($num_ver =~ /^(\d+)/ && $1 >= 14) { # VC8+
282 $opt{sGMTIME_max} = 32535291599;
283 $opt{sLOCALTIME_max} = 32535244799;
285 if ($num_ver =~ /^(\d+)/ && $1 >= 16) { # VC10+
286 $opt{i_stdint} = 'define';
288 if ($num_ver =~ /^(\d+)/ && $1 >= 19) { # VC14+
289 $opt{stdio_base} = 'PERLIO_FILE_base(fp)';
290 $opt{stdio_bufsiz} = '(PERLIO_FILE_cnt(fp) + PERLIO_FILE_ptr(fp) - PERLIO_FILE_base(fp))';
291 $opt{stdio_cnt} = 'PERLIO_FILE_cnt(fp)';
292 $opt{stdio_ptr} = 'PERLIO_FILE_ptr(fp)';
293 $opt{i_stdbool} = 'define';
298 if ($opt{useithreads} eq 'define' && $opt{ccflags} =~ /-DPERL_IMPLICIT_SYS\b/) {
299 $opt{d_pseudofork} = 'define';
302 if ($opt{usecplusplus} eq 'define') {
303 $opt{d_cplusplus} = 'define';
304 $opt{extern_C} = 'extern "C"';
307 #if the fields above are defined, they override the defaults in the premade
310 s/~([\w_]+)~/exists $opt{$1} ? $opt{$1} : ''/eg;
311 if (/^([\w_]+)=(.*)$/) {
313 # this depends on cf_time being empty in the template (or we'll
315 if ($k eq 'cf_time') {
316 $_ = "$k='" . localtime(time) . "'\n" if $v =~ /^\s*'\s*'/;
318 elsif (exists $opt{$k}) {
319 $_ = "$k='$opt{$k}'\n";