Merge branch 'master' of git://git.kernel.org/pub/scm/linux/storage/multipath-tools/
[platform/upstream/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         kpartx
29
30 ifeq   ($(MULTIPATH_VERSION),)
31 VERSION = $(shell basename ${PWD} | cut -d'-' -f3)
32 else
33 VERSION = $(MULTIPATH_VERSION)
34 endif
35
36 all: recurse
37
38 recurse:
39         @for dir in $(BUILDDIRS); do \
40         $(MAKE) -C $$dir BUILD=$(BUILD) VERSION=$(VERSION) \
41                 KRNLSRC=$(KRNLSRC) KRNLOBJ=$(KRNLOBJ) || exit $?; \
42         done
43
44 recurse_clean:
45         @for dir in $(BUILDDIRS); do \
46         $(MAKE) -C $$dir clean || exit $?; \
47         done
48
49 recurse_install:
50         @for dir in $(BUILDDIRS); do \
51         $(MAKE) -C $$dir install || exit $?; \
52         done
53
54 recurse_uninstall:
55         @for dir in $(BUILDDIRS); do \
56         $(MAKE) -C $$dir uninstall || exit $?; \
57         done
58
59 clean:  recurse_clean
60         rm -f multipath-tools.spec
61         rm -rf rpms
62
63 install:        recurse_install
64
65 uninstall:      recurse_uninstall
66
67 release:
68         sed -e "s/__VERSION__/${VERSION}/" \
69         multipath-tools.spec.in > multipath-tools.spec
70
71 rpm: release
72         rpmbuild -bb multipath-tools.spec