[win32] re-add PERLVARI?C? change that somehow went missing in makedef.pl
[p5sagit/p5-mst-13.2.git] / win32 / config_sh.PL
1 my %opt;
2 while (@ARGV && $ARGV[0] =~ /^([\w_]+)=(.*)$/)
3  {
4   $opt{$1}=$2;
5   shift(@ARGV);
6  }
7
8 $opt{'archname'} = 'MSWin32';
9 if (defined $ENV{'PROCESSOR_ARCHITECTURE'})
10  {
11   $opt{'archname'} .= '-'.$ENV{'PROCESSOR_ARCHITECTURE'};
12  }
13
14 if ($opt{'ccflags'} =~ /USE_THREADS/)
15  {
16   $opt{'archname'} .= '-thread';
17  }
18
19 if ($] =~ /\.(\d\d\d)?(\d\d)?$/) { # should always be true
20   $opt{PATCHLEVEL} = int($1 || 0);
21   $opt{SUBVERSION} = $2 || '00';
22 }
23
24 $opt{'cf_by'} = $ENV{USERNAME} unless $opt{'cf_by'};
25 $opt{'cf_email'} = $opt{'cf_by'} . '@' . (gethostbyname('localhost'))[0]
26         unless $opt{'cf_email'};
27
28 while (<>)
29  {
30   s/~([\w_]+)~/$opt{$1}/g;
31   if (/^([\w_]+)=(.*)$/) {
32     # this depends on cf_time being empty in the template (or we'll get a loop)
33     if ($1 eq 'cf_time') {
34       $_ = "$1='" . localtime(time) . "'\n" if $2 =~ /^\s*'\s*'/;
35     }
36     elsif (exists $opt{$1}) {
37       $_ = "$1='$opt{$1}'\n";
38     }
39   }
40   print;
41  }
42