initial checkin
[rersyncrecent.git] / Makefile.PL
blobcaedd4194df93d4b0c574ccce82001abed9537e8
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 = MM->parse_version($version_from);
9 if ($ARGV[0] && $ARGV[0] eq "--setversion") {
10     die "Your perl is a bit dated[$]].\nDo not make a release with it\n" if $] < 5.008;
11     die "Your MakeMaker is a bit dated[$ExtUtils::MakeMaker::VERSION].\nYou should get a new one\n"
12         if $ExtUtils::MakeMaker::VERSION < 6.4502;
13     use lib "lib";
14     eval {  require $version_from; }; die $@ if $@;
15     my $makefile = "Makefile";
16     unless (-f $makefile) {
17         $makefile = "Makefile.old";
18     }
19     unless (-f $makefile) {
20         die "no Makefile and no Makefile.old found";
21     }
22     open my $fh, "make -f $makefile the-release-name|" or die "Could not fork: $!";
23     local $/;
24     my ($have_version) = <$fh> =~ /^version\s+([\d\._]+)/m;
25     close $fh or die "Could not close: $!";
26     my ($namespace) = $version_from;
27     $namespace =~ s|^lib/(.+)\.pm$|$1|;
28     $namespace =~ s|/|::|g;
29     eval qq{ if (\$$namespace\::VERSION != \$version) {
30         warn "Not equal: $namespace\\::VERSION[\$$namespace\::VERSION] MM generated version[\$version]";
31         \$version_diff = 1;
32     }};
35 my $provides = {
36                 "File::Rsync::Mirror::Recent" =>
37                 {
38                  version => $version,
39                  file => $version_from,
40                 }
41                };
42 for my $m (qw(Recentfile Recentfile::Done Recentfile::FakeBigFloat )) {
43     my $fullm = "File::Rsync::Mirror::$m";
44     my $file = $fullm;
45     $file =~ s/::/\//g;
46     $file = "lib/$file.pm";
47     my $v = MM->parse_version($file);
48     $provides->{$fullm} = {
49                            version => $v,
50                            file => $file,
51                           };
54 my $preferzip = "gzip"; # bzip2 | gzip
55 warn "XXXXXXXXXX current zip variant: $preferzip XXXXXXXXXX\n" for 1..3;
56 sleep 2;
57 WriteMakefile
58     (
59      NAME                => 'File::Rsync::Mirror::Recent',
60      VERSION             => $version,
61      AUTHOR              => 'Andreas König <andreas.koenig.7os6VVqR@franz.ak.mind.de>',
62      PL_FILES            => {},
63      PREREQ_PM =>
64      {
65       # 'Data::Serializer' => 0.46, # restricted to YAML without it
66       'accessors'        => 0,
67       'Data::Float'      => 0,
68       'File::Rsync'      => 0,
69       'Test::More'       => 0,
70       'File::Basename'   => 0,
71       'File::Path'       => 0,
72       'File::Temp'       => 0,
73       'List::MoreUtils'  => 0,
74       'List::Pairwise'   => 0,
75       'Scalar::Util'     => 0,
76       'Data::Serializer' => 0,
77       'Time::HiRes'      => 0,
78       'YAML::Syck'       => 0,
79       'version'          => 0,
80      },
81      EXE_FILES    => [
82                       'bin/rrr',
83                       'bin/rrr-aggregate',
84                       'bin/rrr-dirtyupdate',
85                       'bin/rrr-news',
86                       'bin/rrr-overview',
87                      ],
88      dist => {
89               DIST_DEFAULT => join(" ", # note: order matters!
90                                    "verify-changes-date",
91                                    "Makefile",
92                                    "META.yml",
93                                    "setversion",
94                                    "all",
95                                    "tardist",
96                                    "release-memo",
97                                   ),
98               $preferzip eq "bzip2" ?
99               (COMPRESS => 'bzip2 -9f',
100                SUFFIX => ".bz2") :
101               (COMPRESS => 'gzip -9f',
102                SUFFIX => ".gz"),
103              },
104      ($ExtUtils::MakeMaker::VERSION >= 6.4502 ?
105       (META_MERGE => {
106                       # write: git push git+ssh://repo.or.cz/srv/git/rersyncrecent.git master
107                       repository => "git://repo.or.cz/rersyncrecent.git",
108                       provides => $provides,
109                      }) : ()),
110      @sign,
111      clean               => { FILES => 'File-Rsync-Mirror-Recent-*' },
112     );
114 if ($version_diff){
115   die "
116 ==> I had to update some \$VERSIONs <==
117 ==> Your Makefile has been rebuilt. <==
118 ==> Please rerun the make command.  <==
122 package MY;
123 sub postamble {
124   my @m;
125   push @m, q{
126 Makefile: }.$version_from.q{
128 META.yml: metafile
129         $(CP) $(DISTVNAME)/META.yml  ./META.yml
131 setversion:
132         $(PERL) Makefile.PL --setversion
134 verify-changes-date:
135         @$(PERL) -ne 'BEGIN{my@t=(localtime)[5,4,3];$$t[0]+=1900;$$t[1]++;$$t=sprintf"%04d-%02d-%02d",@t}' \
136                 -e '$$ok++,exit if /^$$t\s/; END{die "Alert: did not find <$$t> in Changes file" unless $$ok}' Changes
138 verify-no-subdir:
139         @$(PERL) -e 'my$$s=join",",grep{!/^($(OKDIRS))\z/x&&-d($$_)}glob"*";' \
140                 -e 'die"unexpected dir:$$s"if$$s'
142 the-release-name :
143         $(NOECHO) $(ECHO) 'version ' $(VERSION)
144         $(NOECHO) $(ECHO) 'release-name ' $(DISTVNAME).tar$(SUFFIX)
146 release-memo:
147         $(NOECHO) $(ECHO) 'after successful make dist and upload do not forget to'
148         $(NOECHO) $(ECHO) ' make tag'
149         $(NOECHO) $(ECHO) ' git push --tags'
150         $(NOECHO) $(ECHO) 'before writing Changes do not forget to'
151         $(NOECHO) $(ECHO) ' git --no-pager log --no-merges --pretty=format:" %x20%x20 - %s (%an)" | less'
153 tag ::
154         git tag -m 'This is $(VERSION)' "$(VERSION)"
156 sign:
157         cpansign -s
159   join "", @m;
162 sub dist_test {
163   return q{
164 # if we depend on $(DISTVNAME).tar$(SUFFIX), then the rest of the
165 # Makefile breaks our intent to NOT remake dist
166 disttest :
167         rm -rf $(DISTVNAME)
168         tar xvjf $(DISTVNAME).tar$(SUFFIX)
169         cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL
170         cd $(DISTVNAME) && $(MAKE) $(PASTHRU)
171         cd $(DISTVNAME) && $(MAKE) test $(PASTHRU)
173 distdir ::
174         touch $(DISTVNAME)/SIGNATURE && $(CP) $(DISTVNAME)/SIGNATURE ./SIGNATURE
175         $(CP) $(DISTVNAME)/META.yml  ./META.yml
176         $(CP) $(DISTVNAME)/MANIFEST  ./MANIFEST
181 sub distdir {
182   my $self = shift;
183   my $out = $self->SUPER::distdir;
184   $out =~ s/distdir :/distdir ::/g;
185   return $out;
188 # dist_dir was the name in very old MakeMaker as of 5.005_04
189 sub dist_dir {
190   my $self = shift;
191   my $out = $self->SUPER::dist_dir;
192   $out =~ s/distdir :/distdir ::/g;
193   return $out;