summaryrefslogtreecommitdiff
path: root/Makefile
blob: 380955a33cae8e94a56b5be03a89a1d0accb6d06 (plain)
  1. SOURCES = ikiwiki
  2. ikiwiki_ORIGIN = http://source.jones.dk/ikiwiki_MODULE.git
  3. ikiwiki_MODULES = templates basewiki smiley
  4. ikiwiki_POMODULES = basewiki smiley
  5. ikiwiki_BRANCH = master-LOCALE
  6. ikiwiki_LOCALES = da
  7. #dummy_MODULES = content_dummy
  8. # uncomment this when ikiwiki.setup is configured for the local environment
  9. #CONFIGS = ikiwiki.setup
  10. # Everything after this is generic
  11. # FIXME: Not all of these are used within templates
  12. masterdir = $(module)
  13. l10ndir = $(module)_l10n/$(locale)
  14. podir = po
  15. all: $(SOURCES)
  16. install::
  17. ifeq ($(strip $(CONFIGS)),)
  18. $(error Please configure ikiwiki.setup and then uncomment it at the top of the Makefile!)
  19. endif
  20. # 1:source 2:locales
  21. define SOURCE_template
  22. $(1): $$($(1)_MODULES) $(foreach module,$$($(1)_MODULES),$(foreach locale,$(2),$(module)_l10n/$(locale))) $(dummy_MODULES)
  23. L10N_MODULES += $$(foreach locale,$(2),$(1)_l10n/$$(locale))
  24. endef
  25. #$(foreach source,$(SOURCES),$(eval $(call SOURCE_template,$(source),$($(source)_LOCALES))))
  26. # 1:moduledir 2:locale 3:mastermodule 4:source
  27. define MODULE_template
  28. $(4): $(1)
  29. $(1): origin = $$(subst MODULE,$(3),$$($(4)_ORIGIN))
  30. $(1): master = $$(subst -LOCALE,$(2:%=-$(2)),$$($(4)_BRANCH))
  31. $(1):
  32. mkdir -p $$@
  33. @if [ -d "$$@/.git" ]; then \
  34. cd $$@ && \
  35. git pull; \
  36. else \
  37. cd $$@ && \
  38. git init && \
  39. git remote add -f -t $$(master) -m $$(master) origin $$(origin) && \
  40. git merge origin && \
  41. git config remote.origin.push +refs/heads/master:refs/heads/$$(master); \
  42. fi
  43. # WARNING: this may wipe unrelated files too!
  44. ultraclean::
  45. rm -rf "$(1)"
  46. ifneq ($(2),)
  47. rm -rf "$(dir $(1))"
  48. endif
  49. .PHONY: $(1)
  50. endef
  51. $(foreach source,$(SOURCES),$(foreach module,$($(source)_MODULES),$(eval $(call MODULE_template,$(masterdir),,$(module),$(source)))))
  52. $(foreach source,$(SOURCES),$(foreach module,$($(source)_MODULES),$(foreach locale,$($(source)_LOCALES),$(eval $(call MODULE_template,$(l10ndir),$(locale),$(module),$(source))))))
  53. # 1:moduledir 2:locale 3:mastermodule 4:source
  54. define POT_template
  55. fileformat = $(if $(filter templates,$(3)),htmltemplate,text)
  56. filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
  57. ALL_POTFILES += $(podir)/$(3).pot
  58. $(3)_L10NFILES = $$(patsubst $(1)/%,%,$$(shell find $(1) -type f -name '*.$$(filetype)'))
  59. ALL_MASTERFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  60. $(podir)/$(3).pot: $(1)
  61. cd "$(1)" && po4a-gettextize -M UTF-8 -L UTF-8 -f $$(fileformat) $$(patsubst %,-m %,$$($(3)_L10NFILES)) -p $(CURDIR)/$$@
  62. .PHONY: $(1)
  63. endef
  64. $(foreach source,$(SOURCES),$(foreach module,$($(source)_POMODULES),$(eval $(call POT_template,$(masterdir),,$(module),$(source)))))
  65. # 1:moduledir 2:locale 3:mastermodule 4:source 5:originmodule
  66. define INITPO_template
  67. fileformat = $(if $(filter templates,$(3)),htmltemplate,text)
  68. filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
  69. ALL_POFILES += $(podir)/$(3).$(2).po
  70. ALL_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  71. $(4)_POMODULES := $(filter-out $(3),$$($(4)_POMODULES))
  72. $(4)_POLOCALES := $(filter-out $(2),$$($(4)_POLOCALES))
  73. $(podir)/$(3).$(2).po: $(1) $(3)
  74. ( cd "$(3)" && po4a-gettextize -M UTF-8 -L UTF-8 -f $$(fileformat) $$(patsubst %,-m %,$$($(3)_L10NFILES)) $$(patsubst %,-l $$(CURDIR)/$(5)/%,$($(3)_L10NFILES)) ) \
  75. | grep -v '#, fuzzy' \
  76. > $$@
  77. # FIXME: needs to depend also on its masterfile
  78. $$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
  79. mkdir -p $(1)
  80. cd "$(1)" && po4a-translate -M UTF-8 -L UTF-8 -k 0 -f $(fileformat) $$(patsubst $(1)/%,-m $(CURDIR)/$(3)/%,$$@) -p $(CURDIR)/$(podir)/$(3).$(locale).po -l $(CURDIR)/$$@
  81. .PHONY: $(1)
  82. endef
  83. $(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)))))))
  84. # 1:moduledir 2:locale 3:mastermodule 4:source
  85. define PO_template
  86. fileformat = $(if $(filter templates,$(3)),htmltemplate,text)
  87. filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
  88. ALL_POFILES += $(podir)/$(3).$(2).po
  89. ALL_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  90. $(podir)/$(3).$(2).po: $(3)
  91. cd "$(3)" && po4a-updatepo -M UTF-8 -f $(fileformat) $(patsubst %,-m %,$$($(3)_L10NFILES)) -p $(CURDIR)/$$@
  92. $$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
  93. mkdir -p $(1)
  94. cd "$(1)" && po4a-translate -M UTF-8 -L UTF-8 -k 100 -f $(fileformat) $$(patsubst $(1)/%,-m $(CURDIR)/$(3)/%,$$@) -p $(CURDIR)/$(podir)/$(3).$(locale).po -l $(CURDIR)/$$@
  95. .PHONY: $(1)
  96. endef
  97. $(foreach source,$(SOURCES),$(foreach module,$($(source)_POMODULES),$(foreach locale,$($(source)_POLOCALES),$(eval $(call PO_template,$(l10ndir),$(locale),$(module),$(source))))))
  98. # 1:dummydir
  99. define DUMMYMODULE_template
  100. $(1):
  101. mkdir -p $$@
  102. # WARNING: this may wipe unrelated files too!
  103. ultraclean::
  104. rm -rf "$(1)"
  105. endef
  106. $(foreach module,$(dummy_MODULES),$(eval $(call DUMMYMODULE_template,$(masterdir))))
  107. # 1:configfile
  108. define CONFIG_template
  109. $(1):
  110. mkdir -p $$@
  111. # WARNING: this may wipe unrelated files too!
  112. install::
  113. ikiwiki --setup $(1) --rebuild
  114. endef
  115. $(foreach config,$(CONFIGS),$(eval $(call CONFIG_template,$(config))))
  116. pot: $(ALL_POTFILES)
  117. po: $(ALL_POFILES)
  118. $(ALL_L10NFILES): $(ALL_MASTERFILES)
  119. translations: $(ALL_L10NFILES)
  120. .PHONY: all $(SOURCES) pot po translations install ultraclean