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