#
#   Copyright (C) 2000-2008,2014,2015 Ola Lundqvist <ola@inguza.com>
#                 2015 Chris Lamb <lamby@debian.org>
#                 2015 Mats Erik Andersson <mats.andersson@gisladisker.se>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA.

export DDATE=`cd .. && dpkg-parsechangelog --show-field Date`

all: debarchiver.1.gz debarchiver.fr.1.gz debarchiver.de.1.gz debarchiver.pt.1.gz

debarchiver.pod:
	podselect ../src/debarchiver.pl > $@

debarchiver.fr.pod:
	po4a -L UTF-8 -A UTF-8 po4a.cfg

debarchiver.pt.pod:
	po4a -L UTF-8 -A UTF-8 po4a.cfg

debarchiver.de.pod:
	po4a -L UTF-8 -A UTF-8 po4a.cfg

debarchiver.1: debarchiver.pod
	pod2man	--center="Debarchiver" \
		--section=1 \
                --release="Debarchiver " \
		--date="$(DDATE)" \
		$^ > $@

debarchiver.fr.1: debarchiver.fr.pod
	pod2man	--utf8 \
		--center="Debarchiver" \
		--section=1 \
		--release="Debarchiver " \
		--date="$(DDATE)" \
		$^ > $@

debarchiver.de.1: debarchiver.de.pod
	pod2man	--utf8 \
		--center="Debarchiver" \
		--section=1 \
		--release="Debarchiver " \
		--date="$(DDATE)" \
		$^ > $@

debarchiver.pt.1: debarchiver.pt.pod
	pod2man	--utf8 \
		--center="Debarchiver" \
		--section=1 \
		--release="Debarchiver " \
		--date="$(DDATE)" \
		$^ > $@

%.1.gz: %.1
	gzip -9n -c $^ > $@

install:
	mkdir -p $(DESTDIR)/usr/share/man/man1
	install -m644 debarchiver.1.gz \
		$(DESTDIR)/usr/share/man/man1
	mkdir -p $(DESTDIR)/usr/share/man/fr/man1
	install -m644 debarchiver.fr.1.gz \
		$(DESTDIR)/usr/share/man/fr/man1/debarchiver.1.gz
	mkdir -p $(DESTDIR)/usr/share/man/de/man1
	install -m644 debarchiver.de.1.gz \
		$(DESTDIR)/usr/share/man/de/man1/debarchiver.1.gz
	mkdir -p $(DESTDIR)/usr/share/man/pt/man1
	install -m644 debarchiver.pt.1.gz \
		$(DESTDIR)/usr/share/man/pt/man1/debarchiver.1.gz

clean:
	-rm -f *.pod
	-rm -f *.1.gz
	-rm -f *.1
