summaryrefslogtreecommitdiff
path: root/Makefile
blob: 73ce1bdc89a93a998ca5938067bbdc4e07c0f660 (plain)
  1. SOURCES ikiwiki
  2. ikiwiki_ORIGIN http://source.jones.dk/ikiwiki_MODULE.git
  3. ikiwiki_MODULES basewiki smiley templates
  4. ikiwiki_BRANCH master-LOCALE
  5. ikiwiki_LOCALES da
  6. #dummy_MODULES = content_dummy
  7. # Everything after this is generic
  8. underlays_l10n = $(foreach source, $(SOURCES), $(foreach locale, $($(source)_LOCALES), $(patsubst %,%_l10n/$(locale),$($(source)_MODULES))))
  9. underlays = $(foreach source, $(SOURCES), $($(source)_MODULES)) $(underlays_l10n)
  10. # FIXME: Handle translation of templates (needs po4a parser for HTML::Template markup)
  11. #potfiles = $(foreach source, $(SOURCES), $(patsubst %,po/%.pot,$($(source)_MODULES)))
  12. potfiles = $(foreach source, $(SOURCES), $(patsubst %,po/%.pot,$(filter-out templates,$($(source)_MODULES))))
  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)_MODULES)),$(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) $(dummy_MODULES)
  25. $(underlays): locale=$(if $(filter l10n/,$(lastword $(subst _, ,$(dir $@)))),$(notdir $@))
  26. $(underlays): underlay=$(@:%_l10n/$(locale)=%)
  27. $(underlays):
  28.     mkdir -$@
  29.     @if [ -"$@/.git" ]; then \
  30.         cd $&& \
  31.         git pull\
  32.     else \
  33.         cd $&& \
  34.         git init && \
  35.         git remote add --$(master) -$(masterorigin $(origin) && \
  36.         git merge origin && \
  37.         git config remote.origin.push +refs/heads/master:refs/heads/$(master); \
  38.     fi
  39. pot: $(potfiles)
  40. popot $(pofiles)
  41. translationspo $(l10nfiles)
  42. $(potfiles): underlay=$(patsubst po/%.pot,%,$@)
  43. $(potfiles):
  44.     cd "$(masterdir)" && po4a-gettextize -M UTF-8 -L UTF-8 -$(fileformat) $(patsubst %,-%,$(l10nfiles_in_underlay)) -$(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 -$(fileformat) $(patsubst %,-%,$(l10nfiles_in_underlay)) $(patsubst %,-$(CURDIR)/$(l10ndir)/%,$(l10nfiles_in_underlay)) ) \
  51.         | grep -'#, fuzzy' \
  52.         > $@
  53. else
  54. $(pofiles):
  55.     cd "$(masterdir)" && po4a-updatepo -M UTF-8 -$(fileformat) $(patsubst %,-%,$(l10nfiles_in_underlay)) -$(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 -$(l10ndir)
  62. ifeq ($(translation_mode),init)
  63.     cd "$(l10ndir)" && po4a-translate -M UTF-8 -L UTF-8 --$(fileformat) -$(CURDIR)/$(patsubst $(l10ndir)/%,$(masterdir)/%,$@) -$(CURDIR)/po/$(underlay).$(locale).po -$(CURDIR)/$@
  64. else
  65.     cd "$(l10ndir)" && po4a-translate -M UTF-8 -L UTF-8 -100 -$(fileformat) -$(CURDIR)/$(patsubst $(l10ndir)/%,$(masterdir)/%,$@) -$(CURDIR)/po/$(underlay).$(locale).po -$(CURDIR)/$@
  66. endif
  67. $(dummy_MODULES):
  68.     mkdir -$@
  69. install:
  70.     $(error FIXMEyou 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 $(dummy_MODULES)
  77. .PHONYpot po translations $(underlays)