sources = ikiwiki origin_ikiwiki = http://source.jones.dk/ikiwiki_$(underlay).git underlays_ikiwiki = basewiki smiley templates master_ikiwiki = master$(locale:%=-$(locale)) locales = da underlays_l10n = $(foreach source, $(sources), $(foreach locale, $(locales), $(patsubst %,%_l10n/$(locale),$(underlays_$(source))))) underlays = $(foreach source, $(sources), $(underlays_$(source))) $(underlays_l10n) 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) $(underlays): locale=$(if $(filter l10n/,$(lastword $(subst _, ,$(dir $@)))),$(notdir $@)) $(underlays): underlay=$(@:%_l10n/$(locale)=%) $(underlays): mkdir -p $@ cd $@ && git init cd $@ && git remote add -f -t $(master) -m $(master) origin $(origin) cd $@ && git merge origin # WARNING: this may wipe unrelated files too! ultraclean: rm -rf $(underlays) rm -rf $(dir $(underlays_l10n))