summaryrefslogtreecommitdiff
path: root/Makefile
blob: e388f0b0a17a47f2aceb7cee70a5e0199b7e4678 (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
  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 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 = $$(patsubst $(1)/%,%,$$(shell find $(1) -type f -name '*.$$(filetype)'))
  60. MASTER_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  61. $(podir)/$(3).pot: $(1)
  62. cd "$(1)" && PERL5LIB="$(CURDIR)/perl" po4a-gettextize -M UTF-8 -L UTF-8 -f $$(fileformat) -o markdown $$(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 5:originmodule
  67. define INITPO_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. LOCALE_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  72. $(4)_POMODULES := $(filter-out $(3),$$($(4)_POMODULES))
  73. $(4)_POLOCALES := $(filter-out $(2),$$($(4)_POLOCALES))
  74. $(podir)/$(3).$(2).po: $(3) $(5)
  75. 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)/$$@
  76. # TODO: Implement the below for automated tests, after unfuzzing the above like this:
  77. # grep -v '^#, fuzzy$' | sed 's/^#, fuzzy,/#,/'
  78. #
  79. # FIXME: needs to depend also on its masterfile
  80. #$$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
  81. # mkdir -p $(1)
  82. # 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)/$$@
  83. endef
  84. $(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)))))))
  85. # 1:moduledir 2:locale 3:mastermodule 4:source
  86. define PO_template
  87. fileformat = $(if $(filter templates,$(3)),htmltemplate,text)
  88. filetype = $(if $(filter templates,$(3)),tmpl,mdwn)
  89. ALL_POFILES += $(podir)/$(3).$(2).po
  90. LOCALE_L10NFILES += $$(patsubst %,$(1)/%,$$($(3)_L10NFILES))
  91. $(podir)/$(3).$(2).po: $(3)
  92. cd "$(3)" && PERL5LIB="$(CURDIR)/perl" po4a-updatepo -M UTF-8 -f $(fileformat) -o markdown $$(patsubst %,-m %,$$($(3)_L10NFILES)) -p $(CURDIR)/$$@
  93. $$(patsubst %,$(1)/%,$$($(3)_L10NFILES)): $(podir)/$(3).$(2).po
  94. mkdir -p $(1)
  95. 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)/$$@
  96. endef
  97. # Only update if not initializing - can't do both at once
  98. ifeq ($(po-init-modules),)
  99. $(foreach source,$(SOURCES),$(foreach module,$($(source)_POMODULES),$(foreach locale,$($(source)_POLOCALES),$(eval $(call PO_template,$(l10ndir),$(locale),$(module),$(source))))))
  100. endif
  101. # 1:dummydir
  102. define DUMMYMODULE_template
  103. $(1):
  104. mkdir -p $$@
  105. # WARNING: this may wipe unrelated files too!
  106. ultraclean::
  107. rm -rf "$(1)"
  108. endef
  109. $(foreach module,$(dummy_MODULES),$(eval $(call DUMMYMODULE_template,$(masterdir))))
  110. # 1:configfile
  111. define CONFIG_template
  112. $(1):
  113. mkdir -p $$@
  114. # WARNING: this may wipe unrelated files too!
  115. install::
  116. ikiwiki --setup $(1) --rebuild
  117. endef
  118. $(foreach config,$(CONFIGS),$(eval $(call CONFIG_template,$(config))))
  119. pot: $(ALL_POTFILES)
  120. po: $(ALL_POFILES)
  121. $(LOCALE_L10NFILES): $(MASTER_L10NFILES)
  122. translations: po $(LOCALE_L10NFILES)
  123. .PHONY: all $(SOURCES) pot po translations install ultraclean