summaryrefslogtreecommitdiff
path: root/win32/config_sh.PL
blob: 5f3f157a0c67aa934bdaccc95560c501529580a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
my %opt;
while (@ARGV && $ARGV[0] =~ /^([\w_]+)=(.*)$/)
 {
  $opt{$1}=$2;
  shift(@ARGV);
 }

$opt{'archname'} = 'MSWin32';
if (defined $ENV{'PROCESSOR_ARCHITECTURE'})
 {
  $opt{'archname'} .= '-'.$ENV{'PROCESSOR_ARCHITECTURE'};
 }

if ($opt{'ccflags'} =~ /USE_THREADS/)
 {
  $opt{'archname'} .= '-thread';
 }

if ($] =~ /\.(\d\d\d)?(\d\d)?$/) { # should always be true
  $opt{PATCHLEVEL} = int($1 || 0);
  $opt{SUBVERSION} = $2 || '00';
}

$opt{'cf_by'} = $ENV{USERNAME} unless $opt{'cf_by'};
$opt{'cf_email'} = $opt{'cf_by'} . '@' . (gethostbyname('localhost'))[0]
	unless $opt{'cf_email'};

while (<>)
 {
  s/~([\w_]+)~/$opt{$1}/g;
  if (/^([\w_]+)=(.*)$/) {
    # 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*'/;
    }
    elsif (exists $opt{$1}) {
      $_ = "$1='$opt{$1}'\n";
    }
  }
  print;
 }