summaryrefslogtreecommitdiff
path: root/Makefile
blob: 2653ff87145d36be6f1f1215e80a632730ce655d (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)" && PERL5LIB="$(CURDIR)/perl" po4a-gettextize -M UTF-8 -L UTF-8 -$$(fileformat) -o markdown $$(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.     mkdir -$(podir)
  75.     cd "$(3)" && PERL5LIB="$(CURDIR)/perl" po4a-gettextize -M UTF-8 -L UTF-8 -$$(fileformat) -o markdown $$(patsubst %,-%,$$($(3)_L10NFILES)) $$(patsubst %,-$$(CURDIR)/$(1)/%,$($(3)_L10NFILES)) ) \
  76.         | grep -'#, fuzzy' \
  77.         > $$@
  78. # FIXME: needs to depend also on its masterfile
  79. $$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
  80.     mkdir -$(1)
  81.     cd "$(1)" && PERL5LIB="$(CURDIR)/perl" po4a-translate -M UTF-8 -L UTF-8 --$(fileformat) -o markdown $$(patsubst $(1)/%,-$(CURDIR)/$(3)/%,$$@) -$(CURDIR)/$(podir)/$(3).$(locale).po -$(CURDIR)/$$@
  82. endef
  83. $(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)))))))
  84. # 1:moduledir 2:locale 3:mastermodule 4:source
  85. define PO_template
  86. fileformat = $(if $(filter templates,$(3)),htmltemplate,text)
  87. filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
  88. ALL_POFILES += $(podir)/$(3).$(2).po
  89. LOCALE_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  90. $(podir)/$(3).$(2).po: $(3)
  91.     cd "$(3)" && PERL5LIB="$(CURDIR)/perl" po4a-updatepo -M UTF-8 -$(fileformat) -o markdown $(patsubst %,-%,$$($(3)_L10NFILES)) -$(CURDIR)/$$@
  92. $$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
  93.     mkdir -$(1)
  94.     cd "$(1)" && PERL5LIB="$(CURDIR)/perl" po4a-translate -M UTF-8 -L UTF-8 -100 -$(fileformat) -o markdown $$(patsubst $(1)/%,-$(CURDIR)/$(3)/%,$$@) -$(CURDIR)/$(podir)/$(3).$(locale).po -$(CURDIR)/$$@
  95. endef
  96. # Only update if not initializing - can't do both at once
  97. ifeq ($(po-init-modules),)
  98. $(foreach source,$(SOURCES),$(foreach module,$($(source)_POMODULES),$(foreach locale,$($(source)_POLOCALES),$(eval $(call PO_template,$(l10ndir),$(locale),$(module),$(source))))))
  99. endif
  100. # 1:dummydir
  101. define DUMMYMODULE_template
  102. $(1):
  103.     mkdir -$$@
  104. # WARNING: this may wipe unrelated files too!
  105. ultraclean::
  106.     rm -rf "$(1)"
  107. endef
  108. $(foreach module,$(dummy_MODULES),$(eval $(call DUMMYMODULE_template,$(masterdir))))
  109. # 1:configfile
  110. define CONFIG_template
  111. $(1):
  112.     mkdir -$$@
  113. # WARNING: this may wipe unrelated files too!
  114. install::
  115.     ikiwiki --setup $(1) --rebuild
  116. endef
  117. $(foreach config,$(CONFIGS),$(eval $(call CONFIG_template,$(config))))
  118. pot: $(ALL_POTFILES)
  119. po: $(ALL_POFILES)
  120. $(LOCALE_L10NFILES): $(MASTER_L10NFILES)
  121. translationspo $(LOCALE_L10NFILES)
  122. .PHONYall $(SOURCESpot po translations install ultraclean