summaryrefslogtreecommitdiff
path: root/make/rules.mk
blob: 1c10382058e5a19973b0fe1b9bba7f8ef61514ce (plain)
  1. # 1:source 2:locales
  2. define SOURCE_template
  3. $(1): $$($(1)_MODULES) $(dummy_MODULES)
  4. .PHONY: $(1)
  5. endef
  6. $(foreach source,$(SOURCES),$(eval $(call SOURCE_template,$(source),$($(source)_LOCALES))))
  7. # 1:moduledir 2:locale 3:mastermodule 4:source
  8. define MODULE_template
  9. $(4): $(1)
  10. $(1): origin = $$(subst MODULE,$(3),$$($(4)_ORIGIN))
  11. $(1): master = $$(subst -LOCALE,$(2:%=-$(2)),$$($(4)_BRANCH))
  12. $(1):
  13. mkdir -p $$@
  14. @if [ -d "$$@/.git" ]; then \
  15. echo $(MAKE) -f "$$(CURDIR)/make/git.mk" -C "$$@" update; \
  16. $(MAKE) -f "$$(CURDIR)/make/git.mk" -C "$$@" update; \
  17. else \
  18. echo $(MAKE) -f "$$(CURDIR)/make/git.mk" -C "$$@" master="$$(master)" origin="$$(origin)" init; \
  19. $(MAKE) -f "$$(CURDIR)/make/git.mk" -C "$$@" master="$$(master)" origin="$$(origin)" init; \
  20. fi
  21. # WARNING: this may wipe unrelated files too!
  22. ultraclean::
  23. rm -rf "$(1)"
  24. ifneq ($(2),)
  25. rm -rf "$(dir $(1))"
  26. endif
  27. .PHONY: $(1)
  28. endef
  29. $(foreach source,$(SOURCES),$(foreach module,$($(source)_MODULES),$(eval $(call MODULE_template,$(masterdir),,$(module),$(source)))))
  30. $(foreach source,$(SOURCES),$(foreach module,$($(source)_MODULES),$(foreach locale,$($(source)_LOCALES),$(eval $(call MODULE_template,$(l10ndir),$(locale),$(module),$(source))))))
  31. # Override po4a with local Markdown-supportive text module
  32. export PERL5LIB = $(CURDIR)/perl
  33. # 1:moduledir 2:locale 3:mastermodule 4:source
  34. define POT_template
  35. fileformat = $(if $(filter templates,$(3)),htmltemplate,text)
  36. filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
  37. ALL_POTFILES += $(podir)/$(3).pot
  38. $(3)_L10NFILES = $$(patsubst $(1)/%,%,$$(shell find $(1) -type f -name '*.$$(filetype)' | LANG=C sort))
  39. MASTER_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  40. $(podir)/$(3).pot: $(1)
  41. $(MAKE) -f "$$(CURDIR)/make/po4a.mk" -C "$(1)" fileformat="$$(fileformat)" l10nfiles="$$($(3)_L10NFILES)" potfile="$(CURDIR)/$$@" mkpot; \
  42. .PHONY: $(1)
  43. endef
  44. $(foreach source,$(SOURCES),$(foreach module,$($(source)_POMODULES),$(eval $(call POT_template,$(masterdir),,$(module),$(source)))))
  45. # 1:moduledir 2:locale 3:mastermodule 4:source 5:originmodule
  46. define INITPO_template
  47. fileformat = $(if $(filter templates,$(3)),htmltemplate,text)
  48. filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
  49. ALL_POFILES += $(podir)/$(3).$(2).po
  50. LOCALE_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  51. $(4)_POMODULES := $(filter-out $(3),$$($(4)_POMODULES))
  52. $(4)_POLOCALES := $(filter-out $(2),$$($(4)_POLOCALES))
  53. $(podir)/$(3).$(2).po: $(3) $(5)
  54. $(MAKE) -f "$$(CURDIR)/make/po4a.mk" -C "$(3)" fileformat="$$(fileformat)" l10nfiles="$$($(3)_L10NFILES)" masterdir="$$(CURDIR)/$(1)" pofile="$(CURDIR)/$$@" mkpo
  55. # TODO: Implement the below for automated tests, after unfuzzing the above like this:
  56. # grep -v '^#, fuzzy$' | sed 's/^#, fuzzy,/#,/'
  57. #
  58. #$$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
  59. # mkdir -p $(1)
  60. # $(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)/$$@"
  61. endef
  62. $(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)))))))
  63. # 1:moduledir 2:locale 3:mastermodule 4:source
  64. define PO_template
  65. fileformat = $(if $(filter templates,$(3)),htmltemplate,text)
  66. filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
  67. ALL_POFILES += $(podir)/$(3).$(2).po
  68. LOCALE_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  69. $(podir)/$(3).$(2).po: $(3)
  70. $(MAKE) -f "$$(CURDIR)/make/po4a.mk" -C "$(3)" fileformat="$$(fileformat)" l10nfiles="$$($(3)_L10NFILES)" pofile="$(CURDIR)/$$@" updatepo
  71. $$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
  72. mkdir -p $(1)
  73. $(MAKE) -f "$$(CURDIR)/make/po4a.mk" -C "$(1)" fileformat="$$(fileformat)" l10nfiles="$$($(3)_L10NFILES)" masterdir="$$(CURDIR)/$(3)" pofile="$(CURDIR)/$(podir)/$(3).$(locale).po" "$$(patsubst $(1)/%,%,$$@)"
  74. endef
  75. # Only update if not initializing - can't do both at once
  76. ifeq ($(po-init-modules),)
  77. $(foreach source,$(SOURCES),$(foreach module,$($(source)_POMODULES),$(foreach locale,$($(source)_POLOCALES),$(eval $(call PO_template,$(l10ndir),$(locale),$(module),$(source))))))
  78. endif
  79. # 1:dummydir
  80. define DUMMYMODULE_template
  81. $(1):
  82. mkdir -p $$@
  83. # WARNING: this may wipe unrelated files too!
  84. ultraclean::
  85. rm -rf "$(1)"
  86. endef
  87. $(foreach module,$(dummy_MODULES),$(eval $(call DUMMYMODULE_template,$(masterdir))))
  88. # 1:configfile
  89. define CONFIG_template
  90. $(1):
  91. mkdir -p $$@
  92. # WARNING: this may wipe unrelated files too!
  93. install::
  94. ikiwiki --setup $(1) --rebuild
  95. endef
  96. $(foreach config,$(CONFIGS),$(eval $(call CONFIG_template,$(config))))