msgpack/perl/Makefile.PL

113 lines
2.9 KiB
Makefile
Raw Normal View History

2010-09-18 14:58:32 +09:00
# Usage: Makefile.PL --pp # disable XS
# Makefile.PL -g # add -g to the compiler and disable optimization flags
2009-04-15 12:55:41 +09:00
use inc::Module::Install;
use Module::Install::XSUtil 0.36;
2009-04-15 12:55:41 +09:00
name 'Data-MessagePack';
all_from 'lib/Data/MessagePack.pm';
2010-05-05 17:25:25 +09:00
readme_from('lib/Data/MessagePack.pm');
2009-04-15 12:55:41 +09:00
2010-09-02 14:37:22 +09:00
perl_version '5.008000';
2009-04-15 12:55:41 +09:00
license 'perl';
tests 't/*.t';
recursive_author_tests('xt');
2009-07-30 16:38:03 +09:00
if ( $] >= 5.008005 and want_xs() ) {
my $has_c99 = c99_available(); # msgpack C library requires C99.
if ( $has_c99 ) {
2010-09-19 22:12:28 +09:00
requires_c99();
2010-09-12 00:09:44 +09:00
use_xshelper();
2010-09-19 22:12:28 +09:00
cc_warnings;
cc_src_paths('xs-src');
2010-09-18 14:58:32 +09:00
if($Module::Install::AUTHOR) {
postamble qq{test :: test_pp\n\n};
}
}
else {
print <<NOT_SUPPORT_C99;
This distribution requires a C99 compiler, but yours seems not to support C99.
Instead of XS, configure PP version.
NOT_SUPPORT_C99
2010-09-02 14:37:22 +09:00
}
}
2010-09-02 23:45:05 +09:00
else {
print "configure PP version\n\n";
2010-09-19 22:12:28 +09:00
requires 'Math::BigInt' => 1.89; # old versions of BigInt were broken
2010-09-02 14:37:22 +09:00
}
2009-07-30 16:38:03 +09:00
clean_files qw{
*.stackdump
*.gcov *.gcda *.gcno
*.out
nytprof
cover_db
};
2009-04-15 12:55:41 +09:00
2009-07-01 18:20:14 +09:00
# copy modules
if ($Module::Install::AUTHOR && -d File::Spec->catfile('..', 'msgpack')) {
mkdir 'msgpack' unless -d 'msgpack';
require File::Copy;
for my $src (<../msgpack/*.h>) {
File::Copy::copy($src, 'msgpack/') or die "copy failed: $!";
}
2010-09-16 21:37:49 +09:00
mkdir 't/std';
for my $data(<../test/*.{json,mpac}>) {
File::Copy::copy($data, 't/std') or die "copy failed: $!";
}
2009-07-01 18:20:14 +09:00
}
2010-05-17 05:49:39 +09:00
requires 'Test::More' => 0.94; # done_testing
2010-05-05 17:25:25 +09:00
test_requires('Test::Requires');
2010-09-02 14:37:22 +09:00
test_with_env( test_pp => PERL_DATA_MESSAGEPACK => 'pp' );
2010-09-06 14:31:53 +09:00
repository('http://github.com/msgpack/msgpack');
2009-04-15 12:55:41 +09:00
auto_include;
WriteAll;
2010-09-02 14:37:22 +09:00
# copied from Makefile.PL in Text::Xslate.
sub test_with_env {
my($name, %env) = @_;
my $dir = '.testenv';
if(not -e $dir) {
mkdir $dir or die "Cannot mkdir '.testenv': $!";
}
clean_files($dir);
{
open my $out, '>', "$dir/$name.pl"
or die "Cannot open '$dir/$name.pl' for writing: $!";
print $out "# This file sets the env for 'make $name', \n";
print $out "# generated by $0 at ", scalar(localtime), ".\n";
print $out "# DO NOT EDIT THIS FILE DIRECTLY.\n";
print $out "\n";
while(my($name, $value) = each %env) {
printf $out '$ENV{q{%s}} = q{%s};'."\n", $name, $value;
}
}
# repeat testing for pure Perl mode
# see also ExtUtils::MM_Any::test_via_harness()
my $t = q{$(FULLPERLRUN) -MExtUtils::Command::MM -e}
.q{ "do q[%s]; test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')"}
.q{ $(TEST_FILES)};
postamble qq{$name :: pure_all\n}
. qq{\t} . q{$(NOECHO) $(ECHO) TESTING: } . $name . qq{\n}
. qq{\t} . sprintf($t, "$dir/$name.pl") . qq{\n\n}
. qq{testall :: $name\n\n};
return;
}