File: configure.pl

package info (click to toggle)
spamassassin 3.1.7-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 5,376 kB
  • ctags: 2,123
  • sloc: perl: 39,706; ansic: 3,133; sh: 1,344; sql: 170; makefile: 168
file content (150 lines) | stat: -rwxr-xr-x 4,233 bytes parent folder | download | duplicates (2)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/perl
# autoconf wrapper (for Unix)/alternative (for Windows)
#
# <@LICENSE>
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to you under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at:
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# </@LICENSE>


use strict;
use warnings;
use Config;

use File::Copy;
use File::Spec::Functions qw(:ALL);

use Cwd qw(chdir);

use constant RUNNING_ON_NATIVE_WINDOWS => ($^O =~ /^(mswin|dos|os2)/i);


# Some nicer error messages.
$SIG{__DIE__} = sub {
  die join(': ', $0, @_);
};


# Build our argument list to call the real configure script later.
our @args = (q{./configure});
our %args;
foreach (@ARGV) {
  if (/^--([^=]+?)=["']?(.*?)["']?$/) {
    $args{$1} = $2;
    push(@args, $_);
  }
  elsif (/^([^=]+?)=["']?(.*?)["']?$/) {
    $ENV{$1} = $2;
  }
}


# Change to the dir this file is in.
my $srcdir;
$srcdir = canonpath(catpath((splitpath($0))[0..1])) || curdir();
if ($srcdir ne curdir()) {
  print "cd $srcdir\n";
  chdir($srcdir) || die "Can't cd to `$srcdir': $!";
}


# Create version.h platform independently.
print join(' ', $Config{'perlpath'}, "version.h.pl") . "\n";
{
  # Do the same thing as for the preprocessor below.
  package version_h;
  my $Z = $0;
  local $0    = "version.h.pl";
  local @ARGV = ();
  # Got to check for defined because the script returns shell error level!
  unless (defined do $0) {
    $0 = $Z;
    die $@ ? $@ : "Can't exec `version.h.pl': $!";
  }
}


# On everything but native Windows (!= cygwin) we use autoconf.
unless (RUNNING_ON_NATIVE_WINDOWS)
{
  print join(' ', @args) . "\n";
  exec @args;
  exit 127;
}
# For Windows we've got our own little autoconf :)
else
{
  # These are the defaults for the Makefile.
  my %env = (
    CC             => 'cl',

    WINCFLAGS      => '/DWIN32 /W4',
    SSLCFLAGS      => '/DSPAMC_SSL',

    SRCDIR         =>  $srcdir,

    WINLIBS        => 'ws2_32.lib',
    SSLLIBS        => 'ssleay32.lib libeay32.lib',

    SPAMC_FILES    => join(' ', 'spamc.c',catfile('replace', 'getopt.c')),
    LIBSPAMC_FILES => 'libspamc.c utils.c',
  );

  # Enable SSL only if requested.
  if ($args{'enable-ssl'} and $args{'enable-ssl'} ne 'yes') {
    delete $env{SSLCFLAGS};
    delete $env{SSLLIBS};
  }
  # Set every unset var in env to it's default value so the preprocessor
  # gets it later on.
  foreach (keys %env) {
    $ENV{$_} = $env{$_} unless $ENV{$_};
  }

  # Now do the real work...
  print "copy config.h.win config.h\n";
  copy(q{config.h.win}, q{config.h}) || die "Can't copy `config.h.win' to `config.h': $!";
  print "copy spamc.h.win spamc.h\n";
  copy(q{spamc.h.win}, q{spamc.h}) || die "Can't copy `spamc.h.win' to `spamc.h': $!";

  # We'll use our preprocessor for variable replacement in the Makefile.
  # Note that variables are enclosed by *two* @s while autoconf uses only
  # one.
  @args = (
    catfile(updir(), 'build', 'preprocessor'),
    q{-Mvars},
    q{-iMakefile.win},
    q{-oMakefile}
  );
  print join(' ', $Config{'perlpath'}, @args) . "\n";
  {
    # We now call the preprocessor in its own namespace (so it doesn't
    # clobber the main namespace. Feed its ARGV and do some zeroth-argument
    # tricks to get nicer error messages.
    package preprocessor;
    my $Z = $0;
    $0    = $::args[0];
    @ARGV = @::args[1 .. 3];
    # Got to check for defined because the script returns shell error level!
    unless (defined do $0) {
      $0 = $Z;
      die $@ ? $@ : "Can't exec `$::args[0]': $!";
    }
  }

  if ($srcdir ne curdir()) {
    print "cd " . updir() . "\n" for splitdir($srcdir);
  }
} #* RUNNING_ON_NATIVE_WINDOWS *#