#
# Thierry Parmentelat - INRIA Sophia Antipolis
#
-### $Id: Makefile 18118 2010-05-21 17:51:26Z thierry $
-### $URL: svn+ssh://thierry@svn.planet-lab.org/svn/build/trunk/Makefile $
-#
####################
# invocation:
#
RPM-UNINSTALL-DEVEL := rpm -e
YUM-INSTALL-DEVEL := yum -y install
-# see also below
-REMOTE-PLDISTROS="wextoolbox"
-
#################### Makefile
# Default target
all:
# this used to be set in the -tags.mk files, but that turned out to require
# error-prone duplicate changes
# so now the nightly build script sets this to what it is currently using
-# we set a default in case we run the build manually:
-# if the local directory was svn checked out, then use the corresponding URL
-svn-info-url-line := $(shell svn info 2> /dev/null | grep URL:)
-default-build-SVNPATH := $(lastword $(svn-info-url-line))
-# otherwise, use this hard-coded default
-ifeq "$(default-build-SVNPATH)" ""
-default-build-SVNPATH := http://svn.planet-lab.org/svn/build/trunk
+# in case we run this manually, i.e. if neither build-SVNPATH nor build-GITPATH is set
+ifeq "$(build-SVNPATH)$(build-GITPATH)" ""
+build-GITPATH-local := $(shell git config remote.origin.url)
+ifneq "$(build-GITPATH-local)" ""
+build-GITPATH := $(build-GITPATH-local)
+else
+build-SVNPATH := $(lastword $(shell svn info 2> /dev/null | grep URL:))
+endif
endif
-# use default if necessary
-build-SVNPATH ?= $(default-build-SVNPATH)
-####################
+#################### pldistros that are defined remotely
+# fetching with svn
+define remote_pldistro_fetch_svn
+$(1).config.SVNPATH := $(shell grep -v "^#" config.$(1).svnpath)
+config.$(1): config.$(1).svnpath
+ @echo "Fetching (svn) details for remote pldistro $(1)"
+ svn export $$($(1).config.SVNPATH) config.$(1)
+endef
+
+FOO=@
+# fetching with git
+define remote_pldistro_fetch_git
+$(1).config.GITPATH := $(shell grep -v "^#" config.$(1).gitpath)
+$(1).config.gitrepo := $$(firstword $$(subst @, ,$$($(1).config.GITPATH)))
+$(1).config.gittag := $$(word 2,$$(subst @, ,$$($(1).config.GITPATH)))
+$(1).config.gittag := $$(if $$($(1).config.gittag),$$($(1).config.gittag),master)
+config.$(1): GITPATH=$(shell grep -v "^#" config.$(1).gitpath)
+config.$(1): config.$(1).gitpath
+ @echo "Fetching (git) details for remote pldistro $(1)"
+ mkdir -p config.$(1)
+ git $(GITTAG) archive --remote=$$($(1).config.gitrepo) $$($(1).config.gittag) | tar -C config.$(1) -xf -
+endef
+
+
+# put it together
define remote_pldistro
$(1).mk: config.$(1)/$(1).mk
- @echo 'creating $(1) from config subdir'
+ @echo 'creating $(1) from config.$(1)'
cp config.$(1)/$(1).mk $(1).mk
$(2).mk: config.$(1)/$(2).mk
- @echo 'creating $(1) tags from config subdir'
+ @echo 'creating $(2) tags from config.$(1)'
cp config.$(1)/$(2).mk $(2).mk
config.$(1)/$(1).mk: config.$(1)
config.$(1)/$(2).mk: config.$(1)
-config.$(1): config.$(1).svnpath
- @echo "Fetching details for pldistro $(1)"
- svn export $(shell grep -v "^#" config.$(1).svnpath) config.$(1)
-
DISTCLEANS += $(1).mk $(2).mk config.$(1)
-
+$(eval $(call remote_pldistro_fetch_$(3),$(1)))
endef
-# somehow this does not work, handle manually instead
-#$(foreach distro, $(REMOTE-PLDISTROS), $(eval $(call remote_pldistro,$(distro),$(distro)-tags)))
-$(eval $(call remote_pldistro,wextoolbox,wextoolbox-tags))
+$(eval $(call remote_pldistro,wextoolbox,wextoolbox-tags,git))
########## stage1 and stage1iter
# extract specs and compute .mk files by running
define stage1_package_vars
$(1).module := $(firstword $($(1)-MODULES))
$(1).specpath := SPECS/$(notdir $($(1)-SPEC))
-$(1).moduledir := MODULES/$(firstword $($(1)-MODULES))
-$(1).codespec := MODULES/$(firstword $($(1)-MODULES))/$($(1)-SPEC)
+$(1).moduledir := MODULES/$$($(1).module)
+$(1).codespec := MODULES/$$($(1).module)/$($(1)-SPEC)
endef
$(foreach package, $(ALL), $(eval $(call stage1_package_vars,$(package))))
# compute all modules
-ALL.modules :=
+ALL.modules := build tests
$(foreach package,$(ALL), $(eval ALL.modules+=$($(package)-MODULES)))
ALL.modules:=$(sort $(ALL.modules))
define stage1_module_vars
ifneq "$($(1)-SVNPATH)" ""
$(1)-SVNPATH := $(strip $($(1)-SVNPATH))
+$(1)-SCMPATH := $(strip $($(1)-SVNPATH))
else
-$(1)-GITPATH := $(strip $($(1)-GITPATH))
-$(1).gitrepo := $(firstword $(subst @, ,$($(1)-GITPATH)))
-$(1).gittag := $(word 2,$(subst @, ,$($(1)-GITPATH)))
-$(1).gittag := $(if $($(1).gittag),$($(1).gittag),master)
+$(1)-GITPATH := $$(strip $$($(1)-GITPATH))
+$(1)-SCMPATH := $$(strip $$($(1)-GITPATH))
+$(1).gitrepo := $$(firstword $$(subst @, ,$$($(1)-GITPATH)))
+$(1).gittag := $$(word 2,$$(subst @, ,$$($(1)-GITPATH)))
+$(1).gittag := $$(if $$($(1).gittag),$$($(1).gittag),master)
endif
endef
$($(1).specpath): header.spec $($(1).codespec)
mkdir -p SPECS
cat header.spec > $($(1).specpath)
+ echo "%define SCMURL $($($(1).module)-SCMPATH)" >> $($(1).specpath)
$(if $($(1).has-date),echo "%define date $(shell date +%Y.%m.%d)" >> $($(1).specpath),)
$(if $($(1)-SPECVARS), \
$(foreach line,$($(1)-SPECVARS), \
### the tests area
# use this makefile to extract tests rather than extracting manually in vbuild-nightly
-$(eval $(call stage1_module_vars,tests))
-$(eval $(call target_extract_module,tests))
tests-clean:
rm -rf MODULES/tests
.PHONY: tests-clean
### this utility allows to extract various info from a spec file
### and to define them in makefiles
spec2make: spec2make.c
- $(CC) -g -Wall $< -o $@ -lrpm -lrpmbuild
+ $(CC) -g -Wall $< -o $@ -lrpm -lrpmbuild -lrpmio -lpopt
### run spec2make on the spec file and include the result
# usage: spec2make package
@echo "Build build-base: $(BASE)"
@echo "Build planetlab-distro: $(PLDISTRO)"
@echo "Build planetlab-tags: $(PLDISTROTAGS)"
- @echo -n 'Build planetlab-tagsid: ' ; fgrep '$$''Id' $(PLDISTROTAGS)
@echo "Build target-arch: $(HOSTARCH)"
@echo "Build target-distro: $(DISTRO)"
@echo "Build target-distroname: $(DISTRONAME)"
module-tools:
@$(foreach module,$(ALL.modules), \
- $(if $($(module)-GITPATH), \
+ $(if $($(module)-GITPATH), \
$(if $($(module)-BRANCH), \
- echo git:$(module):$($(module)-BRANCH); , \
- echo git:$(module); ), \
+ echo $(module):$($(module)-BRANCH); , \
+ echo $(module); ), \
$(if $($(module)-BRANCH), \
echo $(module):$($(module)-BRANCH); , \
echo $(module); )))
.PHONY: info info-packages info-modules info-branches module-tools
+show-multi-modules:
+ @$(foreach package,$(ALL),$(if $(subst x1,,x$(words $($(package)-MODULES))), echo p=$(package) mods=$($(package)-MODULES) ;))
+.PHONY: show-multi-modules
####################
help:
@echo "********** Run make in two stages:"