summaryrefslogtreecommitdiffstats
path: root/po/common.mk
blob: a3d05ee90697808b6428dc71eb676f8e036b4b36 (plain)
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
# Makefile for manpages-l10n
#
# Copyright © 2017-2019 Dr. Tobias Quathamer <toddy@debian.org>
#
# 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 3 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, see <http://www.gnu.org/licenses/>.

# Filter out the 'common' directory
pofiles = $(sort $(wildcard $(srcdir)/man*/*.po))
manpages = $(addprefix $(distribution)/, $(patsubst %.po,%, $(pofiles)))

MOSTLYCLEANFILES = $(manpages)

# Common rules for all manpage sections
$(distribution)/%: %.po
	$(srcdir)/../generate-manpage.sh $(distribution) $<

# Generate all localized manpages for given distribution
all-local: $(manpages)

# Install localized manpages for given distribution
install-data-hook: $(manpages)
	for directory in $(srcdir)/$(distribution)/man*; do \
		mansection=$$(basename $$directory) ; \
		$(mkinstalldirs) $(DESTDIR)$(mandir)/$(LANGUAGE)/$$mansection ; \
	done
	for manpage in $(manpages); do \
		if test ! -f "$$manpage"; then \
			continue ; \
		fi ; \
		filename=$$(basename $$manpage) ; \
		mansection=$$(basename $$(dirname $$manpage)) ; \
		$(INSTALL_DATA) $$manpage $(DESTDIR)$(mandir)/$(LANGUAGE)/$$mansection ; \
		if test "$(compressor)" != "none" ; then \
			$(compressor) $(DESTDIR)$(mandir)/$(LANGUAGE)/$$mansection/$$filename ; \
		fi ; \
	done
	perl $(top_srcdir)/create-links.pl $(DESTDIR)$(mandir)/$(LANGUAGE) $(comp_extension) \
		$(top_srcdir)/upstream/$(distribution)/links.txt

# Uninstall localized manpages for given distribution
uninstall-hook:
	for link in $$(cut -d" " -f2 $(top_srcdir)/upstream/$(distribution)/links.txt); do \
		rm -f $(DESTDIR)$(mandir)/$(LANGUAGE)/$$link$(comp_extension) ; \
	done
	for manpage in $(manpages); do \
		filename=$$(basename $$manpage) ; \
		mansection=$$(basename $$(dirname $$manpage)) ; \
		rm -f $(DESTDIR)$(mandir)/$(LANGUAGE)/$$mansection/$$filename$(comp_extension) ; \
	done

# Reformat all .po files and commit changes
.PHONY: reformat
reformat:
	$(srcdir)/../format-po.sh ; \
	git commit -m "Reformat .po files, no content changes" . || true

# Reformat all .po files and commit changes
.PHONY: update-po
update-po: reformat
	$(srcdir)/../update-translations.sh ; \
	git commit -m "Update .po files from templates and common messages" . || true