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