2 # Thierry Parmentelat - INRIA Sophia Antipolis
4 ### $Id: Makefile 18118 2010-05-21 17:51:26Z thierry $
5 ### $URL: svn+ssh://thierry@svn.planet-lab.org/svn/build/trunk/Makefile $
10 # (*) make stage1=true
11 # this extracts all specfiles and computes .mk from specfiles
12 # you need to specify PLDISTRO here if relevant - see below
14 # for more info on how to invoke this stuff
16 #################### (fedora) distributions
18 # (*) as of nov. 2007, myplc-devel is deprecated
19 # (*) instead, we create a fresh vserver that holds required tools (see e.g. planetlab-devel.lst)
20 # (*) the build uses the current fedora version as a target for the produced images
21 # (*) so you simply need to create a fedora 8 build image for building fedora-8 images
23 #################### (planetlab) distributions
25 # (*) see README-pldistros.txt
26 # (*) then you need to run
27 # make stage1=true PLDISTRO=onelab
30 # This build deals with 3 kinds of objects
32 # (*) packages are named upon the RPM name; they are mostly lowercase
33 # Add a package to ALL if you want it built as part of the default set.
34 # (*) modules are named after the subversion tree; as of this writing their names
35 # are mostly mixed case like MyPLC or VserverReference
36 # (this is something we'll fix while moving to git)
37 # (*) rpms are named in the spec files. A package typically defines several rpms;
38 # rpms are used for defining DEPEND-DEVEL-RPMS. See also package.rpmnames
40 #################### packages
41 # basics: how to build a package - you need/may define the following variables
44 # a package needs one or several modules to build.
47 # the package's specfile; this is relative to the FIRST module in package-MODULES
51 # (*) package-SPECVARS
52 # space-separated list of spec variable definitions, where you can reference make variable that relate to
53 # packages defined BEFORE the current one (note: you should use = - as opposed to := - to define these)
54 # e.g. mydriver-SPECVARS = foo=$(kernel-rpm-release)
55 # would let you use the %release from the kernel's package when rpmbuild'ing mydriver - see automatic below
56 # (*) package-DEPEND-PACKAGES
57 # a set of *packages* that this package depends on
58 # (*) package-DEPEND-DEVEL-RPMS
59 # a set of *rpms* that the build will rpm-install before building <package>
60 # the build will attempt to uninstall those once the package is built, this is not fatal though
61 # this is intended to denote local rpms, i.e. ones that are results of our own build
62 # stock rpms should be mentioned in config.planetlab/devel.pkgs
63 # (*) package-DEPEND-FILES
64 # a set of files that the package depends on - and that make needs to know about
65 # if this contains RPMS/yumgroups.xml, then the toplevel RPMS's index
66 # is refreshed with createrepo prior to running rpmbuild
67 # (*) package-EXCLUDE-DEVEL-RPMS
68 # a set of *rpms* that the build will rpm-uninstall before building <package>
69 # this is intended to denote stock rpms, and the build will attempt to yum-install them
70 # back after the package is rebuilt
71 # (*) package-RPMFLAGS: Miscellaneous RPM flags
72 # (*) package-RPMBUILD: If not rpmbuild - mostly used for sudo'ing rpmbuild
73 # (*) package-BUILD-FROM-SRPM: set this to any non-empty value, if your package is able to produce
74 # a source rpms by running 'make srpm'
75 # (*) package-RPMDATE: set this to any non-empty value to get the rpm package's release field hold the current date
76 # this is useful for container packages, like e.g. bootstrapfs or vserver, that contains much more than the
79 #################### modules
80 # Required information about the various modules (set this in e.g. planetlab-tags.mk)
84 # the complete path where this module lies;
85 # you can specify the trunk or a given tag with this variable
89 # which by analogy with svn revision scheme, is expected to be <url>@<tag>
91 #################### automatic variables
93 # the build defines some make variables that are extracted from spec files
95 # (*) $ make ulogd-pkginfo
96 # to see the list f variables attached to a given package
97 # (*) $ make kernel-devel-rpminfo
98 # to see the list of variables attached to a given rpm
102 # exported to spec files as plrelease
103 PLANETLAB_RELEASE = 5.0
108 # minimal compat with macos, just so this does not complain
109 HOSTARCH := $(shell uname -i 2> /dev/null || uname -m 2> /dev/null)
110 DISTRO := $(shell ./getdistro.sh)
111 RELEASE := $(shell ./getrelease.sh)
112 DISTRONAME := $(shell ./getdistroname.sh)
113 RPM-INSTALL-DEVEL := rpm --force -Uvh
114 # uninstall -- cannot force rpm -e
115 # need to ignore result, kernel-headers cannot be uninstalled as glibc depends on it
116 RPM-UNINSTALL-DEVEL := rpm -e
117 YUM-INSTALL-DEVEL := yum -y install
120 REMOTE-PLDISTROS="wextoolbox"
122 #################### Makefile
128 PLDISTRO := planetlab
131 ########## savedpldistro.mk holds PLDISTRO - it is generated at stage1 (see below)
133 include savedpldistro.mk
136 # when re-running the nightly build after failure, we need to gather the former values
137 # do this by running make stage1=skip +PLDISTRO
138 ifeq "$(stage1)" "skip"
139 include savedpldistro.mk
142 #################### include onelab.mk
143 # describes the set of components
144 PLDISTROCONTENTS := $(PLDISTRO).mk
145 include $(PLDISTROCONTENTS)
147 #################### include <pldistro>-tags.mk
148 # describes where to fetch components
149 ifeq "$(PLDISTROTAGS)" ""
150 PLDISTROTAGS := $(PLDISTRO)-tags.mk
152 include $(PLDISTROTAGS)
154 # this used to be set in the -tags.mk files, but that turned out to require
155 # error-prone duplicate changes
156 # so now the nightly build script sets this to what it is currently using
157 # in case we run this manually, i.e. if neither build-SVNPATH nor build-GITPATH is set
158 ifeq "$(build-SVNPATH)$(build-GITPATH)" ""
159 build-GITPATH-local := $(shell git config remote.origin.url)
160 ifneq "$(build-GITPATH-local)" ""
161 build-GITPATH := $(build-GITPATH-local)
163 build-SVNPATH := $(lastword $(shell svn info 2> /dev/null | grep URL:))
167 define remote_pldistro
168 $(1).mk: config.$(1)/$(1).mk
169 @echo 'creating $(1) from config subdir'
170 cp config.$(1)/$(1).mk $(1).mk
172 $(2).mk: config.$(1)/$(2).mk
173 @echo 'creating $(1) tags from config subdir'
174 cp config.$(1)/$(2).mk $(2).mk
176 config.$(1)/$(1).mk: config.$(1)
177 config.$(1)/$(2).mk: config.$(1)
179 config.$(1): config.$(1).svnpath
180 @echo "Fetching details for pldistro $(1)"
181 svn export $(shell grep -v "^#" config.$(1).svnpath) config.$(1)
183 DISTCLEANS += $(1).mk $(2).mk config.$(1)
187 # somehow this does not work, handle manually instead
188 #$(foreach distro, $(REMOTE-PLDISTROS), $(eval $(call remote_pldistro,$(distro),$(distro)-tags)))
189 $(eval $(call remote_pldistro,wextoolbox,wextoolbox-tags))
191 ########## stage1 and stage1iter
192 # extract specs and compute .mk files by running
194 # entering stage1, we compute all the spec files
195 # then we use stage1iter to compute the .mk iteratively,
196 # ensuring that the n-1 first makefiles are loaded when creating the n-th one
197 # when stage1iter is set, it is supposed to be an index (starting at 1) in $(ALL)
199 ALLMKS := $(foreach package, $(ALL), MAKE/$(package).mk)
201 ### stage1iter : need some arithmetic, see
202 # http://www.cmcrossroads.com/articles/ask-mr.-make/learning-gnu-make-functions-with-arithmetic.html
203 ifneq "$(stage1iter)" ""
204 # the first n packages
205 packages := $(wordlist 1,$(words $(stage1iter)),$(ALL))
207 package := $(word $(words $(packages)),$(packages))
208 # the n-1 first packages
209 stage1iter_1 := $(wordlist 2,$(words $(stage1iter)),$(stage1iter))
210 previous := $(wordlist 1,$(words $(stage1iter_1)),$(ALL))
211 previousmks := $(foreach package,$(previous),MAKE/$(package).mk)
212 include $(previousmks)
215 @echo "========== stage1iter : $(package)"
216 # @echo "stage1iter : included .mk files : $(previousmks)"
217 all: $($(package).specpath)
218 all: MAKE/$(package).mk
224 @echo "========== stage1"
227 # specs and makes are done sequentially by stage1iter
230 arg=""; for n in $(ALL) ; do arg="$$arg x"; $(MAKE) --no-print-directory stage1iter="$$arg"; done
233 ### once .mks are OK, you can run make normally
240 # mention $(ALL) here rather than rpms
241 # this is because the inter-package dependencies are expressed like
242 # util-vserver: util-python
248 ### yumgroups.xml : compute from all known .pkgs files
251 ./yumgroups.sh $(PLDISTRO) > $@
253 createrepo = createrepo --quiet -g yumgroups.xml RPMS/
255 repo: RPMS/yumgroups.xml
262 # * we always use the first module's location (SVNPATH/GITPATH) to extract the spec file
263 # * no matter what SCM is used, SPEC should hold a relative path from the module's root
265 define stage1_package_vars
266 $(1).module := $(firstword $($(1)-MODULES))
267 $(1).specpath := SPECS/$(notdir $($(1)-SPEC))
268 $(1).moduledir := MODULES/$(firstword $($(1)-MODULES))
269 $(1).codespec := MODULES/$(firstword $($(1)-MODULES))/$($(1)-SPEC)
272 $(foreach package, $(ALL), $(eval $(call stage1_package_vars,$(package))))
274 # compute all modules
276 $(foreach package,$(ALL), $(eval ALL.modules+=$($(package)-MODULES)))
277 ALL.modules:=build tests $(sort $(ALL.modules))
279 # extract revision from -SVNPATH or tag from -GITPATH
280 define stage1_module_vars
281 ifneq "$($(1)-SVNPATH)" ""
282 $(1)-SVNPATH := $(strip $($(1)-SVNPATH))
284 $(1)-GITPATH := $(strip $($(1)-GITPATH))
285 $(1).gitrepo := $(firstword $(subst @, ,$($(1)-GITPATH)))
286 $(1).gittag := $(word 2,$(subst @, ,$($(1)-GITPATH)))
287 $(1).gittag := $(if $($(1).gittag),$($(1).gittag),master)
291 $(foreach module,$(ALL.modules), $(eval $(call stage1_module_vars,$(module))))
294 # for each package, compute whether we need to set date
295 # the heuristic is that we mention the date as part of the rpm release flag if
296 # (*) the package has requested it by setting package-RPMDATE (container packages should do that)
297 # (*) or SVNPATH contains 'trunk' or 'branches'
298 # (*) or GITPATH has no '@' (trunk)
299 # (*) or GITPATH contains a '@', and the gittag part has no '-' (this is to tell a tag from a branch..)
301 define package_hasdate
302 $(1).has-date = $(if $($(1)-RPMDATE),yes, \
303 $(if $($($(1).module)-SVNPATH), \
304 $(if $(findstring /trunk,$($($(1).module)-SVNPATH)),yes, \
305 $(if $(findstring /branches,$($($(1).module)-SVNPATH)),yes,)), \
306 $(if $(not $($($(1).module).gittag)), yes,\
307 $(if $(findstring -,$($($(1).module).gittag)),,yes))))
310 $(foreach package, $(ALL), $(eval $(call package_hasdate,$(package))))
312 ### the common header for generated specfiles
313 # useful when trying new specfiles manually
315 (echo -n "# Generated by planetlab build from $($(1)-SPEC) on " ; date) > $@
316 echo "%define distro $(DISTRO)" >> $@
317 echo "%define distrorelease $(RELEASE)" >> $@
318 echo "%define distroname $(DISTRONAME)" >> $@
319 echo "%define pldistro $(PLDISTRO)" >> $@
320 echo "%define plrelease $(PLANETLAB_RELEASE)" >> $@
321 echo "# use MD5 and gzip for binary and source files" >> $@
322 echo "%global _binary_filedigest_algorithm 1" >> $@
323 echo "%global _source_filedigest_algorithm 1" >> $@
324 echo "%global _source_payload w9.gzdio" >> $@
325 echo "%global _binary_payload w9.gzdio" >> $@
327 ### make up spec file - extract module first
329 $($(1).specpath): header.spec $($(1).codespec)
331 cat header.spec > $($(1).specpath)
332 $(if $($(1).has-date),echo "%define date $(shell date +%Y.%m.%d)" >> $($(1).specpath),)
333 $(if $($(1)-SPECVARS), \
334 $(foreach line,$($(1)-SPECVARS), \
335 echo "%define" $(word 1,$(subst =, ,$(line))) "$(word 2,$(subst =, ,$(line)))" >> $($(1).specpath) ;))
336 echo "# included from $($(1)-SPEC)" >> $($(1).specpath)
337 cat $($(1).codespec) >> $($(1).specpath)
339 $($(1).codespec): $($(1).moduledir)
343 $(foreach package,$(ALL),$(eval $(call target_spec,$(package))))
345 ### module extraction
346 define target_extract_module
348 @(echo -n "XXXXXXXXXXXXXXX -- BEG MODULE $(1) : $@ " ; date)
351 $(if $($(1)-SVNPATH),\
352 svn export $($(1)-SVNPATH) $(1),\
353 mkdir $(1) ; (git archive --remote=$($(1).gitrepo) $($(1).gittag) | tar -C $(1) -xf - ) \
354 || { rm -rf $(1); false; } )
355 @(echo -n "XXXXXXXXXXXXXXX -- END MODULE $(1) : $@ " ; date)
357 $(1)-module: MODULES/$(1)
361 $(foreach module,$(ALL.modules),$(eval $(call target_extract_module,$(module))))
364 # use this makefile to extract tests rather than extracting manually in vbuild-nightly
370 # Base rpmbuild in the current directory
371 # issues on fedora 8 : see the following posts
372 # http://forums.fedoraforum.org/showthread.php?t=39625 - and more specifically post#6
373 # https://www.redhat.com/archives/fedora-devel-list/2007-November/msg00171.html
375 FAKEROOT=/longbuildroot
376 PWD=$(shell /bin/pwd)
377 ifeq "$(PWD)" "$(REALROOT)"
378 export HOME := $(FAKEROOT)
380 export HOME := $(PWD)
383 ifeq "$(shell pwd)" "/build"
384 rm -f $(FAKEROOT) ; ln -s $(REALROOT) $(FAKEROOT)
387 echo "%_topdir $(HOME)" >> $@
388 echo "%_tmppath $(HOME)/tmp" >> $@
389 echo "%__spec_install_pre %{___build_pre}" >> $@
390 ./getrpmmacros.sh >> $@
392 ### this utility allows to extract various info from a spec file
393 ### and to define them in makefiles
394 spec2make: spec2make.c
395 $(CC) -g -Wall $< -o $@ -lrpm -lrpmbuild
397 ### run spec2make on the spec file and include the result
398 # usage: spec2make package
400 MAKE/$(1).mk: $($(1).specpath) spec2make .rpmmacros
402 ./spec2make $($(1)-RPMFLAGS) $($(1).specpath) $(1) > MAKE/$(1).mk || { rm MAKE/$(1).mk; exit 1; }
405 $(foreach package,$(ALL),$(eval $(call target_mk,$(package))))
407 # stores PLDISTRO in a file
408 # this is done at stage1. later run wont get confused
409 SAVED_VARS=PLDISTRO PLDISTROTAGS build-SVNPATH PERSONALITY MAILTO BASE WEBPATH TESTBUILDURL WEBROOT
411 @echo "# do not edit" > $@
412 @$(foreach var,$(SAVED_VARS),echo "$(var):=$($(var))" >> $@ ;)
413 @echo "# do not edit" > aliases
414 @echo -n "alias m=\"make " >> aliases
415 @$(foreach var,$(SAVED_VARS),echo -n " $(var)=$($(var))" >> aliases ;)
416 @echo "\"" >> aliases
417 @echo "alias m1=\"m stage1=true\"" >> aliases
419 savedpldistro: savedpldistro.mk
420 .PHONY: savedpldistro
422 # always refresh this
425 #################### regular make
427 define stage2_variables
428 ### devel dependencies
429 $(1).rpmbuild = $(if $($(1)-RPMBUILD),$($(1)-RPMBUILD),$(RPMBUILD)) $($(1)-RPMFLAGS)
430 $(1).all-devel-rpm-paths := $(foreach rpm,$($(1)-DEPEND-DEVEL-RPMS),$($(rpm).rpm-path))
431 $(1).depend-devel-packages := $(sort $(foreach rpm,$($(1)-DEPEND-DEVEL-RPMS),$($(rpm).package)))
432 ALL-DEVEL-RPMS += $($(1)-DEPEND-DEVEL-RPMS)
435 $(foreach package,$(ALL),$(eval $(call stage2_variables,$(package))))
436 ALL-DEVEL-RPMS := $(sort $(ALL-DEVEL-RPMS))
439 ### pack sources into tarballs
440 ALLTARBALLS:= $(foreach package, $(ALL), $($(package).tarballs))
441 tarballs: $(ALLTARBALLS)
442 @echo $(words $(ALLTARBALLS)) source tarballs OK
445 SOURCES/%.tar.bz2: SOURCES/%
446 tar chpjf $@ -C SOURCES $*
448 SOURCES/%.tar.gz: SOURCES/%
449 tar chpzf $@ -C SOURCES $*
451 SOURCES/%.tgz: SOURCES/%
452 tar chpzf $@ -C SOURCES $*
455 URLS/%: url=$(subst @colon@,:,$(subst @slash@,/,$(notdir $@)))
456 URLS/%: basename=$(notdir $(url))
458 echo curl $(url) -o SOURCES/$(basename)
461 ### the directory SOURCES/<package>-<version> is made
462 # with a (set of) copy -rl from MODULES/<module>
463 # the former is $(package.source)
464 ALLSOURCES:=$(foreach package, $(ALL), $($(package).source))
465 # so that make does not use the rule below directly for creating the tarball files
466 .SECONDARY: $(ALLSOURCES)
468 sources: $(ALLSOURCES)
469 @echo $(words $(ALLSOURCES)) versioned source trees OK
472 # argument is a package
473 # do things differently if multiple modules are mentioned (sigh..)
474 define target_copy_link_modules_sources
475 $($(1).source): $(foreach module,$($(1)-MODULES),MODULES/$(module))
476 $(if $(word 2,$($(1)-MODULES)),\
477 mkdir -p $($(1).source) && $(foreach module,$($(1)-MODULES), cp -rl MODULES/$(module) $($(1).source)/$(module);) ,\
478 mkdir -p SOURCES && cp -rl MODULES/$($(1)-MODULES) $($(1).source))
481 $(foreach package,$(ALL),$(eval $(call target_copy_link_modules_sources,$(package))))
484 ALLMODULES:=$(foreach module, $(ALL.modules), MODULES/$(module))
485 .SECONDARY: $(ALLMODULES)
486 modules: $(ALLMODULES)
487 @echo $(words $(ALLMODULES)) modules OK "(fetched from scm)"
491 ALLSRPMS:=$(foreach package,$(ALL),$($(package).srpm))
493 @echo $(words $(ALLSRPMS)) source rpms OK
496 ### these macro handles the DEPEND-DEVEL-RPMS and EXCLUDE-DEVEL-RPMS tags for a hiven package
497 # before building : rpm-install DEPEND-DEVEL-RPMS and rpm-uninstall EXCLUDE
498 define handle_devel_rpms_pre
499 $(if $($(1).all-devel-rpm-paths), echo "Installing for $(1)-DEPEND-DEVEL-RPMS" ; $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
500 $(if $($(1)-EXCLUDE-DEVEL-RPMS), echo "Uninstalling for $(1)-EXCLUDE-DEVEL-RPMS" ; $(RPM-UNINSTALL-DEVEL) $($(1)-EXCLUDE-DEVEL-RPMS))
503 define handle_devel_rpms_post
504 -$(if $($(1)-DEPEND-DEVEL-RPMS), echo "Unstalling for $(1)-DEPEND-DEVEL-RPMS" ; $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
505 $(if $($(1)-EXCLUDE-DEVEL-RPMS), "Reinstalling for $(1)-EXCLUDE-DEVEL-RPMS" ; $(YUM-INSTALL-DEVEL) $($(1)-EXCLUDE-DEVEL-RPMS) )
508 # usage: target_source_rpm package
509 define target_source_rpm
510 ifeq "$($(1)-BUILD-FROM-SRPM)" ""
511 $($(1).srpm): $($(1).specpath) .rpmmacros $($(1).tarballs)
512 mkdir -p BUILD SRPMS tmp
513 @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) (using SOURCES) " ; date)
514 $(call handle_devel_rpms_pre,$(1))
515 $($(1).rpmbuild) -bs $($(1).specpath)
516 $(call handle_devel_rpms_post,$(1))
517 @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
519 $($(1).srpm): $($(1).specpath) .rpmmacros $($(1).source)
520 mkdir -p BUILD SRPMS tmp
521 @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) (using make srpm) " ; date)
522 $(call handle_devel_rpms_pre,$(1))
523 make -C $($(1).source) srpm SPECFILE=$(HOME)/$($(1).specpath) EXPECTED_SRPM=$(notdir $($(1).srpm)) && \
524 rm -f SRPMS/$(notdir $($(1).srpm)) && \
525 ln $($(1).source)/$(notdir $($(1).srpm)) SRPMS/$(notdir $($(1).srpm))
526 $(call handle_devel_rpms_post,$(1))
527 @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
531 $(foreach package,$(ALL),$(eval $(call target_source_rpm,$(package))))
533 ### binary rpms are made from source rpm
534 ALLRPMS:=$(foreach package,$(ALL),$($(package).rpms))
535 # same as above, mention $(ALL) and not $(ALLRPMS)
537 @echo $(words $(ALLRPMS)) binary rpms OK
540 # use tmp dirs when building binary rpm so make remains idempotent
541 # otherwise SOURCES/ or SPEC gets touched again - which leads to rebuilding
542 RPM-USE-TMP-DIRS = --define "_sourcedir $(HOME)/tmp" --define "_specdir $(HOME)/tmp"
543 RPM-USE-COMPILE-DIRS = --define "_sourcedir $(HOME)/COMPILE" --define "_specdir $(HOME)/COMPILE"
545 # usage: build_binary_rpm package
546 # xxx hacky - invoke createrepo if DEPEND-FILES mentions RPMS/yumgroups.xml
547 define target_binary_rpm
548 $($(1).rpms): $($(1).srpm)
550 @(echo -n "XXXXXXXXXXXXXXX -- BEG RPM $(1) " ; date)
551 $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPEND-FILES)), $(createrepo) , )
552 $(call handle_devel_rpms_pre,$(1))
553 $($(1).rpmbuild) --rebuild $(RPM-USE-TMP-DIRS) $($(1).srpm)
554 $(call handle_devel_rpms_post,$(1))
555 @(echo -n "XXXXXXXXXXXXXXX -- END RPM $(1) " ; date)
556 # for manual use only - in case we need to investigate the results of an rpmbuild
557 $(1)-compile: $($(1).srpm)
559 @(echo -n "XXXXXXXXXXXXXXX -- BEG compile $(1) " ; date)
560 $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPEND-FILES)), $(createrepo) , )
561 $(call handle_devel_rpms_pre,$(1))
562 $($(1).rpmbuild) --recompile $(RPM-USE-TMP-DIRS) $($(1).srpm)
563 $(call handle_devel_rpms_post,$(1))
564 @(echo -n "XXXXXXXXXXXXXXX -- END compile $(1) " ; date)
568 $(foreach package,$(ALL),$(eval $(call target_binary_rpm,$(package))))
570 # e.g. make proper -> does propers rpms
571 # usage shorthand_target package
572 define target_shorthand
575 $(1)-spec: $($(1)-SPEC)
579 $(1)-tarball: $($(1).tarballs)
582 $(1)-source: $($(1).source)
583 $(1)-rpms: $($(1).rpms)
585 $(1)-srpm: $($(1).srpm)
589 $(foreach package,$(ALL),$(eval $(call target_shorthand,$(package))))
591 ### file dependencies
592 define package_depends_on_file
597 define target_dependfiles
598 $(foreach file,$($(1)-DEPEND-FILES),$(eval $(call package_depends_on_file,$(1),$(file))))
601 $(foreach package,$(ALL),$(eval $(call target_dependfiles,$(package))))
603 ### package dependencies
604 define package_depends_on_package
607 $($(1).srpm):$($(2).rpms)
610 define target_depends
611 $(foreach package,$($(1)-DEPEND-PACKAGES) $($(1).depend-devel-packages),$(eval $(call package_depends_on_package,$(1),$(package))))
614 $(foreach package,$(ALL),$(eval $(call target_depends,$(package))))
617 # usage: target_clean package
620 $(foreach module,$($(1)-MODULES),rm -rf MODULES/$(module);)
621 .PHONY: $(1)-clean-modules
622 CLEANS += $(1)-clean-modules
624 rm -rf $($(1).source)
625 .PHONY: $(1)-clean-source
626 CLEANS += $(1)-clean-source
628 rm -rf $($(1).tarballs)
629 .PHONY: $(1)-clean-tarball
630 CLEANS += $(1)-clean-tarball
632 rm -rf BUILD/$(notdir $($(1).source))
633 CLEANS += $(1)-clean-build
636 .PHONY: $(1)-clean-rpms
637 CLEANS += $(1)-clean-rpms
640 .PHONY: $(1)-clean-srpm
641 CLEANS += $(1)-clean-srpm
642 $(1)-codeclean: $(1)-clean-source $(1)-clean-tarball $(1)-clean-build $(1)-clean-rpms $(1)-clean-srpm
643 $(1)-clean: $(1)-clean-modules $(1)-codeclean
644 .PHONY: $(1)-codeclean $(1)-clean
646 rm -rf $($(1).specpath)
647 .PHONY: $(1)-clean-spec
650 .PHONY: $(1)-clean-make
651 $(1)-distclean: $(1)-distclean1 $(1)-distclean2
652 $(1)-distclean1: $(1)-clean-spec $(1)-clean-make
653 $(1)-distclean2: $(1)-clean
654 .PHONY: $(1)-distclean $(1)-distclean1 $(1)-distclean2
657 $(foreach package,$(ALL),$(eval $(call target_clean,$(package))))
665 @echo Available clean targets
668 ### brute force clean
670 rm -rf savedpldistro.mk .rpmmacros spec2make header.spec SPECS MAKE $(DISTCLEANS)
672 rm -rf MODULES SOURCES BUILD BUILDROOT RPMS SRPMS tmp
673 distclean: distclean1 distclean2
674 .PHONY: distclean1 distclean2 distclean
677 -$(RPM-UNINSTALL-DEVEL) $(ALL-DEVEL-RPMS)
680 # gather build information for the 'About' page
681 # when run from crontab, INIT_CWD not properly set (says /root ..)
682 # so, the nightly build passes BASE here
683 # also store BASE in .base for any post-processing purposes
685 @echo 'Creating myplc-release'
687 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx build info" >> $@
688 $(MAKE) --no-print-directory version-build >> $@
689 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx svn info" >> $@
690 $(MAKE) --no-print-directory version-tags >> $@
691 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx rpm info" >> $@
692 $(MAKE) --no-print-directory version-rpms >> $@
693 @echo $(BASE) > .base
696 @echo -n 'Build build-date: ' ; date '+%Y.%m.%d'
697 @echo -n 'Build build-time: ' ; date '+%H:%M-%Z'
698 @echo -n 'Build build-hostname: ' ; hostname
699 @echo "Build build-base: $(BASE)"
700 @echo "Build planetlab-distro: $(PLDISTRO)"
701 @echo "Build planetlab-tags: $(PLDISTROTAGS)"
702 @echo -n 'Build planetlab-tagsid: ' ; fgrep '$$''Id' $(PLDISTROTAGS)
703 @echo "Build target-arch: $(HOSTARCH)"
704 @echo "Build target-distro: $(DISTRO)"
705 @echo "Build target-distroname: $(DISTRONAME)"
706 @echo "Build target-release: $(RELEASE)"
707 @echo "Build target-personality: $(PERSONALITY)"
711 VFORMAT="%30s := %s\n"
712 define print_tag_target
714 @$(if $($(1)-SVNPATH),\
715 printf $(VFORMAT) $(1)-SVNPATH "$($(1)-SVNPATH)",\
716 printf $(VFORMAT) $(1)-GITPATH "$($(1)-GITPATH)" )
719 $(foreach module,$(ALL.modules), $(eval $(call print_tag_target,$(module))))
721 version-tags: $(foreach module, $(ALL.modules), $(module)-version-tag)
723 RFORMAT="%20s :: version=%s release=%s\n"
724 define rpm_version_target
726 @printf $(RFORMAT) $($(1).rpm-name) $($(1).rpm-version) $($(1).rpm-release)
727 version-rpms: $(1)-version-rpm
730 $(foreach package,$(sort $(ALL)), $(eval $(call rpm_version_target,$(package))))
732 versions: myplc-release version-build version-tags version-rpms
733 .PHONY: versions version-build version-rpms version-tags
735 #################### package info
736 PKGKEYS := tarballs source srpm rpms rpmnames rpm-release rpm-name rpm-version rpm-subversion
737 %-pkginfo: package=$(subst -pkginfo,,$@)
739 @$(foreach key,$(PKGKEYS),echo "$(package).$(key)=$($(package).$(key))";)
741 RPMKEYS := rpm-path package
742 %-rpminfo: rpm=$(subst -rpminfo,,$@)
744 @$(foreach key,$(RPMKEYS),echo "$(rpm).$(key)=$($(rpm).$(key))";)
746 #################### various lists - designed to run with stage1=true
748 @$(foreach package,$(ALL), echo package=$(package) ref_module=$($(package).module) modules=$($(package)-MODULES) rpmnames=$($(package).rpmnames); )
751 @$(foreach module,$(ALL.modules), echo module=$(module) \
752 $(if $($(module)-SVNPATH),svnpath=$($(module)-SVNPATH),gitpath=$($(module)-GITPATH)) ; )
755 @$(foreach module,$(ALL.modules), \
756 $(if $($(module)-BRANCH),echo module=$(module) branch=$($(module)-BRANCH);))
759 @$(foreach module,$(ALL.modules), \
760 $(if $($(module)-GITPATH), \
761 $(if $($(module)-BRANCH), \
762 echo git:$(module):$($(module)-BRANCH); , \
763 echo git:$(module); ), \
764 $(if $($(module)-BRANCH), \
765 echo $(module):$($(module)-BRANCH); , \
768 info: info-packages info-modules info-branches
770 .PHONY: info info-packages info-modules info-branches module-tools
774 @echo "********** Run make in two stages:"
776 @echo "make stage1=true PLDISTRO=onelab"
777 @echo " -> extracts all spec files in SPECS/ and mk files in MAKE/"
778 @echo " as well as save PLDISTRO for subsequent runs"
780 @echo "********** Then you can use the following targets"
782 @echo " rebuilds everything"
783 @echo 'make util-vserver'
784 @echo " makes the RPMS related to util-vserver"
785 @echo " equivalent to 'make util-vserver-rpms'"
787 @echo "********** Or, vertically - step-by-step for a given package"
788 @echo 'make util-vserver-source'
789 @echo " creates source link in SOURCES/util-vserver-<version>"
790 @echo 'make util-vserver-tarball'
791 @echo " creates source tarball in SOURCES/util-vserver-<version>.<tarextension>"
792 @echo 'make util-vserver-srpm'
793 @echo " build source rpm in SRPMS/"
794 @echo 'make util-vserver-rpms'
795 @echo " build rpm(s) in RPMS/"
797 @echo "********** Or, horizontally, reach a step for all known packages"
799 @echo 'make tarballs'
803 @echo "********** Manual targets"
804 @echo "make package-compile"
805 @echo " The regular process uses rpmbuild --rebuild, that performs"
806 @echo " a compilation directory cleanup upon completion. If you need to investigate"
807 @echo " the intermediate compilation directory, use the -compile targets"
808 @echo "********** Cleaning examples"
810 @echo " removes the files made by make"
811 @echo "make distclean"
812 @echo " brute-force cleaning, removes entire directories - requires a new stage1"
813 @echo "make develclean"
814 @echo " rpm-uninstalls all devel packages installed during build"
816 @echo "make iptables-distclean"
817 @echo " deep clean for a given package"
818 @echo "make iptables-codeclean"
819 @echo " run this if you've made a local/manual change in the MODULES area for iptables"
821 @echo "make util-vserver-clean"
822 @echo " removes codebase, source, tarball, build, rpm and srpm for util-vserver"
823 @echo "make util-vserver-clean-modules"
824 @echo " and so on for source, tarball, build, rpm and srpm"
826 @echo "********** Info examples"
828 @echo " Displays the value of a given variable (here ALL)"
829 @echo " with only a single plus sign only the value is displayed"
831 @echo " is equivalent to make packages modules branches"
832 @echo " provides various info on these objects"
833 @echo "make ulogd-pkginfo"
834 @echo " Displays know attributes of a package"
835 @echo "make kernel-devel-rpminfo"
836 @echo " Displays know attributes of an rpm"
837 @echo "make stage1=true PLDISTROTAGS=planetlab-tags-4.2.mk packages modules branches module-tools"
838 @echo " Lists mentioned items - module-tools is used in modules.update"
840 @echo "********** Known pakages are"
843 #################### convenience, for debugging only
844 # make +foo : prints the value of $(foo)
845 # make ++foo : idem but verbose, i.e. foo=$(foo)
846 ++%: varname=$(subst +,,$@)
848 @echo "$(varname)=$($(varname))"
849 +%: varname=$(subst +,,$@)
851 @echo "$($(varname))"