Audio-SndFile
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
use Config;
$|=1;
print "Testing for pkg-config...\n";
system("pkg-config --version") and die "You don't have pkg-config installed.
You can get pkg-config at http://pkgconfig.freedesktop.org/wiki/
";
print "Testing for sndfile via pkg-config...";
system("pkg-config sndfile") and die "
Can't find sndfile development files not installed.
Please make sure you've installed libsndfile and libsndfile-dev
Recent linux distributions should have them as packages. Otherwise,
you can find libsndfile at http://www.mega-nerd.com/libsndfile/
";
print "ok\n";
my $sndversion = `pkg-config --modversion sndfile`;
my ($major,$medium,$minor) = split /\./,$sndversion;
die "This module is made for libsndfile versions 1.X.X. You have $sndversion\n" if ($major != 1);
chomp(my $flags = `pkg-config --cflags --libs sndfile`);
chomp(my $inc = `pkg-config --cflags sndfile`);
chomp(my $libs = `pkg-config --libs sndfile`);
warn "According to pkg-config, LIBS should be '$libs' and INC should be '$inc'\n";
BEGIN {
require 'lib/Audio/SndFile/Constants.pm';
}
my $boiler = <<BOILER;
##########################################################################
# This file is generated by Makefile.PL and should not be edited by hand #
##########################################################################
BOILER
print "Testing for enums\n";
# note: you cannot test for enums using the preprocessor, so
# create a short program for each enum we know about and see if
# it compiles. this might fail if $Config{cc} needs any additional
# flags besides the ones from pkg-config to build and link an executable.
# also, it's pretty slow
# also also, we probably need something like this for the newer functions
# unless they're better documented than the enums :P
my $cc = "$Config{cc} $flags";
my $redir = "";
if (-e "/dev/null") {
# assume unix type redirection (not needed but makes the output a lot cleaner)
$redir = " >/dev/null 2>&1";
}
my @not_found;
open F,">","constants.xs" or die "Can't write constants.xs: $!";
print F $boiler;
for (@Audio::SndFile::Constants::EXPORT_OK) {
print "$_ ...";
open C,">test.c" or die "Can't write test.c: $!";
print C qq(
#include <sndfile.h>
#include <stdio.h>
int main() {
printf("%d\\n",$_);
}
);
close C;
if (system("$cc test.c$redir") == 0) {
print "found\n";
print F qq(
int
$_()
CODE:
RETVAL = $_;
OUTPUT:
RETVAL
);
}
else {
print "not found\n";
push @not_found,$_;
}
}
close F;
print "\n";
if (@not_found) {
print "You are missing @not_found.\n";
if (grep { !/^SF_FORMAT_/ } @not_found) {
print "You are missing some expected constants.
If building this module fails, you might want to upgrade to a more
recent version of libsndfile
";
}
else {
print "Some filetypes are not supported by your version of libsndfile.
Otherwise you will probably be alright.
";
}
}
else {
print "Good. You've got all formats I know about\n";
}
my %nf = map { $_ => 1 } @not_found;
my (@define,@fnotfound);
print "Testing functions...\n";
my %test_functions = (
sf_write_sync => "sf_write_sync(&sndfile);"
);
for (sort keys %test_functions) {
print "$_...";
open C,">test.c" or die "Can't write test.c: $!";
print C qq{
#include <sndfile.h>
#include <stdio.h>
int main() {
SNDFILE sndfile;
$test_functions{$_}
}
};
close C;
if (system("$cc test.c$redir") == 0) {
print "found\n";
push @define,"-D$_=$_";
}
else {
push @fnotfound,$_;
print "not found\n";
}
}
my (@cfound, @cnotfound);
print "Testing for commands...\n";
for (qw(SFC_GET_LOG_INFO SFC_CALC_SIGNAL_MAX SFC_CALC_NORM_SIGNAL_MAX SFC_CALC_MAX_ALL_CHANNELS
SFC_CALC_NORM_MAX_ALL_CHANNELS SFC_GET_SIGNAL_MAX SFC_GET_MAX_ALL_CHANNELS
SFC_SET_NORM_FLOAT SFC_SET_NORM_DOUBLE SFC_GET_NORM_FLOAT SFC_GET_NORM_DOUBLE
SFC_SET_SCALE_FLOAT_INT_READ SFC_GET_SIMPLE_FORMAT_COUNT SFC_GET_SIMPLE_FORMAT
SFC_GET_FORMAT_INFO SFC_GET_FORMAT_MAJOR_COUNT SFC_GET_FORMAT_MAJOR SFC_GET_FORMAT_SUBTYPE_COUNT
SFC_GET_FORMAT_SUBTYPE SFC_SET_ADD_PEAK_CHUNK SFC_UPDATE_HEADER_NOW SFC_SET_UPDATE_HEADER_AUTO
SFC_FILE_TRUNCATE SFC_SET_RAW_START_OFFSET SFC_SET_CLIPPING SFC_GET_CLIPPING
SFC_GET_EMBED_FILE_INFO)) {
print "$_...";
open C,">test.c" or die "Can't write test.c: $!";
print C qq(
#include <sndfile.h>
#include <stdio.h>
int main() {
printf("$_=%d\\n",$_);
return 0;
}
);
close C;
if (system("$cc test.c$redir") == 0) {
print "found\n";
push @define,"-D$_=$_";
push @cfound,$_;
}
else {
print "not found\n";
push @cnotfound,$_;
}
}
( run in 1.852 second using v1.01-cache-2.11-cpan-39bf76dae61 )