I'm preparing a new release of Audio::Taglib, which is an interface to
Taglib (as one might suspect!) I'm comfortable with the Linux aspects
of Makefile.PL, but I have no facility to test for the other targets,
and I'd rather not use the CPAN testing process for that purpose.
Here's the file; suggestions/comments for freebad, darwin and windows
ould be appreciated. Thanks.
use 5.008001;
use ExtUtils::MakeMaker;
use Config;
sub bail($) {
my $reason = shift;
warn $reason;
exit(0);
}
# Check TagLib (taglib.so) is installed and that the version is
correct.
# Note that this depends on the search path --
# If the one you want is down-path, then modify your
# PATH environment variable, or edit for a fixed path
bail('Please install the taglib C++ library first')
unless system('taglib-config --version >& /dev/null') == 0;
chomp(my $libver = qx{taglib-config --version});
bail( "This module supports ONLY TagLib version 1.5.*\n" .
"You have $libver. Please install taglib ver 1.5.*")
unless $libver =~ m/^1\.5/;
chomp(my $libs = qx{taglib-config --libs});
# Configure compile flags
chomp(my $cflags = qx{taglib-config --cflags});
# Configure include files.
# ./include has a needed .h
my $inc = " -I./include $cflags";
# Configure various os-es
my ($define, $ldd);
if ( $Config{'osname'} eq 'darwin' ) {
$inc = ' -I/opt/local/include ' . $inc;
$libs = "-L/opt/local/lib -L/System/Library/Perl/lib $libs" .
' -lperl -liconv';
$ldd = "-bundle -undefined dynamic_lookup -dynamiclib $libs";
$define = '-D_BSD_ICONV -DNO_DOXYGEN';
}
elsif ( $Config{'osname'} eq 'freebsd' ) {
$ldd = " -shared $libs";
$define = '-D_BSD_ICONV -DNO_DOXYGEN';
}
else {
# Windows??
$ldd = " -shared $libs";
$define = '-DNO_DOXYGEN';
}
$Verbose = 2;
WriteMakefile(
NAME => 'Audio::TagLib',
MIN_PERL_VERSION => '5.008001',
VERSION_FROM => 'lib/Audio/TagLib.pm',
LICENSE => 'perl',
(
$Config{'version'} >= 5.005
?
(
ABSTRACT_FROM => 'lib/Audio/TagLib.pm',
AUTHOR => 'Geoffrey Leach <[email protected]>'
)
: ()
),
CC => 'g++',
LD => 'g++',
LDDLFLAGS => $ldd,
XSOPT => '-C++ -hiertype',
LIBS => $libs,
DEFINE => $define,
INC => $inc,
);
package MY;
sub xs_c {
my $cmd = shift->SUPER::xs_c(@_);
$cmd .= sprintf(<<'END', $^X);
%1$s -pi -e 's/newXSproto_portable\("TagLib/newXSproto_portable
("Audio::TagLib/g' $*.c
%1$s -pi -e 's/XS\(boot_TagLib\)/XS(boot_Audio__TagLib)/g' $*.c
END
return $cmd;
}