Mail-SpamAssassin

 view release on metacpan or  search on metacpan

spamc/configure.pl  view on Meta::CPAN

# 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             => 'gcc',

    WINCFLAGS      => '',
    SSLCFLAGS      => '-DSPAMC_SSL',

    SRCDIR         =>  $srcdir,

    WINLIBS        => '-lws2_32 -o spamc.exe',
    SSLLIBS        => '-lcrypto -lssl',

    SPAMC_FILES    => 'spamc.c getopt.c',
    LIBSPAMC_FILES => 'libspamc.c utils.c',
  );

  my $cl_found = 0;
  foreach my $path (File::Spec->path()) {
    if( -x $path . '\cl.exe' ) {
      $cl_found = 1;
    }
  }
  if($cl_found) {
    $env{'CC'}        = 'cl';
    $env{'WINCFLAGS'} = '/DWIN32 /W4';
    $env{'SSLCFLAGS'} = '/DSPAMC_SSL';
    $env{'WINLIBS'}   = 'ws2_32.lib';
    $env{'SSLLIBS'}   = 'ssleay32.lib libeay32.lib';
  }

  # 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...



( run in 2.685 seconds using v1.01-cache-2.11-cpan-b16cb0d3907 )