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
113 REMOTE-PLDISTROS="wextoolbox"
115 #################### Makefile
121 PLDISTRO := planetlab
123 export CVS_RSH := ssh
125 ########## savedpldistro.mk holds PLDISTRO - it is generated at stage1 (see below)
127 include savedpldistro.mk
130 # when re-running the nightly build after failure, we need to gather the former values
131 # do this by running make stage1=skip +PLDISTRO
132 ifeq "$(stage1)" "skip"
133 include savedpldistro.mk
136 #################### include onelab.mk
137 # describes the set of components
138 PLDISTROCONTENTS := $(PLDISTRO).mk
139 include $(PLDISTROCONTENTS)
141 #################### include <pldistro>-tags.mk
142 # describes where to fetch components, and the related tags if using cvs
143 PLDISTROTAGS := $(PLDISTRO)-tags.mk
144 include $(PLDISTROTAGS)
146 # this used to be set in the -tags.mk files, but that turned out to require
147 # error-prone duplicate changes
148 # so now the nightly build script sets this to what it is currently using
149 # we set a default in case we run the build manually:
150 # if the local directory was svn checked out, then use the corresponding URL
151 svn-info-url-line := $(shell svn info 2> /dev/null | grep URL:)
152 default-build-SVNPATH := $(lastword $(svn-info-url-line))
153 # otherwise, use this hard-coded default
154 ifeq "$(default-build-SVNPATH)" ""
155 default-build-SVNPATH := http://svn.planet-lab.org/svn/build/trunk
157 # use default if necessary
158 build-SVNPATH ?= $(default-build-SVNPATH)
161 define remote_pldistro
162 $(1).mk: config.$(1)/$(1).mk
163 @echo 'creating $(1) from config subdir'
164 cp config.$(1)/$(1).mk $(1).mk
166 $(2).mk: config.$(1)/$(2).mk
167 @echo 'creating $(1) tags from config subdir'
168 cp config.$(1)/$(2).mk $(2).mk
170 config.$(1)/$(1).mk: config.$(1)
171 config.$(1)/$(2).mk: config.$(1)
173 config.$(1): config.$(1).svnpath
174 @echo "Fetching details for pldistro $(1)"
175 svn export $(shell grep -v "^#" config.$(1).svnpath) config.$(1)
177 DISTCLEANS += $(1).mk $(2).mk config.$(1)
181 # somehow this does not work, handle manually instead
182 #$(foreach distro, $(REMOTE-PLDISTROS), $(eval $(call remote_pldistro,$(distro),$(distro)-tags)))
183 $(eval $(call remote_pldistro,wextoolbox,wextoolbox-tags))
185 ########## stage1 and stage1iter
186 # extract specs and compute .mk files by running
188 # entering stage1, we compute all the spec files
189 # then we use stage1iter to compute the .mk iteratively,
190 # ensuring that the n-1 first makefiles are loaded when creating the n-th one
191 # when stage1iter is set, it is supposed to be an index (starting at 1) in $(ALL)
193 ALLMKS := $(foreach package, $(ALL), MAKE/$(package).mk)
195 ### stage1iter : need some arithmetic, see
196 # http://www.cmcrossroads.com/articles/ask-mr.-make/learning-gnu-make-functions-with-arithmetic.html
197 ifneq "$(stage1iter)" ""
198 # the first n packages
199 packages := $(wordlist 1,$(words $(stage1iter)),$(ALL))
201 package := $(word $(words $(packages)),$(packages))
202 # the n-1 first packages
203 stage1iter_1 := $(wordlist 2,$(words $(stage1iter)),$(stage1iter))
204 previous := $(wordlist 1,$(words $(stage1iter_1)),$(ALL))
205 previousmks := $(foreach package,$(previous),MAKE/$(package).mk)
206 include $(previousmks)
209 @echo "========== stage1iter : $(package)"
210 # @echo "stage1iter : included .mk files : $(previousmks)"
211 all: $($(package).specpath)
212 all: MAKE/$(package).mk
218 @echo "========== stage1"
221 # specs and makes are done sequentially by stage1iter
224 arg=""; for n in $(ALL) ; do arg="$$arg x"; $(MAKE) --no-print-directory stage1iter="$$arg"; done
227 ### once .mks are OK, you can run make normally
234 # mention $(ALL) here rather than rpms
235 # this is because the inter-package dependencies are expressed like
236 # util-vserver: util-python
242 ### yumgroups.xml : compute from all known .pkgs files
245 ./yumgroups.sh $(PLDISTRO) > $@
247 createrepo = createrepo --quiet -g yumgroups.xml RPMS/
249 repo: RPMS/yumgroups.xml
256 # * to make configuration easier, we always use the first module's
257 # definitions (CVSROOT,TAG, or SVNPATH) to extract the spec file
258 # * for the same reason, in case cvs is used, the first module name is added to
259 # $(package)-SPEC - otherwise the cvs modules have to define spec as
260 # <module>/<module>.spec while svn modules just define it as <module>.spec
262 define stage1_variables
263 $(1).spec = $(notdir $($(1)-SPEC))
264 $(1).specpath = SPECS/$(1).spec
265 $(1).module = $(firstword $($(1)-MODULES))
266 $(1)-SVNPATH = $(strip $($(1)-SVNPATH))
269 $(foreach package, $(ALL), $(eval $(call stage1_variables,$(package))))
272 # for each package, compute whether we need to set date
273 # the heuristic is that we mention the date as part of the rpm release flag if
274 # (*) the package has requested it by setting package-RPMDATE (container packages should do that)
275 # (*) or SVNPATH contains 'trunk' or 'branches'
277 define package_hasdate
278 $(1).has-date = $(if $($(1)-RPMDATE),yes, \
279 $(if $($($(1).module)-SVNPATH), \
280 $(if $(findstring /trunk,$($($(1).module)-SVNPATH)),yes, \
281 $(if $(findstring /branches,$($($(1).module)-SVNPATH)),yes,)), \
282 $(if $(findstring HEAD,$($($(1).module)-TAG)),yes,)))
285 $(foreach package, $(ALL), $(eval $(call package_hasdate,$(package))))
287 ### the common header for generated specfiles
288 # useful when trying new specfiles manually
290 (echo -n "# Generated by planetlab build from $($(1)-SPEC) on " ; date) > $@
291 echo "%define distro $(DISTRO)" >> $@
292 echo "%define distrorelease $(RELEASE)" >> $@
293 echo "%define distroname $(DISTRONAME)" >> $@
294 echo "%define pldistro $(PLDISTRO)" >> $@
295 echo "%define plrelease $(PLANETLAB_RELEASE)" >> $@
297 ### extract spec file from scm
299 $($(1).specpath): header.spec
301 cat header.spec > $($(1).specpath)
302 $(if $($(1).has-date),echo "%define date $(shell date +%Y.%m.%d)" >> $($(1).specpath),)
303 $(if $($(1)-SPECVARS), \
304 $(foreach line,$($(1)-SPECVARS), \
305 echo "%define" $(word 1,$(subst =, ,$(line))) "$(word 2,$(subst =, ,$(line)))" >> $($(1).specpath) ;))
306 echo "# included from $($(1)-SPEC)" >> $($(1).specpath)
307 $(if $($($(1).module)-SVNPATH),\
308 svn cat $($($(1).module)-SVNPATH)/$($(1)-SPEC) >> $($(1).specpath) || rm $($(1).specpath),\
309 cvs -d $($($(1).module)-CVSROOT) checkout \
310 -r $($($(1).module)-TAG) \
311 -p $($(1).module)/$($(1)-SPEC) >> $($(1).specpath))
314 $(foreach package,$(ALL),$(eval $(call target_spec,$(package))))
317 # Base rpmbuild in the current directory
318 # issues on fedora 8 : see the following posts
319 # http://forums.fedoraforum.org/showthread.php?t=39625 - and more specifically post#6
320 # https://www.redhat.com/archives/fedora-devel-list/2007-November/msg00171.html
322 FAKEROOT=/longbuildroot
323 PWD=$(shell /bin/pwd)
324 ifeq "$(PWD)" "$(REALROOT)"
325 export HOME := $(FAKEROOT)
327 export HOME := $(PWD)
330 ifeq "$(shell pwd)" "/build"
331 rm -f $(FAKEROOT) ; ln -s $(REALROOT) $(FAKEROOT)
334 echo "%_topdir $(HOME)" >> $@
335 echo "%_tmppath $(HOME)/tmp" >> $@
336 echo "%__spec_install_pre %{___build_pre}" >> $@
337 ./getrpmmacros.sh >> $@
339 ### this utility allows to extract various info from a spec file
340 ### and to define them in makefiles
341 spec2make: spec2make.c
342 $(CC) -g -Wall $< -o $@ -lrpm -lrpmbuild
344 ### run spec2make on the spec file and include the result
345 # usage: spec2make package
347 MAKE/$(1).mk: $($(1).specpath) spec2make .rpmmacros
349 ./spec2make $($(1)-RPMFLAGS) $($(1).specpath) $(1) > MAKE/$(1).mk || { rm MAKE/$(1).mk; exit 1; }
352 $(foreach package,$(ALL),$(eval $(call target_mk,$(package))))
354 # stores PLDISTRO in a file
355 # this is done at stage1. later run wont get confused
357 echo "PLDISTRO:=$(PLDISTRO)" > $@
358 echo "PLDISTROTAGS:=$(PLDISTROTAGS)" >> $@
359 echo "build-SVNPATH:=$(build-SVNPATH)" >> $@
360 echo "PERSONALITY:=$(PERSONALITY)" >> $@
361 echo "MAILTO:=$(MAILTO)" >> $@
362 echo "BASE:=$(BASE)" >> $@
363 echo "WEBPATH:=$(WEBPATH)" >> $@
364 echo "TESTBUILDURL:=$(TESTBUILDURL)" >> $@
365 echo "WEBROOT:=$(WEBROOT)" >> $@
367 savedpldistro: savedpldistro.mk
368 .PHONY: savedpldistro
370 # always refresh this
373 #################### regular make
375 define stage2_variables
376 ### devel dependencies
377 $(1).rpmbuild = $(if $($(1)-RPMBUILD),$($(1)-RPMBUILD),$(RPMBUILD)) $($(1)-RPMFLAGS)
378 $(1).all-devel-rpm-paths := $(foreach rpm,$($(1)-DEPEND-DEVEL-RPMS),$($(rpm).rpm-path))
379 $(1).depend-devel-packages := $(sort $(foreach rpm,$($(1)-DEPEND-DEVEL-RPMS),$($(rpm).package)))
380 ALL-DEVEL-RPMS += $($(1)-DEPEND-DEVEL-RPMS)
383 $(foreach package,$(ALL),$(eval $(call stage2_variables,$(package))))
384 ALL-DEVEL-RPMS := $(sort $(ALL-DEVEL-RPMS))
387 ### pack sources into tarballs
388 ALLTARBALLS:= $(foreach package, $(ALL), $($(package).tarballs))
389 tarballs: $(ALLTARBALLS)
390 @echo $(words $(ALLTARBALLS)) source tarballs OK
393 SOURCES/%.tar.bz2: SOURCES/%
394 tar chpjf $@ -C SOURCES $*
396 SOURCES/%.tar.gz: SOURCES/%
397 tar chpzf $@ -C SOURCES $*
399 SOURCES/%.tgz: SOURCES/%
400 tar chpzf $@ -C SOURCES $*
403 URLS/%: url=$(subst @colon@,:,$(subst @slash@,/,$(notdir $@)))
404 URLS/%: basename=$(notdir $(url))
406 echo curl $(url) -o SOURCES/$(basename)
409 ### the directory SOURCES/<package>-<version> is made
410 # with a copy -rl from CODEBASES/<package>
411 # the former is $(package.source) and the latter is $(package.codebase)
412 ALLSOURCES:=$(foreach package, $(ALL), $($(package).source))
413 # so that make does not use the rule below directly for creating the tarball files
414 .SECONDARY: $(ALLSOURCES)
416 sources: $(ALLSOURCES)
417 @echo $(words $(ALLSOURCES)) versioned source trees OK
420 define target_link_codebase_sources
421 $($(1).source): $($(1).codebase) ; mkdir -p SOURCES ; cp -rl $($(1).codebase) $($(1).source)
424 $(foreach package,$(ALL),$(eval $(call target_link_codebase_sources,$(package))))
426 ### codebase extraction
427 ALLCODEBASES:=$(foreach package, $(ALL), $($(package).codebase))
428 # so that make does not use the rule below directly for creating the tarball files
429 .SECONDARY: $(ALLCODEBASES)
431 codebases : $(ALLCODEBASES)
432 @echo $(words $(ALLCODEBASES)) codebase OK
436 # usage: extract_single_module package
437 define extract_single_module
439 $(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))
442 # usage: extract_multi_module package
443 define extract_multi_module
444 mkdir -p CODEBASES/$(1) && cd CODEBASES/$(1) && (\
445 $(foreach m,$($(1)-MODULES), $(if $($(m)-SVNPATH), svn export $($(m)-SVNPATH) $(m);, cvs -d $($(m)-CVSROOT) export -r $($(m)-TAG) $(m);)))
448 CODEBASES/%: package=$(notdir $@)
449 CODEBASES/%: multi_module=$(word 2,$($(package)-MODULES))
451 @(echo -n "XXXXXXXXXXXXXXX -- BEG CODEBASE $(package) : $@ " ; date)
452 $(if $(multi_module),\
453 $(call extract_multi_module,$(package)),\
454 $(call extract_single_module,$(package)))
455 @(echo -n "XXXXXXXXXXXXXXX -- END CODEBASE $(package) : $@ " ; date)
458 ALLSRPMS:=$(foreach package,$(ALL),$($(package).srpm))
460 @echo $(words $(ALLSRPMS)) source rpms OK
463 # usage: target_source_rpm package
464 define target_source_rpm
465 ifeq "$($(1)-BUILD-FROM-SRPM)" ""
466 $($(1).srpm): $($(1).specpath) .rpmmacros $($(1).tarballs)
467 mkdir -p BUILD SRPMS tmp
468 @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) (using SOURCES) " ; date)
469 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
470 $($(1).rpmbuild) -bs $($(1).specpath)
471 -$(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
472 @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
474 $($(1).srpm): $($(1).specpath) .rpmmacros $($(1).codebase)
475 mkdir -p BUILD SRPMS tmp
476 @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) (using make srpm) " ; date)
477 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
478 make -C $($(1).codebase) srpm SPECFILE=$(HOME)/$($(1).specpath) && \
479 rm -f SRPMS/$(notdir $($(1).srpm)) && \
480 ln $($(1).codebase)/$(notdir $($(1).srpm)) SRPMS/$(notdir $($(1).srpm))
481 -$(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
482 @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
486 $(foreach package,$(ALL),$(eval $(call target_source_rpm,$(package))))
488 ### binary rpms are made from source rpm
489 ALLRPMS:=$(foreach package,$(ALL),$($(package).rpms))
490 # same as above, mention $(ALL) and not $(ALLRPMS)
492 @echo $(words $(ALLRPMS)) binary rpms OK
495 # use tmp dirs when building binary rpm so make remains idempotent
496 # otherwise SOURCES/ or SPEC gets touched again - which leads to rebuilding
497 RPM-USE-TMP-DIRS = --define "_sourcedir $(HOME)/tmp" --define "_specdir $(HOME)/tmp"
498 RPM-USE-COMPILE-DIRS = --define "_sourcedir $(HOME)/COMPILE" --define "_specdir $(HOME)/COMPILE"
500 # usage: build_binary_rpm package
501 # xxx hacky - invoke createrepo if DEPEND-FILES mentions RPMS/yumgroups.xml
502 define target_binary_rpm
503 $($(1).rpms): $($(1).srpm)
505 @(echo -n "XXXXXXXXXXXXXXX -- BEG RPM $(1) " ; date)
506 $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPEND-FILES)), $(createrepo) , )
507 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
508 $($(1).rpmbuild) --rebuild $(RPM-USE-TMP-DIRS) $($(1).srpm)
509 -$(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
510 @(echo -n "XXXXXXXXXXXXXXX -- END RPM $(1) " ; date)
511 # for manual use only - in case we need to investigate the results of an rpmbuild
512 $(1)-compile: $($(1).srpm)
514 @(echo -n "XXXXXXXXXXXXXXX -- BEG compile $(1) " ; date)
515 $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPEND-FILES)), $(createrepo) , )
516 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
517 $($(1).rpmbuild) --recompile $(RPM-USE-TMP-DIRS) $($(1).srpm)
518 -$(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
519 @(echo -n "XXXXXXXXXXXXXXX -- END compile $(1) " ; date)
523 $(foreach package,$(ALL),$(eval $(call target_binary_rpm,$(package))))
525 # e.g. make proper -> does propers rpms
526 # usage shorthand_target package
527 define target_shorthand
530 $(1)-spec: $($(1)-SPEC)
534 $(1)-tarball: $($(1).tarballs)
536 $(1)-codebase: $($(1).codebase)
538 $(1)-source: $($(1).source)
539 .PHONY: $(1)-codebase
540 $(1)-rpms: $($(1).rpms)
542 $(1)-srpm: $($(1).srpm)
546 $(foreach package,$(ALL),$(eval $(call target_shorthand,$(package))))
548 ### file dependencies
549 define package_depends_on_file
554 define target_dependfiles
555 $(foreach file,$($(1)-DEPEND-FILES),$(eval $(call package_depends_on_file,$(1),$(file))))
558 $(foreach package,$(ALL),$(eval $(call target_dependfiles,$(package))))
560 ### package dependencies
561 define package_depends_on_package
564 $($(1).srpm):$($(2).rpms)
567 define target_depends
568 $(foreach package,$($(1)-DEPEND-PACKAGES) $($(1).depend-devel-packages),$(eval $(call package_depends_on_package,$(1),$(package))))
571 $(foreach package,$(ALL),$(eval $(call target_depends,$(package))))
574 # usage: target_clean package
577 rm -rf $($(1).codebase)
578 .PHONY: $(1)-clean-codebase
579 CLEANS += $(1)-clean-codebase
581 rm -rf $($(1).source)
582 .PHONY: $(1)-clean-source
583 CLEANS += $(1)-clean-source
585 rm -rf $($(1).tarballs)
586 .PHONY: $(1)-clean-tarball
587 CLEANS += $(1)-clean-tarball
589 rm -rf BUILD/$(notdir $($(1).source))
590 CLEANS += $(1)-clean-build
593 .PHONY: $(1)-clean-rpms
594 CLEANS += $(1)-clean-rpms
597 .PHONY: $(1)-clean-srpm
598 CLEANS += $(1)-clean-srpm
599 $(1)-codeclean: $(1)-clean-source $(1)-clean-tarball $(1)-clean-build $(1)-clean-rpms $(1)-clean-srpm
600 $(1)-clean: $(1)-clean-codebase $(1)-codeclean
601 .PHONY: $(1)-codeclean $(1)-clean
603 rm -rf $($(1).specpath)
604 .PHONY: $(1)-clean-spec
607 .PHONY: $(1)-clean-make
608 $(1)-distclean: $(1)-distclean1 $(1)-distclean2
609 $(1)-distclean1: $(1)-clean-spec $(1)-clean-make
610 $(1)-distclean2: $(1)-clean
611 .PHONY: $(1)-distclean $(1)-distclean1 $(1)-distclean2
614 $(foreach package,$(ALL),$(eval $(call target_clean,$(package))))
622 @echo Available clean targets
625 ### brute force clean
627 rm -rf savedpldistro.mk .rpmmacros spec2make header.spec SPECS MAKE $(DISTCLEANS)
629 rm -rf CODEBASES SOURCES BUILD RPMS SRPMS tmp
630 distclean: distclean1 distclean2
631 .PHONY: distclean1 distclean2 distclean
634 -$(RPM-UNINSTALL-DEVEL) $(ALL-DEVEL-RPMS)
637 # gather build information for the 'About' page
638 # when run from crontab, INIT_CWD not properly set (says /root ..)
639 # so, the nightly build passes BASE here
640 # also store BASE in .base for any post-processing purposes
642 @echo 'Creating myplc-release'
644 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx build info" >> $@
645 $(MAKE) --no-print-directory version-build >> $@
646 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx svn info" >> $@
647 $(MAKE) --no-print-directory version-svns >> $@
648 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx rpm info" >> $@
649 $(MAKE) --no-print-directory version-rpms >> $@
650 @echo $(BASE) > .base
653 @echo -n 'Build build-date: ' ; date '+%Y.%m.%d'
654 @echo -n 'Build build-time: ' ; date '+%H:%M-%Z'
655 @echo -n 'Build build-hostname: ' ; hostname
656 @echo "Build build-base: $(BASE)"
657 @echo "Build planetlab-distro: $(PLDISTRO)"
658 @echo "Build planetlab-tags: $(PLDISTROTAGS)"
659 @echo -n 'Build planetlab-tagsid: ' ; fgrep '$$''Id' $(PLDISTROTAGS)
660 @echo "Build target-arch: $(HOSTARCH)"
661 @echo "Build target-distro: $(DISTRO)"
662 @echo "Build target-distroname: $(DISTRONAME)"
663 @echo "Build target-release: $(RELEASE)"
664 @echo "Build target-personality: $(PERSONALITY)"
668 VFORMAT="%30s := %s\n"
669 define svn_version_target
671 @$(if $($(1)-SVNPATH),\
672 printf $(VFORMAT) $(1)-SVNPATH "$($(1)-SVNPATH)",\
673 printf $(VFORMAT) $(1)-CVSROOT "$($(1)-CVSROOT)" ; printf $(VFORMAT) $(1)-TAG "$($(1)-TAG)")
676 # compute all modules
678 $(foreach package,$(ALL), $(eval ALL-MODULES+=$($(package)-MODULES)))
679 ALL-MODULES:=$(sort $(ALL-MODULES))
681 $(foreach module,$(ALL-MODULES), $(eval $(call svn_version_target,$(module))))
683 version-svns: $(foreach module, $(ALL-MODULES), $(module)-version-svn)
685 RFORMAT="%20s :: version=%s release=%s\n"
686 define rpm_version_target
688 @printf $(RFORMAT) $($(1).rpm-name) $($(1).rpm-version) $($(1).rpm-release)
689 version-rpms: $(1)-version-rpm
692 $(foreach package,$(sort $(ALL)), $(eval $(call rpm_version_target,$(package))))
694 versions: myplc-release version-build version-svns version-rpms
695 .PHONY: versions version-build version-rpms version-svns
697 #################### package info
698 PKGKEYS := tarballs source codebase srpm rpms rpmnames rpm-release rpm-name rpm-version rpm-subversion
699 %-pkginfo: package=$(subst -pkginfo,,$@)
701 @$(foreach key,$(PKGKEYS),echo "$(package).$(key)=$($(package).$(key))";)
703 RPMKEYS := rpm-path package
704 %-rpminfo: rpm=$(subst -rpminfo,,$@)
706 @$(foreach key,$(RPMKEYS),echo "$(rpm).$(key)=$($(rpm).$(key))";)
708 #################### various lists - designed to run with stage1=true
710 @$(foreach package,$(ALL), echo package=$(package) ref_module=$($(package).module) modules=$($(package)-MODULES) rpmnames=$($(package).rpmnames); )
713 @$(foreach module,$(ALL-MODULES), echo module=$(module) svnpath=$($(module)-SVNPATH); )
716 @$(foreach module,$(ALL-MODULES), \
717 $(if $($(module)-SVNBRANCH),echo module=$(module) branch=$($(module)-SVNBRANCH);))
720 @$(foreach module,$(ALL-MODULES), \
721 $(if $($(module)-SVNPATH), \
722 $(if $($(module)-SVNBRANCH), \
723 echo $(module):$($(module)-SVNBRANCH); , \
726 info: packages modules branches
728 .PHONY: info packages modules branches module-tools
732 @$(if $(tests-SVNPATH), echo $(tests-SVNPATH) > $@, \
733 echo "http://svn.planet-lab.org/svn/tests/trunk" > $@)
738 @echo "********** Run make in two stages:"
740 @echo "make stage1=true PLDISTRO=onelab"
741 @echo " -> extracts all spec files in SPECS/ and mk files in MAKE/"
742 @echo " as well as save PLDISTRO for subsequent runs"
744 @echo "********** Then you can use the following targets"
746 @echo " rebuilds everything"
747 @echo 'make util-vserver'
748 @echo " makes the RPMS related to util-vserver"
749 @echo " equivalent to 'make util-vserver-rpms'"
751 @echo "********** Or, vertically - step-by-step for a given package"
752 @echo 'make util-vserver-codebase'
753 @echo " performs codebase extraction in CODEBASES/util-vserver"
754 @echo 'make util-vserver-source'
755 @echo " creates source link in SOURCES/util-vserver-<version>"
756 @echo 'make util-vserver-tarball'
757 @echo " creates source tarball in SOURCES/util-vserver-<version>.<tarextension>"
758 @echo 'make util-vserver-srpm'
759 @echo " build source rpm in SRPMS/"
760 @echo 'make util-vserver-rpms'
761 @echo " build rpm(s) in RPMS/"
763 @echo "********** Or, horizontally, reach a step for all known packages"
764 @echo 'make codebases'
766 @echo 'make tarballs'
770 @echo "********** Manual targets"
771 @echo "make package-compile"
772 @echo " The regular process uses rpmbuild --rebuild, that performs"
773 @echo " a compilation directory cleanup upon completion. If you need to investigate"
774 @echo " the intermediate compilation directory, use the -compile targets"
775 @echo "********** Cleaning examples"
777 @echo " removes the files made by make"
778 @echo "make distclean"
779 @echo " brute-force cleaning, removes entire directories - requires a new stage1"
780 @echo "make develclean"
781 @echo " rpm-uninstalls all devel packages installed during build"
783 @echo "make iptables-distclean"
784 @echo " deep clean for a given package"
785 @echo "make iptables-codeclean"
786 @echo " run this if you've made a change in the CODEBASES area for iptables"
788 @echo "make util-vserver-clean"
789 @echo " removes codebase, source, tarball, build, rpm and srpm for util-vserver"
790 @echo "make util-vserver-clean-codebase"
791 @echo " and so on for source, tarball, build, rpm and srpm"
793 @echo "********** Info examples"
795 @echo " Displays the value of a given variable (here ALL)"
796 @echo " with only a single plus sign only the value is displayed"
798 @echo " is equivalent to make packages modules branches"
799 @echo " provides various info on these objects"
800 @echo "make ulogd-pkginfo"
801 @echo " Displays know attributes of a package"
802 @echo "make kernel-devel-rpminfo"
803 @echo " Displays know attributes of an rpm"
804 @echo "make stage1=true PLDISTROTAGS=planetlab-tags-4.2.mk packages modules branches module-tools"
805 @echo " Lists mentioned items - module-tools is used in modules.update"
807 @echo "********** Known pakages are"
810 #################### convenience, for debugging only
811 # make +foo : prints the value of $(foo)
812 # make ++foo : idem but verbose, i.e. foo=$(foo)
813 ++%: varname=$(subst +,,$@)
815 @echo "$(varname)=$($(varname))"
816 +%: varname=$(subst +,,$@)
818 @echo "$($(varname))"