File: Makefile.PL

package info (click to toggle)
gscan2pdf 1.2.6-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,560 kB
  • ctags: 445
  • sloc: perl: 16,714; xml: 32; makefile: 5
file content (221 lines) | stat: -rw-r--r-- 7,793 bytes parent folder | download
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
use ExtUtils::MakeMaker;

# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.

my $program = "gscan2pdf";
my $year    = (localtime)[5] + 1900;
my $author  = "Jeffrey Ratcliffe";
my $email   = 'ra28145@users.sourceforge.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 = ();
foreach (@argv) {
    if (m!PREFIX=(.+)!i) {
        $prefixdir = $1;
        push @ARGV, $_;
    }
    elsif (m!SHAREINSTDIR=(.+)!i) {
        $shareinstdir = $1;
    }
    elsif (m!SHAREDIR=(.+)!i) {
        $sharedir = $1;
    }
    else {
        push @ARGV, $_;
    }
}

$prefixdir = "/usr"                unless ($prefixdir);
$sharedir  = $prefixdir . "/share" unless ($sharedir);
$localedir = $sharedir . "/locale" unless ($localedir);

WriteMakefile(
    NAME      => $program,
    VERSION   => $version,
    EXE_FILES => [ "bin/$program", 'bin/scanimage-perl', 'bin/scanadf-perl' ],
    PREREQ_PM => {
        Glib                   => 1.210,
        Gtk2                   => 1.090,
        Sane                   => 0.05,
        Gtk2::Ex::Simple::List => 0,
        Gtk2::ImageView        => 0,
        Image::Magick          => 0,
        Locale::gettext        => 1.05,
        Config::General        => 2.40,
        PDF::API2              => 0,
        Set::IntSpan           => 1.10,
        Goo::Canvas            => 0,
        Readonly               => 0,
        Log::Log4perl          => 0,
        Try::Tiny              => 0,
        List::MoreUtils        => 0,
    },
    clean => { FILES => '$(SOURCE_TIDY)' },
    (
        $] >= 5.005
        ?    ## Add these new keywords supported since 5.005
          (
            ABSTRACT_FROM => "bin/$program",     # retrieve abstract from module
            AUTHOR        => "$author <$email>"
          )
        : ()
    ),
);

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/;
    return $string;
}

sub MY::postamble {
    my $postamble = <<'END';
SHELL = bash
PO = $(wildcard po/*.po)
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)

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.gz rpm/SOURCES/$(NAME)-$(VERSION).tar.gz
	( 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)/appdata :
	$(MKPATH) $@

icon_install : $(NAME).desktop $(NAME).svg stock-rotate-90.svg \
               stock-rotate-180.svg stock-rotate-270.svg scanner.svg pdf.svg \
               stock-selection-all-16.png $(NAME).svg $(NAME).appdata.xml \
             | $(DESTDIR)$(SHAREDIR)/$(NAME) $(DESTDIR)$(SHAREDIR)/applications \
               $(DESTDIR)$(SHAREDIR)/pixmaps \
               $(DESTDIR)$(SHAREDIR)/appdata
	$(CP) $(NAME).desktop $(DESTDIR)$(SHAREDIR)/applications
	$(CP) $(NAME).svg stock-rotate-90.svg stock-rotate-180.svg \
	      stock-rotate-270.svg scanner.svg pdf.svg \
	      stock-selection-all-16.png $(DESTDIR)$(SHAREDIR)/$(NAME)
	$(CP) $(NAME).svg $(DESTDIR)$(SHAREDIR)/pixmaps
	$(CP) $(NAME).appdata.xml $(DESTDIR)$(SHAREDIR)/appdata

html : htdocs/index.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 : bin/$(NAME) debian/changelog
	$(CP) $(NAME).spec $(NAME).spec_tmp
	sed 's/^Version:.*/Version: $(VERSION)/' < $(NAME).spec_tmp | \
         sed '/^%changelog/q' > $(NAME).spec
	rm $(NAME).spec_tmp
	echo "*" `date +'%a %b %d %Y'` "$(AUTHOR) <$(EMAIL)>" >> $(NAME).spec
	sed 's/^$(NAME).*//' < debian/changelog | \
         sed 's/^ --.*//' | sed 's/^  \*/  -/' | sed '/^$$/d' >> $(NAME).spec

$(NAME).Suse.spec : bin/$(NAME) debian/changelog
	$(CP) $(NAME).Suse.spec $(NAME).spec_tmp
	sed 's/^Version:.*/Version: $(VERSION)/' < $(NAME).spec_tmp | \
         sed '/^%changelog/q' > $(NAME).Suse.spec
	rm $(NAME).spec_tmp
	echo "*" `date +'%a %b %d %Y'` "$(AUTHOR) <$(EMAIL)>" >> $(NAME).Suse.spec
	sed 's/^$(NAME).*//' < debian/changelog | \
         sed 's/^ --.*//' | sed 's/^  \*/  -/' | sed '/^$$/d' >> $(NAME).Suse.spec

ppa : tardist
	$(RM_RF) /tmp/$(NAME)
	$(MKPATH) /tmp/$(NAME)
	cp $(NAME)-$(VERSION).tar.gz /tmp/$(NAME)/$(NAME)_$(VERSION).orig.tar.gz
	cd /tmp/$(NAME) && tar xvfz $(NAME)_$(VERSION).orig.tar.gz
	cd /tmp/$(NAME)/$(NAME)-$(VERSION) && debuild -S -sa
	dput $(NAME)-ppa /tmp/$(NAME)/$(NAME)_$(VERSION)*_source.changes

debdist : tardist
	$(RM_RF) /tmp/$(NAME)
	$(MKPATH) /tmp/$(NAME)
	cp $(NAME)-$(VERSION).tar.gz /tmp/$(NAME)/$(NAME)_$(VERSION).orig.tar.gz
	cd /tmp/$(NAME) && tar xvfz $(NAME)_$(VERSION).orig.tar.gz
	cd /tmp/$(NAME)/$(NAME)-$(VERSION) && debuild
	$(CP) /tmp/$(NAME)/$(NAME)_$(VERSION)*_all.deb \
              /tmp/$(NAME)/$(NAME)_$(VERSION)*.diff.gz \
              /tmp/$(NAME)/$(NAME)_$(VERSION)*.dsc \
              /tmp/$(NAME)/$(NAME)_$(VERSION).orig.tar.gz .

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 :
	scp $(NAME)-$(VERSION).tar.gz \
         rpm/RPMS/noarch/$(NAME)-$(VERSION)* \
         rpm/SRPMS/$(NAME)-$(VERSION)* \
         /tmp/$(NAME)/$(NAME)_$(VERSION)*.deb \
	  ra28145,$(NAME)@frs.sf.net:/home/frs/project/g/gs/$(NAME)/$(NAME)/$(VERSION)/

po/$(NAME).pot : $(SOURCE)
	xgettext -L perl --keyword=get --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|be)' > $@

tidy : MANIFEST $(SOURCE_TIDY)

%.tdy : %
	perltidy $* && if ! diff -q $@ $* > /dev/null; then cp $@ $*; fi
END
    $postamble;
}