2 # Thierry Parmentelat - INRIA Sophia Antipolis
8 # this extracts all specfiles and computes .mk from specfiles
9 # you need to specify PLDISTRO here if relevant - see below
11 # for more info on how to invoke this stuff
13 #################### (fedora) distributions
15 # (*) as of nov. 2007, myplc-devel is deprecated
16 # (*) instead, we create a fresh vserver that holds required tools (see e.g. planetlab-devel.lst)
17 # (*) the build uses the current fedora version as a target for the produced images
18 # (*) so you simply need to create a fedora 8 build image for building fedora-8 images
20 #################### (planetlab) distributions
22 # (*) see README-pldistros.txt
23 # (*) then you need to run
24 # make stage1=true PLDISTRO=onelab
27 # This build deals with 3 kinds of objects
29 # (*) packages are named upon the RPM name; they are mostly lowercase
30 # Add a package to ALL if you want it built as part of the default set.
31 # (*) modules are named after the subversion tree; as of this writing their names
32 # are mostly mixed case like MyPLC or VserverReference
33 # (this is something we'll fix while moving to git)
34 # (*) rpms are named in the spec files. A package typically defines several rpms;
35 # rpms are used for defining DEPEND-DEVEL-RPMS. See also package.rpmnames
37 #################### packages
38 # basics: how to build a package - you need/may define the following variables
41 # a package needs one or several modules to build.
44 # the package's specfile; this is relative to the FIRST module in package-MODULES
48 # (*) package-SPECVARS
49 # space-separated list of spec variable definitions, where you can reference make variable that relate to
50 # packages defined BEFORE the current one (note: you should use = - as opposed to := - to define these)
51 # e.g. mydriver-SPECVARS = foo=$(kernel-rpm-release)
52 # would let you use the %release from the kernel's package when rpmbuild'ing mydriver - see automatic below
53 # (*) package-DEPEND-PACKAGES
54 # a set of *packages* that this package depends on
55 # (*) package-DEPEND-DEVEL-RPMS
56 # a set of *rpms* that the build will rpm-install before building <package>
57 # the build will attempt to uninstall those once the package is built, this is not fatal though
58 # this is intended to denote local rpms, i.e. ones that are results of our own build
59 # stock rpms should be mentioned in config.planetlab/devel.pkgs
60 # (*) package-DEPEND-FILES
61 # a set of files that the package depends on - and that make needs to know about
62 # if this contains RPMS/yumgroups.xml, then the toplevel RPMS's index
63 # is refreshed with createrepo prior to running rpmbuild
64 # (*) package-EXCLUDE-DEVEL-RPMS
65 # a set of *rpms* that the build will rpm-uninstall before building <package>
66 # this is intended to denote stock rpms, and the build will attempt to yum-install them
67 # back after the package is rebuilt
68 # (*) package-RPMFLAGS: Miscellaneous RPM flags
69 # (*) package-RPMBUILD: If not rpmbuild - mostly used for sudo'ing rpmbuild
70 # (*) package-BUILD-FROM-SRPM: set this to any non-empty value, if your package is able to produce
71 # a source rpms by running 'make srpm'
72 # (*) package-RPMDATE: set this to any non-empty value to get the rpm package's release field hold the current date
73 # this is useful for container packages, like e.g. bootstrapfs or vserver, that contains much more than the
76 #################### modules
77 # Required information about the various modules (set this in e.g. planetlab-tags.mk)
81 # the complete path where this module lies;
82 # you can specify the trunk or a given tag with this variable
86 # which by analogy with svn revision scheme, is expected to be <url>@<tag>
88 #################### automatic variables
90 # the build defines some make variables that are extracted from spec files
92 # (*) $ make ulogd-pkginfo
93 # to see the list f variables attached to a given package
94 # (*) $ make kernel-devel-rpminfo
95 # to see the list of variables attached to a given rpm
99 # exported to spec files as plrelease
100 PLANETLAB_RELEASE = 5.0
105 # minimal compat with macos, just so this does not complain
106 HOSTARCH := $(shell uname -i 2> /dev/null || uname -m 2> /dev/null)
107 DISTRO := $(shell ./getdistro.sh)
108 RELEASE := $(shell ./getrelease.sh)
109 DISTRONAME := $(shell ./getdistroname.sh)
110 RPM-INSTALL-DEVEL := rpm --force -Uvh
111 # uninstall -- cannot force rpm -e
112 # need to ignore result, kernel-headers cannot be uninstalled as glibc depends on it
113 RPM-UNINSTALL-DEVEL := rpm -e
114 YUM-INSTALL-DEVEL := yum -y install
116 #################### Makefile
122 PLDISTRO := planetlab
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
143 ifeq "$(PLDISTROTAGS)" ""
144 PLDISTROTAGS := $(PLDISTRO)-tags.mk
146 include $(PLDISTROTAGS)
148 # this used to be set in the -tags.mk files, but that turned out to require
149 # error-prone duplicate changes
150 # so now the nightly build script sets this to what it is currently using
151 # in case we run this manually, i.e. if neither build-SVNPATH nor build-GITPATH is set
152 ifeq "$(build-SVNPATH)$(build-GITPATH)" ""
153 build-GITPATH-local := $(shell git config remote.origin.url)
154 ifneq "$(build-GITPATH-local)" ""
155 build-GITPATH := $(build-GITPATH-local)
157 build-SVNPATH := $(lastword $(shell svn info 2> /dev/null | grep URL:))
161 #################### pldistros that are defined remotely
163 define remote_pldistro_fetch_svn
164 $(1).config.SVNPATH := $(shell grep -v "^#" config.$(1).svnpath)
165 config.$(1): config.$(1).svnpath
166 @echo "Fetching (svn) details for remote pldistro $(1)"
167 svn export $$($(1).config.SVNPATH) config.$(1)
172 define remote_pldistro_fetch_git
173 $(1).config.GITPATH := $(shell grep -v "^#" config.$(1).gitpath)
174 $(1).config.gitrepo := $$(firstword $$(subst @, ,$$($(1).config.GITPATH)))
175 $(1).config.gittag := $$(word 2,$$(subst @, ,$$($(1).config.GITPATH)))
176 $(1).config.gittag := $$(if $$($(1).config.gittag),$$($(1).config.gittag),master)
177 config.$(1): GITPATH=$(shell grep -v "^#" config.$(1).gitpath)
178 config.$(1): config.$(1).gitpath
179 @echo "Fetching (git) details for remote pldistro $(1)"
181 git $(GITTAG) archive --remote=$$($(1).config.gitrepo) $$($(1).config.gittag) | tar -C config.$(1) -xf -
186 define remote_pldistro
187 $(1).mk: config.$(1)/$(1).mk
188 @echo 'creating $(1) from config.$(1)'
189 cp config.$(1)/$(1).mk $(1).mk
191 $(2).mk: config.$(1)/$(2).mk
192 @echo 'creating $(2) tags from config.$(1)'
193 cp config.$(1)/$(2).mk $(2).mk
195 config.$(1)/$(1).mk: config.$(1)
196 config.$(1)/$(2).mk: config.$(1)
198 DISTCLEANS += $(1).mk $(2).mk config.$(1)
199 $(eval $(call remote_pldistro_fetch_$(3),$(1)))
202 $(eval $(call remote_pldistro,wextoolbox,wextoolbox-tags,git))
204 ########## stage1 and stage1iter
205 # extract specs and compute .mk files by running
207 # entering stage1, we compute all the spec files
208 # then we use stage1iter to compute the .mk iteratively,
209 # ensuring that the n-1 first makefiles are loaded when creating the n-th one
210 # when stage1iter is set, it is supposed to be an index (starting at 1) in $(ALL)
212 ALLMKS := $(foreach package, $(ALL), MAKE/$(package).mk)
214 ### stage1iter : need some arithmetic, see
215 # http://www.cmcrossroads.com/articles/ask-mr.-make/learning-gnu-make-functions-with-arithmetic.html
216 ifneq "$(stage1iter)" ""
217 # the first n packages
218 packages := $(wordlist 1,$(words $(stage1iter)),$(ALL))
220 package := $(word $(words $(packages)),$(packages))
221 # the n-1 first packages
222 stage1iter_1 := $(wordlist 2,$(words $(stage1iter)),$(stage1iter))
223 previous := $(wordlist 1,$(words $(stage1iter_1)),$(ALL))
224 previousmks := $(foreach package,$(previous),MAKE/$(package).mk)
225 include $(previousmks)
228 @echo "========== stage1iter : $(package)"
229 # @echo "stage1iter : included .mk files : $(previousmks)"
230 all: $($(package).specpath)
231 all: MAKE/$(package).mk
237 @echo "========== stage1"
240 # specs and makes are done sequentially by stage1iter
243 arg=""; for n in $(ALL) ; do arg="$$arg x"; $(MAKE) --no-print-directory stage1iter="$$arg"; done
246 ### once .mks are OK, you can run make normally
253 # mention $(ALL) here rather than rpms
254 # this is because the inter-package dependencies are expressed like
255 # util-vserver: util-python
261 ### yumgroups.xml : compute from all known .pkgs files
264 ./yumgroups.sh $(PLDISTRO) > $@
266 createrepo = createrepo --quiet -g yumgroups.xml RPMS/
268 repo: RPMS/yumgroups.xml
275 # * we always use the first module's location (SVNPATH/GITPATH) to extract the spec file
276 # * no matter what SCM is used, SPEC should hold a relative path from the module's root
278 define stage1_package_vars
279 $(1).module := $(firstword $($(1)-MODULES))
280 $(1).specpath := SPECS/$(notdir $($(1)-SPEC))
281 $(1).moduledir := MODULES/$$($(1).module)
282 $(1).codespec := MODULES/$$($(1).module)/$($(1)-SPEC)
285 $(foreach package, $(ALL), $(eval $(call stage1_package_vars,$(package))))
287 # compute all modules
288 ALL.modules := build tests
289 $(foreach package,$(ALL), $(eval ALL.modules+=$($(package)-MODULES)))
290 ALL.modules:=$(sort $(ALL.modules))
292 # extract revision from -SVNPATH or tag from -GITPATH
293 define stage1_module_vars
294 ifneq "$($(1)-SVNPATH)" ""
295 $(1)-SVNPATH := $(strip $($(1)-SVNPATH))
296 $(1)-SCMPATH := $(strip $($(1)-SVNPATH))
298 $(1)-GITPATH := $$(strip $$($(1)-GITPATH))
299 $(1)-SCMPATH := $$(strip $$($(1)-GITPATH))
300 $(1).gitrepo := $$(firstword $$(subst @, ,$$($(1)-GITPATH)))
301 $(1).gittag := $$(word 2,$$(subst @, ,$$($(1)-GITPATH)))
302 $(1).gittag := $$(if $$($(1).gittag),$$($(1).gittag),master)
306 $(foreach module,$(ALL.modules), $(eval $(call stage1_module_vars,$(module))))
309 # for each package, compute whether we need to set date
310 # the heuristic is that we mention the date as part of the rpm release flag if
311 # (*) the package has requested it by setting package-RPMDATE (container packages should do that)
312 # (*) or SVNPATH contains 'trunk' or 'branches'
313 # (*) or GITPATH has no '@' (trunk)
314 # (*) or GITPATH contains a '@', and the gittag part has no '-' (this is to tell a tag from a branch..)
316 define package_hasdate
317 $(1).has-date = $(if $($(1)-RPMDATE),yes, \
318 $(if $($($(1).module)-SVNPATH), \
319 $(if $(findstring /trunk,$($($(1).module)-SVNPATH)),yes, \
320 $(if $(findstring /branches,$($($(1).module)-SVNPATH)),yes,)), \
321 $(if $(not $($($(1).module).gittag)), yes,\
322 $(if $(findstring -,$($($(1).module).gittag)),,yes))))
325 $(foreach package, $(ALL), $(eval $(call package_hasdate,$(package))))
327 ### the common header for generated specfiles
328 # useful when trying new specfiles manually
330 (echo -n "# Generated by planetlab build from $($(1)-SPEC) on " ; date) > $@
331 echo "%define distro $(DISTRO)" >> $@
332 echo "%define distrorelease $(RELEASE)" >> $@
333 echo "%define distroname $(DISTRONAME)" >> $@
334 echo "%define pldistro $(PLDISTRO)" >> $@
335 echo "%define plrelease $(PLANETLAB_RELEASE)" >> $@
336 echo "# use MD5 and gzip for binary and source files" >> $@
337 echo "%global _binary_filedigest_algorithm 1" >> $@
338 echo "%global _source_filedigest_algorithm 1" >> $@
339 echo "%global _source_payload w9.gzdio" >> $@
340 echo "%global _binary_payload w9.gzdio" >> $@
342 ### make up spec file - extract module first
344 $($(1).specpath): header.spec $($(1).codespec)
346 cat header.spec > $($(1).specpath)
347 echo "%define SCMURL $($($(1).module)-SCMPATH)" >> $($(1).specpath)
348 $(if $($(1).has-date),echo "%define date $(shell date +%Y.%m.%d)" >> $($(1).specpath),)
349 $(if $($(1)-SPECVARS), \
350 $(foreach line,$($(1)-SPECVARS), \
351 echo "%define" $(word 1,$(subst =, ,$(line))) "$(word 2,$(subst =, ,$(line)))" >> $($(1).specpath) ;))
352 echo "# included from $($(1)-SPEC)" >> $($(1).specpath)
353 cat $($(1).codespec) >> $($(1).specpath)
355 $($(1).codespec): $($(1).moduledir)
359 $(foreach package,$(ALL),$(eval $(call target_spec,$(package))))
361 ### module extraction
362 define target_extract_module
364 @(echo -n "XXXXXXXXXXXXXXX -- BEG MODULE $(1) : $@ " ; date)
367 $(if $($(1)-SVNPATH),\
368 svn export $($(1)-SVNPATH) $(1),\
369 mkdir $(1) ; (git archive --remote=$($(1).gitrepo) $($(1).gittag) | tar -C $(1) -xf - ) \
370 || { rm -rf $(1); false; } )
371 @(echo -n "XXXXXXXXXXXXXXX -- END MODULE $(1) : $@ " ; date)
373 $(1)-module: MODULES/$(1)
377 $(foreach module,$(ALL.modules),$(eval $(call target_extract_module,$(module))))
380 # use this makefile to extract tests rather than extracting manually in vbuild-nightly
386 # Base rpmbuild in the current directory
387 # issues on fedora 8 : see the following posts
388 # http://forums.fedoraforum.org/showthread.php?t=39625 - and more specifically post#6
389 # https://www.redhat.com/archives/fedora-devel-list/2007-November/msg00171.html
391 FAKEROOT=/longbuildroot
392 PWD=$(shell /bin/pwd)
393 ifeq "$(PWD)" "$(REALROOT)"
394 export HOME := $(FAKEROOT)
396 export HOME := $(PWD)
399 ifeq "$(shell pwd)" "/build"
400 rm -f $(FAKEROOT) ; ln -s $(REALROOT) $(FAKEROOT)
403 echo "%_topdir $(HOME)" >> $@
404 echo "%_tmppath $(HOME)/tmp" >> $@
405 echo "%__spec_install_pre %{___build_pre}" >> $@
406 ./getrpmmacros.sh >> $@
408 ### this utility allows to extract various info from a spec file
409 ### and to define them in makefiles
410 spec2make: spec2make.c
411 $(CC) -g -Wall $< -o $@ -lrpm -lrpmbuild -lrpmio -lpopt
413 ### run spec2make on the spec file and include the result
414 # usage: spec2make package
416 MAKE/$(1).mk: $($(1).specpath) spec2make .rpmmacros
418 ./spec2make $($(1)-RPMFLAGS) $($(1).specpath) $(1) > MAKE/$(1).mk || { rm MAKE/$(1).mk; exit 1; }
421 $(foreach package,$(ALL),$(eval $(call target_mk,$(package))))
423 # stores PLDISTRO in a file
424 # this is done at stage1. later run wont get confused
425 SAVED_VARS=PLDISTRO PLDISTROTAGS build-SVNPATH PERSONALITY MAILTO BASE WEBPATH TESTBUILDURL WEBROOT
427 @echo "# do not edit" > $@
428 @$(foreach var,$(SAVED_VARS),echo "$(var):=$($(var))" >> $@ ;)
429 @echo "# do not edit" > aliases
430 @echo -n "alias m=\"make " >> aliases
431 @$(foreach var,$(SAVED_VARS),echo -n " $(var)=$($(var))" >> aliases ;)
432 @echo "\"" >> aliases
433 @echo "alias m1=\"m stage1=true\"" >> aliases
435 savedpldistro: savedpldistro.mk
436 .PHONY: savedpldistro
438 # always refresh this
441 #################### regular make
443 define stage2_variables
444 ### devel dependencies
445 $(1).rpmbuild = $(if $($(1)-RPMBUILD),$($(1)-RPMBUILD),$(RPMBUILD)) $($(1)-RPMFLAGS)
446 $(1).all-devel-rpm-paths := $(foreach rpm,$($(1)-DEPEND-DEVEL-RPMS),$($(rpm).rpm-path))
447 $(1).depend-devel-packages := $(sort $(foreach rpm,$($(1)-DEPEND-DEVEL-RPMS),$($(rpm).package)))
448 ALL-DEVEL-RPMS += $($(1)-DEPEND-DEVEL-RPMS)
451 $(foreach package,$(ALL),$(eval $(call stage2_variables,$(package))))
452 ALL-DEVEL-RPMS := $(sort $(ALL-DEVEL-RPMS))
455 ### pack sources into tarballs
456 ALLTARBALLS:= $(foreach package, $(ALL), $($(package).tarballs))
457 tarballs: $(ALLTARBALLS)
458 @echo $(words $(ALLTARBALLS)) source tarballs OK
461 SOURCES/%.tar.bz2: SOURCES/%
462 tar chpjf $@ -C SOURCES $*
464 SOURCES/%.tar.gz: SOURCES/%
465 tar chpzf $@ -C SOURCES $*
467 SOURCES/%.tgz: SOURCES/%
468 tar chpzf $@ -C SOURCES $*
471 URLS/%: url=$(subst @colon@,:,$(subst @slash@,/,$(notdir $@)))
472 URLS/%: basename=$(notdir $(url))
474 echo curl $(url) -o SOURCES/$(basename)
477 ### the directory SOURCES/<package>-<version> is made
478 # with a (set of) copy -rl from MODULES/<module>
479 # the former is $(package.source)
480 ALLSOURCES:=$(foreach package, $(ALL), $($(package).source))
481 # so that make does not use the rule below directly for creating the tarball files
482 .SECONDARY: $(ALLSOURCES)
484 sources: $(ALLSOURCES)
485 @echo $(words $(ALLSOURCES)) versioned source trees OK
488 # argument is a package
489 # do things differently if multiple modules are mentioned (sigh..)
490 define target_copy_link_modules_sources
491 $($(1).source): $(foreach module,$($(1)-MODULES),MODULES/$(module))
492 $(if $(word 2,$($(1)-MODULES)),\
493 mkdir -p $($(1).source) && $(foreach module,$($(1)-MODULES), cp -rl MODULES/$(module) $($(1).source)/$(module);) ,\
494 mkdir -p SOURCES && cp -rl MODULES/$($(1)-MODULES) $($(1).source))
497 $(foreach package,$(ALL),$(eval $(call target_copy_link_modules_sources,$(package))))
500 ALLMODULES:=$(foreach module, $(ALL.modules), MODULES/$(module))
501 .SECONDARY: $(ALLMODULES)
502 modules: $(ALLMODULES)
503 @echo $(words $(ALLMODULES)) modules OK "(fetched from scm)"
507 ALLSRPMS:=$(foreach package,$(ALL),$($(package).srpm))
509 @echo $(words $(ALLSRPMS)) source rpms OK
512 ### these macro handles the DEPEND-DEVEL-RPMS and EXCLUDE-DEVEL-RPMS tags for a hiven package
513 # before building : rpm-install DEPEND-DEVEL-RPMS and rpm-uninstall EXCLUDE
514 define handle_devel_rpms_pre
515 $(if $($(1).all-devel-rpm-paths), echo "Installing for $(1)-DEPEND-DEVEL-RPMS" ; $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
516 $(if $($(1)-EXCLUDE-DEVEL-RPMS), echo "Uninstalling for $(1)-EXCLUDE-DEVEL-RPMS" ; $(RPM-UNINSTALL-DEVEL) $($(1)-EXCLUDE-DEVEL-RPMS))
519 define handle_devel_rpms_post
520 -$(if $($(1)-DEPEND-DEVEL-RPMS), echo "Unstalling for $(1)-DEPEND-DEVEL-RPMS" ; $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
521 $(if $($(1)-EXCLUDE-DEVEL-RPMS), "Reinstalling for $(1)-EXCLUDE-DEVEL-RPMS" ; $(YUM-INSTALL-DEVEL) $($(1)-EXCLUDE-DEVEL-RPMS) )
524 # usage: target_source_rpm package
525 define target_source_rpm
526 ifeq "$($(1)-BUILD-FROM-SRPM)" ""
527 $($(1).srpm): $($(1).specpath) .rpmmacros $($(1).tarballs)
528 mkdir -p BUILD SRPMS tmp
529 @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) (using SOURCES) " ; date)
530 $(call handle_devel_rpms_pre,$(1))
531 $($(1).rpmbuild) -bs $($(1).specpath)
532 $(call handle_devel_rpms_post,$(1))
533 @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
535 $($(1).srpm): $($(1).specpath) .rpmmacros $($(1).source)
536 mkdir -p BUILD SRPMS tmp
537 @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) (using make srpm) " ; date)
538 $(call handle_devel_rpms_pre,$(1))
539 make -C $($(1).source) srpm SPECFILE=$(HOME)/$($(1).specpath) EXPECTED_SRPM=$(notdir $($(1).srpm)) && \
540 rm -f SRPMS/$(notdir $($(1).srpm)) && \
541 ln $($(1).source)/$(notdir $($(1).srpm)) SRPMS/$(notdir $($(1).srpm))
542 $(call handle_devel_rpms_post,$(1))
543 @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
547 $(foreach package,$(ALL),$(eval $(call target_source_rpm,$(package))))
549 ### binary rpms are made from source rpm
550 ALLRPMS:=$(foreach package,$(ALL),$($(package).rpms))
551 # same as above, mention $(ALL) and not $(ALLRPMS)
553 @echo $(words $(ALLRPMS)) binary rpms OK
556 # use tmp dirs when building binary rpm so make remains idempotent
557 # otherwise SOURCES/ or SPEC gets touched again - which leads to rebuilding
558 RPM-USE-TMP-DIRS = --define "_sourcedir $(HOME)/tmp" --define "_specdir $(HOME)/tmp"
559 RPM-USE-COMPILE-DIRS = --define "_sourcedir $(HOME)/COMPILE" --define "_specdir $(HOME)/COMPILE"
561 # usage: build_binary_rpm package
562 # xxx hacky - invoke createrepo if DEPEND-FILES mentions RPMS/yumgroups.xml
563 define target_binary_rpm
564 $($(1).rpms): $($(1).srpm)
566 @(echo -n "XXXXXXXXXXXXXXX -- BEG RPM $(1) " ; date)
567 $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPEND-FILES)), $(createrepo) , )
568 $(call handle_devel_rpms_pre,$(1))
569 $($(1).rpmbuild) --rebuild $(RPM-USE-TMP-DIRS) $($(1).srpm)
570 $(call handle_devel_rpms_post,$(1))
571 @(echo -n "XXXXXXXXXXXXXXX -- END RPM $(1) " ; date)
572 # for manual use only - in case we need to investigate the results of an rpmbuild
573 $(1)-compile: $($(1).srpm)
575 @(echo -n "XXXXXXXXXXXXXXX -- BEG compile $(1) " ; date)
576 $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPEND-FILES)), $(createrepo) , )
577 $(call handle_devel_rpms_pre,$(1))
578 $($(1).rpmbuild) --recompile $(RPM-USE-TMP-DIRS) $($(1).srpm)
579 $(call handle_devel_rpms_post,$(1))
580 @(echo -n "XXXXXXXXXXXXXXX -- END compile $(1) " ; date)
584 $(foreach package,$(ALL),$(eval $(call target_binary_rpm,$(package))))
586 # e.g. make proper -> does propers rpms
587 # usage shorthand_target package
588 define target_shorthand
591 $(1)-spec: $($(1)-SPEC)
595 $(1)-tarball: $($(1).tarballs)
598 $(1)-source: $($(1).source)
599 $(1)-rpms: $($(1).rpms)
601 $(1)-srpm: $($(1).srpm)
605 $(foreach package,$(ALL),$(eval $(call target_shorthand,$(package))))
607 ### file dependencies
608 define package_depends_on_file
613 define target_dependfiles
614 $(foreach file,$($(1)-DEPEND-FILES),$(eval $(call package_depends_on_file,$(1),$(file))))
617 $(foreach package,$(ALL),$(eval $(call target_dependfiles,$(package))))
619 ### package dependencies
620 define package_depends_on_package
623 $($(1).srpm):$($(2).rpms)
626 define target_depends
627 $(foreach package,$($(1)-DEPEND-PACKAGES) $($(1).depend-devel-packages),$(eval $(call package_depends_on_package,$(1),$(package))))
630 $(foreach package,$(ALL),$(eval $(call target_depends,$(package))))
633 # usage: target_clean package
636 $(foreach module,$($(1)-MODULES),rm -rf MODULES/$(module);)
637 .PHONY: $(1)-clean-modules
638 CLEANS += $(1)-clean-modules
640 rm -rf $($(1).source)
641 .PHONY: $(1)-clean-source
642 CLEANS += $(1)-clean-source
644 rm -rf $($(1).tarballs)
645 .PHONY: $(1)-clean-tarball
646 CLEANS += $(1)-clean-tarball
648 rm -rf BUILD/$(notdir $($(1).source))
649 CLEANS += $(1)-clean-build
652 .PHONY: $(1)-clean-rpms
653 CLEANS += $(1)-clean-rpms
656 .PHONY: $(1)-clean-srpm
657 CLEANS += $(1)-clean-srpm
658 $(1)-codeclean: $(1)-clean-source $(1)-clean-tarball $(1)-clean-build $(1)-clean-rpms $(1)-clean-srpm
659 $(1)-clean: $(1)-clean-modules $(1)-codeclean
660 .PHONY: $(1)-codeclean $(1)-clean
662 rm -rf $($(1).specpath)
663 .PHONY: $(1)-clean-spec
666 .PHONY: $(1)-clean-make
667 $(1)-distclean: $(1)-distclean1 $(1)-distclean2
668 $(1)-distclean1: $(1)-clean-spec $(1)-clean-make
669 $(1)-distclean2: $(1)-clean
670 .PHONY: $(1)-distclean $(1)-distclean1 $(1)-distclean2
673 $(foreach package,$(ALL),$(eval $(call target_clean,$(package))))
681 @echo Available clean targets
684 ### brute force clean
686 rm -rf savedpldistro.mk .rpmmacros spec2make header.spec SPECS MAKE $(DISTCLEANS)
688 rm -rf MODULES SOURCES BUILD BUILDROOT RPMS SRPMS tmp
689 distclean: distclean1 distclean2
690 .PHONY: distclean1 distclean2 distclean
693 -$(RPM-UNINSTALL-DEVEL) $(ALL-DEVEL-RPMS)
696 # gather build information for the 'About' page
697 # when run from crontab, INIT_CWD not properly set (says /root ..)
698 # so, the nightly build passes BASE here
699 # also store BASE in .base for any post-processing purposes
701 @echo 'Creating myplc-release'
703 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx build info" >> $@
704 $(MAKE) --no-print-directory version-build >> $@
705 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx svn info" >> $@
706 $(MAKE) --no-print-directory version-tags >> $@
707 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx rpm info" >> $@
708 $(MAKE) --no-print-directory version-rpms >> $@
709 @echo $(BASE) > .base
712 @echo -n 'Build build-date: ' ; date '+%Y.%m.%d'
713 @echo -n 'Build build-time: ' ; date '+%H:%M-%Z'
714 @echo -n 'Build build-hostname: ' ; hostname
715 @echo "Build build-base: $(BASE)"
716 @echo "Build planetlab-distro: $(PLDISTRO)"
717 @echo "Build planetlab-tags: $(PLDISTROTAGS)"
718 @echo "Build target-arch: $(HOSTARCH)"
719 @echo "Build target-distro: $(DISTRO)"
720 @echo "Build target-distroname: $(DISTRONAME)"
721 @echo "Build target-release: $(RELEASE)"
722 @echo "Build target-personality: $(PERSONALITY)"
726 VFORMAT="%30s := %s\n"
727 define print_tag_target
729 @$(if $($(1)-SVNPATH),\
730 printf $(VFORMAT) $(1)-SVNPATH "$($(1)-SVNPATH)",\
731 printf $(VFORMAT) $(1)-GITPATH "$($(1)-GITPATH)" )
734 $(foreach module,$(ALL.modules), $(eval $(call print_tag_target,$(module))))
736 version-tags: $(foreach module, $(ALL.modules), $(module)-version-tag)
738 RFORMAT="%20s :: version=%s release=%s\n"
739 define rpm_version_target
741 @printf $(RFORMAT) $($(1).rpm-name) $($(1).rpm-version) $($(1).rpm-release)
742 version-rpms: $(1)-version-rpm
745 $(foreach package,$(sort $(ALL)), $(eval $(call rpm_version_target,$(package))))
747 versions: myplc-release version-build version-tags version-rpms
748 .PHONY: versions version-build version-rpms version-tags
750 #################### package info
751 PKGKEYS := tarballs source srpm rpms rpmnames rpm-release rpm-name rpm-version rpm-subversion
752 %-pkginfo: package=$(subst -pkginfo,,$@)
754 @$(foreach key,$(PKGKEYS),echo "$(package).$(key)=$($(package).$(key))";)
756 RPMKEYS := rpm-path package
757 %-rpminfo: rpm=$(subst -rpminfo,,$@)
759 @$(foreach key,$(RPMKEYS),echo "$(rpm).$(key)=$($(rpm).$(key))";)
761 #################### various lists - designed to run with stage1=true
763 @$(foreach package,$(ALL), echo package=$(package) ref_module=$($(package).module) modules=$($(package)-MODULES) rpmnames=$($(package).rpmnames); )
766 @$(foreach module,$(ALL.modules), echo module=$(module) \
767 $(if $($(module)-SVNPATH),svnpath=$($(module)-SVNPATH),gitpath=$($(module)-GITPATH)) ; )
770 @$(foreach module,$(ALL.modules), \
771 $(if $($(module)-BRANCH),echo module=$(module) branch=$($(module)-BRANCH);))
774 @$(foreach module,$(ALL.modules), \
775 $(if $($(module)-GITPATH), \
776 $(if $($(module)-BRANCH), \
777 echo $(module):$($(module)-BRANCH); , \
779 $(if $($(module)-BRANCH), \
780 echo $(module):$($(module)-BRANCH); , \
783 info: info-packages info-modules info-branches
785 .PHONY: info info-packages info-modules info-branches module-tools
788 @$(foreach package,$(ALL),$(if $(subst x1,,x$(words $($(package)-MODULES))), echo p=$(package) mods=$($(package)-MODULES) ;))
789 .PHONY: show-multi-modules
792 @echo "********** Run make in two stages:"
794 @echo "make stage1=true PLDISTRO=onelab"
795 @echo " -> extracts all spec files in SPECS/ and mk files in MAKE/"
796 @echo " as well as save PLDISTRO for subsequent runs"
798 @echo "********** Then you can use the following targets"
800 @echo " rebuilds everything"
801 @echo 'make util-vserver'
802 @echo " makes the RPMS related to util-vserver"
803 @echo " equivalent to 'make util-vserver-rpms'"
805 @echo "********** Or, vertically - step-by-step for a given package"
806 @echo 'make util-vserver-source'
807 @echo " creates source link in SOURCES/util-vserver-<version>"
808 @echo 'make util-vserver-tarball'
809 @echo " creates source tarball in SOURCES/util-vserver-<version>.<tarextension>"
810 @echo 'make util-vserver-srpm'
811 @echo " build source rpm in SRPMS/"
812 @echo 'make util-vserver-rpms'
813 @echo " build rpm(s) in RPMS/"
815 @echo "********** Or, horizontally, reach a step for all known packages"
817 @echo 'make tarballs'
821 @echo "********** Manual targets"
822 @echo "make package-compile"
823 @echo " The regular process uses rpmbuild --rebuild, that performs"
824 @echo " a compilation directory cleanup upon completion. If you need to investigate"
825 @echo " the intermediate compilation directory, use the -compile targets"
826 @echo "********** Cleaning examples"
828 @echo " removes the files made by make"
829 @echo "make distclean"
830 @echo " brute-force cleaning, removes entire directories - requires a new stage1"
831 @echo "make develclean"
832 @echo " rpm-uninstalls all devel packages installed during build"
834 @echo "make iptables-distclean"
835 @echo " deep clean for a given package"
836 @echo "make iptables-codeclean"
837 @echo " run this if you've made a local/manual change in the MODULES area for iptables"
839 @echo "make util-vserver-clean"
840 @echo " removes codebase, source, tarball, build, rpm and srpm for util-vserver"
841 @echo "make util-vserver-clean-modules"
842 @echo " and so on for source, tarball, build, rpm and srpm"
844 @echo "********** Info examples"
846 @echo " Displays the value of a given variable (here ALL)"
847 @echo " with only a single plus sign only the value is displayed"
849 @echo " is equivalent to make packages modules branches"
850 @echo " provides various info on these objects"
851 @echo "make ulogd-pkginfo"
852 @echo " Displays know attributes of a package"
853 @echo "make kernel-devel-rpminfo"
854 @echo " Displays know attributes of an rpm"
855 @echo "make stage1=true PLDISTROTAGS=planetlab-tags-4.2.mk packages modules branches module-tools"
856 @echo " Lists mentioned items - module-tools is used in modules.update"
858 @echo "********** Known pakages are"
861 #################### convenience, for debugging only
862 # make +foo : prints the value of $(foo)
863 # make ++foo : idem but verbose, i.e. foo=$(foo)
864 ++%: varname=$(subst +,,$@)
866 @echo "$(varname)=$($(varname))"
867 +%: varname=$(subst +,,$@)
869 @echo "$($(varname))"