summaryrefslogtreecommitdiff
path: root/Makefile
blob: 22779aa1b984da3d6552418d76284c6d630203c2 (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. source_of_underlay = $(firstword $(foreach source, $(sources), $(if $(filter $(underlay),$(underlays_$(source))),$(source))))
  14. origin = $(origin_$(source_of_underlay))
  15. master = $(master_$(source_of_underlay))
  16. all: $(underlays) $(dummies)
  17. $(underlays): locale=$(if $(filter l10n/,$(lastword $(subst _, ,$(dir $@)))),$(notdir $@))
  18. $(underlays): underlay=$(@:%_l10n/$(locale)=%)
  19. $(underlays):
  20. mkdir -p $@
  21. @if [ -d "$@/.git" ]; then \
  22. cd $@ && \
  23. git pull; \
  24. else \
  25. cd $@ && \
  26. git init && \
  27. git remote add -f -t $(master) -m $(master) origin $(origin) && \
  28. git merge origin && \
  29. git config remote.origin.push +refs/heads/master:refs/heads/$(master); \
  30. fi
  31. pot: $(potfiles)
  32. po: pot $(pofiles)
  33. # FIXME: The po4a plugin for HTML::Template needs to be written...
  34. $(potfiles): underlay=$(patsubst po/%.pot,%,$@)
  35. $(pofiles): underlay=$(basename $(patsubst po/%.po,%,$@))
  36. $(pofiles): locale=$(patsubst .%,%,$(suffix $(patsubst po/%.po,%,$@)))
  37. $(pofiles): underlay_l10n=$(underlay)_l10n/$(locale)
  38. $(potfiles) $(pofiles): fileformat = $(if $(filter templates,$(underlay)),htmltemplate,text)
  39. $(potfiles) $(pofiles): filetype = $(if $(filter templates,$(underlay)),tmpl,mdwn)
  40. $(potfiles) $(pofiles): srcfiles = $(shell cd "$(underlay)" && find * -type f -name '*.$(filetype)')
  41. $(potfiles):
  42. cd $(underlay) && po4a-gettextize -M UTF-8 -L UTF-8 -f $(fileformat) $(patsubst %,-m %,$(srcfiles)) -p $(CURDIR)/$@
  43. ifeq ($(translation_mode),init)
  44. $(pofiles):
  45. # cd $(underlay) && po4a-gettextize -M UTF-8 -L UTF-8 -f $(fileformat) $(patsubst %,-m %,$(srcfiles)) $(patsubst %,-l $(CURDIR)/$(underlay_l10n)/%,$(srcfiles)) -p $(CURDIR)/$@
  46. ( cd "$(underlay)" && po4a-gettextize -M UTF-8 -L UTF-8 -f $(fileformat) $(patsubst %,-m %,$(srcfiles)) $(patsubst %,-l $(CURDIR)/$(underlay_l10n)/%,$(srcfiles)) ) \
  47. | grep -v '#, fuzzy' \
  48. > $@
  49. else
  50. $(pofiles):
  51. cd "$(underlay)" && po4a-updatepo -M UTF-8 -f $(fileformat) $(patsubst %,-m %,$(srcfiles)) -p $(CURDIR)/$@
  52. endif
  53. $(dummies):
  54. mkdir -p $@
  55. install:
  56. $(error FIXME: you need to adjust ikiwiki.setup first!)
  57. # ikiwiki --setup ikiwiki.setup --rebuild
  58. # WARNING: this may wipe unrelated files too!
  59. ultraclean:
  60. rm -rf $(underlays)
  61. rm -rf $(dir $(underlays_l10n))
  62. rm -rf $(dummies)
  63. .PHONY: pot po translations $(underlays)