Subject: | Makefile.PL hardcoded for operating systems |
Date: | Thu, 28 Oct 2010 09:58:43 -0700 |
To: | <bug-Audio-TagLib [...] rt.cpan.org> |
From: | "Mike Johnson" <mikejohnson [...] volcanomail.com> |
Hi,
I am trying to build Audio::TagLib.
Audio::Taglib requires taglib C++ library, which I have successfully built.
But the Makefile.PL that comes with Audio::TagLib seems to be hardcoded for Unix builds, specifically Macintosh OS-X darwin.
I have included the Makefile.PL below.
Does the Perl standard provide an abstraction layer over makefile creation,
or does each module developer have to hardcode the various compiler/linker commands and switches
in each Makefile.PL?
Any recommendations on converting the Makefile.PL so I can build with Visual Studio 2010 on Windows 7?
Thanks!
Mike
############### Makefile.PL ###################
use 5.008003;
use ExtUtils::MakeMaker;
use Config;
sub bail($) {
my $reason = shift;
warn $reason, $/;
exit(0);
}
# a simple workaround to perform the necessary pre-checks
# instead of overloading MakeMaker subs or another wrapper
warn 'This module ONLY supports TagLib version 1.5.*', $/;
bail('Please install the taglib C++ library first')
unless system('taglib-config --version') == 0;
chomp(my $libver = qx{taglib-config --version});
bail('Please install taglib ver 1.5.*')
unless $libver =~ m/^1\.5/;
chomp(my $libs = qx{taglib-config --libs});
$libs .= ' -L/System/Library/Perl/lib/'. $Config{version}. ' -lperl -liconv' if $^O eq 'darwin';
chomp(my $cflags = qx{taglib-config --cflags});
my $inc = " -I/usr/include -I./include -I. $cflags";
WriteMakefile(
NAME => 'Audio::TagLib',
VERSION_FROM => 'lib/Audio/TagLib.pm', # finds $VERSION
LICENSE => 'perl',
PREREQ_PM => {}, # e.g., Module::Name => 1.1
(
$] >= 5.005 # Add these new keywords supported since 5.005
?
(
ABSTRACT_FROM => 'lib/Audio/TagLib.pm', # retrieve abstract from module
AUTHOR => 'Dongxu, Ma '
)
: ()
),
CC => 'g++',
LD => 'g++',
LDDLFLAGS => $^O eq 'darwin' ? "-dynamiclib $libs" : "-shared ". $libs,
XSOPT => '-C++ -hiertype',
LIBS => $libs,
DEFINE => ( $^O eq 'freebsd' || $^O eq 'darwin' ) ? '-D_BSD_ICONV -DNO_DOXYGEN' : '-DNO_DOXYGEN', # e.g., '-DHAVE_SOMETHING'
INC => $inc, # e.g., '-I. -I/usr/include/other'
# Un-comment this if you add C files to link with later:
# OBJECT => '$(O_FILES)', # link all the C files too
);
package MY;
sub xs_c {
my $cmd = shift->SUPER::xs_c(@_);
$cmd .= sprintf(<<'END', $^X);
%1$s -pi -e 's/newXSproto\("TagLib/newXSproto("Audio::TagLib/g' $*.c
%1$s -pi -e 's/XS\(boot_TagLib\)/XS(boot_Audio__TagLib)/g' $*.c
END
return $cmd;
}