NEWS: mention ${CPPFLAGS} vs. ${AM_CFLAGS}
[elinks.git] / po / Makefile
bloba2d40273490d963c4b79669795eb6aa0056bd49f
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
10 # Name of the file containing the list of files to translate (used by
11 # xgettext)
12 POTFILES_ABS_LIST = potfiles.list
14 POTFILES_REL = $(shell find $(top_srcdir)/src/ -name '*.[ch]' -o -name options.inc -o -name 'actions-*.inc' | sort)
16 quiet_cmd_gmsgfmt = ' [$(PO_COLOR)GMSGFMT$(END_COLOR)] $(RELPATH)$(@)'
17 cmd_gmsgfmt = rm -f -- "$@" && $(GMSGFMT) --statistics -o "$@" -- "$<"
20 # Distributed elinks-*.tar.gz packages include po/*.gmo files, so that
21 # users can install ELinks even if they don't have a msgfmt program.
22 # However, if srcdir != builddir, then this Makefile ignores the *.gmo
23 # files in the srcdir and builds new ones in the builddir.
24 %.gmo: $(srcdir)%.po
25 $(call ecmd,gmsgfmt)
28 ### The default rule
30 # Note: Target `all-local' must not depend on target '$(srcdir)$(PACKAGE).pot',
31 # otherwise packages like GCC can not be built if only parts of the source have
32 # been downloaded.
34 # Note 2: We aren't gcc, we are ELinks. And I want that dependency ;-). --pasky
36 # Note 3: I changed my mind, it is really annoying if you just insert one line
37 # and suddenly you have tons of changes in all the .po files updating the line
38 # informations. --pasky
40 # $(CATALOGS) is empty if --disable-nls. Beats using *-(yes|no) targets.
42 all-local: $(CATALOGS)
45 ### Creating the template po template file
47 # This pulls in _all_ .c and .h files in the src directory. Even files that has
48 # not been added to the git repo. Beware of junk entries!
50 $(srcdir)$(POTFILES_ABS_LIST): $(POTFILES_REL)
51 @( cd $(top_srcdir); \
52 find src/ -type f -name '*.[ch]' -o -name options.inc -o -name 'actions-*.inc' | sort ) \
53 > $(srcdir)$(POTFILES_ABS_LIST)
55 $(srcdir)$(PACKAGE).pot: $(srcdir)$(POTFILES_ABS_LIST)
56 $(XGETTEXT) --default-domain=$(PACKAGE) \
57 --directory=$(top_srcdir) \
58 --add-comments --language=C \
59 --keyword=_ --keyword=N_ --keyword=n_:1,2 --keyword=N__ -f $(srcdir)$(POTFILES_ABS_LIST) \
60 && test -f $(PACKAGE).po \
61 && mv -f $(PACKAGE).po $(srcdir)$(PACKAGE).pot
64 ### Updating po and gmo files
66 # Update by merging all .po files with the .po template master file.
68 # It is possible to update only a single .po file by setting the PO variable to
69 # either <lang> or <lang>.po when calling make. Example: make update-po PO=is
71 update-po: Makefile $(srcdir)$(PACKAGE).pot
72 @test -z "$(srcdir)" || cd $(srcdir)
73 @$(foreach lang,$(basename $(if $(strip $(PO)),$(PO),$(GMOFILES))), \
74 echo -n "$(lang): "; \
75 if $(MSGMERGE) $(srcdir)$(lang).po $(srcdir)$(PACKAGE).pot -o $(lang).new.po; then \
76 mv -f $(lang).new.po $(srcdir)$(lang).po; \
77 else \
78 echo "msgmerge failed!"; \
79 rm -f $(lang).new.po; \
80 fi; \
82 $(MAKE) update-gmo
84 update-gmo: Makefile $(GMOFILES)
88 ### Check single or all po files
91 check-po:
92 @$(foreach lang,$(basename $(if $(strip $(PO)),$(PO),$(GMOFILES))), \
93 echo -n "$(lang): "; \
94 $(GMSGFMT) --check --check-accelerators="~" --verbose --statistics -o /dev/null $(srcdir)$(lang).po; \
97 ### Installation and distribution
99 # Use *-local targets to place and remove .gmo files.
101 install-local: all-local
102 $(MKINSTALLDIRS) $(DESTDIR)$(localedir)
103 @$(foreach lang,$(basename $(if $(strip $(PO)),$(PO),$(CATALOGS))), \
104 $(MKINSTALLDIRS) $(DESTDIR)$(localedir)/$(lang)/LC_MESSAGES; \
105 $(call ncmd,installdata,$(lang).gmo,$(DESTDIR)$(localedir)/$(lang)/LC_MESSAGES/$(PACKAGE).mo); \
108 clean-local:
109 @rm -f $(PACKAGE).po *.new.po $(srcdir)$(POTFILES_ABS_LIST)
111 include $(top_srcdir)/Makefile.lib