summaryrefslogtreecommitdiff
path: root/make/rules.mk
blob: 91aff1435a070e4899245e55ba7c40ba24261efa (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)'))
  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. # FIXME: needs to depend also on its masterfile
  59. #$$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
  60. # mkdir -p $(1)
  61. # $(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)/$$@"
  62. endef
  63. $(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)))))))
  64. # 1:moduledir 2:locale 3:mastermodule 4:source
  65. define PO_template
  66. fileformat = $(if $(filter templates,$(3)),htmltemplate,text)
  67. filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
  68. ALL_POFILES += $(podir)/$(3).$(2).po
  69. LOCALE_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  70. $(podir)/$(3).$(2).po: $(3)
  71. $(MAKE) -f "$$(CURDIR)/make/po4a.mk" -C "$(3)" fileformat="$$(fileformat)" l10nfiles="$$($(3)_L10NFILES)" pofile="$(CURDIR)/$$@" updatepo
  72. $$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
  73. mkdir -p $(1)
  74. $(MAKE) -f "$$(CURDIR)/make/po4a.mk" -C "$(1)" fileformat="$$(fileformat)" l10nfiles="$$($(3)_L10NFILES)" masterdir="$$(CURDIR)/$(3)" pofile="$(CURDIR)/$(podir)/$(3).$(locale).po" "$(CURDIR)/$$@"
  75. endef
  76. # Only update if not initializing - can't do both at once
  77. ifeq ($(po-init-modules),)
  78. $(foreach source,$(SOURCES),$(foreach module,$($(source)_POMODULES),$(foreach locale,$($(source)_POLOCALES),$(eval $(call PO_template,$(l10ndir),$(locale),$(module),$(source))))))
  79. endif
  80. # 1:dummydir
  81. define DUMMYMODULE_template
  82. $(1):
  83. mkdir -p $$@
  84. # WARNING: this may wipe unrelated files too!
  85. ultraclean::
  86. rm -rf "$(1)"
  87. endef
  88. $(foreach module,$(dummy_MODULES),$(eval $(call DUMMYMODULE_template,$(masterdir))))
  89. # 1:configfile
  90. define CONFIG_template
  91. $(1):
  92. mkdir -p $$@
  93. # WARNING: this may wipe unrelated files too!
  94. install::
  95. ikiwiki --setup $(1) --rebuild
  96. endef
  97. $(foreach config,$(CONFIGS),$(eval $(call CONFIG_template,$(config))))