* Makefile mostly reverted to rev. 7084 - do not use srpm packages for now
[build.git] / Makefile
1 #
2 # Thierry Parmentelat - INRIA Sophia Antipolis 
3 #
4 ### $Id$
5
6 ####################
7 # invokation:
8 #
9 # (*) make stage1=true
10 #     this extracts all specfiles and computes .mk from specfiles
11 #     you need to specify PLDISTRO here if relevant - see below
12 # (*) make help
13 #     for more info on how to invoke this stuff
14 #
15 #################### (fedora) distributions
16 #
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 
21 #     
22 #################### (planetlab) distributions
23 #
24 # (*) the default distribution is called 'planetlab'
25 # (*) you may define an alternative distribution, e.g. onelab
26 # in this case you need to
27 # (*) create onelab.mk that defines your *packages* (see below)
28 # (*) create onelab-tags.mk that defines where to fetch your *modules*
29 # (*) create your main yumgroups.xml as groups/<distro>.xml
30 # (*) there are also various places where a set of modules are defined.
31 #     check for .lst files in the various modules that build root images
32 #     and mimick what's done for planetlab 
33 # (*) then you need to run 
34 #     make stage1=true PLDISTRO=onelab
35 #
36 #################### 
37 # This build deals with 2 kinds of objects
38
39 # (*) packages are named upon the RPM name; they are moslty lowercase
40 #     Add a package to ALL if you want it built as part of the default set.
41 # (*) modules are named after the subversion tree; as of this writing their names 
42 #     are mostly mixedcase like MyPLC or Vserverreference
43
44 #################### packages
45 # basics: how to build a package - you need/may define the following variables
46
47 # (*) package-MODULES
48 #     a package needs one or several modules to build. 
49 #     to this end, define 
50 # (*) package-SPEC
51 #     the package's specfile; this is relative to the FIRST module in package-MODULES
52 #     see 'codebase' below
53 #
54 # Optional:
55 #
56 # (*) package-SPECVARS
57 #     space-separated list of spec variable definitions, where you can reference make variable that relate to 
58 #     packages defined BEFORE the current one (note: you should use = - as opposed to := - to define these)
59 #     e.g. mydriver-SPECVARS = foo=$(kernel-rpm-release) 
60 #     would let you use the %release from the kernel's package when rpmbuild'ing mydriver - see automatic below
61 # (*) package-DEPENDS
62 #     a set of *packages* that this package depends on
63 # (*) package-DEPENDFILES
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-RPMFLAGS: Miscellaneous RPM flags
68 # (*) package-RPMBUILD: If not rpmbuild - mostly used for sudo'ing rpmbuild
69 #
70 #################### modules
71 # Required information about the various modules (set this in e.g. planetlab-tags.mk)
72 #
73 # (*) module-SVNPATH
74 #     the complete path where this module lies; 
75 #     you can specify the trunk or a given tag with this variable
76
77 # OR if the module is managed under cvs (will be obsoleted)
78
79 # (*) module-CVSROOT
80 # (*) module-TAG
81 #
82 #################### automatic variables
83 #
84 # the build defines the following make variables - these are extracted from spec files
85 # (*) package-TARBALL : from the Source<n>: declaration
86 #     example: kernel-i386-TARBALL = SOURCES/linux-2.6.20.tar.bz2
87 # (*) package-SOURCE : 
88 #     example: kernel-i386-SOURCE = SOURCES/linux-2.6.20
89 # (*) package-SRPM
90 #     example: kernel-i386-SRPM = SRPMS/kernel-2.6.20-1.2949.fc6.vs2.2.0.1.0.planetlab.src.rpm
91 # (*) package-RPM
92 #     example: kernel-i386-RPM = \
93 #       RPMS/i686/kernel-2.6.20-1.2949.fc6.vs2.2.0.1.0.planetlab.i686.rpm \
94 #       RPMS/i686/kernel-devel-2.6.20-1.2949.fc6.vs2.2.0.1.0.planetlab.i686.rpm \
95 #       RPMS/i686/kernel-vserver-2.6.20-1.2949.fc6.vs2.2.0.1.0.planetlab.i686.rpm \
96 #       RPMS/i686/kernel-debuginfo-2.6.20-1.2949.fc6.vs2.2.0.1.0.planetlab.i686.rpm
97 # (*) package-rpm-name
98 #     example: kernel-i386-rpm-name = kernel
99 # (*) package-rpm-release
100 #     example: kernel-i386-rpm-release = 1.2949.fc6.vs2.2.0.1.0.planetlab
101 # (*) package-version
102 #     example: kernel-i386-rpm-version = 2.6.20
103 # (*) package-subversion
104 #     example: myplc-rpm-subversion = 15
105 ####################
106
107 #
108 # Default values
109 #
110 HOSTARCH := $(shell uname -i)
111 DISTRO := $(shell ./getdistro.sh)
112 RELEASE := $(shell ./getrelease.sh)
113
114 #################### Makefile
115 # Default target
116 all:
117 .PHONY:all
118
119 ### default values
120 PLDISTRO := planetlab
121 RPMBUILD := rpmbuild
122 export CVS_RSH := ssh
123
124 ########## pldistro.mk holds PLDISTRO - it is generated at stage1 (see below)
125 ifeq "$(stage1)" ""
126 include pldistro.mk
127 endif
128
129 #################### include onelab.mk
130 # describes the set of components
131 PLDISTROCONTENTS := $(PLDISTRO).mk
132 include $(PLDISTROCONTENTS)
133
134 #################### include <pldistro>-tags.mk
135 # describes where to fetch components, and the related tags if using cvs
136 PLDISTROTAGS := $(PLDISTRO)-tags.mk
137 include $(PLDISTROTAGS)
138
139 ########## stage1 and stage2
140 # extract specs and compute .mk files by running 
141 # make stage1=true
142 # entering stage1, we compute all the spec files
143 # then we use stage2 to compute the .mk iteratively, 
144 # ensuring that the n-1 first makefiles are loaded when creating the n-th one
145 # when stage2 is set, it is supposed to be an index (starting at 1) in $(ALL)
146
147 ALLMKS := $(foreach package, $(ALL), MAKE/$(package).mk)
148
149 ### stage2 : need some arithmetic, see
150 # http://www.cmcrossroads.com/articles/ask-mr.-make/learning-gnu-make-functions-with-arithmetic.html
151 ifneq "$(stage2)" ""
152 # the first n packages
153 packages := $(wordlist 1,$(words $(stage2)),$(ALL))
154 # the n-th package
155 package := $(word $(words $(packages)),$(packages))
156 # the n-1 first packages
157 stage2_1 := $(wordlist 2,$(words $(stage2)),$(stage2))
158 previous := $(wordlist 1,$(words $(stage2_1)),$(ALL))
159 previousmks := $(foreach package,$(previous),MAKE/$(package).mk)
160 include $(previousmks)
161 all: verbose
162 verbose:
163         @echo "========== stage2 : $(package)"
164 #       @echo "stage2 : included .mk files : $(previousmks)"
165 all: $($(package)_specpath)
166 all: MAKE/$(package).mk
167 else
168 ### stage1
169 ifneq "$(stage1)" ""
170 all : verbose
171 verbose :
172         @echo "========== stage1"
173 all : spec2make
174 all : .rpmmacros
175 # specs and makes are done sequentially by stage2
176 all : stage2
177 stage2:
178         arg=""; for n in $(ALL) ; do arg="$$arg x"; $(MAKE) --no-print-directory stage2="$$arg"; done
179 ### regular make
180 else
181 ### once .mks are OK, you can run make normally
182 include $(ALLMKS)
183 #all : tarballs
184 #all : sources
185 #all : codebases
186 #all : rpms
187 #all : srpms
188 all: rpms
189 all: srpms
190 endif
191 endif
192
193 ####################
194 # gather build information for the 'About' page
195 SOURCES/myplc-release:
196         @echo 'Creating myplc-release'
197         mkdir -p SOURCES
198         rm -f $@
199         (echo -n 'Build bdate: ' ; date '+%Y.%m.%d') >> $@
200         (echo -n 'Build btime: ' ; date '+%H:%M') >> $@
201         (echo -n 'Build hostname: ' ; hostname) >> $@
202         (echo -n 'Build location: ' ; pwd) >> $@
203         (echo -n 'Build tags file: ' ; fgrep '$$''Id' $(PLDISTROTAGS)) >> $@
204         echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx modules versions info" >> $@
205         $(MAKE) --no-print-directory versions >> $@
206
207 ####################
208 # notes: 
209 # * to make configuration easier, we always use the first module's
210 # definitions (CVSROOT,TAG, or SVNPATH) to extract the spec file
211 # * for the same reason, in case cvs is used, the first module name is added to 
212 # $(package)-SPEC - otherwise the cvs modules have to define spec as 
213 # <module>/<module>.spec while svn modules just define it as <module>.spec
214 #
215 define stage1_variables
216 $(1)_spec = $(notdir $($(1)-SPEC))
217 $(1)_specpath = SPECS/$(notdir $($(1)-SPEC))
218 $(1)_module = $(firstword $($(1)-MODULES))
219 endef
220
221 $(foreach package, $(ALL), $(eval $(call stage1_variables,$(package))))
222
223 #
224 # for each package, compute whether we need to set date (i.e. whether we use the trunk)
225 # the myplc package is forced to have a date, because it is more convenient
226 # (we cannot bump its number everytime something changes in the system)
227
228 define package_hasdate
229 $(1)_hasdate = $(if $(subst myplc,,$(1)), \
230                   $(if $($(1)-SVNPATH),\
231                      $(if $(findstring /trunk,$($(1)-SVNPATH)),yes,),\
232                      $(if $(findstring HEAD,$($(1)-TAG)),yes,)), \
233                 yes)
234 endef
235
236 $(foreach package, $(ALL), $(eval $(call package_hasdate,$(package))))
237
238 ### extract spec file from scm
239 # usage: extract_spec_file package 
240 # see early releases for comments on other possible implementations
241 # cannot use variables in such rules, we need to inline everything, sigh
242 define target_spec
243 $($(1)_specpath):
244         mkdir -p SPECS
245         (echo -n "# Generated by planetlab build from $($(1)-SPEC) on " ; date) > $($(1)_specpath)
246         echo "%define distroname $(DISTRO)" >> $($(1)_specpath)
247         echo "%define distrorelease $(RELEASE)" >> $($(1)_specpath)
248         echo "%define pldistro $(PLDISTRO)" >> $($(1)_specpath)
249         $(if $($(1)_hasdate),echo "%define date $(shell date +%Y.%m.%d)" >> $($(1)_specpath),)
250         echo "# included from codebase specfile" >> $($(1)_specpath)
251         $(if $($(1)-SPECVARS), \
252           $(foreach line,$($(1)-SPECVARS), \
253             echo "%define" $(word 1,$(subst =, ,$(line))) "$(word 2,$(subst =, ,$(line)))" >> $($(1)_specpath) ;))
254         $(if $($($(1)_module)-SVNPATH),\
255           svn cat $($($(1)_module)-SVNPATH)/$($(1)-SPEC) >> $($(1)_specpath),\
256           cvs -d $($($(1)_module)-CVSROOT) checkout \
257               -r $($($(1)_module)-TAG) \
258               -p $($(1)_module)/$($(1)-SPEC) >> $($(1)_specpath))
259         @if [ -z $($(1)_specpath) ] ; then rm $($(1)_specpath) ; exit 1 ; fi
260 endef
261
262 $(foreach package,$(ALL),$(eval $(call target_spec,$(package))))
263
264 ### this utility allows to extract various info from a spec file
265 ### and to define them in makefiles
266 spec2make: spec2make.c
267         $(CC) -g -Wall $< -o $@ -lrpm -lrpmbuild
268
269 # Base rpmbuild in the current directory
270 # trying a longer topdir 
271 # http://forums.fedoraforum.org/showthread.php?t=39625
272 # and more specifically post#6
273 # hard-wired for now 
274 export HOME := /building
275 .rpmmacros:
276         rm -f /building ; ln -s /build /building
277         rm -f $@ 
278         echo "%_topdir $(HOME)" >> $@
279         echo "%_tmppath $(HOME)/tmp" >> $@
280         echo "%_netsharedpath /proc:/dev/pts" >> $@
281         echo "%_install_langs C:de:en:es:fr" >> $@
282
283 ### run spec2make on the spec file and include the result
284 # usage: spec2make package
285 define target_mk
286 MAKE/$(1).mk: $($(1)_specpath) spec2make .rpmmacros
287         mkdir -p MAKE
288         ./spec2make $($(1)-RPMFLAGS) $($(1)_specpath) $(1) > MAKE/$(1).mk
289         @if [ -z MAKE/$(1).mk ] ; then rm MAKE/$(1).mk ; exit 1 ; fi
290 endef
291
292 $(foreach package,$(ALL),$(eval $(call target_mk,$(package))))
293
294 # stores PLDISTRO in a file
295 # this is done at stage1. later run wont get confused
296 pldistro.mk:
297         echo "PLDISTRO:=$(PLDISTRO)" > $@
298         echo "PLDISTROTAGS:=$(PLDISTROTAGS)" >> $@
299
300 savepldistro: pldistro.mk
301 .PHONY: savepldistro
302
303 # always refresh this
304 all: savepldistro
305
306 ####################
307 ### pack sources into tarballs
308 ALLTARBALLS:= $(foreach package, $(ALL), $($(package)-TARBALL))
309 tarballs: $(ALLTARBALLS)
310         @echo $(words $(ALLTARBALLS)) source tarballs OK
311 .PHONY: tarballs
312
313 SOURCES/%.tar.bz2: SOURCES/%
314         tar chpjf $@ -C SOURCES $*
315
316 SOURCES/%.tar.gz: SOURCES/%
317         tar chpzf $@ -C SOURCES $*
318
319 SOURCES/%.tgz: SOURCES/%
320         tar chpzf $@ -C SOURCES $*
321
322 ##
323 URLS/%: url=$(subst @colon@,:,$(subst @slash@,/,$(notdir $@)))
324 URLS/%: basename=$(notdir $(url))
325 URLS/%: 
326         echo curl $(url) -o SOURCES/$(basename)
327         touch $@
328
329 ### the directory SOURCES/<package>-<version> is made 
330 # with a copy -rl from CODEBASES/<package>
331 # the former is $(package-SOURCE) and the latter is $(package-CODEBASE)
332 ALLSOURCES:=$(foreach package, $(ALL), $($(package)-SOURCE))
333 # so that make does not use the rule below directly for creating the tarball files
334 .SECONDARY: $(ALLSOURCES)
335
336 sources: $(ALLSOURCES)
337         @echo $(words $(ALLSOURCES)) versioned source trees OK
338 .PHONY: sources
339
340 define target_link_codebase_sources
341 $($(1)-SOURCE): $($(1)-CODEBASE) ; mkdir -p SOURCES ; cp -rl $($(1)-CODEBASE) $($(1)-SOURCE)
342 endef
343
344 $(foreach package,$(ALL),$(eval $(call target_link_codebase_sources,$(package))))
345
346 ### codebase extraction
347 ALLCODEBASES:=$(foreach package, $(ALL), $($(package)-CODEBASE))
348 # so that make does not use the rule below directly for creating the tarball files
349 .SECONDARY: $(ALLCODEBASES)
350
351 codebases : $(ALLCODEBASES)
352         @echo $(words $(ALLCODEBASES)) codebase OK
353 .PHONY: codebases
354
355 ### extract codebase 
356 # usage: extract_single_module package 
357 define extract_single_module
358         mkdir -p CODEBASES
359         $(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))
360 endef
361
362 # usage: extract_multi_module package 
363 define extract_multi_module
364         mkdir -p CODEBASES/$(1) && cd CODEBASES/$(1) && (\
365         $(foreach m,$($(1)-MODULES), $(if $($(m)-SVNPATH), svn export $($(m)-SVNPATH) $(m);, cvs -d $($(m)-CVSROOT) export -r $($(m)-TAG) $(m);)))
366 endef
367
368 CODEBASES/%: package=$(notdir $@)
369 CODEBASES/%: multi_module=$(word 2,$($(package)-MODULES))
370 CODEBASES/%: 
371         @(echo -n "XXXXXXXXXXXXXXX -- BEG CODEBASE $(package) : $@ " ; date)
372         $(if $(multi_module),\
373           $(call extract_multi_module,$(package)),\
374           $(call extract_single_module,$(package)))
375         @(echo -n "XXXXXXXXXXXXXXX -- END CODEBASE $(package) : $@ " ; date)
376
377 ### rpmbuild invokation
378 ALLRPMS:=$(foreach package,$(ALL),$($(package)-RPM))
379 rpms: $(ALLRPMS)
380         @echo $(words $(ALLRPMS)) binary rpms OK
381 .PHONY: rpms
382
383 # usage: build_binary_rpm package
384 # xxx hacky - invoke createrepo if DEPENDFILES mentions RPMS/yumgroups.xml
385 define target_binary_rpm 
386 $($(1)-RPM): $($(1)_specpath) $($(1)-TARBALL) .rpmmacros
387         mkdir -p BUILD RPMS tmp
388         @(echo -n "XXXXXXXXXXXXXXX -- BEG RPM $(1) " ; date)
389         $(if $(findstring RPMS/yumgroups.xml,$($(1)-DEPENDFILES)), createrepo --quiet -g yumgroups.xml RPMS/ , )
390         $(if $($(1)-RPMBUILD),\
391           $($(1)-RPMBUILD) $($(1)-RPMFLAGS) -bb $($(1)_specpath), \
392           $(RPMBUILD)  $($(1)-RPMFLAGS) -bb $($(1)_specpath))
393         @(echo -n "XXXXXXXXXXXXXXX -- END RPM $(1) " ; date)
394 endef
395
396 $(foreach package,$(ALL),$(eval $(call target_binary_rpm,$(package))))
397
398 ### source rpms
399 ALLSRPMS:=$(foreach package,$(ALL),$($(package)-SRPM))
400 srpms: $(ALLSRPMS)
401         @echo $(words $(ALLSRPMS)) source rpms OK
402 .PHONY: srpms
403
404 # usage: target_source_rpm package
405 # select upon the package name, whether it contains srpm or not
406 define target_source_rpm 
407 ifeq "$(subst srpm,,$(1))" "$(1)"
408 $($(1)-SRPM): $($(1)_specpath) .rpmmacros $($(1)-TARBALL) 
409         mkdir -p BUILD SRPMS tmp
410         @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) " ; date)
411         $(if $($(1)-RPMBUILD),\
412           $($(1)-RPMBUILD) $($(1)-RPMFLAGS) -bs $($(1)_specpath),
413           $(RPMBUILD) $($(1)-RPMFLAGS) -bs $($(1)_specpath))    
414         @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
415 else
416 $($(1)-SRPM): $($(1)_specpath) .rpmmacros $($(1)-CODEBASE)
417         mkdir -p BUILD SRPMS tmp
418         @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) (using make srpm) " ; date)
419         make -C $($(1)-CODEBASE) srpm && \
420            rm -f SRPMS/$(notdir $($(1)-SRPM)) && \
421            ln $($(1)-CODEBASE)/$(notdir $($(1)-SRPM)) SRPMS/$(notdir $($(1)-SRPM)) 
422         @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
423 endif
424 endef
425
426 $(foreach package,$(ALL),$(eval $(call target_source_rpm,$(package))))
427
428 ### RPMS/yumgroups.xml
429 ifndef YUMGROUPS
430 YUMGROUPS := groups/$(PLDISTRO).xml
431 endif
432 RPMS/yumgroups.xml: $(YUMGROUPS)
433         install -D -m 644 $(YUMGROUPS) $@
434
435 ### shorthand target
436 # e.g. make proper -> does propers rpms
437 # usage shorthand_target package
438 define target_shorthand 
439 $(1): $($(package)-RPM)
440 .PHONY: $(1)
441 $(1)-spec: $($(package)-SPEC)
442 .PHONY: $(1)-spec
443 $(1)-mk: $($(package)-MK)
444 .PHONY: $(1)-mk
445 $(1)-tarball: $($(package)-TARBALL)
446 .PHONY: $(1)-tarball
447 $(1)-codebase: $($(package)-CODEBASE)
448 .PHONY: $(1)-source
449 $(1)-source: $($(package)-SOURCE)
450 .PHONY: $(1)-codebase
451 $(1)-rpm: $($(package)-RPM)
452 .PHONY: $(1)-rpm
453 $(1)-srpm: $($(package)-SRPM)
454 .PHONY: $(1)-srpm
455 endef
456
457 $(foreach package,$(ALL),$(eval $(call target_shorthand,$(package))))
458
459 ### dependencies
460 define package_depends_on_file
461 $(1):$(2)
462 $($(1)-RPM):$(2)
463 endef
464
465 define target_dependfiles
466 $(foreach file,$($(1)-DEPENDFILES),$(eval $(call package_depends_on_file,$(1),$(file))))
467 endef
468
469 define package_depends_on_package
470 $(1):$(2)
471 $(1):$($(2)-RPM)
472 $($(1)-RPM):$($(2)-RPM)
473 endef
474
475 define target_depends
476 $(foreach package,$($(1)-DEPENDS),$(eval $(call package_depends_on_package,$(1),$(package))))
477 endef
478
479 $(foreach package,$(ALL),$(eval $(call target_depends,$(package))))
480 $(foreach package,$(ALL),$(eval $(call target_dependfiles,$(package))))
481
482
483 ### clean target
484 # usage: target_clean package
485 define target_clean
486 $(1)-clean-codebase:
487         rm -rf $($(1)-CODEBASE)
488 .PHONY: $(1)-clean-codebase
489 CLEANS += $(1)-clean-codebase
490 $(1)-clean-source:
491         rm -rf $($(1)-SOURCE)
492 .PHONY: $(1)-clean-source
493 CLEANS += $(1)-clean-source
494 $(1)-clean-tarball:
495         rm -rf $($(1)-TARBALL)
496 .PHONY: $(1)-clean-tarball
497 CLEANS += $(1)-clean-tarball
498 $(1)-clean-build:
499         rm -rf BUILD/$(notdir $($(1)-SOURCE))
500 CLEANS += $(1)-clean-build
501 $(1)-clean-rpm:
502         rm -rf $($(1)-RPM)
503 .PHONY: $(1)-clean-rpm
504 CLEANS += $(1)-clean-rpm
505 $(1)-clean-srpm:
506         rm -rf $($(1)-SRPM)
507 .PHONY: $(1)-clean-srpm
508 CLEANS += $(1)-clean-srpm
509 $(1)-clean: $(1)-clean-codebase $(1)-clean-source $(1)-clean-tarball $(1)-clean-build $(1)-clean-rpm $(1)-clean-srpm
510 .PHONY: $(1)-clean
511 endef
512
513 $(foreach package,$(ALL),$(eval $(call target_clean,$(package))))
514
515 ### clean precisely
516 clean:
517         $(MAKE) $(CLEANS)
518 .PHONY: clean
519
520 clean-help:
521         @echo Available clean targets
522         @echo $(CLEANS)
523
524 ### brute force clean
525 distclean1:
526         rm -rf pldistro.mk .rpmmacros spec2make SPECS MAKE 
527 distclean2:
528         rm -rf CODEBASES SOURCES BUILD RPMS SRPMS tmp
529 distclean: distclean1 distclean2
530 .PHONY: distclean1 distclean2 distclean
531
532 # xxx tmp - I cannot use this on my mac for local testing
533 ISMACOS=$(findstring Darwin,$(shell uname))
534 ifneq "$(ISMACOS)" ""
535 #################### produce reliable version information
536 # for a given module
537 VFORMAT="%30s := %s\n"
538 define print_version
539 $(1)-version:
540         @$(if $($(1)-SVNPATH),\
541            printf $(VFORMAT) $(1)-SVNPATH "$($(1)-SVNPATH)",\
542            printf $(VFORMAT) $(1)-CVSROOT "$($(1)-CVSROOT)" ; printf $(VFORMAT) $(1)-TAG "$($(1)-TAG)")
543 endef
544
545 # compute all modules
546 ALL-MODULES :=
547 $(foreach package,$(ALL), $(eval ALL-MODULES+=$($(package)-MODULES)))
548 ALL-MODULES:=$(sort $(ALL-MODULES))
549
550 $(foreach module,$(ALL-MODULES), $(eval $(call print_version,$(module))))
551
552 versions: $(foreach module, $(ALL-MODULES), $(module)-version)
553 else
554 versions:
555         @echo "warning : the 'versions' target is not supported on macos"
556 endif
557
558 #################### include install Makefile
559 # the default is to use the distro-dependent install file
560 # however the main distro file can redefine PLDISTROINSTALL
561 ifndef PLDISTROINSTALL
562 PLDISTROINSTALL := $(PLDISTRO)-install.mk
563 endif
564 # only if present
565 -include $(PLDISTROINSTALL)
566
567 ####################
568 help:
569         @echo "Known pakages are"
570         @echo "  $(ALL)"
571         @echo "Run make in two stages:"
572         @echo ""
573         @echo "make stage1=true PLDISTRO=onelab"
574         @echo " -> extracts all spec files in SPECS/ and mk files in MAKE/"
575         @echo "    as well as save PLDISTRO for subsequent runs"
576         @echo ""
577         @echo "Then you can use the following targets"
578         @echo '$ make'
579         @echo "  rebuilds everything"
580         @echo '$ make util-vserver'
581         @echo "  makes the RPMS related to util-vserver"
582         @echo "  equivalent to 'make util-vserver-rpm'"
583         @echo ""
584         @echo "Or, vertically - step-by-step for a given package"
585         @echo '$ make util-vserver-codebase'
586         @echo "  performs codebase extraction in CODEBASES/util-vserver"
587         @echo '$ make util-vserver-source'
588         @echo "  creates source link in SOURCES/util-vserver-<version>"
589         @echo '$ make util-vserver-tarball'
590         @echo "  creates source tarball in SOURCES/util-vserver-<version>.<tarextension>"
591         @echo '$ make util-vserver-rpm'
592         @echo "  build rpm(s) in RPMS/"
593         @echo '$ make util-vserver-srpm'
594         @echo "  build source rpm in SRPMS/"
595         @echo ""
596         @echo "Or, horizontally, reach a step for all known packages"
597         @echo '$ make codebases'
598         @echo '$ make sources'
599         @echo '$ make tarballs'
600         @echo '$ make rpms'
601         @echo '$ make srpms'
602         @echo ""
603         @echo "Cleaning examples"
604         @echo "$ make clean"
605         @echo "  removes the files made by make"
606         @echo "$ make distclean"
607         @echo "  brute-force cleaning, removes entire directories - requires a new stage1"
608         @echo "$ make util-vserver-clean"
609         @echo "  removes codebase, source, tarball, build, rpm and srpm for util-vserver"
610         @echo "$ make util-vserver-clean-codebase"
611         @echo "  and so on for source, tarball, build, rpm and srpm"
612
613 #################### convenience, for debugging only
614 # make +foo : prints the value of $(foo)
615 # make ++foo : idem but verbose, i.e. foo=$(foo)
616 ++%: varname=$(subst +,,$@)
617 ++%:
618         @echo "$(varname)=$($(varname))"
619 +%: varname=$(subst +,,$@)
620 +%:
621         @echo "$($(varname))"