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