Merge with http://elinks.cz/elinks.git
[elinks.git] / po / Makefile
bloba23bbfc13952595e49f87a211e2308943258c18e
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/gather-accelerator-contexts.pl
57 $(XGETTEXT) --default-domain=$(PACKAGE) \
58 --directory=$(top_srcdir) \
59 --add-comments --language=C \
60 --keyword=_ --keyword=N_ --keyword=n_:1,2 --keyword=N__ -f $(srcdir)$(POTFILES_ABS_LIST) \
61 && test -f $(PACKAGE).po \
62 && $(PERL) -I"$(srcdir)perl" $(srcdir)perl/gather-accelerator-contexts.pl $(top_srcdir) $(PACKAGE).po \
63 && mv -f $(PACKAGE).po $(srcdir)$(PACKAGE).pot
66 ### Updating po and gmo files
68 # Update by merging all .po files with the .po template master file.
70 # It is possible to update only a single .po file by setting the PO variable to
71 # either <lang> or <lang>.po when calling make. Example: make update-po PO=is
73 update-po: Makefile $(srcdir)$(PACKAGE).pot
74 @test -z "$(srcdir)" || cd $(srcdir)
75 @$(foreach lang,$(basename $(if $(strip $(PO)),$(PO),$(GMOFILES))), \
76 echo -n "$(lang): "; \
77 if $(MSGMERGE) $(srcdir)$(lang).po $(srcdir)$(PACKAGE).pot -o $(lang).new.po; then \
78 mv -f $(lang).new.po $(srcdir)$(lang).po; \
79 else \
80 echo "msgmerge failed!"; \
81 rm -f $(lang).new.po; \
82 fi; \
84 $(MAKE) update-gmo
86 update-gmo: Makefile $(GMOFILES)
90 ### Check single or all po files
93 check-po:
94 @$(foreach lang,$(basename $(if $(strip $(PO)),$(PO),$(GMOFILES))), \
95 echo -n "$(lang): "; \
96 $(GMSGFMT) --check --check-accelerators="~" --verbose --statistics -o /dev/null $(srcdir)$(lang).po; \
97 $(PERL) -I"$(srcdir)perl" $(srcdir)perl/check-accelerator-contexts.pl $(srcdir)$(lang).po; \
100 ### Installation and distribution
102 # Use *-local targets to place and remove .gmo files.
104 install-local: all-local
105 $(MKINSTALLDIRS) $(DESTDIR)$(localedir)
106 @$(foreach lang,$(basename $(if $(strip $(PO)),$(PO),$(CATALOGS))), \
107 $(MKINSTALLDIRS) $(DESTDIR)$(localedir)/$(lang)/LC_MESSAGES; \
108 $(call ncmd,installdata,$(lang).gmo,$(DESTDIR)$(localedir)/$(lang)/LC_MESSAGES/$(PACKAGE).mo); \
111 clean-local:
112 @rm -f $(PACKAGE).po *.new.po $(srcdir)$(POTFILES_ABS_LIST)
114 include $(top_srcdir)/Makefile.lib