| 1 |
use 5.008; |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
use ExtUtils::MakeMaker; |
| 6 |
|
| 7 |
use Config; |
| 8 |
|
| 9 |
my @DEFINES; |
| 10 |
my %macro; |
| 11 |
|
| 12 |
my $as_perl = eval { |
| 13 |
require ActivePerl; |
| 14 |
defined &ActivePerl::BUILD ? ActivePerl::BUILD() : undef |
| 15 |
}; |
| 16 |
|
| 17 |
my $is_as_822 = 0; |
| 18 |
print "Checking if this is ActiveState Perl 5.8.8 build 822 or higher... "; |
| 19 |
if ("$]" == 5.008_008 and defined $as_perl and $as_perl >= 822) { |
| 20 |
$is_as_822 = 1; |
| 21 |
push @DEFINES, '-DVMG_COMPAT_ARRAY_PUSH_NOLEN=1'; |
| 22 |
} |
| 23 |
print $is_as_822 ? "yes\n" : "no\n"; |
| 24 |
|
| 25 |
my $is_gcc_34 = 0; |
| 26 |
print "Checking if this is gcc 3.4 on Windows trying to link against an import library... "; |
| 27 |
if ($^O eq 'MSWin32' and not grep /^LD[A-Z]*=/, @ARGV) { |
| 28 |
my ($libperl, $gccversion) = map $_ || '', @Config{qw<libperl gccversion>}; |
| 29 |
if ($gccversion =~ /^3\.4\.[0-9]+/ and $libperl =~ s/\.lib$//) { |
| 30 |
$is_gcc_34 = 1; |
| 31 |
my ($lddlflags, $ldflags) = @Config{qw<lddlflags ldflags>}; |
| 32 |
$_ ||= '', s/-L(?:".*?"|\S+)//g for $lddlflags, $ldflags; |
| 33 |
$libperl = "-l$libperl"; |
| 34 |
my $libdirs = join ' ', |
| 35 |
map { s/(?<!\\)((?:\\\\)*")/\\$1/g; qq[-L"$_"] } |
| 36 |
@Config{qw<bin sitebin>}; |
| 37 |
$macro{LDDLFLAGS} = "$lddlflags $libdirs $libperl"; |
| 38 |
$macro{LDFLAGS} = "$ldflags $libdirs $libperl"; |
| 39 |
eval <<' MY_SECTION'; |
| 40 |
package MY; |
| 41 |
sub dynamic_lib { |
| 42 |
my $self = shift; |
| 43 |
my $inherited = $self->SUPER::dynamic_lib(@_); |
| 44 |
$inherited =~ s/"?\$\(PERL_ARCHIVE\)"?//g; |
| 45 |
return $inherited; |
| 46 |
} |
| 47 |
MY_SECTION |
| 48 |
die $@ if $@; |
| 49 |
} |
| 50 |
} |
| 51 |
print $is_gcc_34 ? "yes\n" : "no\n"; |
| 52 |
|
| 53 |
# Threads, Windows and 5.8.x don't seem to be best friends |
| 54 |
if ($^O eq 'MSWin32' && "$]" < 5.009) { |
| 55 |
push @DEFINES, '-DXSH_MULTIPLICITY=0'; |
| 56 |
print "Thread safety disabled for perl 5.8.x on Windows.\n" |
| 57 |
} |
| 58 |
|
| 59 |
# Fork emulation got "fixed" in 5.10.1 |
| 60 |
if ($^O eq 'MSWin32' && "$]" < 5.010_001) { |
| 61 |
push @DEFINES, '-DXSH_FORKSAFE=0'; |
| 62 |
print "Fork safety not ensured for perl 5.8.x and 5.10.0 on Windows.\n"; |
| 63 |
} |
| 64 |
|
| 65 |
@DEFINES = (DEFINE => join ' ', @DEFINES) if @DEFINES; |
| 66 |
%macro = (macro => { %macro }) if %macro; # Beware of the circle |
| 67 |
|
| 68 |
my $dist = 'Variable-Magic'; |
| 69 |
|
| 70 |
(my $name = $dist) =~ s{-}{::}g; |
| 71 |
|
| 72 |
(my $file = $dist) =~ s{-}{/}g; |
| 73 |
$file = "lib/$file.pm"; |
| 74 |
|
| 75 |
my $bug_web = "http://rt.cpan.org/Dist/Display.html?Name=$dist", |
| 76 |
my $bug_mailto = 'bug-' . lc($dist) . '@rt.cpan.org'; |
| 77 |
|
| 78 |
my $repo_host = 'git.vpit.fr'; |
| 79 |
my @repo_path = ('perl', 'modules', "$dist.git"); |
| 80 |
my $repo_url = join '/', 'http:', '', $repo_host, @repo_path, ''; |
| 81 |
my $repo_web = "http://$repo_host/?p=" . join('%2F', @repo_path); |
| 82 |
|
| 83 |
my %PREREQ_PM = ( |
| 84 |
'Carp' => 0, |
| 85 |
'Exporter' => 0, |
| 86 |
'XSLoader' => 0, |
| 87 |
'base' => 0, |
| 88 |
); |
| 89 |
|
| 90 |
my %BUILD_REQUIRES = ( |
| 91 |
'Carp' => 0, |
| 92 |
'Config' => 0, |
| 93 |
'ExtUtils::MakeMaker' => 0, |
| 94 |
'IO::Handle' => 0, |
| 95 |
'IO::Select' => 0, |
| 96 |
'IPC::Open3' => 0, |
| 97 |
'POSIX' => 0, |
| 98 |
'Socket' => 0, |
| 99 |
'Test::More' => 0, |
| 100 |
'lib' => 0, |
| 101 |
%PREREQ_PM, |
| 102 |
); |
| 103 |
|
| 104 |
my %META = ( |
| 105 |
'meta-spec' => { |
| 106 |
version => '2', |
| 107 |
url => 'http://search.cpan.org/perldoc?CPAN::Meta::Spec', |
| 108 |
}, |
| 109 |
configure_requires => { |
| 110 |
'Config' => 0, |
| 111 |
'ExtUtils::MakeMaker' => 0, |
| 112 |
}, |
| 113 |
build_requires => { |
| 114 |
%BUILD_REQUIRES, |
| 115 |
}, |
| 116 |
dynamic_config => 1, |
| 117 |
resources => { |
| 118 |
bugtracker => { |
| 119 |
web => $bug_web, |
| 120 |
mailto => $bug_mailto, |
| 121 |
}, |
| 122 |
homepage => "http://search.cpan.org/dist/$dist/", |
| 123 |
license => 'http://dev.perl.org/licenses/', |
| 124 |
repository => { |
| 125 |
type => 'git', |
| 126 |
url => $repo_url, |
| 127 |
web => $repo_web, |
| 128 |
}, |
| 129 |
}, |
| 130 |
); |
| 131 |
|
| 132 |
WriteMakefile( |
| 133 |
NAME => $name, |
| 134 |
AUTHOR => 'Vincent Pit <[email protected]>', |
| 135 |
LICENSE => 'perl', |
| 136 |
VERSION_FROM => $file, |
| 137 |
ABSTRACT_FROM => $file, |
| 138 |
PL_FILES => {}, |
| 139 |
@DEFINES, |
| 140 |
BUILD_REQUIRES => \%BUILD_REQUIRES, |
| 141 |
PREREQ_PM => \%PREREQ_PM, |
| 142 |
MIN_PERL_VERSION => '5.008', |
| 143 |
META_MERGE => \%META, |
| 144 |
dist => { |
| 145 |
PREOP => "pod2text -u $file > \$(DISTVNAME)/README", |
| 146 |
COMPRESS => 'gzip -9f', SUFFIX => 'gz' |
| 147 |
}, |
| 148 |
clean => { |
| 149 |
FILES => "$dist-* *.gcov *.gcda *.gcno cover_db Debian_CPANTS.txt*" |
| 150 |
}, |
| 151 |
%macro, |
| 152 |
); |