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