Convert UNIX Makefile.PL to build on Windows?

Posted by mikejohnson on 2010-10-27 18:51
Forums: PPM | OS: Windows

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.

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;
}

chorny | Thu, 2010-10-28 03:56

mikejohnson | Thu, 2010-10-28 09:02

Done.
I have posted a (more generalized) question as a new bug, as per your request.
Thanks,
Mike

gelffleach | Sat, 2011-03-12 14:36

I have recently taken on the responsibility of maintaining Audio::Taglib. Regrettably, I have no Windoze or Mac expertise. Consequently, I'd be grateful for any guidance that can be provided.