The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
# This Makefile.PL for File-LibMagic was generated by
# inc::MyMakeMaker <self>
# and Dist::Zilla::Plugin::MakeMaker::Awesome 0.33.
# Don't edit it but the dist.ini and plugins used to construct it.

use strict;
use warnings;

use 5.008;
use ExtUtils::MakeMaker;

my %WriteMakefileArgs = (
  "ABSTRACT" => "Determine MIME types of data or files using libmagic",
  "AUTHOR" => "Andreas Fitzner, Michael Hendricks <michael\@ndrix.org>, Dave Rolsky <autarch\@urth.org>",
  "C" => [
    "lib/File/LibMagic.c"
  ],
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::CBuilder" => 0,
    "ExtUtils::MakeMaker" => 0
  },
  "DISTNAME" => "File-LibMagic",
  "EXE_FILES" => [],
  "INC" => "-I. -Ic",
  "LDFROM" => "LibMagic\$(OBJ_EXT)",
  "LIBS" => "-lmagic",
  "LICENSE" => "perl",
  "MIN_PERL_VERSION" => "5.008",
  "NAME" => "File::LibMagic",
  "OBJECT" => "lib/File/LibMagic\$(OBJ_EXT)",
  "PREREQ_PM" => {
    "Carp" => 0,
    "Exporter" => 0,
    "XSLoader" => 0,
    "base" => 0,
    "strict" => 0,
    "warnings" => 0
  },
  "TEST_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0,
    "File::Spec" => 0,
    "IO::Handle" => 0,
    "IPC::Open3" => 0,
    "Test::Fatal" => 0,
    "Test::More" => "0.96",
    "lib" => 0
  },
  "VERSION_FROM" => "lib/File/LibMagic.pm",
  "XS" => {
    "lib/File/LibMagic.xs" => "lib/File/LibMagic.c"
  },
  "test" => {
    "TESTS" => "t/*.t"
  }
);
$WriteMakefileArgs{DEFINE} = _defines();
$WriteMakefileArgs{INC}    = join q{ }, _includes(), $WriteMakefileArgs{INC};
$WriteMakefileArgs{LIBS}   = join q{ }, _libs(), $WriteMakefileArgs{LIBS};

my %FallbackPrereqs = (
  "Carp" => 0,
  "Exporter" => 0,
  "ExtUtils::CBuilder" => 0,
  "ExtUtils::MakeMaker" => 0,
  "File::Spec" => 0,
  "IO::Handle" => 0,
  "IPC::Open3" => 0,
  "Test::Fatal" => 0,
  "Test::More" => "0.96",
  "XSLoader" => 0,
  "base" => 0,
  "lib" => 0,
  "strict" => 0,
  "warnings" => 0
);

unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
  delete $WriteMakefileArgs{TEST_REQUIRES};
  delete $WriteMakefileArgs{BUILD_REQUIRES};
  $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
}

delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
  unless eval { ExtUtils::MakeMaker->VERSION(6.52) };

WriteMakefile(%WriteMakefileArgs);

use lib qw( inc );
use Config::AutoConf;
use Getopt::Long;

my @libs;
my @includes;

sub _libs     { return map { '-L' . $_ } @libs }
sub _includes { return map { '-I' . $_ } @includes }

sub _defines {
    GetOptions(
        'lib:s@'     => \@libs,
        'include:s@' => \@includes,
    );

    my $ac = Config::AutoConf->new(
        extra_link_flags   => [ _libs() ],
        extra_include_dirs => [ _includes() ],
    );

    _check_libmagic($ac);

    return $ac->check_lib( 'magic', 'magic_version' )
        ? '-DHAVE_MAGIC_VERSION'
        : q{};
}

sub _check_libmagic {
    my $ac = shift;

    return
        if $ac->check_header('magic.h')
        && $ac->check_lib( 'magic', 'magic_open' );

    warn <<'EOF';

  This module requires the libmagic.so library and magic.h header. See
  INSTALL.md for more details on installing these.

EOF

    exit 1;
}