1# Makefile for PO directory in any package using GNU gettext.
2
3# Usually the message domain is the same as the package name.
4PACKAGE = amanda
5MAINTAINER_EMAIL = support@zmanda.com
6
7POFILES = $(wildcard *.po)
8#MOFILES = $(patsubst %.po,%.mo,$(POFILES))
9MOFILES =
10
11CFILES = $(wildcard $(top_srcdir)/*/*.[ch])
12PLFILES = $(wildcard $(top_srcdir)/*/*.pl.in)
13SHFILES = $(wildcard $(top_srcdir)/*/*.sh.in)
14ALLFILES = $(CFILES) $(PLFILES) $(SHFILES)
15
16# This variable depends on the location of this directory.
17top_builddir = ..
18localedir=$(datadir)/locale
19
20# These options get passed to xgettext.
21XGETTEXT_OPTIONS = --keyword=_ --keyword=_T
22
23# This is the list of locale categories, beyond LC_MESSAGES, for which the
24# message catalogs shall be used.  It is usually empty.
25EXTRA_LOCALE_CATEGORIES =
26
27
28GMSGFMT = gmsgfmt
29MSGFMT = msgfmt
30MSGINIT = msginit
31MSGMERGE = msgmerge
32MSGMERGE_UPDATE = msgmerge --update
33XGETTEXT = xgettext
34
35DISTFILES =			\
36	${POFILES}		\
37	${MOFILES}		\
38	boldquot.sed		\
39	en@boldquot.header	\
40	en@quot.header		\
41	insert-header.sin	\
42	Makefile.am		\
43	Makefile.in		\
44	Makevars		\
45	quot.sed		\
46	remove-potcdate.sin	\
47	Rules-quot		\
48	stamp-po
49
50SUFFIXES = .po .mo .sed .sin
51
52.sin.sed:
53	sed -e '/^#/d' $< > t-$@
54	mv t-$@ $@
55
56all: $(MOFILES)
57
58# This target rebuilds amanda.pot; it is an expensive operation.
59# Note that amanda.pot is not touched if it doesn't need to be changed.
60amanda.pot: $(ALLFILES)
61	@echo $(XGETTEXT) --language=C --output=amanda.pot ...
62	@$(XGETTEXT) --output=amanda.pot --default-domain=amanda           \
63	  --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) --language=C	   \
64	  $(CFILES)
65	@echo $(XGETTEXT) --language=Perl --join-existing --output=amanda.pot ...
66	@$(XGETTEXT) --output=amanda.pot --default-domain=amanda           \
67	  --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) --language=Perl  \
68	  --join-existing $(PLFILES)
69	@echo $(XGETTEXT) --language=Shell --join-existing --output=amanda.pot ...
70	@$(XGETTEXT) --output=amanda.pot --default-domain=amanda           \
71	  --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) --language=Shell \
72	  --join-existing $(SHFILES)
73	@test ! -f amanda.po || {                                          \
74	  if test -f $(srcdir)/amanda.pot; then                            \
75	    sed -f remove-potcdate.sed < $(srcdir)/amanda.pot > amanda.1po && \
76	    sed -f remove-potcdate.sed < amanda.po > amanda.2po &&         \
77	    if cmp amanda.1po amanda.2po >/dev/null 2>&1; then             \
78	      rm -f amanda.1po amanda.2po amanda.po;                       \
79	    else                                                           \
80	      rm -f amanda.1po amanda.2po $(srcdir)/amanda.pot &&          \
81	      mv amanda.po $(srcdir)/amanda.pot;                           \
82	    fi;                                                            \
83	  else                                                             \
84	    mv amanda.po $(srcdir)/amanda.pot;                             \
85	  fi;                                                              \
86	}
87
88
89# This target rebuilds a PO file if amanda.pot has changed.
90# Note that a PO file is not touched if it doesn't need to be changed.
91%.po: amanda.pot
92	@lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
93	if test "$$lang" = "en_ZM"; then  \
94	  echo msgen -o en.po amanda.pot; \
95	  msgen -o en.po amanda.pot; \
96	elif test -f "$(srcdir)/$${lang}.po"; then \
97	  echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po amanda.pot"; \
98	  cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po amanda.pot; \
99	else \
100	  echo $(MSGINIT) --locale=$${lang} --input=amanda.pot --output-file=$${lang}.po; \
101	  $(MSGINIT) --no-translator --locale=$${lang} --input=amanda.pot --output-file=$${lang}.po; \
102	fi
103
104#en_ZM.po: en.po zlocale.pl ztranslation
105#	@chmod +x ./zlocale.pl
106#	./zlocale.pl
107
108%.mo: %.po
109	@echo "$(MSGFMT) -o $@ $<"; \
110	$(MSGFMT) -o t-$@ $< && mv t-$@ $@
111
112install-data-hook: $(MOFILES)
113	@for cat in "" $(MOFILES); do \
114	  if test -z "$$cat" -o "$$cat" = "en.mo"; then \
115	    continue; \
116	  fi; \
117	  cat=`basename $$cat`; \
118	  lang=`echo $$cat | sed -e 's/\.mo$$//'`; \
119	  dir=$(localedir)/$$lang/LC_MESSAGES; \
120	  $(mkdir_p) $(DESTDIR)$$dir; \
121	  if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
122	  $(INSTALL) $$realcat $(DESTDIR)$$dir/amanda.mo; \
123	  echo "installing $$realcat as $(DESTDIR)$$dir/amanda.mo"; \
124	  for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
125	    if test -n "$$lc"; then \
126	      if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
127	        link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
128	        mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
129	        mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
130	        (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
131	         for file in *; do \
132	           if test -f $$file; then \
133	             ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
134	           fi; \
135	         done); \
136	        rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
137	      else \
138	        if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
139	          :; \
140	        else \
141	          rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
142	          mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
143	        fi; \
144	      fi; \
145	      rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/amanda.mo; \
146	      ln -s ../LC_MESSAGES/amanda.mo $(DESTDIR)$(localedir)/$$lang/$$lc/amanda.mo 2>/dev/null || \
147	      ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/amanda.mo $(DESTDIR)$(localedir)/$$lang/$$lc/amanda.mo 2>/dev/null || \
148	      cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/amanda.mo $(DESTDIR)$(localedir)/$$lang/$$lc/amanda.mo; \
149	      echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/amanda.mo"; \
150	    fi; \
151	  done; \
152	 done
153