# Standart Makefiles
SVNBINDCOMMON := svn-build-common/
MAKEFILES_NAME := Makefile Makefile.common
ST_MAKEFILES_NAME := $(addsuffix .project, $(MAKEFILES_NAME))

get_url = $(shell svn info $(1)|fgrep URL:|head -n 1|cut -f2 -d' ')
chk_name = $(filter $(1), $(notdir $(call get_url, $(1))))

URL := $(call get_url, .)
ST_URL := $(addprefix $(dir $(URL)), $(SVNBINDCOMMON))

sw_MAKEFILES_ALL := $(addprefix sw_MAKEFILE_, $(MAKEFILES_NAME))
sw_MAKEFILES := $(addprefix sw_MAKEFILE_, $(foreach makefile, $(MAKEFILES_NAME), \
	$(call chk_name, $(makefile))))

.PHONY: update $(sw_MAKEFILES_ALL)

-include Makefile.common

update: $(sw_MAKEFILES)
	svn update $(wildcard *)

$(sw_MAKEFILES_ALL):
	svn sw $(addprefix $(ST_URL), $(addsuffix .project, \
		$(patsubst sw_MAKEFILE_%, %, $@))) $(patsubst sw_MAKEFILE_%, %, $@)

