summaryrefslogtreecommitdiff
path: root/make/rules.mk
blob: 850dcef2f04d97b7d8c50a455660ca83074d81e3 (plain)
  1. # use markdown template for po4a, or some custom one?
  2. HTMLTEMPLATE = text
  3. # 1:source 2:locales
  4. define SOURCE_template
  5. $(1): init $$($(1)_MODULES) $(dummy_MODULES)
  6. .PHONY: $(1)
  7. endef
  8. $(foreach source,$(SOURCES),$(eval $(call SOURCE_template,$(source),$($(source)_LOCALES))))
  9. # Override po4a with local Markdown-supportive text module
  10. export PERL5LIB = $(CURDIR)/perl
  11. # 1:moduledir 2:locale 3:mastermodule 4:source
  12. define POT_template
  13. fileformat = $(if $(filter templates,$(3)),$(HTMLTEMPLATE),text)
  14. filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
  15. ALL_POTFILES += $(podir)/$(3).pot
  16. $(3)_L10NFILES = $$(patsubst $(1)/%,%,$$(shell find $(1) -type f -name '*.$$(filetype)' | LANG=C sort))
  17. MASTER_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  18. $(podir)/$(3).pot: $(1)
  19. $(MAKE) -f "$$(CURDIR)/make/po4a.mk" -C "$(1)" package="$(4)" module="$(3)" version="$(5)" locale="LOCALE" fileformat="$$(fileformat)" l10nfiles="$$($(3)_L10NFILES)" potfile="$(CURDIR)/$$@" mkpot; \
  20. .PHONY: $(1)
  21. endef
  22. $(foreach source,$(SOURCES),$(foreach module,$($(source)_POMODULES),$(eval $(call POT_template,$(masterdir),,$(module),$(source),$($(source)_VERSION)))))
  23. # 1:moduledir 2:locale 3:mastermodule 4:source 5:originmodule
  24. define INITPO_template
  25. fileformat = $(if $(filter templates,$(3)),$(HTMLTEMPLATE),text)
  26. filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
  27. ALL_POFILES += $(podir)/$(3).$(2).po
  28. LOCALE_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  29. $(4)_POMODULES := $(filter-out $(3),$$($(4)_POMODULES))
  30. $(4)_POLOCALES := $(filter-out $(2),$$($(4)_POLOCALES))
  31. $(podir)/$(3).$(2).po: $(3) $(5)
  32. $(MAKE) -f "$$(CURDIR)/make/po4a.mk" -C "$(3)" fileformat="$$(fileformat)" l10nfiles="$$($(3)_L10NFILES)" masterdir="$$(CURDIR)/$(1)" pofile="$(CURDIR)/$$@" mkpo
  33. # TODO: Implement the below for automated tests, after unfuzzing the above like this:
  34. # grep -v '^#, fuzzy$' | sed 's/^#, fuzzy,/#,/'
  35. #
  36. #$$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
  37. # mkdir -p $(1)
  38. # $(MAKE) -f "$$(CURDIR)/make/po4a.mk" -C "$(1)" fileformat="$$(fileformat)" l10nfiles="$$($(3)_L10NFILES)" masterdir="$$(CURDIR)/$(3)" pofile="$(CURDIR)/$(podir)/$(3).$(locale).po" threshold=0 "$(CURDIR)/$$@"
  39. endef
  40. $(foreach source,$(SOURCES),$(foreach module,$(po-init-modules),$(foreach locale,$(po-init-locales),$(eval $(call INITPO_template,$(l10ndir),$(locale),$(module),$(source),$(if $(po-init-fromlocale),$(module)_l10n/$(po-init-fromlocale),$(module)))))))
  41. # 1:moduledir 2:locale 3:mastermodule 4:source
  42. define PO_template
  43. fileformat = $(if $(filter templates,$(3)),$(HTMLTEMPLATE),text)
  44. filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
  45. ALL_POFILES += $(podir)/$(3).$(2).po
  46. LOCALE_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  47. $(podir)/$(3).$(2).po: $(3)
  48. $(MAKE) -f "$$(CURDIR)/make/po4a.mk" -C "$(3)" fileformat="$$(fileformat)" l10nfiles="$$($(3)_L10NFILES)" pofile="$(CURDIR)/$$@" updatepo
  49. $$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
  50. mkdir -p $(1)
  51. $(MAKE) -f "$$(CURDIR)/make/po4a.mk" -C "$(1)" fileformat="$$(fileformat)" l10nfiles="$$($(3)_L10NFILES)" masterdir="$$(CURDIR)/$(3)" pofile="$(CURDIR)/$(podir)/$(3).$(locale).po" "$$(patsubst $(1)/%,%,$$@)"
  52. endef
  53. # Only update if not initializing - can't do both at once
  54. ifeq ($(po-init-modules),)
  55. $(foreach source,$(SOURCES),$(foreach module,$($(source)_POMODULES),$(foreach locale,$($(source)_POLOCALES),$(eval $(call PO_template,$(l10ndir),$(locale),$(module),$(source))))))
  56. endif
  57. # 1:configfile
  58. define CONFIG_template
  59. $(1):
  60. mkdir -p $$@
  61. # WARNING: this may wipe unrelated files too!
  62. install::
  63. ikiwiki --setup $(1) --rebuild
  64. endef
  65. $(foreach config,$(CONFIGS),$(eval $(call CONFIG_template,$(config))))