]> git.vpit.fr Git - perl/modules/Scope-Upper.git/blob - Makefile.PL
Protect against d_cplusplus perls
[perl/modules/Scope-Upper.git] / Makefile.PL
1 use 5.006_001;
2
3 use strict;
4 use warnings;
5 use ExtUtils::MakeMaker;
6
7 use Config;
8
9 if ($Config{d_cplusplus}) {
10  print STDERR <<'FAILPLUSPLUS';
11 Configuration aborted: C++ compilers are not supported
12
13     Your perl has been built with a C++ compiler, which is then handed to
14     XS extensions as if it were a proper C compiler. This extension is
15     written in C, and naturally only supports C compilers, so it cannot be
16     built with your perl.
17
18     Note that building perl with a C++ compiler is only supposed to be done
19     by core developers in order to check that the perl headers can be
20     included from C++ code. Its use in the wild is not supported by the
21     perl5 porters. If your vendor has built its perl binary with a C++
22     compiler, please consider reporting this issue to them.
23
24     This text will be displayed 10 seconds, and then the configuration
25     script will exit.
26 FAILPLUSPLUS
27  sleep 10;
28  exit 0;
29 }
30
31 my $pl   = $Config{perl_patchlevel};
32 my $desc = $Config{git_describe};
33 for ($pl, $desc) {
34  $_ = undef unless defined and length;
35 }
36
37 my @DEFINES;
38 my %macro;
39
40 print "Checking if this is an official release of perl... ";
41 my $is_release = ("$]" < 5.011) ? (defined($pl) || defined($desc) ? 0 : 1)
42                                 : (defined($desc)                 ? 0 : 1);
43 push @DEFINES, "-DSU_RELEASE=$is_release";
44 print $is_release  ? "yes\n" : "no\n";
45
46 my $is_gcc_34 = 0;
47 print "Checking if this is gcc 3.4 on Windows trying to link against an import library... ";
48 if ($^O eq 'MSWin32' and not grep /^LD[A-Z]*=/, @ARGV) {
49  my ($libperl, $gccversion) = map $_ || '', @Config{qw<libperl gccversion>};
50  if ($gccversion =~ /^3\.4\.[0-9]+/ and $libperl =~ s/\.lib$//) {
51   $is_gcc_34 = 1;
52   my ($lddlflags, $ldflags) = @Config{qw<lddlflags ldflags>};
53   $_ ||= '', s/-L(?:".*?"|\S+)//g for $lddlflags, $ldflags;
54   $libperl = "-l$libperl";
55   my $libdirs = join ' ',
56                  map { s/(?<!\\)((?:\\\\)*")/\\$1/g; qq[-L"$_"] }
57                   @Config{qw<bin sitebin>};
58   $macro{LDDLFLAGS}    = "$lddlflags $libdirs $libperl";
59   $macro{LDFLAGS}      = "$ldflags $libdirs $libperl";
60   eval <<'  MY_SECTION';
61    package MY;
62    sub dynamic_lib {
63     my $self = shift;
64     my $inherited = $self->SUPER::dynamic_lib(@_);
65     $inherited =~ s/"?\$\(PERL_ARCHIVE\)"?//g;
66     return $inherited;
67    }
68   MY_SECTION
69   die $@ if $@;
70  }
71 }
72 print $is_gcc_34 ? "yes\n" : "no\n";
73
74 # Threads, Windows and 5.8.x don't seem to be best friends
75 if ($^O eq 'MSWin32' && "$]" < 5.009) {
76  push @DEFINES, '-DXSH_MULTIPLICITY=0';
77 }
78
79 @DEFINES = (DEFINE => join ' ', @DEFINES) if @DEFINES;
80 %macro   = (macro  => { %macro })         if %macro; # Beware of the cycle
81
82 my $dist = 'Scope-Upper';
83
84 (my $name = $dist) =~ s{-}{::}g;
85
86 (my $file = $dist) =~ s{-}{/}g;
87 $file = "lib/$file.pm";
88
89 my %PREREQ_PM = (
90  'Exporter' => 0,
91  'XSLoader' => 0,
92  'base'     => 0,
93 );
94
95 my %BUILD_REQUIRES = (
96  'ExtUtils::MakeMaker' => 0,
97  'Config'              => 0,
98  'POSIX'               => 0,
99  'Test::More'          => 0,
100  %PREREQ_PM,
101 );
102
103 my %META = (
104  configure_requires => {
105   'Config'              => 0,
106   'ExtUtils::MakeMaker' => 0,
107  },
108  build_requires => {
109   %BUILD_REQUIRES,
110  },
111  dynamic_config => 1,
112  resources => {
113   bugtracker => "http://rt.cpan.org/Dist/Display.html?Name=$dist",
114   homepage   => "http://search.cpan.org/dist/$dist/",
115   license    => 'http://dev.perl.org/licenses/',
116   repository => "http://git.profvince.com/?p=perl%2Fmodules%2F$dist.git",
117  },
118 );
119
120 WriteMakefile(
121  NAME             => $name,
122  AUTHOR           => 'Vincent Pit <perl@profvince.com>',
123  LICENSE          => 'perl',
124  VERSION_FROM     => $file,
125  ABSTRACT_FROM    => $file,
126  PL_FILES         => {},
127  @DEFINES,
128  BUILD_REQUIRES   => \%BUILD_REQUIRES,
129  PREREQ_PM        => \%PREREQ_PM,
130  MIN_PERL_VERSION => '5.006001',
131  META_MERGE       => \%META,
132  dist             => {
133   PREOP    => "pod2text -u $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 );
141
142 package MY;
143
144 sub postamble {
145  return <<'POSTAMBLE';
146 testdeb: all
147         PERL_DL_NONLAZY=1 PERLDB_OPTS="NonStop=1" $(FULLPERLRUN) -MTAP::Harness -e 'TAP::Harness->new({verbosity => q{$(TEST_VERBOSE)}, lib => [ q{$(INST_LIB)}, q{$(INST_ARCHLIB)} ], switches => [ q{-d} ]})->runtests(@ARGV)' $(TEST_FILES)
148 POSTAMBLE
149 }