summaryrefslogtreecommitdiff
path: root/Makefile
blob: 4fa08a990be7254c799ad9574c4746719ec28304 (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 = $$(shell cd "$(1)" && find * -type f -name '*.$$(filetype)')
  59. ALL_L10NFILES += $$(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
  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. $(4)_POMODULES := $(filter-out $(3),$$($(4)_POMODULES))
  71. $(4)_POLOCALES := $(filter-out $(2),$$($(4)_POLOCALES))
  72. $(podir)/$(3).$(2).po: $(1) $(3)
  73. ( cd "$(3)" && po4a-gettextize -M UTF-8 -L UTF-8 -f $$(fileformat) $$(patsubst %,-m %,$$($(3)_L10NFILES)) $$(patsubst %,-l $$(CURDIR)/$(1)/%,$($(3)_L10NFILES)) ) \
  74. | grep -v '#, fuzzy' \
  75. > $$@
  76. # FIXME: needs to depend also on its masterfile
  77. $$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
  78. mkdir -p $(1)
  79. 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)/$$@
  80. .PHONY: $(1)
  81. endef
  82. $(foreach source,$(SOURCES),$(foreach module,$(po-init-modules),$(foreach locale,$(po-init-locales),$(eval $(call INITPO_template,$(l10ndir),$(locale),$(module),$(source))))))
  83. # 1:moduledir 2:locale 3:mastermodule 4:source
  84. define PO_template
  85. fileformat = $(if $(filter templates,$(3)),htmltemplate,text)
  86. filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
  87. ALL_POFILES += $(podir)/$(3).$(2).po
  88. $(podir)/$(3).$(2).po: $(3)
  89. cd "$(3)" && po4a-updatepo -M UTF-8 -f $(fileformat) $(patsubst %,-m %,$$($(3)_L10NFILES)) -p $(CURDIR)/$$@
  90. $$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
  91. mkdir -p $(1)
  92. 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)/$$@
  93. .PHONY: $(1)
  94. endef
  95. $(foreach source,$(SOURCES),$(foreach module,$($(source)_POMODULES),$(foreach locale,$($(source)_POLOCALES),$(eval $(call PO_template,$(l10ndir),$(locale),$(module),$(source))))))
  96. # 1:dummydir
  97. define DUMMYMODULE_template
  98. $(1):
  99. mkdir -p $$@
  100. # WARNING: this may wipe unrelated files too!
  101. ultraclean::
  102. rm -rf "$(1)"
  103. endef
  104. $(foreach module,$(dummy_MODULES),$(eval $(call DUMMYMODULE_template,$(masterdir))))
  105. # 1:configfile
  106. define CONFIG_template
  107. $(1):
  108. mkdir -p $$@
  109. # WARNING: this may wipe unrelated files too!
  110. install::
  111. ikiwiki --setup $(1) --rebuild
  112. endef
  113. $(foreach config,$(CONFIGS),$(eval $(call CONFIG_template,$(config))))
  114. pot: $(ALL_POTFILES)
  115. po: $(ALL_POFILES)
  116. translations: $(ALL_L10NFILES)
  117. .PHONY: all $(SOURCES) pot po translations install ultraclean