X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=win32%2Fconfig_sh.PL;h=9e53b54827e211df2b6b580e407112417807dc79;hb=5f7fde29e6223390b222de18e00bc300ef0fa8c9;hp=8194988f28c598e14bee858c9683d208e6b3e4d5;hpb=00dc2f4f23da07658d2634f904ac3a098aaa4153;p=p5sagit%2Fp5-mst-13.2.git diff --git a/win32/config_sh.PL b/win32/config_sh.PL index 8194988..9e53b54 100644 --- a/win32/config_sh.PL +++ b/win32/config_sh.PL @@ -1,3 +1,15 @@ +# take a semicolon separated path list and turn it into a quoted +# list of paths that Text::Parsewords will grok +sub mungepath { + my $p = shift; + # remove leading/trailing semis/spaces + $p =~ s/^[ ;]+//; + $p =~ s/[ ;]+$//; + $p =~ s/'/"/g; + my @p = map { $_ = "\"$_\"" if /\s/ and !/^".*"$/; $_ } split /;/, $p; + return join(' ', @p); +} + my %opt; while (@ARGV && $ARGV[0] =~ /^([\w_]+)=(.*)$/) { @@ -5,26 +17,50 @@ while (@ARGV && $ARGV[0] =~ /^([\w_]+)=(.*)$/) shift(@ARGV); } -if ($] =~ /\.(\d\d\d)?(\d\d)?$/) { # should always be true - $opt{PATCHLEVEL} = int($1 || 0); - $opt{SUBVERSION} = $2 || '00'; -} +my $pl_h = '../patchlevel.h'; $opt{VERSION} = $]; +$opt{INST_VER} =~ s|~VERSION~|$]|g; +if (-e $pl_h) { + open PL, "<$pl_h" or die "Can't open $pl_h: $!"; + while () { + if (/^#\s*define\s+(PERL_\w+)\s+([\d.]+)/) { + $opt{$1} = $2; + } + } + close PL; +} +elsif ($] =~ /^(\d+)\.(\d\d\d)?(\d\d)?$/) { # should always be true + $opt{PERL_REVISION} = $1; + $opt{PERL_VERSION} = int($2 || 0); + $opt{PERL_SUBVERSION} = $3; + $opt{PERL_APIVERSION} = $]; +} +else { + die "Can't parse perl version ($])"; +} + +$opt{PERL_SUBVERSION} ||= '00'; + $opt{'cf_by'} = $ENV{USERNAME} unless $opt{'cf_by'}; $opt{'cf_email'} = $opt{'cf_by'} . '@' . (gethostbyname('localhost'))[0] unless $opt{'cf_email'}; +$opt{'usemymalloc'} = 'y' if $opt{'d_mymalloc'} eq 'define'; + +$opt{libpth} = mungepath($opt{libpth}) if exists $opt{libpth}; +$opt{incpath} = mungepath($opt{incpath}) if exists $opt{incpath}; while (<>) { s/~([\w_]+)~/$opt{$1}/g; if (/^([\w_]+)=(.*)$/) { + my($k,$v) = ($1,$2); # this depends on cf_time being empty in the template (or we'll get a loop) - if ($1 eq 'cf_time') { - $_ = "$1='" . localtime(time) . "'\n" if $2 =~ /^\s*'\s*'/; + if ($k eq 'cf_time') { + $_ = "$k='" . localtime(time) . "'\n" if $v =~ /^\s*'\s*'/; } - elsif (exists $opt{$1}) { - $_ = "$1='$opt{$1}'\n"; + elsif (exists $opt{$k}) { + $_ = "$k='$opt{$k}'\n"; } } print;