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)
171 define remote_pldistro_fetch_git
172 $(1).config.GITPATH := $(shell grep -v "^#" config.$(1).gitpath)
173 $(1).config.gitrepo := $(firstword $(subst @, ,$$($(1).config.GITPATH)))
174 $(1).config.gittag := $(word 2,$(subst @, ,$$($(1).config.GITPATH)))
175 $(1).config.gittag := $(if $$($(1).config.gittag),$$($(1).config.gittag),master)
176 config.$(1): GITPATH=$(shell grep -v "^#" config.$(1).gitpath)
177 config.$(1): config.$(1).gitpath
178 @echo "Fetching (git) details for remote pldistro $(1)"
180 git $(GITTAG) archive --remote=$$($(1).config.gitrepo) $$($(1).config.gittag) | tar -C config.$(1) -xf -
185 define remote_pldistro
186 $(1).mk: config.$(1)/$(1).mk
187 @echo 'creating $(1) from config.$(1)'
188 cp config.$(1)/$(1).mk $(1).mk
190 $(2).mk: config.$(1)/$(2).mk
191 @echo 'creating $(2) tags from config.$(1)'
192 cp config.$(1)/$(2).mk $(2).mk
194 config.$(1)/$(1).mk: config.$(1)
195 config.$(1)/$(2).mk: config.$(1)
197 DISTCLEANS += $(1).mk $(2).mk config.$(1)
198 $(eval $(call remote_pldistro_fetch_$(3),$(1)))
201 # somehow this does not work, handle manually instead
202 #REMOTE-PLDISTROS="wextoolbox"
203 #$(foreach distro, $(REMOTE-PLDISTROS), $(eval $(call remote_pldistro,$(distro),$(distro)-tags)))
204 $(eval $(call remote_pldistro,wextoolbox,wextoolbox-tags,svn))
206 ########## stage1 and stage1iter
207 # extract specs and compute .mk files by running
209 # entering stage1, we compute all the spec files
210 # then we use stage1iter to compute the .mk iteratively,
211 # ensuring that the n-1 first makefiles are loaded when creating the n-th one
212 # when stage1iter is set, it is supposed to be an index (starting at 1) in $(ALL)
214 ALLMKS := $(foreach package, $(ALL), MAKE/$(package).mk)
216 ### stage1iter : need some arithmetic, see
217 # http://www.cmcrossroads.com/articles/ask-mr.-make/learning-gnu-make-functions-with-arithmetic.html
218 ifneq "$(stage1iter)" ""
219 # the first n packages
220 packages := $(wordlist 1,$(words $(stage1iter)),$(ALL))
222 package := $(word $(words $(packages)),$(packages))
223 # the n-1 first packages
224 stage1iter_1 := $(wordlist 2,$(words $(stage1iter)),$(stage1iter))
225 previous := $(wordlist 1,$(words $(stage1iter_1)),$(ALL))
226 previousmks := $(foreach package,$(previous),MAKE/$(package).mk)
227 include $(previousmks)
230 @echo "========== stage1iter : $(package)"
231 # @echo "stage1iter : included .mk files : $(previousmks)"
232 all: $($(package).specpath)
233 all: MAKE/$(package).mk
239 @echo "========== stage1"
242 # specs and makes are done sequentially by stage1iter
245 arg=""; for n in $(ALL) ; do arg="$$arg x"; $(MAKE) --no-print-directory stage1iter="$$arg"; done
248 ### once .mks are OK, you can run make normally
255 # mention $(ALL) here rather than rpms
256 # this is because the inter-package dependencies are expressed like
257 # util-vserver: util-python
263 ### yumgroups.xml : compute from all known .pkgs files
266 ./yumgroups.sh $(PLDISTRO) > $@
268 createrepo = createrepo --quiet -g yumgroups.xml RPMS/
270 repo: RPMS/yumgroups.xml
277 # * we always use the first module's location (SVNPATH/GITPATH) to extract the spec file
278 # * no matter what SCM is used, SPEC should hold a relative path from the module's root
280 define stage1_package_vars
281 $(1).module := $(firstword $($(1)-MODULES))
282 $(1).specpath := SPECS/$(notdir $($(1)-SPEC))
283 $(1).moduledir := MODULES/$$($(1).module)
284 $(1).codespec := MODULES/$$($(1).module)/$($(1)-SPEC)
287 $(foreach package, $(ALL), $(eval $(call stage1_package_vars,$(package))))
289 # compute all modules
290 ALL.modules := build tests
291 $(foreach package,$(ALL), $(eval ALL.modules+=$($(package)-MODULES)))
292 ALL.modules:=$(sort $(ALL.modules))
294 # extract revision from -SVNPATH or tag from -GITPATH
295 define stage1_module_vars
296 ifneq "$($(1)-SVNPATH)" ""
297 $(1)-SVNPATH := $(strip $($(1)-SVNPATH))
299 $(1)-GITPATH := $(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 $(if $($(1).has-date),echo "%define date $(shell date +%Y.%m.%d)" >> $($(1).specpath),)
348 $(if $($(1)-SPECVARS), \
349 $(foreach line,$($(1)-SPECVARS), \
350 echo "%define" $(word 1,$(subst =, ,$(line))) "$(word 2,$(subst =, ,$(line)))" >> $($(1).specpath) ;))
351 echo "# included from $($(1)-SPEC)" >> $($(1).specpath)
352 cat $($(1).codespec) >> $($(1).specpath)
354 $($(1).codespec): $($(1).moduledir)
358 $(foreach package,$(ALL),$(eval $(call target_spec,$(package))))
360 ### module extraction
361 define target_extract_module
363 @(echo -n "XXXXXXXXXXXXXXX -- BEG MODULE $(1) : $@ " ; date)
366 $(if $($(1)-SVNPATH),\
367 svn export $($(1)-SVNPATH) $(1),\
368 mkdir $(1) ; (git archive --remote=$($(1).gitrepo) $($(1).gittag) | tar -C $(1) -xf - ) \
369 || { rm -rf $(1); false; } )
370 @(echo -n "XXXXXXXXXXXXXXX -- END MODULE $(1) : $@ " ; date)
372 $(1)-module: MODULES/$(1)
376 $(foreach module,$(ALL.modules),$(eval $(call target_extract_module,$(module))))
379 # use this makefile to extract tests rather than extracting manually in vbuild-nightly
385 # Base rpmbuild in the current directory
386 # issues on fedora 8 : see the following posts
387 # http://forums.fedoraforum.org/showthread.php?t=39625 - and more specifically post#6
388 # https://www.redhat.com/archives/fedora-devel-list/2007-November/msg00171.html
390 FAKEROOT=/longbuildroot
391 PWD=$(shell /bin/pwd)
392 ifeq "$(PWD)" "$(REALROOT)"
393 export HOME := $(FAKEROOT)
395 export HOME := $(PWD)
398 ifeq "$(shell pwd)" "/build"
399 rm -f $(FAKEROOT) ; ln -s $(REALROOT) $(FAKEROOT)
402 echo "%_topdir $(HOME)" >> $@
403 echo "%_tmppath $(HOME)/tmp" >> $@
404 echo "%__spec_install_pre %{___build_pre}" >> $@
405 ./getrpmmacros.sh >> $@
407 ### this utility allows to extract various info from a spec file
408 ### and to define them in makefiles
409 spec2make: spec2make.c
410 $(CC) -g -Wall $< -o $@ -lrpm -lrpmbuild
412 ### run spec2make on the spec file and include the result
413 # usage: spec2make package
415 MAKE/$(1).mk: $($(1).specpath) spec2make .rpmmacros
417 ./spec2make $($(1)-RPMFLAGS) $($(1).specpath) $(1) > MAKE/$(1).mk || { rm MAKE/$(1).mk; exit 1; }
420 $(foreach package,$(ALL),$(eval $(call target_mk,$(package))))
422 # stores PLDISTRO in a file
423 # this is done at stage1. later run wont get confused
424 SAVED_VARS=PLDISTRO PLDISTROTAGS build-SVNPATH PERSONALITY MAILTO BASE WEBPATH TESTBUILDURL WEBROOT
426 @echo "# do not edit" > $@
427 @$(foreach var,$(SAVED_VARS),echo "$(var):=$($(var))" >> $@ ;)
428 @echo "# do not edit" > aliases
429 @echo -n "alias m=\"make " >> aliases
430 @$(foreach var,$(SAVED_VARS),echo -n " $(var)=$($(var))" >> aliases ;)
431 @echo "\"" >> aliases
432 @echo "alias m1=\"m stage1=true\"" >> aliases
434 savedpldistro: savedpldistro.mk
435 .PHONY: savedpldistro
437 # always refresh this
440 #################### regular make
442 define stage2_variables
443 ### devel dependencies
444 $(1).rpmbuild = $(if $($(1)-RPMBUILD),$($(1)-RPMBUILD),$(RPMBUILD)) $($(1)-RPMFLAGS)
445 $(1).all-devel-rpm-paths := $(foreach rpm,$($(1)-DEPEND-DEVEL-RPMS),$($(rpm).rpm-path))
446 $(1).depend-devel-packages := $(sort $(foreach rpm,$($(1)-DEPEND-DEVEL-RPMS),$($(rpm).package)))
447 ALL-DEVEL-RPMS += $($(1)-DEPEND-DEVEL-RPMS)
450 $(foreach package,$(ALL),$(eval $(call stage2_variables,$(package))))
451 ALL-DEVEL-RPMS := $(sort $(ALL-DEVEL-RPMS))
454 ### pack sources into tarballs
455 ALLTARBALLS:= $(foreach package, $(ALL), $($(package).tarballs))
456 tarballs: $(ALLTARBALLS)
457 @echo $(words $(ALLTARBALLS)) source tarballs OK
460 SOURCES/%.tar.bz2: SOURCES/%
461 tar chpjf $@ -C SOURCES $*
463 SOURCES/%.tar.gz: SOURCES/%
464 tar chpzf $@ -C SOURCES $*
466 SOURCES/%.tgz: SOURCES/%
467 tar chpzf $@ -C SOURCES $*
470 URLS/%: url=$(subst @colon@,:,$(subst @slash@,/,$(notdir $@)))
471 URLS/%: basename=$(notdir $(url))
473 echo curl $(url) -o SOURCES/$(basename)
476 ### the directory SOURCES/<package>-<version> is made
477 # with a (set of) copy -rl from MODULES/<module>
478 # the former is $(package.source)
479 ALLSOURCES:=$(foreach package, $(ALL), $($(package).source))
480 # so that make does not use the rule below directly for creating the tarball files
481 .SECONDARY: $(ALLSOURCES)
483 sources: $(ALLSOURCES)
484 @echo $(words $(ALLSOURCES)) versioned source trees OK
487 # argument is a package
488 # do things differently if multiple modules are mentioned (sigh..)
489 define target_copy_link_modules_sources
490 $($(1).source): $(foreach module,$($(1)-MODULES),MODULES/$(module))
491 $(if $(word 2,$($(1)-MODULES)),\
492 mkdir -p $($(1).source) && $(foreach module,$($(1)-MODULES), cp -rl MODULES/$(module) $($(1).source)/$(module);) ,\
493 mkdir -p SOURCES && cp -rl MODULES/$($(1)-MODULES) $($(1).source))
496 $(foreach package,$(ALL),$(eval $(call target_copy_link_modules_sources,$(package))))
499 ALLMODULES:=$(foreach module, $(ALL.modules), MODULES/$(module))
500 .SECONDARY: $(ALLMODULES)
501 modules: $(ALLMODULES)
502 @echo $(words $(ALLMODULES)) modules OK "(fetched from scm)"
506 ALLSRPMS:=$(foreach package,$(ALL),$($(package).srpm))
508 @echo $(words $(ALLSRPMS)) source rpms OK
511 ### these macro handles the DEPEND-DEVEL-RPMS and EXCLUDE-DEVEL-RPMS tags for a hiven package
512 # before building : rpm-install DEPEND-DEVEL-RPMS and rpm-uninstall EXCLUDE
513 define handle_devel_rpms_pre
514 $(if $($(1).all-devel-rpm-paths), echo "Installing for $(1)-DEPEND-DEVEL-RPMS" ; $(RPM-INSTALL-DEVEL) $($(1).all-devel-rpm-paths))
515 $(if $($(1)-EXCLUDE-DEVEL-RPMS), echo "Uninstalling for $(1)-EXCLUDE-DEVEL-RPMS" ; $(RPM-UNINSTALL-DEVEL) $($(1)-EXCLUDE-DEVEL-RPMS))
518 define handle_devel_rpms_post
519 -$(if $($(1)-DEPEND-DEVEL-RPMS), echo "Unstalling for $(1)-DEPEND-DEVEL-RPMS" ; $(RPM-UNINSTALL-DEVEL) $($(1)-DEPEND-DEVEL-RPMS))
520 $(if $($(1)-EXCLUDE-DEVEL-RPMS), "Reinstalling for $(1)-EXCLUDE-DEVEL-RPMS" ; $(YUM-INSTALL-DEVEL) $($(1)-EXCLUDE-DEVEL-RPMS) )
523 # usage: target_source_rpm package
524 define target_source_rpm
525 ifeq "$($(1)-BUILD-FROM-SRPM)" ""
526 $($(1).srpm): $($(1).specpath) .rpmmacros $($(1).tarballs)
527 mkdir -p BUILD SRPMS tmp
528 @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) (using SOURCES) " ; date)
529 $(call handle_devel_rpms_pre,$(1))
530 $($(1).rpmbuild) -bs $($(1).specpath)
531 $(call handle_devel_rpms_post,$(1))
532 @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
534 $($(1).srpm): $($(1).specpath) .rpmmacros $($(1).source)
535 mkdir -p BUILD SRPMS tmp
536 @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) (using make srpm) " ; date)
537 $(call handle_devel_rpms_pre,$(1))
538 make -C $($(1).source) srpm SPECFILE=$(HOME)/$($(1).specpath) EXPECTED_SRPM=$(notdir $($(1).srpm)) && \
539 rm -f SRPMS/$(notdir $($(1).srpm)) && \
540 ln $($(1).source)/$(notdir $($(1).srpm)) SRPMS/$(notdir $($(1).srpm))
541 $(call handle_devel_rpms_post,$(1))
542 @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
546 $(foreach package,$(ALL),$(eval $(call target_source_rpm,$(package))))
548 ### binary rpms are made from source rpm
549 ALLRPMS:=$(foreach package,$(ALL),$($(package).rpms))
550 # same as above, mention $(ALL) and not $(ALLRPMS)
552 @echo $(words $(ALLRPMS)) binary rpms OK
555 # use tmp dirs when building binary rpm so make remains idempotent
556 # otherwise SOURCES/ or SPEC gets touched again - which leads to rebuilding
557 RPM-USE-TMP-DIRS = --define "_sourcedir $(HOME)/tmp" --define "_specdir $(HOME)/tmp"
558 RPM-USE-COMPILE-DIRS = --define "_sourcedir $(HOME)/COMPILE" --define "_specdir $(HOME)/COMPILE"
560 # usage: build_binary_rpm package
561 # xxx hacky - invoke createrepo if DEPEND-FILES mentions RPMS/yumgroups.xml
562 define target_binary_rpm
563 $($(1).rpms): $($(1).srpm)
565 @(echo -n "XXXXXXXXXXXXXXX -- BEG RPM $(1) " ; date)
566 $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPEND-FILES)), $(createrepo) , )
567 $(call handle_devel_rpms_pre,$(1))
568 $($(1).rpmbuild) --rebuild $(RPM-USE-TMP-DIRS) $($(1).srpm)
569 $(call handle_devel_rpms_post,$(1))
570 @(echo -n "XXXXXXXXXXXXXXX -- END RPM $(1) " ; date)
571 # for manual use only - in case we need to investigate the results of an rpmbuild
572 $(1)-compile: $($(1).srpm)
574 @(echo -n "XXXXXXXXXXXXXXX -- BEG compile $(1) " ; date)
575 $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPEND-FILES)), $(createrepo) , )
576 $(call handle_devel_rpms_pre,$(1))
577 $($(1).rpmbuild) --recompile $(RPM-USE-TMP-DIRS) $($(1).srpm)
578 $(call handle_devel_rpms_post,$(1))
579 @(echo -n "XXXXXXXXXXXXXXX -- END compile $(1) " ; date)
583 $(foreach package,$(ALL),$(eval $(call target_binary_rpm,$(package))))
585 # e.g. make proper -> does propers rpms
586 # usage shorthand_target package
587 define target_shorthand
590 $(1)-spec: $($(1)-SPEC)
594 $(1)-tarball: $($(1).tarballs)
597 $(1)-source: $($(1).source)
598 $(1)-rpms: $($(1).rpms)
600 $(1)-srpm: $($(1).srpm)
604 $(foreach package,$(ALL),$(eval $(call target_shorthand,$(package))))
606 ### file dependencies
607 define package_depends_on_file
612 define target_dependfiles
613 $(foreach file,$($(1)-DEPEND-FILES),$(eval $(call package_depends_on_file,$(1),$(file))))
616 $(foreach package,$(ALL),$(eval $(call target_dependfiles,$(package))))
618 ### package dependencies
619 define package_depends_on_package
622 $($(1).srpm):$($(2).rpms)
625 define target_depends
626 $(foreach package,$($(1)-DEPEND-PACKAGES) $($(1).depend-devel-packages),$(eval $(call package_depends_on_package,$(1),$(package))))
629 $(foreach package,$(ALL),$(eval $(call target_depends,$(package))))
632 # usage: target_clean package
635 $(foreach module,$($(1)-MODULES),rm -rf MODULES/$(module);)
636 .PHONY: $(1)-clean-modules
637 CLEANS += $(1)-clean-modules
639 rm -rf $($(1).source)
640 .PHONY: $(1)-clean-source
641 CLEANS += $(1)-clean-source
643 rm -rf $($(1).tarballs)
644 .PHONY: $(1)-clean-tarball
645 CLEANS += $(1)-clean-tarball
647 rm -rf BUILD/$(notdir $($(1).source))
648 CLEANS += $(1)-clean-build
651 .PHONY: $(1)-clean-rpms
652 CLEANS += $(1)-clean-rpms
655 .PHONY: $(1)-clean-srpm
656 CLEANS += $(1)-clean-srpm
657 $(1)-codeclean: $(1)-clean-source $(1)-clean-tarball $(1)-clean-build $(1)-clean-rpms $(1)-clean-srpm
658 $(1)-clean: $(1)-clean-modules $(1)-codeclean
659 .PHONY: $(1)-codeclean $(1)-clean
661 rm -rf $($(1).specpath)
662 .PHONY: $(1)-clean-spec
665 .PHONY: $(1)-clean-make
666 $(1)-distclean: $(1)-distclean1 $(1)-distclean2
667 $(1)-distclean1: $(1)-clean-spec $(1)-clean-make
668 $(1)-distclean2: $(1)-clean
669 .PHONY: $(1)-distclean $(1)-distclean1 $(1)-distclean2
672 $(foreach package,$(ALL),$(eval $(call target_clean,$(package))))
680 @echo Available clean targets
683 ### brute force clean
685 rm -rf savedpldistro.mk .rpmmacros spec2make header.spec SPECS MAKE $(DISTCLEANS)
687 rm -rf MODULES SOURCES BUILD BUILDROOT RPMS SRPMS tmp
688 distclean: distclean1 distclean2
689 .PHONY: distclean1 distclean2 distclean
692 -$(RPM-UNINSTALL-DEVEL) $(ALL-DEVEL-RPMS)
695 # gather build information for the 'About' page
696 # when run from crontab, INIT_CWD not properly set (says /root ..)
697 # so, the nightly build passes BASE here
698 # also store BASE in .base for any post-processing purposes
700 @echo 'Creating myplc-release'
702 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx build info" >> $@
703 $(MAKE) --no-print-directory version-build >> $@
704 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx svn info" >> $@
705 $(MAKE) --no-print-directory version-tags >> $@
706 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx rpm info" >> $@
707 $(MAKE) --no-print-directory version-rpms >> $@
708 @echo $(BASE) > .base
711 @echo -n 'Build build-date: ' ; date '+%Y.%m.%d'
712 @echo -n 'Build build-time: ' ; date '+%H:%M-%Z'
713 @echo -n 'Build build-hostname: ' ; hostname
714 @echo "Build build-base: $(BASE)"
715 @echo "Build planetlab-distro: $(PLDISTRO)"
716 @echo "Build planetlab-tags: $(PLDISTROTAGS)"
717 @echo -n 'Build planetlab-tagsid: ' ; fgrep '$$''Id' $(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 git:$(module):$($(module)-BRANCH); , \
778 echo git:$(module); ), \
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
789 @echo "********** Run make in two stages:"
791 @echo "make stage1=true PLDISTRO=onelab"
792 @echo " -> extracts all spec files in SPECS/ and mk files in MAKE/"
793 @echo " as well as save PLDISTRO for subsequent runs"
795 @echo "********** Then you can use the following targets"
797 @echo " rebuilds everything"
798 @echo 'make util-vserver'
799 @echo " makes the RPMS related to util-vserver"
800 @echo " equivalent to 'make util-vserver-rpms'"
802 @echo "********** Or, vertically - step-by-step for a given package"
803 @echo 'make util-vserver-source'
804 @echo " creates source link in SOURCES/util-vserver-<version>"
805 @echo 'make util-vserver-tarball'
806 @echo " creates source tarball in SOURCES/util-vserver-<version>.<tarextension>"
807 @echo 'make util-vserver-srpm'
808 @echo " build source rpm in SRPMS/"
809 @echo 'make util-vserver-rpms'
810 @echo " build rpm(s) in RPMS/"
812 @echo "********** Or, horizontally, reach a step for all known packages"
814 @echo 'make tarballs'
818 @echo "********** Manual targets"
819 @echo "make package-compile"
820 @echo " The regular process uses rpmbuild --rebuild, that performs"
821 @echo " a compilation directory cleanup upon completion. If you need to investigate"
822 @echo " the intermediate compilation directory, use the -compile targets"
823 @echo "********** Cleaning examples"
825 @echo " removes the files made by make"
826 @echo "make distclean"
827 @echo " brute-force cleaning, removes entire directories - requires a new stage1"
828 @echo "make develclean"
829 @echo " rpm-uninstalls all devel packages installed during build"
831 @echo "make iptables-distclean"
832 @echo " deep clean for a given package"
833 @echo "make iptables-codeclean"
834 @echo " run this if you've made a local/manual change in the MODULES area for iptables"
836 @echo "make util-vserver-clean"
837 @echo " removes codebase, source, tarball, build, rpm and srpm for util-vserver"
838 @echo "make util-vserver-clean-modules"
839 @echo " and so on for source, tarball, build, rpm and srpm"
841 @echo "********** Info examples"
843 @echo " Displays the value of a given variable (here ALL)"
844 @echo " with only a single plus sign only the value is displayed"
846 @echo " is equivalent to make packages modules branches"
847 @echo " provides various info on these objects"
848 @echo "make ulogd-pkginfo"
849 @echo " Displays know attributes of a package"
850 @echo "make kernel-devel-rpminfo"
851 @echo " Displays know attributes of an rpm"
852 @echo "make stage1=true PLDISTROTAGS=planetlab-tags-4.2.mk packages modules branches module-tools"
853 @echo " Lists mentioned items - module-tools is used in modules.update"
855 @echo "********** Known pakages are"
858 #################### convenience, for debugging only
859 # make +foo : prints the value of $(foo)
860 # make ++foo : idem but verbose, i.e. foo=$(foo)
861 ++%: varname=$(subst +,,$@)
863 @echo "$(varname)=$($(varname))"
864 +%: varname=$(subst +,,$@)
866 @echo "$($(varname))"