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 # this used to be set in the -tags.mk files, but that turned out to require
135 # error-prone duplicate changes
136 # so now the nightly build script sets this to what it is currently using
137 # we set a default in case we run the build manually:
138 # if the local directory was svn checked out, then use the corresponding URL
139 svn-info-url-line := $(shell svn info 2> /dev/null | grep URL:)
140 default-build-SVNPATH := $(lastword $(svn-info-url-line))
141 # otherwise, use this hard-coded default
142 ifeq "$(default-build-SVNPATH)" ""
143 default-build-SVNPATH := http://svn.planet-lab.org/svn/build/trunk
145 # use default if necessary
146 build-SVNPATH ?= $(default-build-SVNPATH)
148 ########## stage1 and stage1iter
149 # extract specs and compute .mk files by running
151 # entering stage1, we compute all the spec files
152 # then we use stage1iter to compute the .mk iteratively,
153 # ensuring that the n-1 first makefiles are loaded when creating the n-th one
154 # when stage1iter is set, it is supposed to be an index (starting at 1) in $(ALL)
156 ALLMKS := $(foreach package, $(ALL), MAKE/$(package).mk)
158 ### stage1iter : need some arithmetic, see
159 # http://www.cmcrossroads.com/articles/ask-mr.-make/learning-gnu-make-functions-with-arithmetic.html
160 ifneq "$(stage1iter)" ""
161 # the first n packages
162 packages := $(wordlist 1,$(words $(stage1iter)),$(ALL))
164 package := $(word $(words $(packages)),$(packages))
165 # the n-1 first packages
166 stage1iter_1 := $(wordlist 2,$(words $(stage1iter)),$(stage1iter))
167 previous := $(wordlist 1,$(words $(stage1iter_1)),$(ALL))
168 previousmks := $(foreach package,$(previous),MAKE/$(package).mk)
169 include $(previousmks)
172 @echo "========== stage1iter : $(package)"
173 # @echo "stage1iter : included .mk files : $(previousmks)"
174 all: $($(package).specpath)
175 all: MAKE/$(package).mk
181 @echo "========== stage1"
184 # specs and makes are done sequentially by stage1iter
187 arg=""; for n in $(ALL) ; do arg="$$arg x"; $(MAKE) --no-print-directory stage1iter="$$arg"; done
190 ### once .mks are OK, you can run make normally
197 # mention $(ALL) here rather than rpms
198 # this is because the inter-package dependencies are expressed like
199 # util-vserver: util-python
205 ### yumgroups.xml : compute from all known .pkgs files
208 ./yumgroups.sh $(PLDISTRO) > $@
210 createrepo = createrepo --quiet -g yumgroups.xml RPMS/
212 repo: RPMS/yumgroups.xml
219 # * to make configuration easier, we always use the first module's
220 # definitions (CVSROOT,TAG, or SVNPATH) to extract the spec file
221 # * for the same reason, in case cvs is used, the first module name is added to
222 # $(package)-SPEC - otherwise the cvs modules have to define spec as
223 # <module>/<module>.spec while svn modules just define it as <module>.spec
225 define stage1_variables
226 $(1).spec = $(notdir $($(1)-SPEC))
227 $(1).specpath = SPECS/$(1).spec
228 $(1).module = $(firstword $($(1)-MODULES))
229 $(1)-SVNPATH = $(strip $($(1)-SVNPATH))
232 $(foreach package, $(ALL), $(eval $(call stage1_variables,$(package))))
235 # for each package, compute whether we need to set date
236 # the heuristic is that we mention the date as part of the rpm release flag if
237 # (*) the package has requested it by setting package-RPMDATE (container packages should do that)
238 # (*) or SVNPATH contains 'trunk' or 'branches'
240 define package_hasdate
241 $(1).has-date = $(if $($(1)-RPMDATE),yes, \
242 $(if $($($(1).module)-SVNPATH), \
243 $(if $(findstring /trunk,$($($(1).module)-SVNPATH)),yes, \
244 $(if $(findstring /branches,$($($(1).module)-SVNPATH)),yes,)), \
245 $(if $(findstring HEAD,$($($(1).module)-TAG)),yes,)))
248 $(foreach package, $(ALL), $(eval $(call package_hasdate,$(package))))
250 ### the common header for generated specfiles
251 # useful when trying new specfiles manually
253 (echo -n "# Generated by planetlab build from $($(1)-SPEC) on " ; date) > $@
254 echo "%define distro $(DISTRO)" >> $@
255 echo "%define distrorelease $(RELEASE)" >> $@
256 echo "%define distroname $(DISTRONAME)" >> $@
257 echo "%define pldistro $(PLDISTRO)" >> $@
258 echo "%define plrelease $(PLANETLAB_RELEASE)" >> $@
260 ### extract spec file from scm
262 $($(1).specpath): header.spec
264 cat header.spec > $($(1).specpath)
265 $(if $($(1).has-date),echo "%define date $(shell date +%Y.%m.%d)" >> $($(1).specpath),)
266 $(if $($(1)-SPECVARS), \
267 $(foreach line,$($(1)-SPECVARS), \
268 echo "%define" $(word 1,$(subst =, ,$(line))) "$(word 2,$(subst =, ,$(line)))" >> $($(1).specpath) ;))
269 echo "# included from $($(1)-SPEC)" >> $($(1).specpath)
270 $(if $($($(1).module)-SVNPATH),\
271 svn cat $($($(1).module)-SVNPATH)/$($(1)-SPEC) >> $($(1).specpath) || rm $($(1).specpath),\
272 cvs -d $($($(1).module)-CVSROOT) checkout \
273 -r $($($(1).module)-TAG) \
274 -p $($(1).module)/$($(1)-SPEC) >> $($(1).specpath))
277 $(foreach package,$(ALL),$(eval $(call target_spec,$(package))))
280 # Base rpmbuild in the current directory
281 # issues on fedora 8 : see the following posts
282 # http://forums.fedoraforum.org/showthread.php?t=39625 - and more specifically post#6
283 # https://www.redhat.com/archives/fedora-devel-list/2007-November/msg00171.html
285 FAKEROOT=/longbuildroot
286 PWD=$(shell /bin/pwd)
287 ifeq "$(PWD)" "$(REALROOT)"
288 export HOME := $(FAKEROOT)
290 export HOME := $(PWD)
293 ifeq "$(shell pwd)" "/build"
294 rm -f $(FAKEROOT) ; ln -s $(REALROOT) $(FAKEROOT)
297 echo "%_topdir $(HOME)" >> $@
298 echo "%_tmppath $(HOME)/tmp" >> $@
299 ./getrpmmacros.sh >> $@
301 ### this utility allows to extract various info from a spec file
302 ### and to define them in makefiles
303 spec2make: spec2make.c
304 $(CC) -g -Wall $< -o $@ -lrpm -lrpmbuild
306 ### run spec2make on the spec file and include the result
307 # usage: spec2make package
309 MAKE/$(1).mk: $($(1).specpath) spec2make .rpmmacros
311 ./spec2make $($(1)-RPMFLAGS) $($(1).specpath) $(1) > MAKE/$(1).mk
312 @if [ -z MAKE/$(1).mk ] ; then rm MAKE/$(1).mk ; exit 1 ; fi
315 $(foreach package,$(ALL),$(eval $(call target_mk,$(package))))
317 # stores PLDISTRO in a file
318 # this is done at stage1. later run wont get confused
320 echo "PLDISTRO:=$(PLDISTRO)" > $@
321 echo "PLDISTROTAGS:=$(PLDISTROTAGS)" >> $@
323 savepldistro: pldistro.mk
326 # always refresh this
329 #################### regular make
331 define stage2_variables
332 ### devel dependencies
333 $(1).rpmbuild = $(if $($(1)-RPMBUILD),$($(1)-RPMBUILD),$(RPMBUILD)) $($(1)-RPMFLAGS)
334 $(1).all-devel-rpm-paths := $(foreach rpm,$($(1)-DEPEND-DEVEL-RPMS),$($(rpm).rpm-path))
335 $(1).depend-devel-packages := $(sort $(foreach rpm,$($(1)-DEPEND-DEVEL-RPMS),$($(rpm).package)))
336 ALL-DEVEL-RPMS += $($(1)-DEPEND-DEVEL-RPMS)
339 $(foreach package,$(ALL),$(eval $(call stage2_variables,$(package))))
340 ALL-DEVEL-RPMS := $(sort $(ALL-DEVEL-RPMS))
343 ### pack sources into tarballs
344 ALLTARBALLS:= $(foreach package, $(ALL), $($(package).tarballs))
345 tarballs: $(ALLTARBALLS)
346 @echo $(words $(ALLTARBALLS)) source tarballs OK
349 SOURCES/%.tar.bz2: SOURCES/%
350 tar chpjf $@ -C SOURCES $*
352 SOURCES/%.tar.gz: SOURCES/%
353 tar chpzf $@ -C SOURCES $*
355 SOURCES/%.tgz: SOURCES/%
356 tar chpzf $@ -C SOURCES $*
359 URLS/%: url=$(subst @colon@,:,$(subst @slash@,/,$(notdir $@)))
360 URLS/%: basename=$(notdir $(url))
362 echo curl $(url) -o SOURCES/$(basename)
365 ### the directory SOURCES/<package>-<version> is made
366 # with a copy -rl from CODEBASES/<package>
367 # the former is $(package.source) and the latter is $(package.codebase)
368 ALLSOURCES:=$(foreach package, $(ALL), $($(package).source))
369 # so that make does not use the rule below directly for creating the tarball files
370 .SECONDARY: $(ALLSOURCES)
372 sources: $(ALLSOURCES)
373 @echo $(words $(ALLSOURCES)) versioned source trees OK
376 define target_link_codebase_sources
377 $($(1).source): $($(1).codebase) ; mkdir -p SOURCES ; cp -rl $($(1).codebase) $($(1).source)
380 $(foreach package,$(ALL),$(eval $(call target_link_codebase_sources,$(package))))
382 ### codebase extraction
383 ALLCODEBASES:=$(foreach package, $(ALL), $($(package).codebase))
384 # so that make does not use the rule below directly for creating the tarball files
385 .SECONDARY: $(ALLCODEBASES)
387 codebases : $(ALLCODEBASES)
388 @echo $(words $(ALLCODEBASES)) codebase OK
392 # usage: extract_single_module package
393 define extract_single_module
395 $(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))
398 # usage: extract_multi_module package
399 define extract_multi_module
400 mkdir -p CODEBASES/$(1) && cd CODEBASES/$(1) && (\
401 $(foreach m,$($(1)-MODULES), $(if $($(m)-SVNPATH), svn export $($(m)-SVNPATH) $(m);, cvs -d $($(m)-CVSROOT) export -r $($(m)-TAG) $(m);)))
404 CODEBASES/%: package=$(notdir $@)
405 CODEBASES/%: multi_module=$(word 2,$($(package)-MODULES))
407 @(echo -n "XXXXXXXXXXXXXXX -- BEG CODEBASE $(package) : $@ " ; date)
408 $(if $(multi_module),\
409 $(call extract_multi_module,$(package)),\
410 $(call extract_single_module,$(package)))
411 @(echo -n "XXXXXXXXXXXXXXX -- END CODEBASE $(package) : $@ " ; date)
414 ALLSRPMS:=$(foreach package,$(ALL),$($(package).srpm))
416 @echo $(words $(ALLSRPMS)) source rpms OK
419 # usage: target_source_rpm package
420 # select upon the package name, whether it contains srpm or not
421 define target_source_rpm
422 ifeq "$($(1)-BUILD-FROM-SRPM)" ""
423 $($(1).srpm): $($(1).specpath) .rpmmacros $($(1).tarballs)
424 mkdir -p BUILD SRPMS tmp
425 @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) (using SOURCES) " ; date)
426 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
427 $($(1).rpmbuild) -bs $($(1).specpath)
428 $(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
429 @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
431 $($(1).srpm): $($(1).specpath) .rpmmacros $($(1).codebase)
432 mkdir -p BUILD SRPMS tmp
433 @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) (using make srpm) " ; date)
434 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
435 make -C $($(1).codebase) srpm SPECFILE=$(HOME)/$($(1).specpath) && \
436 rm -f SRPMS/$(notdir $($(1).srpm)) && \
437 ln $($(1).codebase)/$(notdir $($(1).srpm)) SRPMS/$(notdir $($(1).srpm))
438 $(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
439 @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
443 $(foreach package,$(ALL),$(eval $(call target_source_rpm,$(package))))
445 ### binary rpms are made from source rpm
446 ALLRPMS:=$(foreach package,$(ALL),$($(package).rpms))
447 # same as above, mention $(ALL) and not $(ALLRPMS)
449 @echo $(words $(ALLRPMS)) binary rpms OK
452 # use tmp dirs when building binary rpm so make remains idempotent
453 # otherwise SOURCES/ or SPEC gets touched again - which leads to rebuilding
454 RPM-USE-TMP-DIRS = --define "_sourcedir $(HOME)/tmp" --define "_specdir $(HOME)/tmp"
455 RPM-USE-COMPILE-DIRS = --define "_sourcedir $(HOME)/COMPILE" --define "_specdir $(HOME)/COMPILE"
457 # usage: build_binary_rpm package
458 # xxx hacky - invoke createrepo if DEPEND-FILES mentions RPMS/yumgroups.xml
459 define target_binary_rpm
460 $($(1).rpms): $($(1).srpm)
462 @(echo -n "XXXXXXXXXXXXXXX -- BEG RPM $(1) " ; date)
463 $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPEND-FILES)), $(createrepo) , )
464 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
465 $($(1).rpmbuild) --rebuild $(RPM-USE-TMP-DIRS) $($(1).srpm)
466 $(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
467 @(echo -n "XXXXXXXXXXXXXXX -- END RPM $(1) " ; date)
468 # for manual use only - in case we need to investigate the results of an rpmbuild
469 $(1)-compile: $($(1).srpm)
471 @(echo -n "XXXXXXXXXXXXXXX -- BEG compile $(1) " ; date)
472 $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPEND-FILES)), $(createrepo) , )
473 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
474 $($(1).rpmbuild) --recompile $(RPM-USE-TMP-DIRS) $($(1).srpm)
475 $(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
476 @(echo -n "XXXXXXXXXXXXXXX -- END compile $(1) " ; date)
480 $(foreach package,$(ALL),$(eval $(call target_binary_rpm,$(package))))
482 # e.g. make proper -> does propers rpms
483 # usage shorthand_target package
484 define target_shorthand
487 $(1)-spec: $($(1)-SPEC)
491 $(1)-tarball: $($(1).tarballs)
493 $(1)-codebase: $($(1).codebase)
495 $(1)-source: $($(1).source)
496 .PHONY: $(1)-codebase
497 $(1)-rpms: $($(1).rpms)
499 $(1)-srpm: $($(1).srpm)
503 $(foreach package,$(ALL),$(eval $(call target_shorthand,$(package))))
505 ### file dependencies
506 define package_depends_on_file
511 define target_dependfiles
512 $(foreach file,$($(1)-DEPEND-FILES),$(eval $(call package_depends_on_file,$(1),$(file))))
515 $(foreach package,$(ALL),$(eval $(call target_dependfiles,$(package))))
517 ### package dependencies
518 define package_depends_on_package
521 $($(1).srpm):$($(2).rpms)
524 define target_depends
525 $(foreach package,$($(1)-DEPEND-PACKAGES) $($(1).depend-devel-packages),$(eval $(call package_depends_on_package,$(1),$(package))))
528 $(foreach package,$(ALL),$(eval $(call target_depends,$(package))))
531 # usage: target_clean package
534 rm -rf $($(1).codebase)
535 .PHONY: $(1)-clean-codebase
536 CLEANS += $(1)-clean-codebase
538 rm -rf $($(1).source)
539 .PHONY: $(1)-clean-source
540 CLEANS += $(1)-clean-source
542 rm -rf $($(1).tarballs)
543 .PHONY: $(1)-clean-tarball
544 CLEANS += $(1)-clean-tarball
546 rm -rf BUILD/$(notdir $($(1).source))
547 CLEANS += $(1)-clean-build
550 .PHONY: $(1)-clean-rpms
551 CLEANS += $(1)-clean-rpms
554 .PHONY: $(1)-clean-srpm
555 CLEANS += $(1)-clean-srpm
556 $(1)-codeclean: $(1)-clean-source $(1)-clean-tarball $(1)-clean-build $(1)-clean-rpms $(1)-clean-srpm
557 $(1)-clean: $(1)-clean-codebase $(1)-codeclean
558 .PHONY: $(1)-codeclean $(1)-clean
560 rm -rf $($(1).specpath)
561 .PHONY: $(1)-clean-spec
564 .PHONY: $(1)-clean-make
565 $(1)-distclean: $(1)-distclean1 $(1)-distclean2
566 $(1)-distclean1: $(1)-clean-spec $(1)-clean-make
567 $(1)-distclean2: $(1)-clean
568 .PHONY: $(1)-distclean $(1)-distclean1 $(1)-distclean2
571 $(foreach package,$(ALL),$(eval $(call target_clean,$(package))))
579 @echo Available clean targets
582 ### brute force clean
584 rm -rf pldistro.mk .rpmmacros spec2make header.spec SPECS MAKE
586 rm -rf CODEBASES SOURCES BUILD RPMS SRPMS tmp
587 distclean: distclean1 distclean2
588 .PHONY: distclean1 distclean2 distclean
591 $(RPM-UNINSTALL-DEVEL) $(ALL-DEVEL-RPMS)
594 # gather build information for the 'About' page
595 # when run from crontab, INIT_CWD not properly set (says /root ..)
596 # so, the nightly build passes NIGHTLY_BASE here
597 # also store the nightly_base in .base for any post-processing purposes
599 @echo 'Creating myplc-release'
601 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx build info" >> $@
602 $(MAKE) --no-print-directory version-build >> $@
603 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx svn info" >> $@
604 $(MAKE) --no-print-directory version-svns >> $@
605 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx rpm info" >> $@
606 $(MAKE) --no-print-directory version-rpms >> $@
607 @echo $(NIGHTLY_BASE) > .base
610 @echo -n 'Build build-date: ' ; date '+%Y.%m.%d'
611 @echo -n 'Build build-time: ' ; date '+%H:%M-%Z'
612 @echo -n 'Build build-hostname: ' ; hostname
613 @echo "Build build-base: $(NIGHTLY_BASE)"
614 @echo "Build planetlab-distro: $(PLDISTRO)"
615 @echo "Build planetlab-tags: $(PLDISTROTAGS)"
616 @echo -n 'Build planetlab-tagsid: ' ; fgrep '$$''Id' $(PLDISTROTAGS)
617 @echo "Build target-arch: $(HOSTARCH)"
618 @echo "Build target-distro: $(DISTRO)"
619 @echo "Build target-distroname: $(DISTRONAME)"
620 @echo "Build target-release: $(RELEASE)"
621 @echo "Build target-personality: $(NIGHTLY_PERSONALITY)"
625 VFORMAT="%30s := %s\n"
626 define svn_version_target
628 @$(if $($(1)-SVNPATH),\
629 printf $(VFORMAT) $(1)-SVNPATH "$($(1)-SVNPATH)",\
630 printf $(VFORMAT) $(1)-CVSROOT "$($(1)-CVSROOT)" ; printf $(VFORMAT) $(1)-TAG "$($(1)-TAG)")
633 # compute all modules
635 $(foreach package,$(ALL), $(eval ALL-MODULES+=$($(package)-MODULES)))
636 ALL-MODULES:=$(sort $(ALL-MODULES))
638 $(foreach module,$(ALL-MODULES), $(eval $(call svn_version_target,$(module))))
640 version-svns: $(foreach module, $(ALL-MODULES), $(module)-version-svn)
642 RFORMAT="%20s :: version=%s release=%s\n"
643 define rpm_version_target
645 @printf $(RFORMAT) $($(1).rpm-name) $($(1).rpm-version) $($(1).rpm-release)
646 version-rpms: $(1)-version-rpm
649 $(foreach package,$(sort $(ALL)), $(eval $(call rpm_version_target,$(package))))
651 versions: myplc-release version-build version-svns version-rpms
652 .PHONY: versions version-build version-rpms version-svns
654 #################### package info
655 PKGKEYS := tarballs source codebase srpm rpms rpmnames rpm-release rpm-name rpm-version rpm-subversion
656 %-pkginfo: package=$(subst -pkginfo,,$@)
658 @$(foreach key,$(PKGKEYS),echo "$(package).$(key)=$($(package).$(key))";)
660 RPMKEYS := rpm-path package
661 %-rpminfo: rpm=$(subst -rpminfo,,$@)
663 @$(foreach key,$(RPMKEYS),echo "$(rpm).$(key)=$($(rpm).$(key))";)
665 #################### various lists - designed to run with stage1=true
667 @$(foreach package,$(ALL), echo package=$(package) ref_module=$($(package).module) modules=$($(package)-MODULES) rpmnames=$($(package).rpmnames); )
670 @$(foreach module,$(ALL-MODULES), echo module=$(module) svnpath=$($(module)-SVNPATH); )
673 @$(foreach module,$(ALL-MODULES), \
674 $(if $($(module)-SVNBRANCH),echo module=$(module) branch=$($(module)-SVNBRANCH);))
677 @$(foreach module,$(ALL-MODULES), \
678 $(if $($(module)-SVNPATH), \
679 $(if $($(module)-SVNBRANCH), \
680 echo $(module):$($(module)-SVNBRANCH); , \
683 info: packages modules branches
685 .PHONY: info packages modules branches module-tools
689 @$(if $(TESTS_SVNPATH), echo $(TESTS_SVNPATH) > $@, \
690 echo "http://svn.planet-lab.org/svn/tests/trunk" > $@)
694 @echo "********** Run make in two stages:"
696 @echo "make stage1=true PLDISTRO=onelab"
697 @echo " -> extracts all spec files in SPECS/ and mk files in MAKE/"
698 @echo " as well as save PLDISTRO for subsequent runs"
700 @echo "********** Then you can use the following targets"
702 @echo " rebuilds everything"
703 @echo 'make util-vserver'
704 @echo " makes the RPMS related to util-vserver"
705 @echo " equivalent to 'make util-vserver-rpms'"
707 @echo "********** Or, vertically - step-by-step for a given package"
708 @echo 'make util-vserver-codebase'
709 @echo " performs codebase extraction in CODEBASES/util-vserver"
710 @echo 'make util-vserver-source'
711 @echo " creates source link in SOURCES/util-vserver-<version>"
712 @echo 'make util-vserver-tarball'
713 @echo " creates source tarball in SOURCES/util-vserver-<version>.<tarextension>"
714 @echo 'make util-vserver-srpm'
715 @echo " build source rpm in SRPMS/"
716 @echo 'make util-vserver-rpms'
717 @echo " build rpm(s) in RPMS/"
719 @echo "********** Or, horizontally, reach a step for all known packages"
720 @echo 'make codebases'
722 @echo 'make tarballs'
726 @echo "********** Manual targets"
727 @echo "make package-compile"
728 @echo " The regular process uses rpmbuild --rebuild, that performs"
729 @echo " a compilation directory cleanup upon completion. If you need to investigate"
730 @echo " the intermediate compilation directory, use the -compile targets"
731 @echo "********** Cleaning examples"
733 @echo " removes the files made by make"
734 @echo "make distclean"
735 @echo " brute-force cleaning, removes entire directories - requires a new stage1"
736 @echo "make develclean"
737 @echo " rpm-uninstalls all devel packages installed during build"
739 @echo "make iptables-distclean"
740 @echo " deep clean for a given package"
741 @echo "make iptables-codeclean"
742 @echo " run this if you've made a change in the CODEBASES area for iptables"
744 @echo "make util-vserver-clean"
745 @echo " removes codebase, source, tarball, build, rpm and srpm for util-vserver"
746 @echo "make util-vserver-clean-codebase"
747 @echo " and so on for source, tarball, build, rpm and srpm"
749 @echo "********** Info examples"
751 @echo " Displays the value of a given variable (here ALL)"
752 @echo " with only a single plus sign only the value is displayed"
754 @echo " is equivalent to make packages modules branches"
755 @echo " provides various info on these objects"
756 @echo "make ulogd-pkginfo"
757 @echo " Displays know attributes of a package"
758 @echo "make kernel-devel-rpminfo"
759 @echo " Displays know attributes of an rpm"
760 @echo "make stage1=true PLDISTROTAGS=planetlab-tags-4.2.mk packages modules branches module-tools"
761 @echo " Lists mentioned items - module-tools is used in modules.update"
763 @echo "********** Known pakages are"
766 #################### convenience, for debugging only
767 # make +foo : prints the value of $(foo)
768 # make ++foo : idem but verbose, i.e. foo=$(foo)
769 ++%: varname=$(subst +,,$@)
771 @echo "$(varname)=$($(varname))"
772 +%: varname=$(subst +,,$@)
774 @echo "$($(varname))"