Imported Upstream version 0.6.1
[platform/upstream/multipath-tools.git] / Makefile
1 # Makefile
2 #
3 # Copyright (C) 2003 Christophe Varoqui, <christophe.varoqui@opensvc.com>
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         libmpathcmd \
24         libmultipath \
25         libmultipath/prioritizers \
26         libmultipath/checkers \
27         libmpathpersist \
28         multipath \
29         multipathd \
30         mpathpersist \
31         kpartx
32
33 ifeq   ($(MULTIPATH_VERSION),)
34 VERSION = $(shell basename ${PWD} | cut -d'-' -f3)
35 else
36 VERSION = $(MULTIPATH_VERSION)
37 endif
38
39 all: recurse
40
41 recurse:
42         @for dir in $(BUILDDIRS); do \
43         $(MAKE) -C $$dir BUILD=$(BUILD) VERSION=$(VERSION) \
44                 KRNLSRC=$(KRNLSRC) KRNLOBJ=$(KRNLOBJ) || exit $?; \
45         done
46
47 recurse_clean:
48         @for dir in $(BUILDDIRS); do \
49         $(MAKE) -C $$dir clean || exit $?; \
50         done
51
52 recurse_install:
53         @for dir in $(BUILDDIRS); do \
54         $(MAKE) -C $$dir install || exit $?; \
55         done
56
57 recurse_uninstall:
58         @for dir in $(BUILDDIRS); do \
59         $(MAKE) -C $$dir uninstall || exit $?; \
60         done
61
62 clean:  recurse_clean
63         rm -f multipath-tools.spec
64         rm -rf rpms
65
66 install:        recurse_install
67
68 uninstall:      recurse_uninstall
69
70 .PHONY: TAGS
71 TAGS:
72         etags -a libmultipath/*.c
73         etags -a libmultipath/*.h
74         etags -a multipathd/*.c
75         etags -a multipathd/*.h
76
77 release:
78         sed -e "s/__VERSION__/${VERSION}/" \
79         multipath-tools.spec.in > multipath-tools.spec
80
81 rpm: release
82         rpmbuild -bb multipath-tools.spec