put the bigfloat stuff into its own file so we can use it everywhere wil less effort
[rersyncrecent.git] / Makefile.PL
blobb029347287f5f7c89d24bb7a24d565cb4947044d
1 use strict;
2 use warnings;
3 use ExtUtils::MakeMaker;
4 $ExtUtils::MakeMaker::VERSION =~ s/_//g;
5 my @sign = (MM->can("signature_target") ? (SIGN => 1) : ());
6 my $version_diff = 0; # we'll have to die if this becomes true
7 my $version_from = 'lib/File/Rsync/Mirror/Recent.pm';
8 my $version;
10     open my $fh, "<", $version_from or die "Could not open $version_from: $!";
11     my @version = grep /VERSION\s*=\s*qv/, <$fh>;
12     our $VERSION;
13     eval $version[0];
14     $version = $VERSION;
16 if ($ARGV[0] && $ARGV[0] eq "--setversion") {
17     die "Your perl is a bit dated[$]].\nDo not make a release with it\n" if $] < 5.008;
18     warn "Your MakeMaker is a bit dated[$ExtUtils::MakeMaker::VERSION].\nYou should get a new one\n"
19         if $ExtUtils::MakeMaker::VERSION < 6.4502;
20     eval {  require $version_from; }; die $@ if $@;
21     my $makefile = "Makefile";
22     unless (-f $makefile) {
23         $makefile = "Makefile.old";
24     }
25     unless (-f $makefile) {
26         die "no Makefile and no Makefile.old found";
27     }
28     open my $fh, "make the-release-name|" or die "Could not fork: $!";
29     local $/;
30     my ($have_version) = <$fh> =~ /^version\s+([\d\._]+)/m;
31     close $fh or die "Could not close: $!";
32     my ($namespace) = $version_from;
33     $namespace =~ s|^lib/(.+)\.pm$|$1|;
34     $namespace =~ s|/|::|g;
35     eval qq{ if (\$$namespace\::VERSION != \$have_version) {
36         warn "Not equal: CPAN::Testers::ParseReport::VERSION[\$$namespace\::VERSION] Makefile version[\$have_version]";
37         \$version_diff = 1;
38     }};
41 WriteMakefile
42     (
43      NAME                => 'File::Rsync::Mirror::Recent',
44      VERSION             => $version,
45      AUTHOR              => 'Andreas König <andreas.koenig.7os6VVqR@franz.ak.mind.de>',
46      PL_FILES            => {},
47      PREREQ_PM =>
48      {
49       # 'Data::Serializer' => 0.46, # restricted to YAML without it
50       'File::Rsync'      => 0,
51       'Test::More'       => 0,
52       'File::Basename'   => 0,
53       'File::Path'       => 0,
54       'File::Temp'       => 0,
55       'Scalar::Util'     => 0,
56       'Time::HiRes'      => 0,
57       'YAML::Syck'       => 0,
58      },
59      EXE_FILES    => [qw(bin/rrr-aggregate bin/rrr-news)],
60      dist => {
61               DIST_DEFAULT => join(" ", # note: order matters!
62                                    "Makefile",
63                                    "META.yml",
64                                    "setversion",
65                                    "all",
66                                    "tardist",
67                                   ),
68               COMPRESS => 'gzip -9',
69              },
70      ($ExtUtils::MakeMaker::VERSION >= 6.4502 ?
71       (META_ADD => {
72                     # write: git push git+ssh://repo.or.cz/srv/git/rersyncrecent.git master
73                     repository => "git://repo.or.cz/rersyncrecent.git",
74                     provides => {
75                                  "File::Rsync::Mirror::Recent" =>
76                                  {
77                                   version => $version,
78                                   file => $version_from,
79                                  }
80                                 },
81                    }) : ()),
82      @sign,
83      clean               => { FILES => 'File-Rsync-Mirror-Recent-*' },
84     );
86 if ($version_diff){
87   die "
88 ==> I had to update some \$VERSIONs <==
89 ==> Your Makefile has been rebuilt. <==
90 ==> Please rerun the make command.  <==
94 package MY;
95 sub postamble {
96   my @m;
97   push @m, q{
98 Makefile: MANIFEST
100 META.yml: metafile
101         $(CP) $(DISTVNAME)/META.yml  ./META.yml
103 setversion:
104         $(PERL) Makefile.PL --setversion
106 the-release-name :
107         $(NOECHO) $(ECHO) 'version ' $(VERSION)
108         $(NOECHO) $(ECHO) 'release-name ' $(DISTVNAME).tar$(SUFFIX)
110 release ::
111         /usr/bin/perl -I../CPAN/GIT/trunk/release-lib -S release $(DISTVNAME).tar$(SUFFIX)
112         rm -rf $(DISTVNAME)
114 sign:
115         cpansign -s
117   join "", @m;
120 sub dist_test {
121   return q{
122 # if we depend on $(DISTVNAME).tar$(SUFFIX), then the rest of the
123 # Makefile breaks our intent to NOT remake dist
124 disttest :
125         rm -rf $(DISTVNAME)
126         tar xvzf $(DISTVNAME).tar$(SUFFIX)
127         cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL
128         cd $(DISTVNAME) && $(MAKE) $(PASTHRU)
129         cd $(DISTVNAME) && $(MAKE) test $(PASTHRU)
131 distdir ::
132         touch $(DISTVNAME)/SIGNATURE && $(CP) $(DISTVNAME)/SIGNATURE ./SIGNATURE
133         $(CP) $(DISTVNAME)/META.yml  ./META.yml
134         $(CP) $(DISTVNAME)/MANIFEST  ./MANIFEST
139 sub distdir {
140   my $self = shift;
141   my $out = $self->SUPER::distdir;
142   $out =~ s/distdir :/distdir ::/g;
143   return $out;
146 # dist_dir was the name in very old MakeMaker as of 5.005_04
147 sub dist_dir {
148   my $self = shift;
149   my $out = $self->SUPER::dist_dir;
150   $out =~ s/distdir :/distdir ::/g;
151   return $out;