Alien-LibANN

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

use strict;
use warnings;
use inc::Devel::CheckLib;
use Cwd ();
use ExtUtils::MakeMaker;
use File::Spec;

if ( -e 'MANIFEST.SKIP' ) {
    system('pod2text lib/Alien/LibANN.pm > README');
}

if ( $^O eq 'MSWin32' ) {
    print STDERR "Win32 is currently not supported";
    exit(0);
}

my $CWD  = Cwd::cwd();
my $DIST = File::Spec->catfile(qw(lib Alien LibANN.pm));
my $PKG  = File::Spec->catfile(qw(src ann_1.1.2.tar.gz));
my $SRC  = File::Spec->catfile(qw(src ann_1.1.2));

$_ = File::Spec->rel2abs($_) for $PKG, $SRC, $DIST;

my $VERSION = do {
    require ExtUtils::MM_Unix;
    ExtUtils::MM_Unix->parse_version($DIST);
};
my $LIBANN_VERSION = '1.1.2';

my $CCFLAGS = $ENV{CCFLAGS} || '-I/usr/local/include';
my $LDFLAGS = $ENV{LDFLAGS} || '-L/usr/local/lib';

eval { Devel::CheckLib::assert_lib( lib => "ANN", LIBS => $LDFLAGS ) };

my $install_libann = 1;
if ( !$@ ) {
    print <<EOF;

*** We've detected an existing installation of libANN ***

That existing installation of libANN may have been installed before by:

  * your distributions packaging system
  * previous installation of Alien::LibANN
  * compiling/installing it manually from source

Because Alien::LibANN may have been called to be installed from a dependency
of another module, we want to make sure that you *really* want to install
this version of libANN.

If you answer "y", then we're going to install
    libANN:         $LIBANN_VERSION
    Alient::LibANN: $VERSION

If you answer "n", then we're going to install
    Alient::LibANN: $VERSION

This operation may OVERWRITE your previous installation, you've been warned!

EOF
    my $yn = prompt( "Really install?", "n" );
    if ( $yn !~ /^y(?:es)?$/ ) {
        $install_libann = 0;
    }
}

if ($install_libann) {
    extract( $PKG => $SRC );
    run_configure( libANN => $SRC );
}

WriteMakefile(
    ABSTRACT           => 'Wrapper for installing libANN v1.1.2',
    AUTHOR             => 'Stephan Conrad <conrad@stephanconrad.de>',
    CCFLAGS            => $CCFLAGS,
    LDFLAGS            => $LDFLAGS,
    NAME               => 'Alien-LibANN',
    CONFIGURE_REQUIRES => {
        'File::Spec'   => 0,
        'Archive::Tar' => 0,
        'IO::Zlib'     => 0,
    },
    VERSION => $VERSION,
);

print "Everything ready, now type 'make'\n";



( run in 2.674 seconds using v1.01-cache-2.11-cpan-64ef6c95b5d )