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)" >> $@
360 savedpldistro: savedpldistro.mk
361 .PHONY: savedpldistro
363 # always refresh this
366 #################### regular make
368 define stage2_variables
369 ### devel dependencies
370 $(1).rpmbuild = $(if $($(1)-RPMBUILD),$($(1)-RPMBUILD),$(RPMBUILD)) $($(1)-RPMFLAGS)
371 $(1).all-devel-rpm-paths := $(foreach rpm,$($(1)-DEPEND-DEVEL-RPMS),$($(rpm).rpm-path))
372 $(1).depend-devel-packages := $(sort $(foreach rpm,$($(1)-DEPEND-DEVEL-RPMS),$($(rpm).package)))
373 ALL-DEVEL-RPMS += $($(1)-DEPEND-DEVEL-RPMS)
376 $(foreach package,$(ALL),$(eval $(call stage2_variables,$(package))))
377 ALL-DEVEL-RPMS := $(sort $(ALL-DEVEL-RPMS))
380 ### pack sources into tarballs
381 ALLTARBALLS:= $(foreach package, $(ALL), $($(package).tarballs))
382 tarballs: $(ALLTARBALLS)
383 @echo $(words $(ALLTARBALLS)) source tarballs OK
386 SOURCES/%.tar.bz2: SOURCES/%
387 tar chpjf $@ -C SOURCES $*
389 SOURCES/%.tar.gz: SOURCES/%
390 tar chpzf $@ -C SOURCES $*
392 SOURCES/%.tgz: SOURCES/%
393 tar chpzf $@ -C SOURCES $*
396 URLS/%: url=$(subst @colon@,:,$(subst @slash@,/,$(notdir $@)))
397 URLS/%: basename=$(notdir $(url))
399 echo curl $(url) -o SOURCES/$(basename)
402 ### the directory SOURCES/<package>-<version> is made
403 # with a copy -rl from CODEBASES/<package>
404 # the former is $(package.source) and the latter is $(package.codebase)
405 ALLSOURCES:=$(foreach package, $(ALL), $($(package).source))
406 # so that make does not use the rule below directly for creating the tarball files
407 .SECONDARY: $(ALLSOURCES)
409 sources: $(ALLSOURCES)
410 @echo $(words $(ALLSOURCES)) versioned source trees OK
413 define target_link_codebase_sources
414 $($(1).source): $($(1).codebase) ; mkdir -p SOURCES ; cp -rl $($(1).codebase) $($(1).source)
417 $(foreach package,$(ALL),$(eval $(call target_link_codebase_sources,$(package))))
419 ### codebase extraction
420 ALLCODEBASES:=$(foreach package, $(ALL), $($(package).codebase))
421 # so that make does not use the rule below directly for creating the tarball files
422 .SECONDARY: $(ALLCODEBASES)
424 codebases : $(ALLCODEBASES)
425 @echo $(words $(ALLCODEBASES)) codebase OK
429 # usage: extract_single_module package
430 define extract_single_module
432 $(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))
435 # usage: extract_multi_module package
436 define extract_multi_module
437 mkdir -p CODEBASES/$(1) && cd CODEBASES/$(1) && (\
438 $(foreach m,$($(1)-MODULES), $(if $($(m)-SVNPATH), svn export $($(m)-SVNPATH) $(m);, cvs -d $($(m)-CVSROOT) export -r $($(m)-TAG) $(m);)))
441 CODEBASES/%: package=$(notdir $@)
442 CODEBASES/%: multi_module=$(word 2,$($(package)-MODULES))
444 @(echo -n "XXXXXXXXXXXXXXX -- BEG CODEBASE $(package) : $@ " ; date)
445 $(if $(multi_module),\
446 $(call extract_multi_module,$(package)),\
447 $(call extract_single_module,$(package)))
448 @(echo -n "XXXXXXXXXXXXXXX -- END CODEBASE $(package) : $@ " ; date)
451 ALLSRPMS:=$(foreach package,$(ALL),$($(package).srpm))
453 @echo $(words $(ALLSRPMS)) source rpms OK
456 # usage: target_source_rpm package
457 define target_source_rpm
458 ifeq "$($(1)-BUILD-FROM-SRPM)" ""
459 $($(1).srpm): $($(1).specpath) .rpmmacros $($(1).tarballs)
460 mkdir -p BUILD SRPMS tmp
461 @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) (using SOURCES) " ; date)
462 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
463 $($(1).rpmbuild) -bs $($(1).specpath)
464 -$(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
465 @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
467 $($(1).srpm): $($(1).specpath) .rpmmacros $($(1).codebase)
468 mkdir -p BUILD SRPMS tmp
469 @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) (using make srpm) " ; date)
470 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
471 make -C $($(1).codebase) srpm SPECFILE=$(HOME)/$($(1).specpath) && \
472 rm -f SRPMS/$(notdir $($(1).srpm)) && \
473 ln $($(1).codebase)/$(notdir $($(1).srpm)) SRPMS/$(notdir $($(1).srpm))
474 -$(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
475 @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
479 $(foreach package,$(ALL),$(eval $(call target_source_rpm,$(package))))
481 ### binary rpms are made from source rpm
482 ALLRPMS:=$(foreach package,$(ALL),$($(package).rpms))
483 # same as above, mention $(ALL) and not $(ALLRPMS)
485 @echo $(words $(ALLRPMS)) binary rpms OK
488 # use tmp dirs when building binary rpm so make remains idempotent
489 # otherwise SOURCES/ or SPEC gets touched again - which leads to rebuilding
490 RPM-USE-TMP-DIRS = --define "_sourcedir $(HOME)/tmp" --define "_specdir $(HOME)/tmp"
491 RPM-USE-COMPILE-DIRS = --define "_sourcedir $(HOME)/COMPILE" --define "_specdir $(HOME)/COMPILE"
493 # usage: build_binary_rpm package
494 # xxx hacky - invoke createrepo if DEPEND-FILES mentions RPMS/yumgroups.xml
495 define target_binary_rpm
496 $($(1).rpms): $($(1).srpm)
498 @(echo -n "XXXXXXXXXXXXXXX -- BEG RPM $(1) " ; date)
499 $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPEND-FILES)), $(createrepo) , )
500 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
501 $($(1).rpmbuild) --rebuild $(RPM-USE-TMP-DIRS) $($(1).srpm)
502 -$(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
503 @(echo -n "XXXXXXXXXXXXXXX -- END RPM $(1) " ; date)
504 # for manual use only - in case we need to investigate the results of an rpmbuild
505 $(1)-compile: $($(1).srpm)
507 @(echo -n "XXXXXXXXXXXXXXX -- BEG compile $(1) " ; date)
508 $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPEND-FILES)), $(createrepo) , )
509 $(if $($(1).all-devel-rpm-paths), $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
510 $($(1).rpmbuild) --recompile $(RPM-USE-TMP-DIRS) $($(1).srpm)
511 -$(if $($(1)-DEPEND-DEVEL-RPMS), $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
512 @(echo -n "XXXXXXXXXXXXXXX -- END compile $(1) " ; date)
516 $(foreach package,$(ALL),$(eval $(call target_binary_rpm,$(package))))
518 # e.g. make proper -> does propers rpms
519 # usage shorthand_target package
520 define target_shorthand
523 $(1)-spec: $($(1)-SPEC)
527 $(1)-tarball: $($(1).tarballs)
529 $(1)-codebase: $($(1).codebase)
531 $(1)-source: $($(1).source)
532 .PHONY: $(1)-codebase
533 $(1)-rpms: $($(1).rpms)
535 $(1)-srpm: $($(1).srpm)
539 $(foreach package,$(ALL),$(eval $(call target_shorthand,$(package))))
541 ### file dependencies
542 define package_depends_on_file
547 define target_dependfiles
548 $(foreach file,$($(1)-DEPEND-FILES),$(eval $(call package_depends_on_file,$(1),$(file))))
551 $(foreach package,$(ALL),$(eval $(call target_dependfiles,$(package))))
553 ### package dependencies
554 define package_depends_on_package
557 $($(1).srpm):$($(2).rpms)
560 define target_depends
561 $(foreach package,$($(1)-DEPEND-PACKAGES) $($(1).depend-devel-packages),$(eval $(call package_depends_on_package,$(1),$(package))))
564 $(foreach package,$(ALL),$(eval $(call target_depends,$(package))))
567 # usage: target_clean package
570 rm -rf $($(1).codebase)
571 .PHONY: $(1)-clean-codebase
572 CLEANS += $(1)-clean-codebase
574 rm -rf $($(1).source)
575 .PHONY: $(1)-clean-source
576 CLEANS += $(1)-clean-source
578 rm -rf $($(1).tarballs)
579 .PHONY: $(1)-clean-tarball
580 CLEANS += $(1)-clean-tarball
582 rm -rf BUILD/$(notdir $($(1).source))
583 CLEANS += $(1)-clean-build
586 .PHONY: $(1)-clean-rpms
587 CLEANS += $(1)-clean-rpms
590 .PHONY: $(1)-clean-srpm
591 CLEANS += $(1)-clean-srpm
592 $(1)-codeclean: $(1)-clean-source $(1)-clean-tarball $(1)-clean-build $(1)-clean-rpms $(1)-clean-srpm
593 $(1)-clean: $(1)-clean-codebase $(1)-codeclean
594 .PHONY: $(1)-codeclean $(1)-clean
596 rm -rf $($(1).specpath)
597 .PHONY: $(1)-clean-spec
600 .PHONY: $(1)-clean-make
601 $(1)-distclean: $(1)-distclean1 $(1)-distclean2
602 $(1)-distclean1: $(1)-clean-spec $(1)-clean-make
603 $(1)-distclean2: $(1)-clean
604 .PHONY: $(1)-distclean $(1)-distclean1 $(1)-distclean2
607 $(foreach package,$(ALL),$(eval $(call target_clean,$(package))))
615 @echo Available clean targets
618 ### brute force clean
620 rm -rf savedpldistro.mk .rpmmacros spec2make header.spec SPECS MAKE $(DISTCLEANS)
622 rm -rf CODEBASES SOURCES BUILD RPMS SRPMS tmp
623 distclean: distclean1 distclean2
624 .PHONY: distclean1 distclean2 distclean
627 -$(RPM-UNINSTALL-DEVEL) $(ALL-DEVEL-RPMS)
630 # gather build information for the 'About' page
631 # when run from crontab, INIT_CWD not properly set (says /root ..)
632 # so, the nightly build passes BASE here
633 # also store BASE in .base for any post-processing purposes
635 @echo 'Creating myplc-release'
637 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx build info" >> $@
638 $(MAKE) --no-print-directory version-build >> $@
639 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx svn info" >> $@
640 $(MAKE) --no-print-directory version-svns >> $@
641 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx rpm info" >> $@
642 $(MAKE) --no-print-directory version-rpms >> $@
643 @echo $(BASE) > .base
646 @echo -n 'Build build-date: ' ; date '+%Y.%m.%d'
647 @echo -n 'Build build-time: ' ; date '+%H:%M-%Z'
648 @echo -n 'Build build-hostname: ' ; hostname
649 @echo "Build build-base: $(BASE)"
650 @echo "Build planetlab-distro: $(PLDISTRO)"
651 @echo "Build planetlab-tags: $(PLDISTROTAGS)"
652 @echo -n 'Build planetlab-tagsid: ' ; fgrep '$$''Id' $(PLDISTROTAGS)
653 @echo "Build target-arch: $(HOSTARCH)"
654 @echo "Build target-distro: $(DISTRO)"
655 @echo "Build target-distroname: $(DISTRONAME)"
656 @echo "Build target-release: $(RELEASE)"
657 @echo "Build target-personality: $(PERSONALITY)"
661 VFORMAT="%30s := %s\n"
662 define svn_version_target
664 @$(if $($(1)-SVNPATH),\
665 printf $(VFORMAT) $(1)-SVNPATH "$($(1)-SVNPATH)",\
666 printf $(VFORMAT) $(1)-CVSROOT "$($(1)-CVSROOT)" ; printf $(VFORMAT) $(1)-TAG "$($(1)-TAG)")
669 # compute all modules
671 $(foreach package,$(ALL), $(eval ALL-MODULES+=$($(package)-MODULES)))
672 ALL-MODULES:=$(sort $(ALL-MODULES))
674 $(foreach module,$(ALL-MODULES), $(eval $(call svn_version_target,$(module))))
676 version-svns: $(foreach module, $(ALL-MODULES), $(module)-version-svn)
678 RFORMAT="%20s :: version=%s release=%s\n"
679 define rpm_version_target
681 @printf $(RFORMAT) $($(1).rpm-name) $($(1).rpm-version) $($(1).rpm-release)
682 version-rpms: $(1)-version-rpm
685 $(foreach package,$(sort $(ALL)), $(eval $(call rpm_version_target,$(package))))
687 versions: myplc-release version-build version-svns version-rpms
688 .PHONY: versions version-build version-rpms version-svns
690 #################### package info
691 PKGKEYS := tarballs source codebase srpm rpms rpmnames rpm-release rpm-name rpm-version rpm-subversion
692 %-pkginfo: package=$(subst -pkginfo,,$@)
694 @$(foreach key,$(PKGKEYS),echo "$(package).$(key)=$($(package).$(key))";)
696 RPMKEYS := rpm-path package
697 %-rpminfo: rpm=$(subst -rpminfo,,$@)
699 @$(foreach key,$(RPMKEYS),echo "$(rpm).$(key)=$($(rpm).$(key))";)
701 #################### various lists - designed to run with stage1=true
703 @$(foreach package,$(ALL), echo package=$(package) ref_module=$($(package).module) modules=$($(package)-MODULES) rpmnames=$($(package).rpmnames); )
706 @$(foreach module,$(ALL-MODULES), echo module=$(module) svnpath=$($(module)-SVNPATH); )
709 @$(foreach module,$(ALL-MODULES), \
710 $(if $($(module)-SVNBRANCH),echo module=$(module) branch=$($(module)-SVNBRANCH);))
713 @$(foreach module,$(ALL-MODULES), \
714 $(if $($(module)-SVNPATH), \
715 $(if $($(module)-SVNBRANCH), \
716 echo $(module):$($(module)-SVNBRANCH); , \
719 info: packages modules branches
721 .PHONY: info packages modules branches module-tools
725 @$(if $(TESTS_SVNPATH), echo $(TESTS_SVNPATH) > $@, \
726 echo "http://svn.planet-lab.org/svn/tests/trunk" > $@)
731 @echo "********** Run make in two stages:"
733 @echo "make stage1=true PLDISTRO=onelab"
734 @echo " -> extracts all spec files in SPECS/ and mk files in MAKE/"
735 @echo " as well as save PLDISTRO for subsequent runs"
737 @echo "********** Then you can use the following targets"
739 @echo " rebuilds everything"
740 @echo 'make util-vserver'
741 @echo " makes the RPMS related to util-vserver"
742 @echo " equivalent to 'make util-vserver-rpms'"
744 @echo "********** Or, vertically - step-by-step for a given package"
745 @echo 'make util-vserver-codebase'
746 @echo " performs codebase extraction in CODEBASES/util-vserver"
747 @echo 'make util-vserver-source'
748 @echo " creates source link in SOURCES/util-vserver-<version>"
749 @echo 'make util-vserver-tarball'
750 @echo " creates source tarball in SOURCES/util-vserver-<version>.<tarextension>"
751 @echo 'make util-vserver-srpm'
752 @echo " build source rpm in SRPMS/"
753 @echo 'make util-vserver-rpms'
754 @echo " build rpm(s) in RPMS/"
756 @echo "********** Or, horizontally, reach a step for all known packages"
757 @echo 'make codebases'
759 @echo 'make tarballs'
763 @echo "********** Manual targets"
764 @echo "make package-compile"
765 @echo " The regular process uses rpmbuild --rebuild, that performs"
766 @echo " a compilation directory cleanup upon completion. If you need to investigate"
767 @echo " the intermediate compilation directory, use the -compile targets"
768 @echo "********** Cleaning examples"
770 @echo " removes the files made by make"
771 @echo "make distclean"
772 @echo " brute-force cleaning, removes entire directories - requires a new stage1"
773 @echo "make develclean"
774 @echo " rpm-uninstalls all devel packages installed during build"
776 @echo "make iptables-distclean"
777 @echo " deep clean for a given package"
778 @echo "make iptables-codeclean"
779 @echo " run this if you've made a change in the CODEBASES area for iptables"
781 @echo "make util-vserver-clean"
782 @echo " removes codebase, source, tarball, build, rpm and srpm for util-vserver"
783 @echo "make util-vserver-clean-codebase"
784 @echo " and so on for source, tarball, build, rpm and srpm"
786 @echo "********** Info examples"
788 @echo " Displays the value of a given variable (here ALL)"
789 @echo " with only a single plus sign only the value is displayed"
791 @echo " is equivalent to make packages modules branches"
792 @echo " provides various info on these objects"
793 @echo "make ulogd-pkginfo"
794 @echo " Displays know attributes of a package"
795 @echo "make kernel-devel-rpminfo"
796 @echo " Displays know attributes of an rpm"
797 @echo "make stage1=true PLDISTROTAGS=planetlab-tags-4.2.mk packages modules branches module-tools"
798 @echo " Lists mentioned items - module-tools is used in modules.update"
800 @echo "********** Known pakages are"
803 #################### convenience, for debugging only
804 # make +foo : prints the value of $(foo)
805 # make ++foo : idem but verbose, i.e. foo=$(foo)
806 ++%: varname=$(subst +,,$@)
808 @echo "$(varname)=$($(varname))"
809 +%: varname=$(subst +,,$@)
811 @echo "$($(varname))"