8361e6c4866e1e95cb1ac7f5657833a1c0b48dd5
[multipath-tools/.git] / Makefile.inc
1 #
2 # Copyright (C) 2004 Christophe Varoqui, <christophe.varoqui@opensvc.com>
3 #
4
5 #
6 # Allow to force some libraries to be used statically. (Uncomment one of the
7 # following lines or define the values when calling make.)
8 #
9 # WITH_LOCAL_LIBDM      = 1
10 # WITH_LOCAL_LIBSYSFS   = 1
11 #
12 # Uncomment to disable RADOS support (e.g. if rados headers are missing).
13 # ENABLE_RADOS = 0
14 #
15 # Uncomment to disable libdmmp support
16 # ENABLE_LIBDMMP = 0
17
18 ifeq ($(TOPDIR),)
19         TOPDIR  = ..
20 endif
21
22 ifndef LIB
23         ifeq ($(shell test -d /lib64 && echo 1),1)
24                 LIB=lib64
25         else
26                 LIB=lib
27         endif
28 endif
29
30 ifndef RUN
31         ifeq ($(shell test -L /var/run -o ! -d /var/run && echo 1),1)
32                 RUN=run
33         else
34                 RUN=var/run
35         endif
36 endif
37
38 ifndef SYSTEMD
39         ifeq ($(shell systemctl --version > /dev/null 2>&1 && echo 1), 1)
40                 SYSTEMD = $(shell systemctl --version 2> /dev/null |  sed -n 's/systemd \([0-9]*\)/\1/p')
41         endif
42 endif
43
44 ifndef SYSTEMDPATH
45         SYSTEMDPATH=usr/lib
46 endif
47
48 prefix          =
49 exec_prefix     = $(prefix)
50 bindir          = $(exec_prefix)/sbin
51 libudevdir      = $(prefix)/$(SYSTEMDPATH)/udev
52 udevrulesdir    = $(libudevdir)/rules.d
53 multipathdir    = $(TOPDIR)/libmultipath
54 man8dir         = $(prefix)/usr/share/man/man8
55 man5dir         = $(prefix)/usr/share/man/man5
56 man3dir         = $(prefix)/usr/share/man/man3
57 syslibdir       = $(prefix)/$(LIB)
58 libdir          = $(prefix)/$(LIB)/multipath
59 unitdir         = $(prefix)/$(SYSTEMDPATH)/systemd/system
60 mpathpersistdir = $(TOPDIR)/libmpathpersist
61 mpathcmddir     = $(TOPDIR)/libmpathcmd
62 thirdpartydir   = $(TOPDIR)/third-party
63 libdmmpdir      = $(TOPDIR)/libdmmp
64 includedir      = $(prefix)/usr/include
65 pkgconfdir      = $(prefix)/$(LIB)/pkgconfig
66
67 GZIP            = gzip -9 -c
68 RM              = rm -f
69 LN              = ln -sf
70 INSTALL_PROGRAM = install
71
72 OPTFLAGS        = -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int \
73                   -Werror=implicit-function-declaration -Werror=format-security \
74                   -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered \
75                   -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong \
76                   --param=ssp-buffer-size=4
77
78 CFLAGS          = $(OPTFLAGS) -fPIC -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\"
79 SHARED_FLAGS    = -shared
80
81 # Check whether a function with name $1 has been declared in header file $2.
82 check_func =                                                                   \
83     $(shell                                                                    \
84         if grep -Eq "^[^[:blank:]]+[[:blank:]]+$1[[:blank:]]*(.*)*" "$2"; then \
85            found=1;                                                            \
86            status="yes";                                                       \
87         else                                                                   \
88            found=0;                                                            \
89            status="no";                                                        \
90         fi;                                                                    \
91         echo 1>&2 "Checking for $1 in $2 ... $$status";                        \
92         echo "$$found"                                                         \
93     )
94
95 %.o:    %.c
96         $(CC) $(CFLAGS) -c -o $@ $<