summaryrefslogtreecommitdiff
path: root/Makefile
blob: daa7aca026d281fd982f208220ea688058956ac3 (plain)
  1. SOURCES = ikiwiki
  2. ikiwiki_ORIGIN = http://source.jones.dk/ikiwiki_MODULE.git
  3. ikiwiki_UNDERLAYS = basewiki smiley templates
  4. ikiwiki_BRANCH = master-LOCALE
  5. ikiwiki_LOCALES = da
  6. #dummy_UNDERLAYS = content_dummy
  7. # Everything after this is generic
  8. underlays_l10n = $(foreach source, $(SOURCES), $(foreach locale, $($(source)_LOCALES), $(patsubst %,%_l10n/$(locale),$($(source)_UNDERLAYS))))
  9. underlays = $(foreach source, $(SOURCES), $($(source)_UNDERLAYS)) $(underlays_l10n)
  10. # FIXME: Handle translation of templates (needs po4a parser for HTML::Template markup)
  11. #potfiles = $(foreach source, $(SOURCES), $(patsubst %,po/%.pot,$($(source)_UNDERLAYS)))
  12. potfiles = $(foreach source, $(SOURCES), $(patsubst %,po/%.pot,$(filter-out templates,$($(source)_UNDERLAYS))))
  13. pofiles = $(foreach source, $(SOURCES), $(foreach locale, $($(source)_LOCALES), $(patsubst %.pot,%.$(locale).po,$(potfiles))))
  14. l10nfiles = $(foreach source, $(SOURCES), $(foreach locale, $($(source)_LOCALES), $(foreach underlay,$(patsubst po/%.$(locale).po,%,$(pofiles)), $(patsubst %,$(l10ndir)/%,$(l10nfiles_in_underlay)))))
  15. source_of_underlay = $(firstword $(foreach source, $(SOURCES), $(if $(filter $(underlay),$($(source)_UNDERLAYS)),$(source))))
  16. origin = $(subst MODULE,$(underlay),$($(source_of_underlay)_ORIGIN))
  17. master = $(subst -LOCALE,$(locale:%=-$(locale)),$($(source_of_underlay)_BRANCH))
  18. masterdir = $(underlay)
  19. l10ndir = $(underlay)_l10n/$(locale)
  20. # FIXME: The po4a plugin for HTML::Template needs to be written...
  21. fileformat = $(if $(filter templates,$(underlay)),htmltemplate,text)
  22. filetype = $(if $(filter templates,$(underlay)),tmpl,mdwn)
  23. l10nfiles_in_underlay = $(shell cd "$(masterdir)" && find * -type f -name '*.$(filetype)')
  24. all: $(underlays) $(dummies)
  25. $(underlays): locale=$(if $(filter l10n/,$(lastword $(subst _, ,$(dir $@)))),$(notdir $@))
  26. $(underlays): underlay=$(@:%_l10n/$(locale)=%)
  27. $(underlays):
  28. mkdir -p $@
  29. @if [ -d "$@/.git" ]; then \
  30. cd $@ && \
  31. git pull; \
  32. else \
  33. cd $@ && \
  34. git init && \
  35. git remote add -f -t $(master) -m $(master) origin $(origin) && \
  36. git merge origin && \
  37. git config remote.origin.push +refs/heads/master:refs/heads/$(master); \
  38. fi
  39. pot: $(potfiles)
  40. po: pot $(pofiles)
  41. translations: po $(l10nfiles)
  42. $(potfiles): underlay=$(patsubst po/%.pot,%,$@)
  43. $(potfiles):
  44. cd "$(masterdir)" && po4a-gettextize -M UTF-8 -L UTF-8 -f $(fileformat) $(patsubst %,-m %,$(l10nfiles_in_underlay)) -p $(CURDIR)/$@
  45. $(pofiles): underlay=$(basename $(patsubst po/%.po,%,$@))
  46. $(pofiles): locale=$(patsubst .%,%,$(suffix $(patsubst po/%.po,%,$@)))
  47. ifeq ($(translation_mode),init)
  48. $(pofiles):
  49. # cd "$(masterdir)" && po4a-gettextize -M UTF-8 -L UTF-8 -f $(fileformat) $(patsubst %,-m %,$(l10nfiles_in_underlay)) $(patsubst %,-l $(CURDIR)/$(l10ndir)/%,$(l10nfiles_in_underlay)) -p $(CURDIR)/$@
  50. ( cd "$(masterdir)" && po4a-gettextize -M UTF-8 -L UTF-8 -f $(fileformat) $(patsubst %,-m %,$(l10nfiles_in_underlay)) $(patsubst %,-l $(CURDIR)/$(l10ndir)/%,$(l10nfiles_in_underlay)) ) \
  51. | grep -v '#, fuzzy' \
  52. > $@
  53. else
  54. $(pofiles):
  55. cd "$(masterdir)" && po4a-updatepo -M UTF-8 -f $(fileformat) $(patsubst %,-m %,$(l10nfiles_in_underlay)) -p $(CURDIR)/$@
  56. endif
  57. #$(error $(l10nfiles):)
  58. $(l10nfiles): underlay=$(patsubst %_l10n,%,$(firstword $(subst /, ,$@)))
  59. $(l10nfiles): locale=$(patsubst %_l10n,%,$(word 2,$(subst /, ,$@)))
  60. $(l10nfiles):
  61. mkdir -p $(l10ndir)
  62. ifeq ($(translation_mode),init)
  63. cd "$(l10ndir)" && po4a-translate -M UTF-8 -L UTF-8 -k 0 -f $(fileformat) -m $(CURDIR)/$(patsubst $(l10ndir)/%,$(masterdir)/%,$@) -p $(CURDIR)/po/$(underlay).$(locale).po -l $(CURDIR)/$@
  64. else
  65. cd "$(l10ndir)" && po4a-translate -M UTF-8 -L UTF-8 -k 100 -f $(fileformat) -m $(CURDIR)/$(patsubst $(l10ndir)/%,$(masterdir)/%,$@) -p $(CURDIR)/po/$(underlay).$(locale).po -l $(CURDIR)/$@
  66. endif
  67. $(dummies):
  68. mkdir -p $@
  69. install:
  70. $(error FIXME: you need to adjust ikiwiki.setup first!)
  71. # ikiwiki --setup ikiwiki.setup --rebuild
  72. # WARNING: this may wipe unrelated files too!
  73. ultraclean:
  74. rm -rf $(underlays)
  75. rm -rf $(dir $(underlays_l10n))
  76. rm -rf $(dummies)
  77. .PHONY: pot po translations $(underlays)