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