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 # this is intended to denote local rpms, i.e. ones that are results of our own build
60 # stock rpms should be mentioned in config.planetlab/devel.pkgs
61 # (*) package-DEPEND-FILES
62 # a set of files that the package depends on - and that make needs to know about
63 # if this contains RPMS/yumgroups.xml, then the toplevel RPMS's index
64 # is refreshed with createrepo prior to running rpmbuild
65 # (*) package-RPMFLAGS: Miscellaneous RPM flags
66 # (*) package-RPMBUILD: If not rpmbuild - mostly used for sudo'ing rpmbuild
67 # (*) package-BUILD-FROM-SRPM: set this to any non-empty value, if your package is able to produce
68 # a source rpms by running 'make srpm'
69 # (*) package-RPMDATE: set this to any non-empty value to get the rpm package's release field hold the current date
70 # this is useful for container packages, like e.g. bootstrapfs or vserver, that contains much more than the
73 #################### modules
74 # Required information about the various modules (set this in e.g. planetlab-tags.mk)
77 # the complete path where this module lies;
78 # you can specify the trunk or a given tag with this variable
80 # OR if the module is managed under cvs (will be obsoleted)
85 #################### automatic variables
87 # the build defines some make variables that are extracted from spec files
89 # (*) $ make ulogd-pkginfo
90 # to see the list f variables attached to a given package
91 # (*) $ make kernel-devel-rpminfo
92 # to see the list of variables attached to a given rpm
96 # exported to spec files as plrelease
97 PLANETLAB_RELEASE = 4.3
102 # minimal compat with macos, just so this does not complain
103 HOSTARCH := $(shell uname -i 2> /dev/null || uname -m 2> /dev/null)
104 DISTRO := $(shell ./getdistro.sh)
105 RELEASE := $(shell ./getrelease.sh)
106 DISTRONAME := $(shell ./getdistroname.sh)
107 RPM-INSTALL-DEVEL := rpm --force -Uvh
108 # uninstall -- cannot force rpm -e
109 # need to ignore result, kernel-headers cannot be uninstalled as glibc depends on it
110 RPM-UNINSTALL-DEVEL := rpm -e
112 REMOTE-PLDISTROS="gnuradio"
114 #################### Makefile
120 PLDISTRO := planetlab
122 export CVS_RSH := ssh
124 ########## savedpldistro.mk holds PLDISTRO - it is generated at stage1 (see below)
126 include savedpldistro.mk
129 # when re-running the nightly build after failure, we need to gather the former values
130 # do this by running make stage1=skip +PLDISTRO
131 ifeq "$(stage1)" "skip"
132 include savedpldistro.mk
135 #################### include onelab.mk
136 # describes the set of components
137 PLDISTROCONTENTS := $(PLDISTRO).mk
138 include $(PLDISTROCONTENTS)
140 #################### include <pldistro>-tags.mk
141 # describes where to fetch components, and the related tags if using cvs
142 PLDISTROTAGS := $(PLDISTRO)-tags.mk
143 include $(PLDISTROTAGS)
145 # this used to be set in the -tags.mk files, but that turned out to require
146 # error-prone duplicate changes
147 # so now the nightly build script sets this to what it is currently using
148 # we set a default in case we run the build manually:
149 # if the local directory was svn checked out, then use the corresponding URL
150 svn-info-url-line := $(shell svn info 2> /dev/null | grep URL:)
151 default-build-SVNPATH := $(lastword $(svn-info-url-line))
152 # otherwise, use this hard-coded default
153 ifeq "$(default-build-SVNPATH)" ""
154 default-build-SVNPATH := http://svn.planet-lab.org/svn/build/trunk
156 # use default if necessary
157 build-SVNPATH ?= $(default-build-SVNPATH)
160 define remote_pldistro
161 $(1).mk: config.$(1)/$(1).mk
162 @echo 'creating $(1) from config subdir'
163 cp config.$(1)/$(1).mk $(1).mk
165 $(2).mk: config.$(1)/$(2).mk
166 @echo 'creating $(1) tags from config subdir'
167 cp config.$(1)/$(2).mk $(2).mk
169 config.$(1)/$(1).mk: config.$(1)
170 config.$(1)/$(2).mk: config.$(1)
172 config.$(1): config.$(1).svnpath
173 @echo "Fetching details for pldistro $(1)"
174 svn export $(shell grep -v "^#" config.$(1).svnpath) config.$(1)
176 DISTCLEANS += $(1).mk $(2).mk config.$(1)
180 $(eval $(call remote_pldistro,gnuradio,gnuradio-tags))
182 ########## stage1 and stage1iter
183 # extract specs and compute .mk files by running
185 # entering stage1, we compute all the spec files
186 # then we use stage1iter to compute the .mk iteratively,
187 # ensuring that the n-1 first makefiles are loaded when creating the n-th one
188 # when stage1iter is set, it is supposed to be an index (starting at 1) in $(ALL)
190 ALLMKS := $(foreach package, $(ALL), MAKE/$(package).mk)
192 ### stage1iter : need some arithmetic, see
193 # http://www.cmcrossroads.com/articles/ask-mr.-make/learning-gnu-make-functions-with-arithmetic.html
194 ifneq "$(stage1iter)" ""
195 # the first n packages
196 packages := $(wordlist 1,$(words $(stage1iter)),$(ALL))
198 package := $(word $(words $(packages)),$(packages))
199 # the n-1 first packages
200 stage1iter_1 := $(wordlist 2,$(words $(stage1iter)),$(stage1iter))
201 previous := $(wordlist 1,$(words $(stage1iter_1)),$(ALL))
202 previousmks := $(foreach package,$(previous),MAKE/$(package).mk)
203 include $(previousmks)
206 @echo "========== stage1iter : $(package)"
207 # @echo "stage1iter : included .mk files : $(previousmks)"
208 all: $($(package).specpath)
209 all: MAKE/$(package).mk
215 @echo "========== stage1"
218 # specs and makes are done sequentially by stage1iter
221 arg=""; for n in $(ALL) ; do arg="$$arg x"; $(MAKE) --no-print-directory stage1iter="$$arg"; done
224 ### once .mks are OK, you can run make normally
231 # mention $(ALL) here rather than rpms
232 # this is because the inter-package dependencies are expressed like
233 # util-vserver: util-python
239 ### yumgroups.xml : compute from all known .pkgs files
242 ./yumgroups.sh $(PLDISTRO) > $@
244 createrepo = createrepo --quiet -g yumgroups.xml RPMS/
246 repo: RPMS/yumgroups.xml
253 # * to make configuration easier, we always use the first module's
254 # definitions (CVSROOT,TAG, or SVNPATH) to extract the spec file
255 # * for the same reason, in case cvs is used, the first module name is added to
256 # $(package)-SPEC - otherwise the cvs modules have to define spec as
257 # <module>/<module>.spec while svn modules just define it as <module>.spec
259 define stage1_variables
260 $(1).spec = $(notdir $($(1)-SPEC))
261 $(1).specpath = SPECS/$(1).spec
262 $(1).module = $(firstword $($(1)-MODULES))
263 $(1)-SVNPATH = $(strip $($(1)-SVNPATH))
266 $(foreach package, $(ALL), $(eval $(call stage1_variables,$(package))))
269 # for each package, compute whether we need to set date
270 # the heuristic is that we mention the date as part of the rpm release flag if
271 # (*) the package has requested it by setting package-RPMDATE (container packages should do that)
272 # (*) or SVNPATH contains 'trunk' or 'branches'
274 define package_hasdate
275 $(1).has-date = $(if $($(1)-RPMDATE),yes, \
276 $(if $($($(1).module)-SVNPATH), \
277 $(if $(findstring /trunk,$($($(1).module)-SVNPATH)),yes, \
278 $(if $(findstring /branches,$($($(1).module)-SVNPATH)),yes,)), \
279 $(if $(findstring HEAD,$($($(1).module)-TAG)),yes,)))
282 $(foreach package, $(ALL), $(eval $(call package_hasdate,$(package))))
284 ### the common header for generated specfiles
285 # useful when trying new specfiles manually
287 (echo -n "# Generated by planetlab build from $($(1)-SPEC) on " ; date) > $@
288 echo "%define distro $(DISTRO)" >> $@
289 echo "%define distrorelease $(RELEASE)" >> $@
290 echo "%define distroname $(DISTRONAME)" >> $@
291 echo "%define pldistro $(PLDISTRO)" >> $@
292 echo "%define plrelease $(PLANETLAB_RELEASE)" >> $@
294 ### extract spec file from scm
296 $($(1).specpath): header.spec
298 cat header.spec > $($(1).specpath)
299 $(if $($(1).has-date),echo "%define date $(shell date +%Y.%m.%d)" >> $($(1).specpath),)
300 $(if $($(1)-SPECVARS), \
301 $(foreach line,$($(1)-SPECVARS), \
302 echo "%define" $(word 1,$(subst =, ,$(line))) "$(word 2,$(subst =, ,$(line)))" >> $($(1).specpath) ;))
303 echo "# included from $($(1)-SPEC)" >> $($(1).specpath)
304 $(if $($($(1).module)-SVNPATH),\
305 svn cat $($($(1).module)-SVNPATH)/$($(1)-SPEC) >> $($(1).specpath) || rm $($(1).specpath),\
306 cvs -d $($($(1).module)-CVSROOT) checkout \
307 -r $($($(1).module)-TAG) \
308 -p $($(1).module)/$($(1)-SPEC) >> $($(1).specpath))
311 $(foreach package,$(ALL),$(eval $(call target_spec,$(package))))
314 # Base rpmbuild in the current directory
315 # issues on fedora 8 : see the following posts
316 # http://forums.fedoraforum.org/showthread.php?t=39625 - and more specifically post#6
317 # https://www.redhat.com/archives/fedora-devel-list/2007-November/msg00171.html
319 FAKEROOT=/longbuildroot
320 PWD=$(shell /bin/pwd)
321 ifeq "$(PWD)" "$(REALROOT)"
322 export HOME := $(FAKEROOT)
324 export HOME := $(PWD)
327 ifeq "$(shell pwd)" "/build"
328 rm -f $(FAKEROOT) ; ln -s $(REALROOT) $(FAKEROOT)
331 echo "%_topdir $(HOME)" >> $@
332 echo "%_tmppath $(HOME)/tmp" >> $@
333 ./getrpmmacros.sh >> $@
335 ### this utility allows to extract various info from a spec file
336 ### and to define them in makefiles
337 spec2make: spec2make.c
338 $(CC) -g -Wall $< -o $@ -lrpm -lrpmbuild
340 ### run spec2make on the spec file and include the result
341 # usage: spec2make package
343 MAKE/$(1).mk: $($(1).specpath) spec2make .rpmmacros
345 ./spec2make $($(1)-RPMFLAGS) $($(1).specpath) $(1) > MAKE/$(1).mk || { rm MAKE/$(1).mk; exit 1; }
348 $(foreach package,$(ALL),$(eval $(call target_mk,$(package))))
350 # stores PLDISTRO in a file
351 # this is done at stage1. later run wont get confused
353 echo "PLDISTRO:=$(PLDISTRO)" > $@
354 echo "PLDISTROTAGS:=$(PLDISTROTAGS)" >> $@
355 echo "build-SVNPATH:=$(build-SVNPATH)" >> $@
356 echo "PERSONALITY:=$(PERSONALITY)" >> $@
357 echo "MAILTO:=$(MAILTO)" >> $@
358 echo "BASE:=$(BASE)" >> $@
359 echo "WEBPATH:=$(WEBPATH)" >> $@
360 echo "TESTBUILDURL:=$(TESTBUILDURL)" >> $@
361 echo "WEBROOT:=$(WEBROOT)" >> $@
363 savedpldistro: savedpldistro.mk
364 .PHONY: savedpldistro
366 # always refresh this
369 #################### regular make
371 define stage2_variables
372 ### devel dependencies
373 $(1).rpmbuild = $(if $($(1)-RPMBUILD),$($(1)-RPMBUILD),$(RPMBUILD)) $($(1)-RPMFLAGS)
374 $(1).all-devel-rpm-paths := $(foreach rpm,$($(1)-DEPEND-DEVEL-RPMS),$($(rpm).rpm-path))
375 $(1).depend-devel-packages := $(sort $(foreach rpm,$($(1)-DEPEND-DEVEL-RPMS),$($(rpm).package)))
376 ALL-DEVEL-RPMS += $($(1)-DEPEND-DEVEL-RPMS)
379 $(foreach package,$(ALL),$(eval $(call stage2_variables,$(package))))
380 ALL-DEVEL-RPMS := $(sort $(ALL-DEVEL-RPMS))
383 ### pack sources into tarballs
384 ALLTARBALLS:= $(foreach package, $(ALL), $($(package).tarballs))
385 tarballs: $(ALLTARBALLS)
386 @echo $(words $(ALLTARBALLS)) source tarballs OK
389 SOURCES/%.tar.bz2: SOURCES/%
390 tar chpjf $@ -C SOURCES $*
392 SOURCES/%.tar.gz: SOURCES/%
393 tar chpzf $@ -C SOURCES $*
395 SOURCES/%.tgz: SOURCES/%
396 tar chpzf $@ -C SOURCES $*
399 URLS/%: url=$(subst @colon@,:,$(subst @slash@,/,$(notdir $@)))
400 URLS/%: basename=$(notdir $(url))
402 echo curl $(url) -o SOURCES/$(basename)
405 ### the directory SOURCES/<package>-<version> is made
406 # with a copy -rl from CODEBASES/<package>
407 # the former is $(package.source) and the latter is $(package.codebase)
408 ALLSOURCES:=$(foreach package, $(ALL), $($(package).source))
409 # so that make does not use the rule below directly for creating the tarball files
410 .SECONDARY: $(ALLSOURCES)
412 sources: $(ALLSOURCES)
413 @echo $(words $(ALLSOURCES)) versioned source trees OK
416 define target_link_codebase_sources
417 $($(1).source): $($(1).codebase) ; mkdir -p SOURCES ; cp -rl $($(1).codebase) $($(1).source)
420 $(foreach package,$(ALL),$(eval $(call target_link_codebase_sources,$(package))))
422 ### codebase extraction
423 ALLCODEBASES:=$(foreach package, $(ALL), $($(package).codebase))
424 # so that make does not use the rule below directly for creating the tarball files
425 .SECONDARY: $(ALLCODEBASES)
427 codebases : $(ALLCODEBASES)
428 @echo $(words $(ALLCODEBASES)) codebase OK
432 # usage: extract_single_module package
433 define extract_single_module
435 $(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))
438 # usage: extract_multi_module package
439 define extract_multi_module
440 mkdir -p CODEBASES/$(1) && cd CODEBASES/$(1) && (\
441 $(foreach m,$($(1)-MODULES), $(if $($(m)-SVNPATH), svn export $($(m)-SVNPATH) $(m);, cvs -d $($(m)-CVSROOT) export -r $($(m)-TAG) $(m);)))
444 CODEBASES/%: package=$(notdir $@)
445 CODEBASES/%: multi_module=$(word 2,$($(package)-MODULES))
447 @(echo -n "XXXXXXXXXXXXXXX -- BEG CODEBASE $(package) : $@ " ; date)
448 $(if $(multi_module),\
449 $(call extract_multi_module,$(package)),\
450 $(call extract_single_module,$(package)))
451 @(echo -n "XXXXXXXXXXXXXXX -- END CODEBASE $(package) : $@ " ; date)
454 ALLSRPMS:=$(foreach package,$(ALL),$($(package).srpm))
456 @echo $(words $(ALLSRPMS)) source rpms OK
459 # usage: target_source_rpm package
460 define target_source_rpm
461 ifeq "$($(1)-BUILD-FROM-SRPM)" ""
462 $($(1).srpm): $($(1).specpath) .rpmmacros $($(1).tarballs)
463 mkdir -p BUILD SRPMS tmp
464 @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) (using SOURCES) " ; date)
465 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
466 $($(1).rpmbuild) -bs $($(1).specpath)
467 -$(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
468 @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
470 $($(1).srpm): $($(1).specpath) .rpmmacros $($(1).codebase)
471 mkdir -p BUILD SRPMS tmp
472 @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) (using make srpm) " ; date)
473 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
474 make -C $($(1).codebase) srpm SPECFILE=$(HOME)/$($(1).specpath) && \
475 rm -f SRPMS/$(notdir $($(1).srpm)) && \
476 ln $($(1).codebase)/$(notdir $($(1).srpm)) SRPMS/$(notdir $($(1).srpm))
477 -$(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
478 @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
482 $(foreach package,$(ALL),$(eval $(call target_source_rpm,$(package))))
484 ### binary rpms are made from source rpm
485 ALLRPMS:=$(foreach package,$(ALL),$($(package).rpms))
486 # same as above, mention $(ALL) and not $(ALLRPMS)
488 @echo $(words $(ALLRPMS)) binary rpms OK
491 # use tmp dirs when building binary rpm so make remains idempotent
492 # otherwise SOURCES/ or SPEC gets touched again - which leads to rebuilding
493 RPM-USE-TMP-DIRS = --define "_sourcedir $(HOME)/tmp" --define "_specdir $(HOME)/tmp"
494 RPM-USE-COMPILE-DIRS = --define "_sourcedir $(HOME)/COMPILE" --define "_specdir $(HOME)/COMPILE"
496 # usage: build_binary_rpm package
497 # xxx hacky - invoke createrepo if DEPEND-FILES mentions RPMS/yumgroups.xml
498 define target_binary_rpm
499 $($(1).rpms): $($(1).srpm)
501 @(echo -n "XXXXXXXXXXXXXXX -- BEG RPM $(1) " ; date)
502 $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPEND-FILES)), $(createrepo) , )
503 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
504 $($(1).rpmbuild) --rebuild $(RPM-USE-TMP-DIRS) $($(1).srpm)
505 -$(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
506 @(echo -n "XXXXXXXXXXXXXXX -- END RPM $(1) " ; date)
507 # for manual use only - in case we need to investigate the results of an rpmbuild
508 $(1)-compile: $($(1).srpm)
510 @(echo -n "XXXXXXXXXXXXXXX -- BEG compile $(1) " ; date)
511 $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPEND-FILES)), $(createrepo) , )
512 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
513 $($(1).rpmbuild) --recompile $(RPM-USE-TMP-DIRS) $($(1).srpm)
514 -$(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
515 @(echo -n "XXXXXXXXXXXXXXX -- END compile $(1) " ; date)
519 $(foreach package,$(ALL),$(eval $(call target_binary_rpm,$(package))))
521 # e.g. make proper -> does propers rpms
522 # usage shorthand_target package
523 define target_shorthand
526 $(1)-spec: $($(1)-SPEC)
530 $(1)-tarball: $($(1).tarballs)
532 $(1)-codebase: $($(1).codebase)
534 $(1)-source: $($(1).source)
535 .PHONY: $(1)-codebase
536 $(1)-rpms: $($(1).rpms)
538 $(1)-srpm: $($(1).srpm)
542 $(foreach package,$(ALL),$(eval $(call target_shorthand,$(package))))
544 ### file dependencies
545 define package_depends_on_file
550 define target_dependfiles
551 $(foreach file,$($(1)-DEPEND-FILES),$(eval $(call package_depends_on_file,$(1),$(file))))
554 $(foreach package,$(ALL),$(eval $(call target_dependfiles,$(package))))
556 ### package dependencies
557 define package_depends_on_package
560 $($(1).srpm):$($(2).rpms)
563 define target_depends
564 $(foreach package,$($(1)-DEPEND-PACKAGES) $($(1).depend-devel-packages),$(eval $(call package_depends_on_package,$(1),$(package))))
567 $(foreach package,$(ALL),$(eval $(call target_depends,$(package))))
570 # usage: target_clean package
573 rm -rf $($(1).codebase)
574 .PHONY: $(1)-clean-codebase
575 CLEANS += $(1)-clean-codebase
577 rm -rf $($(1).source)
578 .PHONY: $(1)-clean-source
579 CLEANS += $(1)-clean-source
581 rm -rf $($(1).tarballs)
582 .PHONY: $(1)-clean-tarball
583 CLEANS += $(1)-clean-tarball
585 rm -rf BUILD/$(notdir $($(1).source))
586 CLEANS += $(1)-clean-build
589 .PHONY: $(1)-clean-rpms
590 CLEANS += $(1)-clean-rpms
593 .PHONY: $(1)-clean-srpm
594 CLEANS += $(1)-clean-srpm
595 $(1)-codeclean: $(1)-clean-source $(1)-clean-tarball $(1)-clean-build $(1)-clean-rpms $(1)-clean-srpm
596 $(1)-clean: $(1)-clean-codebase $(1)-codeclean
597 .PHONY: $(1)-codeclean $(1)-clean
599 rm -rf $($(1).specpath)
600 .PHONY: $(1)-clean-spec
603 .PHONY: $(1)-clean-make
604 $(1)-distclean: $(1)-distclean1 $(1)-distclean2
605 $(1)-distclean1: $(1)-clean-spec $(1)-clean-make
606 $(1)-distclean2: $(1)-clean
607 .PHONY: $(1)-distclean $(1)-distclean1 $(1)-distclean2
610 $(foreach package,$(ALL),$(eval $(call target_clean,$(package))))
618 @echo Available clean targets
621 ### brute force clean
623 rm -rf savedpldistro.mk .rpmmacros spec2make header.spec SPECS MAKE $(DISTCLEANS)
625 rm -rf CODEBASES SOURCES BUILD RPMS SRPMS tmp
626 distclean: distclean1 distclean2
627 .PHONY: distclean1 distclean2 distclean
630 -$(RPM-UNINSTALL-DEVEL) $(ALL-DEVEL-RPMS)
633 # gather build information for the 'About' page
634 # when run from crontab, INIT_CWD not properly set (says /root ..)
635 # so, the nightly build passes BASE here
636 # also store BASE in .base for any post-processing purposes
638 @echo 'Creating myplc-release'
640 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx build info" >> $@
641 $(MAKE) --no-print-directory version-build >> $@
642 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx svn info" >> $@
643 $(MAKE) --no-print-directory version-svns >> $@
644 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx rpm info" >> $@
645 $(MAKE) --no-print-directory version-rpms >> $@
646 @echo $(BASE) > .base
649 @echo -n 'Build build-date: ' ; date '+%Y.%m.%d'
650 @echo -n 'Build build-time: ' ; date '+%H:%M-%Z'
651 @echo -n 'Build build-hostname: ' ; hostname
652 @echo "Build build-base: $(BASE)"
653 @echo "Build planetlab-distro: $(PLDISTRO)"
654 @echo "Build planetlab-tags: $(PLDISTROTAGS)"
655 @echo -n 'Build planetlab-tagsid: ' ; fgrep '$$''Id' $(PLDISTROTAGS)
656 @echo "Build target-arch: $(HOSTARCH)"
657 @echo "Build target-distro: $(DISTRO)"
658 @echo "Build target-distroname: $(DISTRONAME)"
659 @echo "Build target-release: $(RELEASE)"
660 @echo "Build target-personality: $(PERSONALITY)"
664 VFORMAT="%30s := %s\n"
665 define svn_version_target
667 @$(if $($(1)-SVNPATH),\
668 printf $(VFORMAT) $(1)-SVNPATH "$($(1)-SVNPATH)",\
669 printf $(VFORMAT) $(1)-CVSROOT "$($(1)-CVSROOT)" ; printf $(VFORMAT) $(1)-TAG "$($(1)-TAG)")
672 # compute all modules
674 $(foreach package,$(ALL), $(eval ALL-MODULES+=$($(package)-MODULES)))
675 ALL-MODULES:=$(sort $(ALL-MODULES))
677 $(foreach module,$(ALL-MODULES), $(eval $(call svn_version_target,$(module))))
679 version-svns: $(foreach module, $(ALL-MODULES), $(module)-version-svn)
681 RFORMAT="%20s :: version=%s release=%s\n"
682 define rpm_version_target
684 @printf $(RFORMAT) $($(1).rpm-name) $($(1).rpm-version) $($(1).rpm-release)
685 version-rpms: $(1)-version-rpm
688 $(foreach package,$(sort $(ALL)), $(eval $(call rpm_version_target,$(package))))
690 versions: myplc-release version-build version-svns version-rpms
691 .PHONY: versions version-build version-rpms version-svns
693 #################### package info
694 PKGKEYS := tarballs source codebase srpm rpms rpmnames rpm-release rpm-name rpm-version rpm-subversion
695 %-pkginfo: package=$(subst -pkginfo,,$@)
697 @$(foreach key,$(PKGKEYS),echo "$(package).$(key)=$($(package).$(key))";)
699 RPMKEYS := rpm-path package
700 %-rpminfo: rpm=$(subst -rpminfo,,$@)
702 @$(foreach key,$(RPMKEYS),echo "$(rpm).$(key)=$($(rpm).$(key))";)
704 #################### various lists - designed to run with stage1=true
706 @$(foreach package,$(ALL), echo package=$(package) ref_module=$($(package).module) modules=$($(package)-MODULES) rpmnames=$($(package).rpmnames); )
709 @$(foreach module,$(ALL-MODULES), echo module=$(module) svnpath=$($(module)-SVNPATH); )
712 @$(foreach module,$(ALL-MODULES), \
713 $(if $($(module)-SVNBRANCH),echo module=$(module) branch=$($(module)-SVNBRANCH);))
716 @$(foreach module,$(ALL-MODULES), \
717 $(if $($(module)-SVNPATH), \
718 $(if $($(module)-SVNBRANCH), \
719 echo $(module):$($(module)-SVNBRANCH); , \
722 info: packages modules branches
724 .PHONY: info packages modules branches module-tools
728 @$(if $(tests-SVNPATH), echo $(tests-SVNPATH) > $@, \
729 echo "http://svn.planet-lab.org/svn/tests/trunk" > $@)
734 @echo "********** Run make in two stages:"
736 @echo "make stage1=true PLDISTRO=onelab"
737 @echo " -> extracts all spec files in SPECS/ and mk files in MAKE/"
738 @echo " as well as save PLDISTRO for subsequent runs"
740 @echo "********** Then you can use the following targets"
742 @echo " rebuilds everything"
743 @echo 'make util-vserver'
744 @echo " makes the RPMS related to util-vserver"
745 @echo " equivalent to 'make util-vserver-rpms'"
747 @echo "********** Or, vertically - step-by-step for a given package"
748 @echo 'make util-vserver-codebase'
749 @echo " performs codebase extraction in CODEBASES/util-vserver"
750 @echo 'make util-vserver-source'
751 @echo " creates source link in SOURCES/util-vserver-<version>"
752 @echo 'make util-vserver-tarball'
753 @echo " creates source tarball in SOURCES/util-vserver-<version>.<tarextension>"
754 @echo 'make util-vserver-srpm'
755 @echo " build source rpm in SRPMS/"
756 @echo 'make util-vserver-rpms'
757 @echo " build rpm(s) in RPMS/"
759 @echo "********** Or, horizontally, reach a step for all known packages"
760 @echo 'make codebases'
762 @echo 'make tarballs'
766 @echo "********** Manual targets"
767 @echo "make package-compile"
768 @echo " The regular process uses rpmbuild --rebuild, that performs"
769 @echo " a compilation directory cleanup upon completion. If you need to investigate"
770 @echo " the intermediate compilation directory, use the -compile targets"
771 @echo "********** Cleaning examples"
773 @echo " removes the files made by make"
774 @echo "make distclean"
775 @echo " brute-force cleaning, removes entire directories - requires a new stage1"
776 @echo "make develclean"
777 @echo " rpm-uninstalls all devel packages installed during build"
779 @echo "make iptables-distclean"
780 @echo " deep clean for a given package"
781 @echo "make iptables-codeclean"
782 @echo " run this if you've made a change in the CODEBASES area for iptables"
784 @echo "make util-vserver-clean"
785 @echo " removes codebase, source, tarball, build, rpm and srpm for util-vserver"
786 @echo "make util-vserver-clean-codebase"
787 @echo " and so on for source, tarball, build, rpm and srpm"
789 @echo "********** Info examples"
791 @echo " Displays the value of a given variable (here ALL)"
792 @echo " with only a single plus sign only the value is displayed"
794 @echo " is equivalent to make packages modules branches"
795 @echo " provides various info on these objects"
796 @echo "make ulogd-pkginfo"
797 @echo " Displays know attributes of a package"
798 @echo "make kernel-devel-rpminfo"
799 @echo " Displays know attributes of an rpm"
800 @echo "make stage1=true PLDISTROTAGS=planetlab-tags-4.2.mk packages modules branches module-tools"
801 @echo " Lists mentioned items - module-tools is used in modules.update"
803 @echo "********** Known pakages are"
806 #################### convenience, for debugging only
807 # make +foo : prints the value of $(foo)
808 # make ++foo : idem but verbose, i.e. foo=$(foo)
809 ++%: varname=$(subst +,,$@)
811 @echo "$(varname)=$($(varname))"
812 +%: varname=$(subst +,,$@)
814 @echo "$($(varname))"