summaryrefslogtreecommitdiff
path: root/Makefile
blob: 9ded9758248e55924816941ea06f7150a08ad189 (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) $(dummy_MODULES)
  23. .PHONY: $(1)
  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 -$$@
  33.     @if [ -"$$@/.git" ]; then \
  34.         cd $$&& \
  35.         git pull\
  36.     else \
  37.         cd $$&& \
  38.         git init && \
  39.         git remote add --$$(master) -$$(masterorigin $$(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. MASTER_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  60. $(podir)/$(3).pot: $(1)
  61.     cd "$(1)" && po4a-gettextize -M UTF-8 -L UTF-8 -$$(fileformat) $$(patsubst %,-%,$$($(3)_L10NFILES)) -$(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. LOCALE_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: $(3) $(5)
  74.     cd "$(3)" && po4a-gettextize -M UTF-8 -L UTF-8 -$$(fileformat) $$(patsubst %,-%,$$($(3)_L10NFILES)) $$(patsubst %,-$$(CURDIR)/$(5)/%,$($(3)_L10NFILES)) ) \
  75.         | grep -'#, fuzzy' \
  76.         > $$@
  77. # FIXME: needs to depend also on its masterfile
  78. $$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
  79.     mkdir -$(1)
  80.     cd "$(1)" && po4a-translate -M UTF-8 -L UTF-8 --$(fileformat) $$(patsubst $(1)/%,-$(CURDIR)/$(3)/%,$$@) -$(CURDIR)/$(podir)/$(3).$(locale).po -$(CURDIR)/$$@
  81. endef
  82. $(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)))))))
  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. LOCALE_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  89. $(podir)/$(3).$(2).po: $(3)
  90.     cd "$(3)" && po4a-updatepo -M UTF-8 -$(fileformat) $(patsubst %,-%,$$($(3)_L10NFILES)) -$(CURDIR)/$$@
  91. $$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
  92.     mkdir -$(1)
  93.     cd "$(1)" && po4a-translate -M UTF-8 -L UTF-8 -100 -$(fileformat) $$(patsubst $(1)/%,-$(CURDIR)/$(3)/%,$$@) -$(CURDIR)/$(podir)/$(3).$(locale).po -$(CURDIR)/$$@
  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 -$$@
  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 -$$@
  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. $(LOCALE_L10NFILES): $(MASTER_L10NFILES)
  117. translationspo $(LOCALE_L10NFILES)
  118. .PHONYall $(SOURCESpot po translations install ultraclean