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 if ($ver =~ /Version (\d+\.\d+)/) {
94 if (exists $opt{cc}) {
95 # cl version detection borrowed from Test::Smoke's configsmoke.pl
96 if ($opt{cc} =~ /\b(?:cl|icl)/) { #MSVC can come as clarm.exe, icl=Intel C
97 my $output = `$opt{cc} --version 2>&1`;
98 $opt{ccversion} = $output =~ /^.*Version\s+([\d.]+)/ ? $1 : '?';
100 elsif ($opt{cc} =~ /\bgcc\b/) {
101 chomp($opt{gccversion} = `$opt{cc} -dumpversion`);
105 $opt{cf_by} = $ENV{USERNAME} unless $opt{cf_by};
106 if (!$opt{cf_email}) {
107 my $computername = eval{(gethostbyname('localhost'))[0]};
108 # gethostbyname might not be implemented in miniperl
109 $computername = $ENV{COMPUTERNAME} if $@;
110 $opt{cf_email} = $opt{cf_by} . '@' . $computername;
112 $opt{usemymalloc} = 'y' if $opt{d_mymalloc} eq 'define';
114 $opt{libpth} = mungepath($opt{libpth}) if exists $opt{libpth};
115 $opt{incpath} = mungepath($opt{incpath}) if exists $opt{incpath};
118 if ($opt{cc} =~ /\b(?:cl|icl)/) {
121 elsif ($opt{cc} =~ /\bgcc\b/) {
122 $int64 = 'long long';
125 # set large files options
126 if ($opt{uselargefiles} eq 'define') {
128 $opt{lseektype} = $int64;
132 $opt{lseektype} = 'long';
136 if ($opt{WIN64} eq 'define') {
137 $opt{d_atoll} = 'define';
138 $opt{d_strtoll} = 'define';
139 $opt{d_strtoull} = 'define';
142 $opt{ssizetype} = $int64;
143 $opt{st_ino_size} = 8;
146 $opt{d_atoll} = 'undef';
147 $opt{d_strtoll} = 'undef';
148 $opt{d_strtoull} = 'undef';
151 $opt{ssizetype} = 'int';
152 $opt{st_ino_size} = 4;
155 # set 64-bit-int options
156 if ($opt{use64bitint} eq 'define') {
157 if ($opt{uselongdouble} eq 'define') {
158 $opt{d_nv_preserves_uv} = 'define';
159 $opt{nv_preserves_uv_bits} = 64;
162 $opt{d_nv_preserves_uv} = 'undef';
163 $opt{nv_preserves_uv_bits} = 53;
165 $opt{ivdformat} = qq{"I64d"};
167 $opt{ivtype} = $int64;
168 $opt{sPRIXU64} = qq{"I64X"};
169 $opt{sPRId64} = qq{"I64d"};
170 $opt{sPRIi64} = qq{"I64i"};
171 $opt{sPRIo64} = qq{"I64o"};
172 $opt{sPRIu64} = qq{"I64u"};
173 $opt{sPRIx64} = qq{"I64x"};
174 $opt{uvXUformat} = qq{"I64X"};
175 $opt{uvoformat} = qq{"I64o"};
177 $opt{uvtype} = qq{unsigned $int64};
178 $opt{uvuformat} = qq{"I64u"};
179 $opt{uvxformat} = qq{"I64x"};
182 $opt{d_nv_preserves_uv} = 'define';
183 $opt{ivdformat} = '"ld"';
185 $opt{ivtype} = 'long';
186 $opt{nv_preserves_uv_bits} = 32;
187 $opt{sPRIXU64} = '"lX"';
188 $opt{sPRId64} = '"ld"';
189 $opt{sPRIi64} = '"li"';
190 $opt{sPRIo64} = '"lo"';
191 $opt{sPRIu64} = '"lu"';
192 $opt{sPRIx64} = '"lx"';
193 $opt{uvXUformat} = '"lX"';
194 $opt{uvoformat} = '"lo"';
196 $opt{uvtype} = 'unsigned long';
197 $opt{uvuformat} = '"lu"';
198 $opt{uvxformat} = '"lx"';
201 unless ($opt{cc} =~ /\bcl/) {
202 if ($opt{WIN64} eq 'define') {
203 $opt{longdblsize} = 16;
204 $opt{longdblinfbytes} = '0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00';
205 $opt{longdblnanbytes} = '0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00';
208 $opt{longdblsize} = 12;
209 $opt{longdblinfbytes} = '0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00';
210 $opt{longdblnanbytes} = '0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x00, 0x00';
214 # set long double options
215 if ($opt{uselongdouble} eq 'define') {
216 $opt{d_Gconvert} = 'sprintf((b),"%.*""Lg",(n),(x))';
217 $opt{d_PRIEUldbl} = 'define';
218 $opt{d_PRIFUldbl} = 'define';
219 $opt{d_PRIGUldbl} = 'define';
220 $opt{d_frexpl} = 'define';
221 $opt{d_isnanl} = 'define';
222 $opt{d_modfl} = 'define';
223 $opt{d_modflproto} = 'define';
224 $opt{d_sqrtl} = 'define';
225 $opt{d_strtold} = 'define';
226 $opt{d_PRIeldbl} = 'define';
227 $opt{d_PRIfldbl} = 'define';
228 $opt{d_PRIgldbl} = 'define';
229 $opt{d_SCNfldbl} = 'define';
230 $opt{nvsize} = $opt{longdblsize};
231 $opt{nvtype} = 'long double';
232 $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';
233 $opt{nvEUformat} = '"LE"';
234 $opt{nvFUformat} = '"LF"';
235 $opt{nvGUformat} = '"LG"';
236 $opt{nveformat} = '"Le"';
237 $opt{nvfformat} = '"Lf"';
238 $opt{nvgformat} = '"Lg"';
239 $opt{longdblkind} = 3;
240 $opt{longdblmantbits} = 64;
243 $opt{d_Gconvert} = 'sprintf((b),"%.*g",(n),(x))';
244 $opt{d_PRIEUldbl} = 'undef';
245 $opt{d_PRIFUldbl} = 'undef';
246 $opt{d_PRIGUldbl} = 'undef';
247 $opt{d_frexpl} = 'undef';
248 $opt{d_isnanl} = 'undef';
249 $opt{d_modfl} = 'undef';
250 $opt{d_modflproto} = 'undef';
251 $opt{d_sqrtl} = 'undef';
252 $opt{d_strtold} = 'undef';
253 $opt{d_PRIeldbl} = 'undef';
254 $opt{d_PRIfldbl} = 'undef';
255 $opt{d_PRIgldbl} = 'undef';
256 $opt{d_SCNfldbl} = 'undef';
258 $opt{nvtype} = 'double';
259 $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';
260 $opt{nvEUformat} = '"E"';
261 $opt{nvFUformat} = '"F"';
262 $opt{nvGUformat} = '"G"';
263 $opt{nveformat} = '"e"';
264 $opt{nvfformat} = '"f"';
265 $opt{nvgformat} = '"g"';
268 # change the s{GM|LOCAL}TIME_{min|max} for VS2005 (aka VC 8) and
269 # VS2008 (aka VC 9) or higher (presuming that later versions will have
270 # at least the range of that).
271 if ($opt{cc} =~ /\bcl/ and $opt{ccversion} =~ /^(\d+)/) {
273 if ($ccversion >= 14) {
274 $opt{sGMTIME_max} = 32535291599;
275 $opt{sLOCALTIME_max} = 32535244799;
277 if($ccversion < 13) { #VC6
281 #find out which MSVC this ICC is using
282 elsif ($opt{cc} =~ /\bicl/) {
283 my $output = `cl --version 2>&1`;
284 my $num_ver = $output =~ /^.*Version\s+([\d.]+)/ ? $1 : '?';
285 if($num_ver =~ /^(\d+)/ && $1 >= 14) {
286 $opt{sGMTIME_max} = 32535291599;
287 $opt{sLOCALTIME_max} = 32535244799;
292 if ($opt{useithreads} eq 'define' && $opt{ccflags} =~ /-DPERL_IMPLICIT_SYS\b/) {
293 $opt{d_pseudofork} = 'define';
296 if ($opt{usecplusplus} eq 'define') {
297 $opt{d_cplusplus} = 'define';
298 $opt{extern_C} = 'extern "C"';
301 #if the fields above are defined, they override the defaults in the premade
304 s/~([\w_]+)~/exists $opt{$1} ? $opt{$1} : ''/eg;
305 if (/^([\w_]+)=(.*)$/) {
307 # this depends on cf_time being empty in the template (or we'll
309 if ($k eq 'cf_time') {
310 $_ = "$k='" . localtime(time) . "'\n" if $v =~ /^\s*'\s*'/;
312 elsif (exists $opt{$k}) {
313 $_ = "$k='$opt{$k}'\n";