1use FindExt; 2# take a semicolon separated path list and turn it into a quoted 3# list of paths that Text::Parsewords will grok 4sub 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 17sub 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 37FindExt::scan_ext("../ext"); 38 39my %opt; 40 41my $optref = loadopts(); 42while (@{$optref} && $optref->[0] =~ /^([\w_]+)=(.*)$/) { 43 $opt{$1}=$2; 44 shift(@{$optref}); 45} 46 47my @dynamic = FindExt::dynamic_extensions(); 48my @noxs = FindExt::noxs_extensions(); 49my @known = sort(@dynamic,split(/\s+/,$opt{'staticext'}),@noxs); 50$opt{'known_extensions'} = join(' ',@known); 51 52if (!$opt{'use5005threads'} || $opt{'use5005threads'} eq 'undef') 53 { 54 @dynamic = grep(!/Thread/,@dynamic); 55 @known = grep(!/Thread/,@dynamic); 56 } 57 58$opt{'dynamic_ext'} = join(' ',@dynamic); 59$opt{'nonxs_ext'} = join(' ',@noxs); 60 61$opt{'extensions'} = join(' ',@known); 62 63my $pl_h = '../patchlevel.h'; 64 65if (-e $pl_h) { 66 open PL, "<$pl_h" or die "Can't open $pl_h: $!"; 67 while (<PL>) { 68 if (/^#\s*define\s+(PERL_\w+)\s+([\d.]+)/) { 69 $opt{$1} = $2; 70 } 71 } 72 close PL; 73} 74else { 75 die "Can't find $pl_h: $!"; 76} 77$opt{VERSION} = "$opt{PERL_REVISION}.$opt{PERL_VERSION}.$opt{PERL_SUBVERSION}"; 78$opt{INST_VER} =~ s|~VERSION~|$opt{VERSION}|g; 79$opt{'version_patchlevel_string'} = "version $opt{PERL_VERSION} subversion $opt{PERL_SUBVERSION}"; 80$opt{'version_patchlevel_string'} .= " patchlevel $opt{PERL_PATCHLEVEL}" if exists $opt{PERL_PATCHLEVEL}; 81 82$opt{'cf_by'} = $ENV{USERNAME} unless $opt{'cf_by'}; 83$opt{'cf_email'} = $opt{'cf_by'} . '@' . (gethostbyname('localhost'))[0] 84 unless $opt{'cf_email'}; 85$opt{'usemymalloc'} = 'y' if $opt{'d_mymalloc'} eq 'define'; 86 87$opt{libpth} = mungepath($opt{libpth}) if exists $opt{libpth}; 88$opt{incpath} = mungepath($opt{incpath}) if exists $opt{incpath}; 89 90# some functions are not available on Win9x 91if (defined(&Win32::IsWin95) && Win32::IsWin95()) { 92 $opt{d_flock} = 'undef'; 93 $opt{d_link} = 'undef'; 94} 95 96while (<>) { 97 s/~([\w_]+)~/$opt{$1}/g; 98 if (/^([\w_]+)=(.*)$/) { 99 my($k,$v) = ($1,$2); 100 # this depends on cf_time being empty in the template (or we'll 101 # get a loop) 102 if ($k eq 'cf_time') { 103 $_ = "$k='" . localtime(time) . "'\n" if $v =~ /^\s*'\s*'/; 104 } 105 elsif (exists $opt{$k}) { 106 $_ = "$k='$opt{$k}'\n"; 107 } 108 } 109 print; 110} 111