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