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