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