[build] be smarter at guessing BUILDDIRS
[multipath-tools/.git] / Makefile
1 # Makefile
2 #
3 # Copyright (C) 2003 Christophe Varoqui, <christophe.varoqui@free.fr>
4
5 BUILD = glibc
6
7 #
8 # Try to supply the linux kernel headers.
9 #
10 ifeq    ($(KRNLSRC),)
11 KRNLLIB = /lib/modules/$(shell uname -r)
12 ifeq    ($(shell test -r $(KRNLLIB)/source && echo 1),1)
13 KRNLSRC = $(KRNLLIB)/source
14 KRNLOBJ = $(KRNLLIB)/build
15 else
16 KRNLSRC = $(KRNLLIB)/build
17 KRNLOBJ = $(KRNLLIB)/build
18 endif
19 endif
20 export KRNLSRC
21 export KRNLOBJ
22
23 BUILDDIRS = $(shell find . -name Makefile -mindepth 2 -exec dirname {} \;)
24
25 VERSION = $(shell basename ${PWD} | cut -d'-' -f3)
26
27 all: recurse
28
29 recurse:
30         @for dir in $(BUILDDIRS); do \
31         $(MAKE) -C $$dir BUILD=$(BUILD) VERSION=$(VERSION) \
32                 KRNLSRC=$(KRNLSRC) KRNLOBJ=$(KRNLOBJ) || exit $?; \
33         done
34
35 recurse_clean:
36         @for dir in $(BUILDDIRS); do\
37         $(MAKE) -C $$dir clean || exit $?; \
38         done
39
40 recurse_install:
41         @for dir in $(BUILDDIRS); do\
42         $(MAKE) -C $$dir install || exit $?; \
43         done
44
45 recurse_uninstall:
46         @for dir in $(BUILDDIRS); do\
47         $(MAKE) -C $$dir uninstall || exit $?; \
48         done
49
50 clean:  recurse_clean
51         rm -f multipath-tools.spec
52         rm -rf rpms
53
54 install:        recurse_install
55
56 uninstall:      recurse_uninstall
57
58 release:
59         sed -e "s/__VERSION__/${VERSION}/" \
60         multipath-tools.spec.in > multipath-tools.spec
61
62 rpm: release
63         rpmbuild -bb multipath-tools.spec