]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blob - Makefile.PL
Force linking against the perl dll when using gcc 3.4 on Windows
[perl/modules/Variable-Magic.git] / Makefile.PL
1 use 5.008;
2
3 use strict;
4 use warnings;
5 use ExtUtils::MakeMaker;
6
7 BEGIN {
8  eval { require Config };
9  die 'OS unsupported' if $@;
10  Config->import(qw/%Config/);
11 }
12
13 my @DEFINES;
14 my %macro;
15
16 my $pl = $Config{perl_patchlevel};
17 print "Checking perl patchlevel... ";
18 if (defined $pl && length $pl) {
19  $pl = int $pl;
20  push @DEFINES, '-DVMG_PERL_PATCHLEVEL=' . $pl;
21  print $pl, "\n";
22 } else {
23  $pl = undef;
24  print "none\n";
25 }
26
27 my $as_perl = eval {
28  require ActivePerl;
29  defined &ActivePerl::BUILD ? ActivePerl::BUILD() : undef
30 };
31
32 my $is_as_822 = 0;
33 print "Checking if this is ActiveState Perl 5.8.8 build 822 or higher... ";
34 if ($^V eq v5.8.8 and defined $as_perl and $as_perl >= 822) {
35  $is_as_822 = 1;
36  push @DEFINES, '-DVMG_COMPAT_ARRAY_PUSH_NOLEN=1';
37 }
38 print $is_as_822 ? "yes\n" : "no\n";
39
40 my $is_5110rel = 0;
41 print "Checking if this is a released perl 5.11.0 or higher... ";
42 if ($^V ge v5.11.0 and not defined $pl) {
43  my $describe = $Config{git_describe};
44  # An empty 'describe' is fine
45  if (defined $describe and $describe !~ /^GitLive-/) {
46   $is_5110rel = 1;
47   push @DEFINES, '-DVMG_COMPAT_ARRAY_PUSH_NOLEN=0';
48  }
49 }
50 print $is_5110rel ? "yes\n" : "no\n";
51
52 my $is_gcc_34 = 0;
53 print "Checking if this is gcc 3.4 on Windows trying to link against an import library... ";
54 if ($^O eq 'MSWin32' and not grep /^LD[A-Z]*=/, @ARGV) {
55  my ($libperl, $gccversion) = map $_ || '', @Config{qw/libperl gccversion/};
56  if ($gccversion =~ /^3\.4\.[0-9]+/ and $libperl =~ s/\.lib$//) {
57   $is_gcc_34 = 1;
58   my ($lddlflags, $ldflags) = @Config{qw/lddlflags ldflags/};
59   $_ ||= '', s/-L(?:".*?"|\S+)//g for $lddlflags, $ldflags;
60   $libperl = "-l$libperl";
61   my $libdirs = join ' ',
62                  map { s/(?<!\\)((?:\\\\)*")/\\$1/g; qq[-L"$_"] }
63                   @Config{qw/bin sitebin/};
64   $macro{LDDLFLAGS}    = "$lddlflags $libdirs $libperl";
65   $macro{LDFLAGS}      = "$ldflags $libdirs $libperl";
66   $macro{PERL_ARCHIVE} = '',
67  }
68 }
69 print $is_gcc_34 ? "yes\n" : "no\n";
70
71 # Threads, Windows and 5.8.x don't seem to be best friends
72 if ($^O eq 'MSWin32' && $^V lt v5.9.0) {
73  push @DEFINES, '-DVMG_MULTIPLICITY=0';
74  print "Thread safety disabled for perl 5.8.x on Windows.\n"
75 }
76
77 # Fork emulation got "fixed" in 5.10.1
78 if ($^O eq 'MSWin32' && $^V lt v5.10.1) {
79  push @DEFINES, '-DVMG_FORKSAFE=0';
80  print "Fork safety not ensured for perl 5.8.x and 5.10.0 on Windows.\n";
81 }
82
83 @DEFINES = (DEFINE => join ' ', @DEFINES) if @DEFINES;
84 %macro   = (macro  => { %macro })         if %macro; # Beware of the circle
85
86 my $dist = 'Variable-Magic';
87
88 (my $name = $dist) =~ s{-}{::}g;
89
90 (my $file = $dist) =~ s{-}{/}g;
91 $file = "lib/$file.pm";
92
93 my %PREREQ_PM = (
94  'Carp'     => 0,
95  'Exporter' => 0,
96  'XSLoader' => 0,
97  'base'     => 0,
98 );
99
100 my %META = (
101  configure_requires => {
102   'Config'              => 0,
103   'ExtUtils::MakeMaker' => 0,
104  },
105  build_requires => {
106   'Carp'                => 0,
107   'Config'              => 0,
108   'ExtUtils::MakeMaker' => 0,
109   'Test::More'          => 0,
110   %PREREQ_PM,
111  },
112  dynamic_config => 1,
113  resources => {
114   bugtracker => "http://rt.cpan.org/NoAuth/ReportBug.html?Queue=$dist",
115   homepage   => "http://search.cpan.org/dist/$dist/",
116   license    => 'http://dev.perl.org/licenses/',
117   repository => "http://git.profvince.com/?p=perl%2Fmodules%2F$dist.git",
118  },
119 );
120
121 WriteMakefile(
122  NAME             => $name,
123  AUTHOR           => 'Vincent Pit <perl@profvince.com>',
124  LICENSE          => 'perl',
125  VERSION_FROM     => $file,
126  ABSTRACT_FROM    => $file,
127  PL_FILES         => {},
128  @DEFINES,
129  PREREQ_PM        => \%PREREQ_PM,
130  MIN_PERL_VERSION => 5.008,
131  META_MERGE       => \%META,
132  dist             => {
133   PREOP    => "pod2text $file > \$(DISTVNAME)/README",
134   COMPRESS => 'gzip -9f', SUFFIX => 'gz'
135  },
136  clean            => {
137   FILES => "$dist-* *.gcov *.gcda *.gcno cover_db Debian_CPANTS.txt"
138  },
139  %macro,
140 );