Fix error
[platform/upstream/multipath-tools.git] / Makefile
1 #
2 # Copyright (C) 2003 Christophe Varoqui, <christophe.varoqui@opensvc.com>
3 #
4
5 TOPDIR := .
6
7 LIB_BUILDDIRS := \
8         libmpathcmd \
9         libmpathutil \
10         libmultipath \
11         libmpathpersist \
12         libmpathvalid
13
14 ifneq ($(ENABLE_LIBDMMP),0)
15 LIB_BUILDDIRS += \
16         libdmmp
17 endif
18
19 BUILDDIRS := $(LIB_BUILDDIRS) \
20         libmultipath/prioritizers \
21         libmultipath/checkers \
22         libmultipath/foreign \
23         multipath \
24         multipathd \
25         mpathpersist \
26         kpartx
27
28
29 BUILDDIRS.clean := $(BUILDDIRS:=.clean) tests.clean
30
31 .PHONY: $(BUILDDIRS)
32
33 all:    $(BUILDDIRS)
34
35 config.mk libmultipath/autoconfig.h:
36         @$(MAKE) -f create-config.mk
37 ifeq ($(V),1)
38         @echo ==== config.mk ====
39         @cat config.mk
40         @echo ==== autoconfig.h ====
41         @cat libmultipath/autoconfig.h
42 endif
43
44 $(BUILDDIRS):   config.mk
45         @$(MAKE) -C $@
46
47 $(LIB_BUILDDIRS:=.abi): $(LIB_BUILDDIRS)
48         @$(MAKE) -C ${@:.abi=} abi
49
50 # Create formal representation of the ABI
51 # Useful for verifying ABI compatibility
52 # Requires abidw from the abigail suite (https://sourceware.org/libabigail/)
53 .PHONY: abi
54 abi:    $(LIB_BUILDDIRS:=.abi)
55         @echo creating abi
56         @mkdir -p $@
57         $(Q)ln -ft $@ $(LIB_BUILDDIRS:=/*.abi)
58
59 abi.tar.gz:     abi
60         $(Q)tar cfz $@ abi
61
62 # Check the ABI against a reference.
63 # This requires the ABI from a previous run to be present
64 # in the directory "reference-abi"
65 # Requires abidiff from the abigail suite
66 abi-test:       abi reference-abi $(wildcard abi/*.abi)
67         @err=0; \
68         for lib in abi/*.abi; do \
69             diff=$$(abidiff --redundant "reference-$$lib" "$$lib") || { \
70                 err=1; \
71                 echo "==== ABI differences in for $$lib ===="; \
72                 echo "$$diff"; \
73             }; \
74         done >$@; \
75         if [ $$err -eq 0 ]; then \
76             echo "*** OK, ABI unchanged ***"; \
77         else \
78             echo "*** WARNING: ABI has changed, see file $@ ***"; \
79         fi; \
80         [ $$err -eq 0 ]
81
82 # Create compile_commands.json, useful for using clangd with an IDE
83 # Requires bear (https://github.com/rizsotto/Bear)
84 compile_commands.json: Makefile Makefile.inc $(BUILDDIRS:=/Makefile)
85         $(Q)$(MAKE) clean
86         $(Q)bear -- $(MAKE)
87
88 libmpathutil libdmmp: libmpathcmd
89 libmultipath: libmpathutil
90 libmpathpersist libmpathvalid multipath multipathd: libmultipath
91 libmultipath/prioritizers libmultipath/checkers libmultipath/foreign: libmultipath
92 mpathpersist multipathd:  libmpathpersist
93
94 libmultipath/checkers.install \
95         libmultipath/prioritizers.install \
96         libmultipath/foreign.install: libmultipath.install
97
98 %.clean:
99         @$(MAKE) -C ${@:.clean=} clean
100
101 %.install:      %
102         @$(MAKE) -C ${@:.install=} install
103
104 $(BUILDDIRS:=.uninstall):
105         @$(MAKE) -C ${@:.uninstall=} uninstall
106
107 # If config.mk is missing, "make clean" in subdir either fails, or tries to
108 # build it. Both is undesirable. Avoid it by creating config.mk temporarily.
109 clean:
110         @touch config.mk
111         $(Q)$(MAKE) $(BUILDDIRS:=.clean) tests.clean || true
112         $(Q)$(RM) -r abi abi.tar.gz abi-test compile_commands.json config.mk
113
114 install: $(BUILDDIRS:=.install)
115 uninstall: $(BUILDDIRS:=.uninstall)
116
117 test-progs:     all
118         @$(MAKE) -C tests progs
119
120 test:   all
121         @$(MAKE) -C tests all
122
123 valgrind-test:  all
124         @$(MAKE) -C tests valgrind
125
126 .PHONY: TAGS
127 TAGS:
128         @etags -a libmultipath/*.c
129         @etags -a libmultipath/*.h
130         @etags -a multipathd/*.c
131         @etags -a multipathd/*.h