1#
2# Makefile for the PO files (translation) catalog
3#
4
5PREFIX ?= /usr
6TOP	 = ../..
7
8# What is this package?
9NLSPACKAGE	= policycoreutils
10POTFILE		= $(NLSPACKAGE).pot
11INSTALL		= /usr/bin/install -c -p
12INSTALL_DATA	= $(INSTALL) -m 644
13INSTALL_DIR	= /usr/bin/install -d
14
15# destination directory
16INSTALL_NLS_DIR = $(PREFIX)/share/locale
17
18# PO catalog handling
19MSGMERGE	= msgmerge
20MSGMERGE_FLAGS	= -q
21XGETTEXT	= xgettext --default-domain=$(NLSPACKAGE)
22MSGFMT		= msgfmt
23
24# All possible linguas
25PO_LINGUAS := $(sort $(patsubst %.po,%,$(wildcard *.po)))
26
27# Only the files matching what the user has set in LINGUAS
28USER_LINGUAS := $(filter $(patsubst %,%%,$(LINGUAS)),$(PO_LINGUAS))
29
30# if no valid LINGUAS, build all languages
31USE_LINGUAS := $(if $(USER_LINGUAS),$(USER_LINGUAS),$(PO_LINGUAS))
32
33POFILES		= $(patsubst %,%.po,$(USE_LINGUAS))
34MOFILES		= $(patsubst %.po,%.mo,$(POFILES))
35POTFILES = \
36	../run_init/open_init_pty.c \
37	../run_init/run_init.c \
38	../semodule_link/semodule_link.c \
39	../audit2allow/audit2allow \
40	../semanage/seobject.py \
41	../setsebool/setsebool.c \
42	../newrole/newrole.c \
43	../load_policy/load_policy.c \
44	../sestatus/sestatus.c \
45	../semodule/semodule.c \
46	../setfiles/setfiles.c \
47	../semodule_package/semodule_package.c \
48	../semodule_deps/semodule_deps.c \
49	../semodule_expand/semodule_expand.c \
50	../scripts/chcat \
51	../scripts/fixfiles \
52	../restorecond/stringslist.c \
53	../restorecond/restorecond.h \
54	../restorecond/utmpwatcher.h \
55	../restorecond/stringslist.h \
56	../restorecond/restorecond.c \
57	../restorecond/utmpwatcher.c \
58	../gui/booleansPage.py \
59	../gui/fcontextPage.py \
60	../gui/loginsPage.py \
61	../gui/mappingsPage.py \
62	../gui/modulesPage.py \
63	../gui/polgen.glade \
64	../gui/polgengui.py \
65	../gui/portsPage.py \
66	../gui/semanagePage.py \
67	../gui/statusPage.py \
68	../gui/system-config-selinux.glade \
69	../gui/system-config-selinux.py \
70	../gui/usersPage.py \
71	../secon/secon.c \
72	booleans.py \
73	../sepolicy/sepolicy.py \
74	../sepolicy/sepolicy/communicate.py \
75	../sepolicy/sepolicy/__init__.py \
76	../sepolicy/sepolicy/network.py \
77	../sepolicy/sepolicy/generate.py \
78	../sepolicy/sepolicy/sepolicy.glade \
79	../sepolicy/sepolicy/gui.py \
80	../sepolicy/sepolicy/manpage.py \
81	../sepolicy/sepolicy/transition.py \
82	../sepolicy/sepolicy/templates/executable.py \
83	../sepolicy/sepolicy/templates/__init__.py \
84	../sepolicy/sepolicy/templates/network.py \
85	../sepolicy/sepolicy/templates/rw.py \
86	../sepolicy/sepolicy/templates/script.py \
87	../sepolicy/sepolicy/templates/semodule.py \
88	../sepolicy/sepolicy/templates/tmp.py \
89	../sepolicy/sepolicy/templates/user.py \
90	../sepolicy/sepolicy/templates/var_lib.py \
91	../sepolicy/sepolicy/templates/var_log.py \
92	../sepolicy/sepolicy/templates/var_run.py \
93	../sepolicy/sepolicy/templates/var_spool.py
94
95#default:: clean
96
97all::  $(MOFILES)
98
99booleans.py:
100	sepolicy booleans -a > booleans.py
101
102$(POTFILE): $(POTFILES) booleans.py
103	$(XGETTEXT) --keyword=_ --keyword=N_ $(POTFILES)
104	@if cmp -s $(NLSPACKAGE).po $(POTFILE); then \
105	    rm -f $(NLSPACKAGE).po; \
106	else \
107	    mv -f $(NLSPACKAGE).po $(POTFILE); \
108	fi; \
109
110update-po: Makefile $(POTFILE) refresh-po
111	@rm -f booleans.py
112
113refresh-po: Makefile
114	for cat in $(POFILES); do \
115		lang=`basename $$cat .po`; \
116		if $(MSGMERGE) $(MSGMERGE_FLAGS) $$lang.po $(POTFILE) > $$lang.pot ; then \
117			mv -f $$lang.pot $$lang.po ; \
118			echo "$(MSGMERGE) of $$lang succeeded" ; \
119		else \
120			echo "$(MSGMERGE) of $$lang failed" ; \
121			rm -f $$lang.pot ; \
122		fi \
123	done
124
125clean:
126	@rm -fv *mo *~ .depend
127	@rm -rf tmp
128
129install: $(MOFILES)
130	@for n in $(MOFILES); do \
131	    l=`basename $$n .mo`; \
132	    $(INSTALL_DIR) $(DESTDIR)$(INSTALL_NLS_DIR)/$$l/LC_MESSAGES; \
133	    $(INSTALL_DATA) --verbose $$n $(DESTDIR)$(INSTALL_NLS_DIR)/$$l/LC_MESSAGES/$(NLSPACKAGE).mo; \
134	done
135
136%.mo: %.po
137	$(MSGFMT) -o $@ $<
138report:
139	@for cat in $(wildcard *.po); do \
140                echo -n "$$cat: "; \
141                msgfmt -v --statistics -o /dev/null $$cat; \
142        done
143
144.PHONY: missing depend
145
146relabel:
147