From: Didier Raboud <odyx@debian.org>
Date: Tue, 9 Aug 2016 18:11:50 +0200
Subject: Debian: po4a infrastructure and translations for manpages
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

Author: Nicolas François <nicolas.francois@centraliens.net>, Helge Kreutzmann <debian@helgefjell.de>
Origin: vendor
Bug-Debian: https://bugs.debian.org/478597
Forwarded: not-needed
---
 man/Makefile      |  17 +++-
 man/Makefile.l10n | 235 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 man/de/Makefile   |   7 ++
 man/fr/Makefile   |   7 ++
 4 files changed, 264 insertions(+), 2 deletions(-)
 create mode 100644 man/Makefile.l10n
 create mode 100644 man/de/Makefile
 create mode 100644 man/fr/Makefile

diff --git a/man/Makefile b/man/Makefile
index e01591a..48f06c4 100644
--- a/man/Makefile
+++ b/man/Makefile
@@ -63,12 +63,18 @@ MAN8	=	cupsaccept.8 \
 		lpmove.8 \
 		lpc.8
 
+LANGUAGES=de fr
 
 #
 # Make everything...
 #
 
-all:	$(MAN1) $(MAN5) $(MAN7) $(MAN8)
+all:	$(MAN1) $(MAN5) $(MAN7) $(MAN8) translations
+
+translations:
+	# Update the translations and build the translated material
+	po4a --previous ../debian/manpage-po4a/cups.cfg
+	for lang in $(LANGUAGES); do $(MAKE) -C $$lang; done
 
 
 #
@@ -91,6 +97,12 @@ unittests:
 
 clean:
 	$(RM) mantohtml mantohtml.o
+	$(RM) $(MAN1) $(MAN5) $(MAN7) $(MAN8)
+	for lang in $(LANGUAGES); do $(MAKE) -C $$lang clean; done
+	# Make sure the PO files are updated and remove generated
+	# translations.
+	po4a --previous --rm-translations ../debian/manpage-po4a/cups.cfg
+	$(RM) ../debian/manpage-po4a/po/cups.pot
 
 
 #
@@ -142,6 +154,7 @@ install-data: all
 		$(RM) $(MANDIR)/man8/$$file; \
 		$(LN) cupsd-helper.8 $(MANDIR)/man8/$$file; \
 	done
+	for lang in $(LANGUAGES); do $(MAKE) -C $$lang install; done
 
 
 #
@@ -189,7 +202,7 @@ uninstall:
 	for file in $(MAN8) cupsenable.8 cupsreject.8 cups-deviced.8 cups-driverd.8 cups-exec.8; do \
 		$(RM) $(MANDIR)/man8/$$file; \
 	done
-	-$(RMDIR) $(MANDIR)/man8
+	-$(RMDIR) $(AMANDIR)/man$(MAN8DIR)
 
 
 #
diff --git a/man/Makefile.l10n b/man/Makefile.l10n
new file mode 100644
index 0000000..08390f5
--- /dev/null
+++ b/man/Makefile.l10n
@@ -0,0 +1,235 @@
+#
+# Man page makefile for CUPS.
+#
+# Copyright © 2007-2019 by Apple Inc.
+# Copyright © 1993-2006 by Easy Software Products.
+#
+# Licensed under Apache License v2.0.  See the file "LICENSE" for more
+# information.
+#
+
+include ../../Makedefs
+
+
+#
+# Man pages...
+#
+
+MAN1	=	cancel.1 \
+		cups.1 \
+		cups-config.1 \
+		cupstestppd.1 \
+		ippeveprinter.1 \
+		$(IPPFIND_MAN) \
+		ipptool.1 \
+		lp.1 \
+		lpoptions.1 \
+		lpq.1 \
+		lprm.1 \
+		lpr.1 \
+		lpstat.1 \
+		ppdc.1 \
+		ppdhtml.1 \
+		ppdi.1 \
+		ppdmerge.1 \
+		ppdpo.1
+MAN5	=	classes.conf.5 \
+		client.conf.5 \
+		cups-files.conf.5 \
+		cups-snmp.conf.5 \
+		cupsd.conf.5 \
+		cupsd-logs.5 \
+		ipptoolfile.5 \
+		mailto.conf.5 \
+		mime.convs.5 \
+		mime.types.5 \
+		ppdcfile.5 \
+		printers.conf.5 \
+		subscriptions.conf.5
+MAN7	=	backend.7 \
+		filter.7 \
+		ippevepcl.7 \
+		notifier.7
+MAN8	=	cupsaccept.8 \
+		cupsctl.8 \
+		cupsfilter.8 \
+		cups-lpd.8 \
+		cups-snmp.8 \
+		cupsd.8 \
+		cupsd-helper.8 \
+		cupsenable.8 \
+		lpadmin.8 \
+		lpinfo.8 \
+		lpmove.8 \
+		lpc.8
+
+
+#
+# Make everything...
+#
+
+# Debian-specific patch: Just assume all files are here.
+all:
+
+
+#
+# Make library targets...
+#
+
+libs:
+
+
+#
+# Make unit tests...
+#
+
+unittests:
+
+
+#
+# Clean all config and object files...
+#
+
+clean:
+	$(RM) mantohtml mantohtml.o
+
+
+#
+# Dummy depend target...
+#
+
+depend:
+
+
+#
+# Install all targets...
+#
+
+# Debian-specific patch: directory-based language namespace
+MANDIR := $(MANDIR)/$(LANGUAGE)
+
+install:	all install-data install-headers install-libs install-exec
+
+
+#
+# Install data files...
+#
+
+# Debian-specific patch: skip if doesn't exist
+install-data: all
+	echo Installing man pages in $(MANDIR)/man1...
+	$(INSTALL_DIR) -m 755 $(MANDIR)/man1
+	for file in $(MAN1); do \
+		[ ! -r $$file ] || \
+		$(INSTALL_MAN) $$file $(MANDIR)/man1; \
+	done
+	echo Installing man pages in $(MANDIR)/man5...
+	$(INSTALL_DIR) -m 755 $(MANDIR)/man5
+	for file in $(MAN5); do \
+		[ ! -r $$file ] || \
+		$(INSTALL_MAN) $$file $(MANDIR)/man5; \
+	done
+	echo Installing man pages in $(MANDIR)/man7...
+	$(INSTALL_DIR) -m 755 $(MANDIR)/man7
+	for file in $(MAN7); do \
+		[ ! -r $$file ] || \
+		$(INSTALL_MAN) $$file $(MANDIR)/man7; \
+	done
+	$(RM) $(MANDIR)/man7/ippeveps.7
+	$(LN) ippevepcl.7 $(MANDIR)/man7/ippeveps.7
+	echo Installing man pages in $(MANDIR)/man8...
+	$(INSTALL_DIR) -m 755 $(MANDIR)/man8
+	for file in $(MAN8); do \
+		[ ! -r $$file ] || \
+		$(INSTALL_MAN) $$file $(MANDIR)/man8; \
+	done
+	$(RM) $(MANDIR)/man8/cupsdisable.8
+	$(LN) cupsenable.8 $(MANDIR)/man8/cupsdisable.8
+	$(RM) $(MANDIR)/man8/cupsreject.8
+	$(LN) cupsaccept.8 $(MANDIR)/man8/cupsreject.8
+	for file in cups-deviced.8 cups-driverd.8 cups-exec.8; do \
+		$(RM) $(MANDIR)/man8/$$file; \
+		$(LN) cupsd-helper.8 $(MANDIR)/man8/$$file; \
+	done
+
+
+#
+# Install programs...
+#
+
+install-exec:
+
+
+#
+# Install headers...
+#
+
+install-headers:
+
+
+#
+# Install libraries...
+#
+
+install-libs:
+
+
+#
+# Uninstall files...
+#
+
+uninstall:
+	echo Uninstalling man pages from $(MANDIR)/man1...
+	for file in $(MAN1); do \
+		$(RM) $(MANDIR)/man1/$$file; \
+	done
+	-$(RMDIR) $(MANDIR)/man1
+	echo Uninstalling man pages from $(MANDIR)/man5...
+	for file in $(MAN5); do \
+		$(RM) $(MANDIR)/man5/$$file; \
+	done
+	-$(RMDIR) $(MANDIR)/man5
+	echo Uninstalling man pages from $(MANDIR)/man7...
+	for file in $(MAN7) ippeveps.7; do \
+		$(RM) $(MANDIR)/man7/$$file; \
+	done
+	-$(RMDIR) $(MANDIR)/man7
+	echo Uninstalling man pages from $(MANDIR)/man8...
+	for file in $(MAN8) cupsenable.8 cupsreject.8 cups-deviced.8 cups-driverd.8 cups-exec.8; do \
+		$(RM) $(MANDIR)/man8/$$file; \
+	done
+	-$(RMDIR) $(MANDIR)/man8
+
+
+#
+# Local programs (not built when cross-compiling...)
+#
+
+local:	html
+
+
+#
+# Make html versions of man pages...
+#
+
+html:	$(MAN1) $(MAN5) $(MAN7) $(MAN8) mantohtml
+	echo Converting man pages to HTML...
+	for file in $(MAN1); do \
+		echo "    $$file..."; \
+		./mantohtml $$file >../doc/help/man-`basename $$file .1`.html; \
+	done
+	for file in $(MAN5); do \
+		echo "    $$file..."; \
+		./mantohtml $$file >../doc/help/man-`basename $$file .5`.html; \
+	done
+	for file in $(MAN7); do \
+		echo "    $$file..."; \
+		./mantohtml $$file >../doc/help/man-`basename $$file .7`.html; \
+	done
+	for file in $(MAN8); do \
+		echo "    $$file..."; \
+		./mantohtml $$file >../doc/help/man-`basename $$file .8`.html; \
+	done
+
+mantohtml:	mantohtml.c
+	$(CC_FOR_BUILD) -o $@ $<
diff --git a/man/de/Makefile b/man/de/Makefile
new file mode 100644
index 0000000..7c23784
--- /dev/null
+++ b/man/de/Makefile
@@ -0,0 +1,7 @@
+#
+#   Man page makefile for the Common UNIX Printing System (CUPS).
+#
+
+LANGUAGE=de
+
+include ../Makefile.l10n
diff --git a/man/fr/Makefile b/man/fr/Makefile
new file mode 100644
index 0000000..6a50e93
--- /dev/null
+++ b/man/fr/Makefile
@@ -0,0 +1,7 @@
+#
+#   Man page makefile for the Common UNIX Printing System (CUPS).
+#
+
+LANGUAGE=fr
+
+include ../Makefile.l10n
