remove nonsensical private INC path
[rersyncrecent.git] / Makefile.PL
blobac5c1596102ddc2058653552c10876fcb3e34bf3
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]){
10     if ($ARGV[0] eq "--setversion") {
11         die "Your perl is a bit dated[$]].\nDo not make a release with it\n" if $] < 5.008;
12         die "Your MakeMaker is a bit dated[$ExtUtils::MakeMaker::VERSION].\nDo not make a release with it\n"
13             if $ExtUtils::MakeMaker::VERSION < 6.4502;
14         local $ENV{LANG} = "C";
15         my $dirty = `git status --porcelain --untracked-files=no`;
16         die "Not everything checked in or out?\n====\n$dirty====\n" if $dirty;
17         use lib "lib";
18         eval {  require $version_from; }; die $@ if $@;
19         my $makefile = "Makefile";
20         unless (-f $makefile) {
21             $makefile = "Makefile.old";
22         }
23         unless (-f $makefile) {
24             die "no Makefile and no Makefile.old found";
25         }
26         open my $fh, "make -f $makefile the-release-name|" or die "Could not fork: $!";
27         local $/;
28         my ($have_version) = <$fh> =~ /^version\s+([\d\._]+)/m;
29         close $fh or die "Could not close: $!";
30         my ($namespace) = $version_from;
31         $namespace =~ s|^lib/(.+)\.pm$|$1|;
32         $namespace =~ s|/|::|g;
33         eval qq{ if (\$$namespace\::VERSION != \$version) {
34         warn "Not equal: $namespace\\::VERSION[\$$namespace\::VERSION] MM generated version[\$version]";
35         \$version_diff = 1;
36     }};
37     } elsif ($ARGV[0] eq "--trial") {
38         die "FIXME: --trial does not seem to work";
39         $version .= "-TRIAL";
40     }
42 # $version .= "-TRIAL";
44 my $provides = {
45                 "File::Rsync::Mirror::Recent" =>
46                 {
47                  version => $version,
48                  file => $version_from,
49                 }
50                };
51 for my $m (qw(Recentfile Recentfile::Done Recentfile::FakeBigFloat )) {
52     my $fullm = "File::Rsync::Mirror::$m";
53     my $file = $fullm;
54     $file =~ s/::/\//g;
55     $file = "lib/$file.pm";
56     my $v = MM->parse_version($file);
57     $provides->{$fullm} = {
58                            version => $v,
59                            file => $file,
60                           };
63 my $preferzip = "bzip2"; # bzip2 | gzip
64 WriteMakefile
65     (
66      NAME                => 'File::Rsync::Mirror::Recent',
67      VERSION             => $version,
68      AUTHOR              => 'Andreas König <andreas.koenig.7os6VVqR@franz.ak.mind.de>',
69      PL_FILES            => {},
70      PREREQ_PM =>
71      {
72       # 'Data::Serializer' => 0.46, # restricted to YAML without it
73       'Data::Float'      => 0,
74       'Data::Serializer' => 0,
75       'File::Basename'   => 0,
76       'File::Find::Rule' => 0,
77       'File::Path'       => 0,
78       'File::Rsync'      => 0,
79       'File::Spec'       => 0,
80       'File::Temp'       => '0.21', # removes bogus test on parent directory
81       'JSON'             => '2',
82       'List::MoreUtils'  => 0,
83       'List::Pairwise'   => 0,
84       'Pod::Usage'       => '1.61', # 1.16 from perl-5.8.1 failed, 1.61 is
85                                     # the oldest working on CPAN now
86       'Scalar::Util'     => 0,
87       'Test::More'       => 0,
88       'Time::HiRes'      => 0,
89       'YAML::Syck'       => 0,
90       'accessors'        => 0,
91       'version'          => 0,
92      },
93      EXE_FILES    => [
94                       grep { !/~/ } glob("bin/rrr bin/rrr-*")
95                      ],
96      dist => {
97               DIST_DEFAULT => join(" ", # note: order matters!
98                                    "verify-changes-date",
99                                    "verify-changes-version",
100                                    "Makefile",
101                                    "META.yml",
102                                    "setversion",
103                                    "all",
104                                    "tardist",
105                                    "memo-howto-release",
106                                   ),
107               $preferzip eq "bzip2" ?
108               (COMPRESS => 'bzip2 -9f',
109                SUFFIX => ".bz2") :
110               (COMPRESS => 'gzip -9f',
111                SUFFIX => ".gz"),
112              },
113      ($ExtUtils::MakeMaker::VERSION >= 6.4502 ?
114       (META_MERGE => {
115                       # write: git push git+ssh://repo.or.cz/srv/git/rersyncrecent.git master
116                       resources => {
117                                     repository => "git://repo.or.cz/rersyncrecent.git",
118                                    },
119                       provides => $provides,
120                      }) : ()),
121      @sign,
122      clean               => { FILES => 'File-Rsync-Mirror-Recent-*' },
123     );
125 if ($version_diff){
126   die "
127 ==> I had to update some \$VERSIONs <==
128 ==> Your Makefile has been rebuilt. <==
129 ==> Please rerun the make command.  <==
133 package MY;
134 sub distsignature {
135     my($self) = shift;
136     my $ret = $self->SUPER::distsignature_target(@_);
137     $ret =~ s|cpansign|\$(PERL) \`dirname \$(PERL)\`/cpansign|g;
138     return $ret;
140 sub postamble {
141   my @m;
142   push @m, q{
143 Makefile: }.$version_from.q{
145 META.yml: metafile
146         $(CP) $(DISTVNAME)/META.yml  ./META.yml
148 setversion:
149         $(PERL) Makefile.PL --setversion
151 verify-changes-date:
152         @$(PERL) -ne 'BEGIN{my@t=(localtime)[5,4,3];$$t[0]+=1900;$$t[1]++;$$t=sprintf"%04d-%02d-%02d",@t}' \
153                 -e '$$ok++,exit if /^$$t\s/; END{die "Alert: did not find <$$t> in Changes file" unless $$ok}' Changes
155 verify-changes-version:
156         @$(PERL) -ne '$$ok++,exit if /\b$(VERSION)\b/; END{die "Alert: did not find <$(VERSION)> in Changes file" unless $$ok}' Changes
158 verify-no-subdir:
159         @$(PERL) -e 'my$$s=join",",grep{!/^($(OKDIRS))\z/x&&-d($$_)}glob"*";' \
160                 -e 'die"unexpected dir:$$s"if$$s'
162 the-release-name :
163         $(NOECHO) $(ECHO) 'version ' $(VERSION)
164         $(NOECHO) $(ECHO) 'release-name ' $(DISTVNAME).tar$(SUFFIX)
166 memo-howto-release:
167         $(NOECHO) $(ECHO) 'after successful make dist and upload do not forget to'
168         $(NOECHO) $(ECHO) ' make tag'
169         $(NOECHO) $(ECHO) ' git push --tags'
170         $(NOECHO) $(ECHO) 'before writing Changes do not forget to'
171         $(NOECHO) $(ECHO) ' git --no-pager log --no-merges --pretty=format:" %x20%x20 - %s (%an)" | less'
173 tag ::
174         git tag -m 'This is $(VERSION)' "$(VERSION)"
176 sign:
177         $(PERL) `dirname $(PERL)`/cpansign -s
179 test-server-run:
180         $(PERL) bin/rrr-init --force t/testserver
181         $(PERL) bin/rrr-server t/testserver/RECENT-1h.yaml &
182         $(PERL) bin/rrr-init --force t/testserver
184   join "", @m;
187 sub dist_test {
188   return q{
189 # if we depend on $(DISTVNAME).tar$(SUFFIX), then the rest of the
190 # Makefile breaks our intent to NOT remake dist
191 disttest :
192         rm -rf $(DISTVNAME)
193         tar xvjf $(DISTVNAME).tar$(SUFFIX)
194         cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL
195         cd $(DISTVNAME) && $(MAKE) $(PASTHRU)
196         cd $(DISTVNAME) && $(MAKE) test $(PASTHRU)
198 distdir ::
199         touch $(DISTVNAME)/SIGNATURE && $(CP) $(DISTVNAME)/SIGNATURE ./SIGNATURE
200         $(CP) $(DISTVNAME)/META.yml  ./META.yml
201         $(CP) $(DISTVNAME)/MANIFEST  ./MANIFEST
206 sub distdir {
207   my $self = shift;
208   my $out = $self->SUPER::distdir;
209   $out =~ s/distdir :/distdir ::/g;
210   return $out;
213 # dist_dir was the name in very old MakeMaker as of 5.005_04
214 sub dist_dir {
215   my $self = shift;
216   my $out = $self->SUPER::dist_dir;
217   $out =~ s/distdir :/distdir ::/g;
218   return $out;