summaryrefslogtreecommitdiff
path: root/Makefile
blob: b85590ab5c4864758df7103c7b270d6659d27eb5 (plain)
  1. SOURCES = ikiwiki
  2. ikiwiki_ORIGIN = git://source.jones.dk/ikiwiki_MODULE
  3. ikiwiki_MODULES = templates basewiki smiley
  4. ikiwiki_POMODULES = smiley
  5. ikiwiki_BRANCH = master-LOCALE
  6. ikiwiki_LOCALES = da no_NB
  7. #ikiwiki_POLOCALES = da
  8. #dummy_MODULES = content_dummy
  9. # uncomment this when ikiwiki.setup is configured for the local environment
  10. #CONFIGS = ikiwiki.setup
  11. # Everything after this is generic
  12. # FIXME: Not all of these are used within templates
  13. masterdir = $(module)
  14. l10ndir = $(module)_l10n/$(locale)
  15. podir = po
  16. all: $(SOURCES)
  17. install::
  18. ifeq ($(strip $(CONFIGS)),)
  19. $(error Please configure ikiwiki.setup and then uncomment it at the top of the Makefile!)
  20. endif
  21. # 1:source 2:locales
  22. define SOURCE_template
  23. $(1): $$($(1)_MODULES) $(dummy_MODULES)
  24. .PHONY: $(1)
  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 branch -m $$(master) && \
  43. git config remote.origin.push +refs/heads/$$(master):refs/heads/$$(master); \
  44. fi
  45. # WARNING: this may wipe unrelated files too!
  46. ultraclean::
  47. rm -rf "$(1)"
  48. ifneq ($(2),)
  49. rm -rf "$(dir $(1))"
  50. endif
  51. .PHONY: $(1)
  52. endef
  53. $(foreach source,$(SOURCES),$(foreach module,$($(source)_MODULES),$(eval $(call MODULE_template,$(masterdir),,$(module),$(source)))))
  54. $(foreach source,$(SOURCES),$(foreach module,$($(source)_MODULES),$(foreach locale,$($(source)_LOCALES),$(eval $(call MODULE_template,$(l10ndir),$(locale),$(module),$(source))))))
  55. # 1:moduledir 2:locale 3:mastermodule 4:source
  56. define POT_template
  57. fileformat = $(if $(filter templates,$(3)),htmltemplate,text)
  58. filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
  59. ALL_POTFILES += $(podir)/$(3).pot
  60. $(3)_L10NFILES = $$(patsubst $(1)/%,%,$$(shell find $(1) -type f -name '*.$$(filetype)'))
  61. MASTER_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  62. $(podir)/$(3).pot: $(1)
  63. cd "$(1)" && PERL5LIB="$(CURDIR)/perl" po4a-gettextize -M UTF-8 -L UTF-8 -f $$(fileformat) -o markdown $$(patsubst %,-m %,$$($(3)_L10NFILES)) -p $(CURDIR)/$$@
  64. .PHONY: $(1)
  65. endef
  66. $(foreach source,$(SOURCES),$(foreach module,$($(source)_POMODULES),$(eval $(call POT_template,$(masterdir),,$(module),$(source)))))
  67. # 1:moduledir 2:locale 3:mastermodule 4:source 5:originmodule
  68. define INITPO_template
  69. fileformat = $(if $(filter templates,$(3)),htmltemplate,text)
  70. filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
  71. ALL_POFILES += $(podir)/$(3).$(2).po
  72. LOCALE_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  73. $(4)_POMODULES := $(filter-out $(3),$$($(4)_POMODULES))
  74. $(4)_POLOCALES := $(filter-out $(2),$$($(4)_POLOCALES))
  75. $(podir)/$(3).$(2).po: $(3) $(5)
  76. cd "$(3)" && PERL5LIB="$(CURDIR)/perl" po4a-gettextize -M UTF-8 -L UTF-8 -f $$(fileformat) -o markdown $$(patsubst %,-m %,$$($(3)_L10NFILES)) $$(patsubst %,-l $$(CURDIR)/$(1)/%,$($(3)_L10NFILES)) -p $(CURDIR)/$$@
  77. # TODO: Implement the below for automated tests, after unfuzzing the above like this:
  78. # grep -v '^#, fuzzy$' | sed 's/^#, fuzzy,/#,/'
  79. #
  80. # FIXME: needs to depend also on its masterfile
  81. #$$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
  82. # mkdir -p $(1)
  83. # cd "$(1)" && PERL5LIB="$(CURDIR)/perl" po4a-translate -M UTF-8 -L UTF-8 -k 0 -f $(fileformat) -o markdown $$(patsubst $(1)/%,-m $(CURDIR)/$(3)/%,$$@) -p $(CURDIR)/$(podir)/$(3).$(locale).po -l $(CURDIR)/$$@
  84. endef
  85. $(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)))))))
  86. # 1:moduledir 2:locale 3:mastermodule 4:source
  87. define PO_template
  88. fileformat = $(if $(filter templates,$(3)),htmltemplate,text)
  89. filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
  90. ALL_POFILES += $(podir)/$(3).$(2).po
  91. LOCALE_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  92. $(podir)/$(3).$(2).po: $(3)
  93. cd "$(3)" && PERL5LIB="$(CURDIR)/perl" po4a-updatepo -M UTF-8 -f $(fileformat) -o markdown $$(patsubst %,-m %,$$($(3)_L10NFILES)) -p $(CURDIR)/$$@
  94. $$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
  95. mkdir -p $(1)
  96. cd "$(1)" && PERL5LIB="$(CURDIR)/perl" po4a-translate -M UTF-8 -L UTF-8 -k 100 -f $(fileformat) -o markdown $$(patsubst $(1)/%,-m $$(CURDIR)/$(3)/%,$$@) -p $(CURDIR)/$(podir)/$(3).$(locale).po -l $(CURDIR)/$$@
  97. endef
  98. # Only update if not initializing - can't do both at once
  99. ifeq ($(po-init-modules),)
  100. $(foreach source,$(SOURCES),$(foreach module,$($(source)_POMODULES),$(foreach locale,$($(source)_POLOCALES),$(eval $(call PO_template,$(l10ndir),$(locale),$(module),$(source))))))
  101. endif
  102. # 1:dummydir
  103. define DUMMYMODULE_template
  104. $(1):
  105. mkdir -p $$@
  106. # WARNING: this may wipe unrelated files too!
  107. ultraclean::
  108. rm -rf "$(1)"
  109. endef
  110. $(foreach module,$(dummy_MODULES),$(eval $(call DUMMYMODULE_template,$(masterdir))))
  111. # 1:configfile
  112. define CONFIG_template
  113. $(1):
  114. mkdir -p $$@
  115. # WARNING: this may wipe unrelated files too!
  116. install::
  117. ikiwiki --setup $(1) --rebuild
  118. endef
  119. $(foreach config,$(CONFIGS),$(eval $(call CONFIG_template,$(config))))
  120. pot: $(ALL_POTFILES)
  121. po: $(ALL_POFILES)
  122. $(LOCALE_L10NFILES): $(MASTER_L10NFILES)
  123. translations: po $(LOCALE_L10NFILES)
  124. .PHONY: all $(SOURCES) pot po translations install ultraclean