2 # Thierry Parmentelat - INRIA Sophia Antipolis
10 # this extracts all specfiles and computes .mk from specfiles
11 # you need to specify PLDISTRO here if relevant - see below
13 # for more info on how to invoke this stuff
15 #################### (fedora) distributions
17 # (*) as of nov. 2007, myplc-devel is deprecated
18 # (*) instead, we create a fresh vserver that holds required tools (see e.g. planetlab-devel.lst)
19 # (*) the build uses the current fedora version as a target for the produced images
20 # (*) so you simply need to create a fedora 8 build image for building fedora-8 images
22 #################### (planetlab) distributions
24 # (*) see README-pldistros.txt
25 # (*) then you need to run
26 # make stage1=true PLDISTRO=onelab
29 # This build deals with 3 kinds of objects
31 # (*) packages are named upon the RPM name; they are mostly lowercase
32 # Add a package to ALL if you want it built as part of the default set.
33 # (*) modules are named after the subversion tree; as of this writing their names
34 # are mostly mixed case like MyPLC or VserverReference
35 # (*) rpms are named in the spec files. A package typically defines several rpms;
36 # rpms are used for defining DEPEND-DEVEL-RPMS. See also package.rpmnames
38 #################### packages
39 # basics: how to build a package - you need/may define the following variables
42 # a package needs one or several modules to build.
45 # the package's specfile; this is relative to the FIRST module in package-MODULES
46 # see 'codebase' below
50 # (*) package-SPECVARS
51 # space-separated list of spec variable definitions, where you can reference make variable that relate to
52 # packages defined BEFORE the current one (note: you should use = - as opposed to := - to define these)
53 # e.g. mydriver-SPECVARS = foo=$(kernel-rpm-release)
54 # would let you use the %release from the kernel's package when rpmbuild'ing mydriver - see automatic below
55 # (*) package-DEPEND-PACKAGES
56 # a set of *packages* that this package depends on
57 # (*) package-DEPEND-DEVEL-RPMS
58 # a set of *rpms* that the build will rpm-install before building <package>
59 # (*) package-DEPEND-FILES
60 # a set of files that the package depends on - and that make needs to know about
61 # if this contains RPMS/yumgroups.xml, then the toplevel RPMS's index
62 # is refreshed with createrepo prior to running rpmbuild
63 # (*) package-RPMFLAGS: Miscellaneous RPM flags
64 # (*) package-RPMBUILD: If not rpmbuild - mostly used for sudo'ing rpmbuild
65 # (*) package-BUILD-FROM-SRPM: set this to any non-empty value, if your package is able to produce
66 # a source rpms by running 'make srpm'
67 # (*) package-RPMDATE: set this to any non-empty value to get the rpm package's release field hold the current date
68 # this is useful for container packages, like e.g. bootstrapfs or vserver, that contains much more than the
71 #################### modules
72 # Required information about the various modules (set this in e.g. planetlab-tags.mk)
75 # the complete path where this module lies;
76 # you can specify the trunk or a given tag with this variable
78 # OR if the module is managed under cvs (will be obsoleted)
83 #################### automatic variables
85 # the build defines some make variables that are extracted from spec files
87 # (*) $ make ulogd-pkginfo
88 # to see the list f variables attached to a given package
89 # (*) $ make kernel-devel-rpminfo
90 # to see the list of variables attached to a given rpm
94 # exported to spec files as plrelease
95 PLANETLAB_RELEASE = 4.2
100 # minimal compat with macos, just so this does not complain
101 HOSTARCH := $(shell uname -i 2> /dev/null || uname -m 2> /dev/null)
102 DISTRO := $(shell ./getdistro.sh)
103 RELEASE := $(shell ./getrelease.sh)
104 DISTRONAME := $(shell ./getdistroname.sh)
105 RPM-INSTALL-DEVEL := rpm --force -Uvh
106 # cannot force rpm -e
107 RPM-UNINSTALL-DEVEL := rpm -e
109 #################### Makefile
115 PLDISTRO := planetlab
117 export CVS_RSH := ssh
119 ########## pldistro.mk holds PLDISTRO - it is generated at stage1 (see below)
124 #################### include onelab.mk
125 # describes the set of components
126 PLDISTROCONTENTS := $(PLDISTRO).mk
127 include $(PLDISTROCONTENTS)
129 #################### include <pldistro>-tags.mk
130 # describes where to fetch components, and the related tags if using cvs
131 PLDISTROTAGS := $(PLDISTRO)-tags.mk
132 include $(PLDISTROTAGS)
134 ########## stage1 and stage1iter
135 # extract specs and compute .mk files by running
137 # entering stage1, we compute all the spec files
138 # then we use stage1iter to compute the .mk iteratively,
139 # ensuring that the n-1 first makefiles are loaded when creating the n-th one
140 # when stage1iter is set, it is supposed to be an index (starting at 1) in $(ALL)
142 ALLMKS := $(foreach package, $(ALL), MAKE/$(package).mk)
144 ### stage1iter : need some arithmetic, see
145 # http://www.cmcrossroads.com/articles/ask-mr.-make/learning-gnu-make-functions-with-arithmetic.html
146 ifneq "$(stage1iter)" ""
147 # the first n packages
148 packages := $(wordlist 1,$(words $(stage1iter)),$(ALL))
150 package := $(word $(words $(packages)),$(packages))
151 # the n-1 first packages
152 stage1iter_1 := $(wordlist 2,$(words $(stage1iter)),$(stage1iter))
153 previous := $(wordlist 1,$(words $(stage1iter_1)),$(ALL))
154 previousmks := $(foreach package,$(previous),MAKE/$(package).mk)
155 include $(previousmks)
158 @echo "========== stage1iter : $(package)"
159 # @echo "stage1iter : included .mk files : $(previousmks)"
160 all: $($(package).specpath)
161 all: MAKE/$(package).mk
167 @echo "========== stage1"
170 # specs and makes are done sequentially by stage1iter
173 arg=""; for n in $(ALL) ; do arg="$$arg x"; $(MAKE) --no-print-directory stage1iter="$$arg"; done
176 ### once .mks are OK, you can run make normally
183 # mention $(ALL) here rather than rpms
184 # this is because the inter-package dependencies are expressed like
185 # util-vserver: util-python
191 ### yumgroups.xml : compute from all known .pkgs files
194 ./yumgroups.sh $(PLDISTRO) > $@
196 createrepo = createrepo --quiet -g yumgroups.xml RPMS/
198 repo: RPMS/yumgroups.xml
205 # * to make configuration easier, we always use the first module's
206 # definitions (CVSROOT,TAG, or SVNPATH) to extract the spec file
207 # * for the same reason, in case cvs is used, the first module name is added to
208 # $(package)-SPEC - otherwise the cvs modules have to define spec as
209 # <module>/<module>.spec while svn modules just define it as <module>.spec
211 define stage1_variables
212 $(1).spec = $(notdir $($(1)-SPEC))
213 $(1).specpath = SPECS/$(1).spec
214 $(1).module = $(firstword $($(1)-MODULES))
215 $(1)-SVNPATH = $(strip $($(1)-SVNPATH))
218 $(foreach package, $(ALL), $(eval $(call stage1_variables,$(package))))
221 # for each package, compute whether we need to set date
222 # the heuristic is that we mention the date as part of the rpm release flag if
223 # (*) the package has requested it by setting package-RPMDATE (container packages should do that)
224 # (*) or SVNPATH contains 'trunk' or 'branches'
226 define package_hasdate
227 $(1).has-date = $(if $($(1)-RPMDATE),yes, \
228 $(if $($($(1).module)-SVNPATH), \
229 $(if $(findstring /trunk,$($($(1).module)-SVNPATH)),yes, \
230 $(if $(findstring /branches,$($($(1).module)-SVNPATH)),yes,)), \
231 $(if $(findstring HEAD,$($($(1).module)-TAG)),yes,)))
234 $(foreach package, $(ALL), $(eval $(call package_hasdate,$(package))))
236 ### the common header for generated specfiles
237 # useful when trying new specfiles manually
239 (echo -n "# Generated by planetlab build from $($(1)-SPEC) on " ; date) > $@
240 echo "%define distro $(DISTRO)" >> $@
241 echo "%define distrorelease $(RELEASE)" >> $@
242 echo "%define distroname $(DISTRONAME)" >> $@
243 echo "%define pldistro $(PLDISTRO)" >> $@
244 echo "%define plrelease $(PLANETLAB_RELEASE)" >> $@
246 ### extract spec file from scm
248 $($(1).specpath): header.spec
250 cat header.spec > $($(1).specpath)
251 $(if $($(1).has-date),echo "%define date $(shell date +%Y.%m.%d)" >> $($(1).specpath),)
252 $(if $($(1)-SPECVARS), \
253 $(foreach line,$($(1)-SPECVARS), \
254 echo "%define" $(word 1,$(subst =, ,$(line))) "$(word 2,$(subst =, ,$(line)))" >> $($(1).specpath) ;))
255 echo "# included from $($(1)-SPEC)" >> $($(1).specpath)
256 $(if $($($(1).module)-SVNPATH),\
257 svn cat $($($(1).module)-SVNPATH)/$($(1)-SPEC) >> $($(1).specpath) || rm $($(1).specpath),\
258 cvs -d $($($(1).module)-CVSROOT) checkout \
259 -r $($($(1).module)-TAG) \
260 -p $($(1).module)/$($(1)-SPEC) >> $($(1).specpath))
263 $(foreach package,$(ALL),$(eval $(call target_spec,$(package))))
266 # Base rpmbuild in the current directory
267 # issues on fedora 8 : see the following posts
268 # http://forums.fedoraforum.org/showthread.php?t=39625 - and more specifically post#6
269 # https://www.redhat.com/archives/fedora-devel-list/2007-November/msg00171.html
271 FAKEROOT=/longbuildroot
272 PWD=$(shell /bin/pwd)
273 ifeq "$(PWD)" "$(REALROOT)"
274 export HOME := $(FAKEROOT)
276 export HOME := $(PWD)
279 ifeq "$(shell pwd)" "/build"
280 rm -f $(FAKEROOT) ; ln -s $(REALROOT) $(FAKEROOT)
283 echo "%_topdir $(HOME)" >> $@
284 echo "%_tmppath $(HOME)/tmp" >> $@
285 ./getrpmmacros.sh >> $@
287 ### this utility allows to extract various info from a spec file
288 ### and to define them in makefiles
289 spec2make: spec2make.c
290 $(CC) -g -Wall $< -o $@ -lrpm -lrpmbuild
292 ### run spec2make on the spec file and include the result
293 # usage: spec2make package
295 MAKE/$(1).mk: $($(1).specpath) spec2make .rpmmacros
297 ./spec2make $($(1)-RPMFLAGS) $($(1).specpath) $(1) > MAKE/$(1).mk
298 @if [ -z MAKE/$(1).mk ] ; then rm MAKE/$(1).mk ; exit 1 ; fi
301 $(foreach package,$(ALL),$(eval $(call target_mk,$(package))))
303 # stores PLDISTRO in a file
304 # this is done at stage1. later run wont get confused
306 echo "PLDISTRO:=$(PLDISTRO)" > $@
307 echo "PLDISTROTAGS:=$(PLDISTROTAGS)" >> $@
309 savepldistro: pldistro.mk
312 # always refresh this
315 #################### regular make
317 define stage2_variables
318 ### devel dependencies
319 $(1).rpmbuild = $(if $($(1)-RPMBUILD),$($(1)-RPMBUILD),$(RPMBUILD)) $($(1)-RPMFLAGS)
320 $(1).all-devel-rpm-paths := $(foreach rpm,$($(1)-DEPEND-DEVEL-RPMS),$($(rpm).rpm-path))
321 $(1).depend-devel-packages := $(sort $(foreach rpm,$($(1)-DEPEND-DEVEL-RPMS),$($(rpm).package)))
322 ALL-DEVEL-RPMS += $($(1)-DEPEND-DEVEL-RPMS)
325 $(foreach package,$(ALL),$(eval $(call stage2_variables,$(package))))
326 ALL-DEVEL-RPMS := $(sort $(ALL-DEVEL-RPMS))
329 ### pack sources into tarballs
330 ALLTARBALLS:= $(foreach package, $(ALL), $($(package).tarballs))
331 tarballs: $(ALLTARBALLS)
332 @echo $(words $(ALLTARBALLS)) source tarballs OK
335 SOURCES/%.tar.bz2: SOURCES/%
336 tar chpjf $@ -C SOURCES $*
338 SOURCES/%.tar.gz: SOURCES/%
339 tar chpzf $@ -C SOURCES $*
341 SOURCES/%.tgz: SOURCES/%
342 tar chpzf $@ -C SOURCES $*
345 URLS/%: url=$(subst @colon@,:,$(subst @slash@,/,$(notdir $@)))
346 URLS/%: basename=$(notdir $(url))
348 echo curl $(url) -o SOURCES/$(basename)
351 ### the directory SOURCES/<package>-<version> is made
352 # with a copy -rl from CODEBASES/<package>
353 # the former is $(package.source) and the latter is $(package.codebase)
354 ALLSOURCES:=$(foreach package, $(ALL), $($(package).source))
355 # so that make does not use the rule below directly for creating the tarball files
356 .SECONDARY: $(ALLSOURCES)
358 sources: $(ALLSOURCES)
359 @echo $(words $(ALLSOURCES)) versioned source trees OK
362 define target_link_codebase_sources
363 $($(1).source): $($(1).codebase) ; mkdir -p SOURCES ; cp -rl $($(1).codebase) $($(1).source)
366 $(foreach package,$(ALL),$(eval $(call target_link_codebase_sources,$(package))))
368 ### codebase extraction
369 ALLCODEBASES:=$(foreach package, $(ALL), $($(package).codebase))
370 # so that make does not use the rule below directly for creating the tarball files
371 .SECONDARY: $(ALLCODEBASES)
373 codebases : $(ALLCODEBASES)
374 @echo $(words $(ALLCODEBASES)) codebase OK
378 # usage: extract_single_module package
379 define extract_single_module
381 $(if $($($(1).module)-SVNPATH), cd CODEBASES && svn export $($($(1).module)-SVNPATH) $(1), cd CODEBASES && cvs -d $($($(1).module)-CVSROOT) export -r $($($(1).module)-TAG) -d $(1) $($(1).module))
384 # usage: extract_multi_module package
385 define extract_multi_module
386 mkdir -p CODEBASES/$(1) && cd CODEBASES/$(1) && (\
387 $(foreach m,$($(1)-MODULES), $(if $($(m)-SVNPATH), svn export $($(m)-SVNPATH) $(m);, cvs -d $($(m)-CVSROOT) export -r $($(m)-TAG) $(m);)))
390 CODEBASES/%: package=$(notdir $@)
391 CODEBASES/%: multi_module=$(word 2,$($(package)-MODULES))
393 @(echo -n "XXXXXXXXXXXXXXX -- BEG CODEBASE $(package) : $@ " ; date)
394 $(if $(multi_module),\
395 $(call extract_multi_module,$(package)),\
396 $(call extract_single_module,$(package)))
397 @(echo -n "XXXXXXXXXXXXXXX -- END CODEBASE $(package) : $@ " ; date)
400 ALLSRPMS:=$(foreach package,$(ALL),$($(package).srpm))
402 @echo $(words $(ALLSRPMS)) source rpms OK
405 # usage: target_source_rpm package
406 # select upon the package name, whether it contains srpm or not
407 define target_source_rpm
408 ifeq "$($(1)-BUILD-FROM-SRPM)" ""
409 $($(1).srpm): $($(1).specpath) .rpmmacros $($(1).tarballs)
410 mkdir -p BUILD SRPMS tmp
411 @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) (using SOURCES) " ; date)
412 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
413 $($(1).rpmbuild) -bs $($(1).specpath)
414 $(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
415 @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
417 $($(1).srpm): $($(1).specpath) .rpmmacros $($(1).codebase)
418 mkdir -p BUILD SRPMS tmp
419 @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) (using make srpm) " ; date)
420 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
421 make -C $($(1).codebase) srpm SPECFILE=$(HOME)/$($(1).specpath) && \
422 rm -f SRPMS/$(notdir $($(1).srpm)) && \
423 ln $($(1).codebase)/$(notdir $($(1).srpm)) SRPMS/$(notdir $($(1).srpm))
424 $(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
425 @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
429 $(foreach package,$(ALL),$(eval $(call target_source_rpm,$(package))))
431 ### binary rpms are made from source rpm
432 ALLRPMS:=$(foreach package,$(ALL),$($(package).rpms))
433 # same as above, mention $(ALL) and not $(ALLRPMS)
435 @echo $(words $(ALLRPMS)) binary rpms OK
438 # use tmp dirs when building binary rpm so make remains idempotent
439 # otherwise SOURCES/ or SPEC gets touched again - which leads to rebuilding
440 RPM-USE-TMP-DIRS = --define "_sourcedir $(HOME)/tmp" --define "_specdir $(HOME)/tmp"
441 RPM-USE-COMPILE-DIRS = --define "_sourcedir $(HOME)/COMPILE" --define "_specdir $(HOME)/COMPILE"
443 # usage: build_binary_rpm package
444 # xxx hacky - invoke createrepo if DEPEND-FILES mentions RPMS/yumgroups.xml
445 define target_binary_rpm
446 $($(1).rpms): $($(1).srpm)
448 @(echo -n "XXXXXXXXXXXXXXX -- BEG RPM $(1) " ; date)
449 $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPEND-FILES)), $(createrepo) , )
450 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
451 $($(1).rpmbuild) --rebuild $(RPM-USE-TMP-DIRS) $($(1).srpm)
452 $(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
453 @(echo -n "XXXXXXXXXXXXXXX -- END RPM $(1) " ; date)
454 # for manual use only - in case we need to investigate the results of an rpmbuild
455 $(1)-compile: $($(1).srpm)
457 @(echo -n "XXXXXXXXXXXXXXX -- BEG compile $(1) " ; date)
458 $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPEND-FILES)), $(createrepo) , )
459 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
460 $($(1).rpmbuild) --recompile $(RPM-USE-TMP-DIRS) $($(1).srpm)
461 $(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
462 @(echo -n "XXXXXXXXXXXXXXX -- END compile $(1) " ; date)
466 $(foreach package,$(ALL),$(eval $(call target_binary_rpm,$(package))))
468 # e.g. make proper -> does propers rpms
469 # usage shorthand_target package
470 define target_shorthand
473 $(1)-spec: $($(1)-SPEC)
477 $(1)-tarball: $($(1).tarballs)
479 $(1)-codebase: $($(1).codebase)
481 $(1)-source: $($(1).source)
482 .PHONY: $(1)-codebase
483 $(1)-rpms: $($(1).rpms)
485 $(1)-srpm: $($(1).srpm)
489 $(foreach package,$(ALL),$(eval $(call target_shorthand,$(package))))
491 ### file dependencies
492 define package_depends_on_file
497 define target_dependfiles
498 $(foreach file,$($(1)-DEPEND-FILES),$(eval $(call package_depends_on_file,$(1),$(file))))
501 $(foreach package,$(ALL),$(eval $(call target_dependfiles,$(package))))
503 ### package dependencies
504 define package_depends_on_package
507 $($(1).srpm):$($(2).rpms)
510 define target_depends
511 $(foreach package,$($(1)-DEPEND-PACKAGES) $($(1).depend-devel-packages),$(eval $(call package_depends_on_package,$(1),$(package))))
514 $(foreach package,$(ALL),$(eval $(call target_depends,$(package))))
517 # usage: target_clean package
520 rm -rf $($(1).codebase)
521 .PHONY: $(1)-clean-codebase
522 CLEANS += $(1)-clean-codebase
524 rm -rf $($(1).source)
525 .PHONY: $(1)-clean-source
526 CLEANS += $(1)-clean-source
528 rm -rf $($(1).tarballs)
529 .PHONY: $(1)-clean-tarball
530 CLEANS += $(1)-clean-tarball
532 rm -rf BUILD/$(notdir $($(1).source))
533 CLEANS += $(1)-clean-build
536 .PHONY: $(1)-clean-rpms
537 CLEANS += $(1)-clean-rpms
540 .PHONY: $(1)-clean-srpm
541 CLEANS += $(1)-clean-srpm
542 $(1)-codeclean: $(1)-clean-source $(1)-clean-tarball $(1)-clean-build $(1)-clean-rpms $(1)-clean-srpm
543 $(1)-clean: $(1)-clean-codebase $(1)-codeclean
544 .PHONY: $(1)-codeclean $(1)-clean
546 rm -rf $($(1).specpath)
547 .PHONY: $(1)-clean-spec
550 .PHONY: $(1)-clean-make
551 $(1)-distclean: $(1)-distclean1 $(1)-distclean2
552 $(1)-distclean1: $(1)-clean-spec $(1)-clean-make
553 $(1)-distclean2: $(1)-clean
554 .PHONY: $(1)-distclean $(1)-distclean1 $(1)-distclean2
557 $(foreach package,$(ALL),$(eval $(call target_clean,$(package))))
565 @echo Available clean targets
568 ### brute force clean
570 rm -rf pldistro.mk .rpmmacros spec2make header.spec SPECS MAKE
572 rm -rf CODEBASES SOURCES BUILD RPMS SRPMS tmp
573 distclean: distclean1 distclean2
574 .PHONY: distclean1 distclean2 distclean
577 $(RPM-UNINSTALL-DEVEL) $(ALL-DEVEL-RPMS)
580 # gather build information for the 'About' page
581 # when run from crontab, INIT_CWD not properly set (says /root ..)
582 # so, the nightly build passes NIGHTLY_BASE here
583 # also store the nightly_base in .base for any post-processing purposes
585 @echo 'Creating myplc-release'
587 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx build info" >> $@
588 $(MAKE) --no-print-directory version-build >> $@
589 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx svn info" >> $@
590 $(MAKE) --no-print-directory version-svns >> $@
591 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx rpm info" >> $@
592 $(MAKE) --no-print-directory version-rpms >> $@
593 @echo $(NIGHTLY_BASE) > .base
596 @echo -n 'Build build-date: ' ; date '+%Y.%m.%d'
597 @echo -n 'Build build-time: ' ; date '+%H:%M-%Z'
598 @echo -n 'Build build-hostname: ' ; hostname
599 @echo "Build build-base: $(NIGHTLY_BASE)"
600 @echo "Build planetlab-distro: $(PLDISTRO)"
601 @echo "Build planetlab-tags: $(PLDISTROTAGS)"
602 @echo -n 'Build planetlab-tagsid: ' ; fgrep '$$''Id' $(PLDISTROTAGS)
603 @echo "Build target-arch: $(HOSTARCH)"
604 @echo "Build target-distro: $(DISTRO)"
605 @echo "Build target-distroname: $(DISTRONAME)"
606 @echo "Build target-release: $(RELEASE)"
607 @echo "Build target-personality: $(NIGHTLY_PERSONALITY)"
611 VFORMAT="%30s := %s\n"
612 define svn_version_target
614 @$(if $($(1)-SVNPATH),\
615 printf $(VFORMAT) $(1)-SVNPATH "$($(1)-SVNPATH)",\
616 printf $(VFORMAT) $(1)-CVSROOT "$($(1)-CVSROOT)" ; printf $(VFORMAT) $(1)-TAG "$($(1)-TAG)")
619 # compute all modules
621 $(foreach package,$(ALL), $(eval ALL-MODULES+=$($(package)-MODULES)))
622 ALL-MODULES:=$(sort $(ALL-MODULES))
624 $(foreach module,$(ALL-MODULES), $(eval $(call svn_version_target,$(module))))
626 version-svns: $(foreach module, $(ALL-MODULES), $(module)-version-svn)
628 RFORMAT="%20s :: version=%s release=%s\n"
629 define rpm_version_target
631 @printf $(RFORMAT) $($(1).rpm-name) $($(1).rpm-version) $($(1).rpm-release)
632 version-rpms: $(1)-version-rpm
635 $(foreach package,$(sort $(ALL)), $(eval $(call rpm_version_target,$(package))))
637 versions: myplc-release version-build version-svns version-rpms
638 .PHONY: versions version-build version-rpms version-svns
640 #################### include install Makefile
641 # the default is to use the distro-dependent install file
642 # however the main distro file can redefine PLDISTROINSTALL
643 ifndef PLDISTROINSTALL
644 PLDISTROINSTALL := $(PLDISTRO)-install.mk
647 -include $(PLDISTROINSTALL)
649 #################### package info
650 PKGKEYS := tarballs source codebase srpm rpms rpmnames rpm-release rpm-name rpm-version rpm-subversion
651 %-pkginfo: package=$(subst -pkginfo,,$@)
653 @$(foreach key,$(PKGKEYS),echo "$(package).$(key)=$($(package).$(key))";)
655 RPMKEYS := rpm-path package
656 %-rpminfo: rpm=$(subst -rpminfo,,$@)
658 @$(foreach key,$(RPMKEYS),echo "$(rpm).$(key)=$($(rpm).$(key))";)
660 #################### various lists - designed to run with stage1=true
662 @$(foreach package,$(ALL), echo package=$(package) ref_module=$($(package).module) modules=$($(package)-MODULES) rpmnames=$($(package).rpmnames); )
665 @$(foreach module,$(ALL-MODULES), echo module=$(module) svnpath=$($(module)-SVNPATH); )
668 @$(foreach module,$(ALL-MODULES), \
669 $(if $($(module)-SVNBRANCH),echo module=$(module) branch=$($(module)-SVNBRANCH);))
672 @$(foreach module,$(ALL-MODULES), \
673 $(if $($(module)-SVNPATH), \
674 $(if $($(module)-SVNBRANCH), \
675 echo $(module):$($(module)-SVNBRANCH); , \
678 info: packages modules branches
680 .PHONY: info packages modules branches module-tools
684 @echo "********** Run make in two stages:"
686 @echo "make stage1=true PLDISTRO=onelab"
687 @echo " -> extracts all spec files in SPECS/ and mk files in MAKE/"
688 @echo " as well as save PLDISTRO for subsequent runs"
690 @echo "********** Then you can use the following targets"
692 @echo " rebuilds everything"
693 @echo 'make util-vserver'
694 @echo " makes the RPMS related to util-vserver"
695 @echo " equivalent to 'make util-vserver-rpms'"
697 @echo "********** Or, vertically - step-by-step for a given package"
698 @echo 'make util-vserver-codebase'
699 @echo " performs codebase extraction in CODEBASES/util-vserver"
700 @echo 'make util-vserver-source'
701 @echo " creates source link in SOURCES/util-vserver-<version>"
702 @echo 'make util-vserver-tarball'
703 @echo " creates source tarball in SOURCES/util-vserver-<version>.<tarextension>"
704 @echo 'make util-vserver-srpm'
705 @echo " build source rpm in SRPMS/"
706 @echo 'make util-vserver-rpms'
707 @echo " build rpm(s) in RPMS/"
709 @echo "********** Or, horizontally, reach a step for all known packages"
710 @echo 'make codebases'
712 @echo 'make tarballs'
716 @echo "********** Manual targets"
717 @echo "make package-compile"
718 @echo " The regular process uses rpmbuild --rebuild, that performs"
719 @echo " a compilation directory cleanup upon completion. If you need to investigate"
720 @echo " the intermediate compilation directory, use the -compile targets"
721 @echo "********** Cleaning examples"
723 @echo " removes the files made by make"
724 @echo "make distclean"
725 @echo " brute-force cleaning, removes entire directories - requires a new stage1"
726 @echo "make develclean"
727 @echo " rpm-uninstalls all devel packages installed during build"
729 @echo "make iptables-distclean"
730 @echo " deep clean for a given package"
731 @echo "make iptables-codeclean"
732 @echo " run this if you've made a change in the CODEBASES area for iptables"
734 @echo "make util-vserver-clean"
735 @echo " removes codebase, source, tarball, build, rpm and srpm for util-vserver"
736 @echo "make util-vserver-clean-codebase"
737 @echo " and so on for source, tarball, build, rpm and srpm"
739 @echo "********** Info examples"
741 @echo " Displays the value of a given variable (here ALL)"
742 @echo " with only a single plus sign only the value is displayed"
744 @echo " is equivalent to make packages modules branches"
745 @echo " provides various info on these objects"
746 @echo "make ulogd-pkginfo"
747 @echo " Displays know attributes of a package"
748 @echo "make kernel-devel-rpminfo"
749 @echo " Displays know attributes of an rpm"
750 @echo "make stage1=true PLDISTROTAGS=planetlab-tags-4.2.mk packages modules branches module-tools"
751 @echo " Lists mentioned items - module-tools is used in modules.update"
753 @echo "********** Known pakages are"
756 #################### convenience, for debugging only
757 # make +foo : prints the value of $(foo)
758 # make ++foo : idem but verbose, i.e. foo=$(foo)
759 ++%: varname=$(subst +,,$@)
761 @echo "$(varname)=$($(varname))"
762 +%: varname=$(subst +,,$@)
764 @echo "$($(varname))"