sources = ikiwiki origin_ikiwiki = http://source.jones.dk/ikiwiki_$(underlay).git underlays_ikiwiki = basewiki smiley templates master_ikiwiki = master$(locale:%=-$(locale)) locales_ikiwiki = da #dummies = content_dummy underlays_l10n = $(foreach source, $(sources), $(foreach locale, $(locales_$(source)), $(patsubst %,%_l10n/$(locale),$(underlays_$(source))))) underlays = $(foreach source, $(sources), $(underlays_$(source))) $(underlays_l10n) # FIXME: Handle translation of templates (needs po4a parser for HTML::Template markup) #potfiles = $(foreach source, $(sources), $(patsubst %,po/%.pot,$(underlays_$(source)))) potfiles = $(foreach source, $(sources), $(patsubst %,po/%.pot,$(filter-out templates,$(underlays_$(source))))) pofiles = $(foreach source, $(sources), $(foreach locale, $(locales_$(source)), $(patsubst %.pot,%.$(locale).po,$(potfiles)))) source_of_underlay = $(firstword $(foreach source, $(sources), $(if $(filter $(underlay),$(underlays_$(source))),$(source)))) origin = $(origin_$(source_of_underlay)) master = $(master_$(source_of_underlay)) all: $(underlays) $(dummies) $(underlays): locale=$(if $(filter l10n/,$(lastword $(subst _, ,$(dir $@)))),$(notdir $@)) $(underlays): underlay=$(@:%_l10n/$(locale)=%) $(underlays): mkdir -p $@ @if [ -d "$@/.git" ]; then \ cd $@ && \ git pull; \ else \ cd $@ && \ git init && \ git remote add -f -t $(master) -m $(master) origin $(origin) && \ git merge origin && \ git config remote.origin.push +refs/heads/master:refs/heads/$(master); \ fi pot: $(potfiles) po: pot $(pofiles) # FIXME: The po4a plugin for HTML::Template needs to be written... $(potfiles): underlay=$(patsubst po/%.pot,%,$@) $(pofiles): underlay=$(basename $(patsubst po/%.po,%,$@)) $(pofiles): locale=$(patsubst .%,%,$(suffix $(patsubst po/%.po,%,$@))) $(pofiles): underlay_l10n=$(underlay)_l10n/$(locale) $(potfiles) $(pofiles): fileformat = $(if $(filter templates,$(underlay)),htmltemplate,text) $(potfiles) $(pofiles): filetype = $(if $(filter templates,$(underlay)),tmpl,mdwn) $(potfiles) $(pofiles): srcfiles = $(shell cd "$(underlay)" && find * -type f -name '*.$(filetype)') $(potfiles): cd $(underlay) && po4a-gettextize -M UTF-8 -L UTF-8 -f $(fileformat) $(patsubst %,-m %,$(srcfiles)) -p $(CURDIR)/$@ ifeq ($(translation_mode),init) $(pofiles): # cd $(underlay) && po4a-gettextize -M UTF-8 -L UTF-8 -f $(fileformat) $(patsubst %,-m %,$(srcfiles)) $(patsubst %,-l $(CURDIR)/$(underlay_l10n)/%,$(srcfiles)) -p $(CURDIR)/$@ ( cd "$(underlay)" && po4a-gettextize -M UTF-8 -L UTF-8 -f $(fileformat) $(patsubst %,-m %,$(srcfiles)) $(patsubst %,-l $(CURDIR)/$(underlay_l10n)/%,$(srcfiles)) ) \ | grep -v '#, fuzzy' \ > $@ else $(pofiles): cd "$(underlay)" && po4a-updatepo -M UTF-8 -f $(fileformat) $(patsubst %,-m %,$(srcfiles)) -p $(CURDIR)/$@ endif $(dummies): mkdir -p $@ install: $(error FIXME: you need to adjust ikiwiki.setup first!) # ikiwiki --setup ikiwiki.setup --rebuild # WARNING: this may wipe unrelated files too! ultraclean: rm -rf $(underlays) rm -rf $(dir $(underlays_l10n)) rm -rf $(dummies) .PHONY: pot po translations $(underlays)