mk/vcs.mk

177 lines
5.5 KiB
Makefile

ifndef HAS_UTIL_MK
include $(HOME)/Documents/mk/util.mk
endif
$(call mk-debug-lno,+ included from$(addprefix $(\n) ,$(MAKEFILE_LIST)))
.PHONY: updaterepos initrepos
all: updaterepos
%/updaterepos:
$(MAKE) -C $* $(@F)
%/initrepos:
$(MAKE) -C $* $(@F)
HG ?= hg
GIT ?= git
BZR ?= bzr
SVN ?= svn
#BZR ?= $(or $(patsubst %,"%",$(subst /,$(DIRSEP),$(wildcard c:/Program?Files/Bazaar/bzr.exe))),bzr)
CVS ?= $(or $(patsubst %,"%",$(subst /,$(DIRSEP),$(wildcard c:/Program?Files/CVS?Suite/cvs.exe))),cvs)
#CVS ?= evs
CVSFLAGS := $(shell cvs --lf --version 2>$(NULL) >$(NULL)&&echo --lf)
CVSUP_FLAGS := -CPd
ifneq (,$(filter http% HTTP%,$(PROXY) $(http_proxy) $(HTTP_PROXY)))
URL_FILTERS := http:% https:%
endif
info-vcs-template =\
$(info $(call $1,$2,$(URL-$2)))
eval-vcs-template =\
$(eval $(call $1,$2,$(URL-$2)))
define HG_TMPL
DIR-$(notdir $1) := $1
ifeq (,$(filter-out $(or $(URL_FILTERS),%),$2))
.PHONY: pull-$1
updaterepos: pull-$1
initrepos: $1/.hg
$1/.hg:
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@echo +++ Creating[hg]: $(SHQ)'$1$(SHQ)' from $(SHQ)'$2$(SHQ)'
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$(RD) $(subst /,$(DIRSEP),$1)
$$(pre_init_cmd-$1)
$(HG) clone $2 $1
$$(post_init_cmd-$1)
pull-$1:
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@echo +++ Updating[hg]: $$(patsubst pull-%,%,$$@) $(SHQ)($2$(SHQ))
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$$(pre_up_cmd-$1)
$(HG) -R $(subst /,$(DIRSEP),$(subst $(DOT_DIR)/,,$1)) pull $(HGPULL_FLAGS) $2
$(HG) -R $(subst /,$(DIRSEP),$(subst $(DOT_DIR)/,,$1)) update $(HGPULL_FLAGS)
$$(post_up_cmd-$1)
endif
endef
define SVN_TMPL
DIR-$(notdir $1) := $1
ifeq (,$(filter-out $(or $(URL_FILTERS),%),$2))
.PHONY: up-$1
updaterepos: up-$1
initrepos: $1/.svn
$1/.svn:
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@echo +++ Creating[svn]: $(SHQ)'$1$(SHQ)' from $(SHQ)'$2$(SHQ)'
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$(RD) $(subst /,$(DIRSEP),$1)
$$(pre_init_cmd-$1)
$(SVN) checkout $2 $1
$$(post_init_cmd-$1)
up-$1:
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@echo +++ Updating[svn]: $$(patsubst up-%,%,$$@) $(SHQ)($2$(SHQ))
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$$(pre_up_cmd-$1)
@cd $(subst /,$(DIRSEP),$1) >$(NULL) 2>&1 && $(SVN) $(SVNFLAGS) update $(SVNUP_FLAGS)
$$(post_up_cmd-$1)
endif
endef
define CVS_TMPL
DIR-$(notdir $1) := $1
ifeq (,$(filter-out $(or $(URL_FILTERS),%),$2))
.PHONY: up-$1
updaterepos: up-$1
initrepos: $1/CVS
$1/CVS:
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@echo +++ Creating[cvs]: $(SHQ)'$1$(SHQ)' from $(SHQ)'$2$(SHQ)'
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$(RD) $(subst /,$(DIRSEP),$1)
$$(pre_init_cmd-$1)
cd $(subst /,$(DIRSEP),$(dir $1)) && $(CVS) -z3 -d $2 co $(notdir $1)
$$(post_init_cmd-$1)
up-$1:
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@echo +++ Updating[cvs]: $$(patsubst up-%,%,$$@) $(SHQ)($2$(SHQ))
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$$(pre_up_cmd-$1)
@cd $(subst /,$(DIRSEP),$1) >$(NULL) 2>&1 && $(CVS) $(CVSFLAGS) up $(CVSUP_FLAGS)
$$(post_up_cmd-$1)
endif
endef
define GIT_TMPL
DIR-$(notdir $1) := $1
ifeq (,$(filter-out $(or $(URL_FILTERS),%),$2))
.PHONY: pull-$1
updaterepos: pull-$1
initrepos: $1/.git
$1/.git:
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@echo +++ Creating[git]: $(SHQ)'$1$(SHQ)' from $(SHQ)'$2$(SHQ)'
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$(RD) $(subst /,$(DIRSEP),$1)
$$(pre_init_cmd-$1)
$(GIT) clone --verbose $(if $(GITCLONE_FLAGS-$1),$(GITCLONE_FLAGS-$1)$(sp))$2 $1
ifneq (,$(filter -n --no-checkout,$(GITCLONE_FLAGS-$1)))
$$(post_clone_cmd-$1)
cd $(subst /,$(DIRSEP),$1) && $(GIT) checkout
endif
$$(post_init_cmd-$1)
pull-$1:
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@echo +++ Updating[git]: $$(patsubst pull-%,%,$$@) $(SHQ)($2$(SHQ))
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$$(pre_up_cmd-$1)
$(GIT) --work-tree $1 pull $(GITPULL_FLAGS)
$$(post_up_cmd-$1)
endif
endef
define BZR_TMPL
DIR-$(notdir $1) := $1
ifeq (,$(filter-out $(or $(URL_FILTERS),%),$2))
.PHONY: pull-$1
updaterepos: pull-$1
initrepos: $1/.bzr
$1/.bzr:
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@echo +++ Creating[bzr]: $(SHQ)'$1$(SHQ)' from $(SHQ)'$2$(SHQ)'
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$(RD) $(subst /,$(DIRSEP),$1)
$$(pre_init_cmd-$1)
$(BZR) branch $2 $1
$$(post_init_cmd-$1)
pull-$1:
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@echo +++ Updating[bzr]: $$(patsubst pull-%,%,$$@) $(SHQ)($2$(SHQ))
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$$(pre_up_cmd-$1)
cd $(subst /,$(DIRSEP),$1) && $(BZR) pull $(BZRPULL_FLAGS)
$$(post_up_cmd-$1)
endif
endef
# Local Variables:
# tab-width: 2
# End: