1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
|
use ExtUtils::MakeMaker;
my $program = "gscan2pdf";
my $year = (localtime)[5] + 1900;
my $author = "Jeffrey Ratcliffe";
my $email = 'jffry@posteo.net';
# Slurp the program source and dig out the version number.
my $text = do { local ( @ARGV, $/ ) = "bin/$program"; <> };
my $version = $1 if ( $text =~ /^my \$VERSION\s*=\s*'(.*)'/m );
my @argv = @ARGV;
my $prefixdir;
my $sharedir;
my $shareinstdir;
@ARGV = ();
for (@argv) {
if (m!PREFIX=(.+)!i) {
$prefixdir = $1;
push @ARGV, $_;
}
elsif (m!SHAREINSTDIR=(.+)!i) {
$shareinstdir = $1;
}
elsif (m!SHAREDIR=(.+)!i) {
$sharedir = $1;
}
elsif (m!LOCALEDIR=(.+)!i) {
$localedir = $1;
}
else {
push @ARGV, $_;
}
}
$prefixdir = "/usr" unless ($prefixdir);
$sharedir = $prefixdir . "/share" unless ($sharedir);
$localedir = $sharedir . "/locale" unless ($localedir);
WriteMakefile(
NAME => $program,
VERSION => $version,
ABSTRACT_FROM => "bin/$program", # retrieve abstract from module
AUTHOR => "$author <$email>",
EXE_FILES => ["bin/$program"],
PREREQ_PM => {
Glib => 1.210,
Gtk3 => 0,
Image::Sane => 0,
Gtk3::SimpleList => 0,
Image::Magick => 0,
Locale::gettext => 1.05,
Config::General => 2.40,
PDF::Builder => 3.022, # for annotations
Set::IntSpan => 1.10,
GooCanvas2 => 0,
Readonly => 0,
Log::Log4perl => 0,
Try::Tiny => 0,
List::MoreUtils => 0,
Filesys::Df => 0,
Date::Calc => 0,
},
BUILD_REQUIRES => {
Test::More => 0,
Sub::Override => 0,
IPC::System::Simple => 0,
},
clean => { FILES => '$(SOURCE_TIDY)' },
dist => { COMPRESS => 'xz -9', SUFFIX => '.xz', },
);
sub MY::macro {
my $self = shift;
my $string = $self->MM::macro();
$string .= "SHAREDIR=$sharedir\n";
$string .= "LOCALEDIR=$localedir\n";
$string .= "AUTHOR=$author\n";
$string .= "EMAIL=$email\n";
$string .= "YEAR=$year\n";
$string .= "SITEPREFIX=$prefixdir\n";
$string .= "INSTALLMAN1DIR=$sharedir/man/man1\n";
$string .= "INSTALLSITEMAN1DIR=$sharedir/man/man1\n";
$string .= "INSTALLMAN3DIR=$sharedir/man/man3\n";
$string .= "INSTALLSITEMAN3DIR=$sharedir/man/man3\n";
$string .= "MAN1EXT=1p\n";
return $string;
}
sub MY::install {
my $self = shift;
my $string = $self->MM::install();
$string =~
s/doc_install/doc_install locale_install icon_install html_install/;
return $string;
}
sub MY::postamble {
my $postamble = <<'END';
SHELL = bash
DEB_BUILD_ROOT = /var/tmp/$(NAME)-$(VERSION)
MANIFEST = $(shell cat MANIFEST)
SOURCE = $(filter bin/% %.pm %.PL %.pl %.t,$(MANIFEST))
SOURCE_TIDY = $(foreach file,$(SOURCE),$(file).tdy)
PO = $(filter %.po,$(MANIFEST))
LANGUAGES = $(patsubst po/$(NAME)-%.po,%,$(PO))
MO = $(foreach lang,$(LANGUAGES),$(DESTDIR)$(LOCALEDIR)/$(lang)/LC_MESSAGES/$(NAME).mo)
ICONS = $(wildcard icons/*)
TLD = net
VENDOR = sourceforge
rpmdist : $(NAME).spec $(NAME).Suse.spec tardist
$(MKPATH) rpm rpm/SPECS rpm/SOURCES rpm/BUILD rpm/RPMS rpm/SRPMS \
rpm/RPMS/noarch || /bin/true
$(CP) $(NAME).spec $(NAME).Suse.spec rpm/SPECS/
$(CP) $(NAME)-$(VERSION).tar.xz rpm/SOURCES/$(NAME)-$(VERSION).tar.xz
( cd rpm/SPECS; \
rpmbuild --nodeps --define='_topdir $(PWD)/rpm' -ba $(NAME).spec; \
rpmbuild --nodeps --define='_topdir $(PWD)/rpm' --define 'dist .Suse' -ba $(NAME).Suse.spec )
locale_install : $(MO)
$(DESTDIR)$(LOCALEDIR)/%/LC_MESSAGES/$(NAME).mo : po/$(NAME)-%.po
$(MKPATH) $(@D)
msgfmt -c $< -o $@
$(CHMOD) 755 $(@D)
$(DESTDIR)$(SHAREDIR)/$(NAME) $(DESTDIR)$(SHAREDIR)/applications $(DESTDIR)$(SHAREDIR)/pixmaps $(DESTDIR)$(SHAREDIR)/metainfo :
$(MKPATH) $@
icon_install : $(TLD).$(VENDOR).$(NAME).desktop $(ICONS) $(TLD).$(VENDOR).$(NAME).appdata.xml \
| $(DESTDIR)$(SHAREDIR)/$(NAME) $(DESTDIR)$(SHAREDIR)/applications \
$(DESTDIR)$(SHAREDIR)/pixmaps \
$(DESTDIR)$(SHAREDIR)/metainfo
$(CP) $(TLD).$(VENDOR).$(NAME).desktop $(DESTDIR)$(SHAREDIR)/applications
$(CP) $(ICONS) $(DESTDIR)$(SHAREDIR)/$(NAME)
$(CP) icons/$(NAME).svg $(DESTDIR)$(SHAREDIR)/pixmaps
$(CP) $(TLD).$(VENDOR).$(NAME).appdata.xml $(DESTDIR)$(SHAREDIR)/metainfo
# remove the =for html sections to satisfy lintian
html_install :
$(MKPATH) $(DESTDIR)$(SHAREDIR)/help/C/$(NAME)
awk -v RS='' '{gsub(/=for html.*/, ""); print; print ""}' bin/$(NAME) | pod2html --noindex --title=$(NAME)-$(VERSION) > $(DESTDIR)$(SHAREDIR)/help/C/$(NAME)/documentation.html
pot : po/$(NAME).pot
po.tar.gz : po/$(NAME).pot $(PO)
cd po; tar cfvz po.tar.gz $(NAME).pot *.po
mv po/po.tar.gz .
$(NAME).spec $(NAME).Suse.spec : bin/$(NAME) debian/changelog
$(CP) $@ $@_tmp
sed 's/^Version:.*/Version: $(VERSION)/' < $@_tmp | \
sed '/^%changelog/q' > $@
rm $@_tmp
echo "*" `date +'%a %b %d %Y'` "$(AUTHOR) <$(EMAIL)>" >> $@
sed 's/^$(NAME).*//' < debian/changelog | \
sed 's/^ --.*//' | sed 's/^ \*/ -/' | sed '/^$$/d' >> $@
debdist : tardist
$(RM_RF) /tmp/$(NAME)
$(MKPATH) /tmp/$(NAME)
cp $(NAME)-$(VERSION).tar.xz /tmp/$(NAME)/$(NAME)_$(VERSION).orig.tar.xz
cd /tmp/$(NAME) && tar xvfJ $(NAME)_$(VERSION).orig.tar.xz
cd /tmp/$(NAME)/$(NAME)-$(VERSION) && debuild
$(CP) /tmp/$(NAME)/$(NAME)_$(VERSION)*_all.deb \
/tmp/$(NAME)/$(NAME)_$(VERSION)*.dsc \
/tmp/$(NAME)/$(NAME)_$(VERSION).orig.tar.xz .
signed_tardist : tardist
gpg --armor --detach-sign $(NAME)-$(VERSION).tar.xz
htdocs/index.html : bin/$(NAME)
[ -d htdocs ] || mkdir htdocs
pod2html --noindex --title=$(NAME)-$(VERSION) bin/$(NAME) > htdocs/index.html
remote-html : htdocs/index.html
scp htdocs/index.html ra28145,$(NAME)@web.sf.net:/home/groups/g/gs/$(NAME)/htdocs/
file_releases : ../../sandbox/$(NAME)_$(VERSION)-1_all.deb
scp $(NAME)-$(VERSION).tar.xz $(NAME)-$(VERSION).tar.xz.asc $< \
ra28145,$(NAME)@frs.sf.net:/home/frs/project/g/gs/$(NAME)/$(NAME)/$(VERSION)/
po/$(NAME).pot : $(SOURCE)
xgettext -L perl --keyword=__ --from-code=UTF-8 -o - -f MANIFEST | \
sed 's/SOME DESCRIPTIVE TITLE/messages.pot for $(NAME)/' | \
sed 's/PACKAGE VERSION/$(NAME)-$(VERSION)/' | \
sed "s/YEAR THE PACKAGE'S COPYRIGHT HOLDER/$(YEAR) $(AUTHOR)/" | \
sed 's/PACKAGE/$(NAME)/' | \
sed 's/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR/$(AUTHOR) <$(EMAIL)>, $(YEAR)/' | \
sed 's/Report-Msgid-Bugs-To: /Report-Msgid-Bugs-To: $(EMAIL)/' | \
grep -v fuzzy > $@
MANIFEST : $(SOURCE)
git ls-files | egrep -v '^\.git' > $@
tidy : MANIFEST $(SOURCE_TIDY)
%.tdy : %
perltidy $* && if ! diff -q $@ $* > /dev/null; then cp $@ $*; fi
END
$postamble;
}
|