| 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("../ext"); |
| 46 | FindExt::scan_ext("ext"); |
| 47 | FindExt::set_static_extensions(split ' ', $opt{'static_ext'}); |
| 48 | |
| 49 | my @dynamic_ext = grep(!/Thread/,FindExt::dynamic_ext()); |
| 50 | my @extensions = grep(!/Thread/,FindExt::extensions()); |
| 51 | $opt{'nonxs_ext'} = join(' ',FindExt::nonxs_ext()) || ' '; |
| 52 | $opt{'static_ext'} = join(' ',FindExt::static_ext()) || ' '; |
| 53 | $opt{'dynamic_ext'} = join(' ',@dynamic_ext) || ' '; |
| 54 | $opt{'extensions'} = join(' ',@extensions) || ' '; |
| 55 | $opt{'known_extensions'} = join(' ',FindExt::known_extensions()) || ' '; |
| 56 | |
| 57 | my $pl_h = '../patchlevel.h'; |
| 58 | |
| 59 | if (-e $pl_h) { |
| 60 | open PL, "<$pl_h" or die "Can't open $pl_h: $!"; |
| 61 | while (<PL>) { |
| 62 | if (/^#\s*define\s+(PERL_\w+)\s+([\d.]+)/) { |
| 63 | $opt{$1} = $2; |
| 64 | } |
| 65 | } |
| 66 | close PL; |
| 67 | } |
| 68 | else { |
| 69 | die "Can't find $pl_h: $!"; |
| 70 | } |
| 71 | $opt{VERSION} = "$opt{PERL_REVISION}.$opt{PERL_VERSION}.$opt{PERL_SUBVERSION}"; |
| 72 | $opt{INST_VER} =~ s|~VERSION~|$opt{VERSION}|g; |
| 73 | $opt{'version_patchlevel_string'} = "version $opt{PERL_VERSION} subversion $opt{PERL_SUBVERSION}"; |
| 74 | $opt{'version_patchlevel_string'} .= " patchlevel $opt{PERL_PATCHLEVEL}" if exists $opt{PERL_PATCHLEVEL}; |
| 75 | |
| 76 | $opt{'osvers'} = join '.', (Win32::GetOSVersion())[1,2]; |
| 77 | |
| 78 | if (exists $opt{cc}) { |
| 79 | # cl and bcc32 version detection borrowed from Test::Smoke's configsmoke.pl |
| 80 | if ($opt{cc} eq 'cl') { |
| 81 | my $output = `cl --version 2>&1`; |
| 82 | $opt{ccversion} = $output =~ /^.*Version\s+([\d.]+)/ ? $1 : '?'; |
| 83 | } |
| 84 | elsif ($opt{cc} eq 'bcc32') { |
| 85 | my $output = `bcc32 --version 2>&1`; |
| 86 | $opt{ccversion} = $output =~ /([\d.]+)/ ? $1 : '?'; |
| 87 | } |
| 88 | elsif ($opt{cc} eq 'gcc') { |
| 89 | chomp($opt{gccversion} = `gcc -dumpversion`); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | $opt{'cf_by'} = $ENV{USERNAME} unless $opt{'cf_by'}; |
| 94 | $opt{'cf_email'} = $opt{'cf_by'} . '@' . (gethostbyname('localhost'))[0] |
| 95 | unless $opt{'cf_email'}; |
| 96 | $opt{'usemymalloc'} = 'y' if $opt{'d_mymalloc'} eq 'define'; |
| 97 | |
| 98 | $opt{libpth} = mungepath($opt{libpth}) if exists $opt{libpth}; |
| 99 | $opt{incpath} = mungepath($opt{incpath}) if exists $opt{incpath}; |
| 100 | |
| 101 | # some functions are not available on Win9x |
| 102 | if (defined(&Win32::IsWin95) && Win32::IsWin95()) { |
| 103 | $opt{d_flock} = 'undef'; |
| 104 | $opt{d_link} = 'undef'; |
| 105 | } |
| 106 | |
| 107 | if ($opt{uselargefiles} ne 'define') { |
| 108 | $opt{lseeksize} = 4; |
| 109 | $opt{lseektype} = 'off_t'; |
| 110 | } |
| 111 | |
| 112 | while (<>) { |
| 113 | s/~([\w_]+)~/$opt{$1}/g; |
| 114 | if (/^([\w_]+)=(.*)$/) { |
| 115 | my($k,$v) = ($1,$2); |
| 116 | # this depends on cf_time being empty in the template (or we'll |
| 117 | # get a loop) |
| 118 | if ($k eq 'cf_time') { |
| 119 | $_ = "$k='" . localtime(time) . "'\n" if $v =~ /^\s*'\s*'/; |
| 120 | } |
| 121 | elsif (exists $opt{$k}) { |
| 122 | $_ = "$k='$opt{$k}'\n"; |
| 123 | } |
| 124 | } |
| 125 | print; |
| 126 | } |