mkdist: include po/elinks.pot
[elinks/kon.git] / po / Makefile
blob29735600024e8029511497a39d60931a105fbfdf
1 top_builddir=..
2 include $(top_builddir)/Makefile.config
4 # Where to install the catalog files.
5 localedir = $(datadir)/locale
7 # These are for some reason not added magically to the Makefile.
8 MSGMERGE = msgmerge
9 PERL = perl
11 # Name of the file containing the list of files to translate (used by
12 # xgettext)
13 POTFILES_ABS_LIST = potfiles.list
15 POTFILES_REL = $(shell find $(top_srcdir)/src/ -name '*.[ch]' -o -name options.inc -o -name 'actions-*.inc' | sort)
17 quiet_cmd_gmsgfmt = ' [$(PO_COLOR)GMSGFMT$(END_COLOR)] $(RELPATH)$(@)'
18 cmd_gmsgfmt = rm -f -- "$@" && $(GMSGFMT) --statistics -o "$@" -- "$<"
21 # Distributed elinks-*.tar.gz packages include po/*.gmo files, so that
22 # users can install ELinks even if they don't have a msgfmt program.
23 # However, if srcdir != builddir, then this Makefile ignores the *.gmo
24 # files in the srcdir and builds new ones in the builddir.
25 %.gmo: $(srcdir)%.po
26 $(call ecmd,gmsgfmt)
29 ### The default rule
31 # Note: Target `all-local' must not depend on target '$(srcdir)$(PACKAGE).pot',
32 # otherwise packages like GCC can not be built if only parts of the source have
33 # been downloaded.
35 # Note 2: We aren't gcc, we are ELinks. And I want that dependency ;-). --pasky
37 # Note 3: I changed my mind, it is really annoying if you just insert one line
38 # and suddenly you have tons of changes in all the .po files updating the line
39 # informations. --pasky
41 # $(CATALOGS) is empty if --disable-nls. Beats using *-(yes|no) targets.
43 all-local: $(CATALOGS)
46 ### Creating the template po template file
48 # This pulls in _all_ .c and .h files in the src directory. Even files that has
49 # not been added to the git repo. Beware of junk entries!
51 $(srcdir)$(POTFILES_ABS_LIST): $(POTFILES_REL)
52 @( cd $(top_srcdir); \
53 find src/ -type f -name '*.[ch]' -o -name options.inc -o -name 'actions-*.inc' | sort ) \
54 > $(srcdir)$(POTFILES_ABS_LIST)
56 $(srcdir)$(PACKAGE).pot: $(srcdir)$(POTFILES_ABS_LIST) $(srcdir)perl/msgaccel-prepare
57 $(XGETTEXT) --default-domain=$(PACKAGE) \
58 --directory=$(top_srcdir) \
59 --add-comments --language=C \
60 --keyword=_ --keyword=N_ --keyword=n_:1,2 --keyword=N__ \
61 --flag=msg_text:2:c-format --flag=die:1:c-format \
62 --flag=secure_fprintf:2:c-format \
63 --flag=DBG:1:c-format --flag=elinks_debug:1:c-format \
64 --flag=WDBG:1:c-format --flag=elinks_wdebug:1:c-format \
65 --flag=ERROR:1:c-format --flag=elinks_error:1:c-format \
66 --flag=INTERNAL:1:c-format --flag=elinks_internal:1:c-format \
67 --flag=usrerror:1:c-format --flag=elinks_log:4:c-format \
68 --flag=LOG_ERR:1:c-format --flag=LOG_WARN:1:c-format \
69 --flag=LOG_INFO:1:c-format --flag=LOG_DBG:1:c-format \
70 --flag=assertm:2:c-format --flag=elinks_assertm:2:c-format \
71 --flag=add_format_to_string:2:c-format \
72 --flag=elinks_vsnprintf:3:c-format --flag=elinks_snprintf:3:c-format \
73 --flag=elinks_vasprintf:2:c-format --flag=elinks_asprintf:2:c-format \
74 --flag=vasprintfa:1:c-format --flag=asprintfa:1:c-format \
75 --flag=_:1:pass-c-format --flag=N_:1:pass-c-format \
76 --flag=n_:1:pass-c-format --flag=n_:2:pass-c-format \
77 --flag=N__:1:pass-c-format \
78 -f $(srcdir)$(POTFILES_ABS_LIST) \
79 && test -f $(PACKAGE).po \
80 && $(PERL) -I"$(srcdir)perl" $(srcdir)perl/msgaccel-prepare -S"$(top_srcdir)" $(PACKAGE).po \
81 && mv -f $(PACKAGE).po $(srcdir)$(PACKAGE).pot
84 ### Updating po and gmo files
86 # Update by merging all .po files with the .po template master file.
88 # It is possible to update only a single .po file by setting the PO variable to
89 # either <lang> or <lang>.po when calling make. Example: make update-po PO=is
91 update-po: Makefile $(srcdir)$(PACKAGE).pot
92 @$(foreach lang,$(basename $(if $(strip $(PO)),$(PO),$(GMOFILES))), \
93 echo -n "$(lang): "; \
94 if $(MSGMERGE) $(srcdir)$(lang).po $(srcdir)$(PACKAGE).pot -o $(lang).new.po; then \
95 mv -f $(lang).new.po $(srcdir)$(lang).po; \
96 else \
97 echo "msgmerge failed!"; \
98 rm -f $(lang).new.po; \
99 fi; \
101 $(MAKE) update-gmo
103 update-gmo: Makefile $(GMOFILES)
107 ### Check single or all po files
110 check-po:
111 @-$(foreach lang,$(basename $(if $(strip $(PO)),$(PO),$(GMOFILES))), \
112 echo -n "$(lang): "; \
113 $(GMSGFMT) --check --check-accelerators="~" --verbose --statistics -o /dev/null $(srcdir)$(lang).po; \
114 $(PERL) -I"$(srcdir)perl" $(srcdir)perl/msgaccel-check $(srcdir)$(lang).po; \
117 ### Installation and distribution
119 # Use *-local targets to place and remove .gmo files.
121 install-local: all-local
122 $(MKINSTALLDIRS) $(DESTDIR)$(localedir)
123 @$(foreach lang,$(basename $(if $(strip $(PO)),$(PO),$(CATALOGS))), \
124 $(MKINSTALLDIRS) $(DESTDIR)$(localedir)/$(lang)/LC_MESSAGES; \
125 $(call ncmd,installdata,$(lang).gmo,$(DESTDIR)$(localedir)/$(lang)/LC_MESSAGES/$(PACKAGE).mo); \
128 uninstall-local:
129 @$(foreach lang,$(basename $(if $(strip $(PO)),$(PO),$(CATALOGS))), \
130 $(call ncmd,uninstall,$(PACKAGE).mo,$(DESTDIR)$(localedir)/$(lang)/LC_MESSAGES); \
133 clean-local:
134 @rm -f $(PACKAGE).po *.new.po $(srcdir)$(POTFILES_ABS_LIST)
136 include $(top_srcdir)/Makefile.lib