Removed one OFED installation test because on some distro's it triggers false complaints.
[mirror/scst/.git] / srpt / Makefile
1 #
2 # Makefile for ib_srpt.ko.
3 #
4
5 SCST_DIR := $(shell pwd)/../scst/src
6 SUBDIRS := $(shell pwd)
7
8 ifeq ($(KVER),)
9   ifeq ($(KDIR),)
10     KVER = $(shell uname -r)
11     KDIR ?= /lib/modules/$(KVER)/build
12   else
13     KVER = $$KERNELRELEASE
14   endif
15 else
16   KDIR ?= /lib/modules/$(KVER)/build
17 endif
18
19 # The file Modules.symvers has been renamed in the 2.6.18 kernel to
20 # Module.symvers. Find out which name to use by looking in $(KDIR).
21 MODULE_SYMVERS:=$(shell if [ -e $(KDIR)/Module.symvers ]; then \
22                        echo Module.symvers; else echo Modules.symvers; fi)
23
24 # Whether or not the OFED kernel modules have been installed.
25 OFED_KERNEL_IB_RPM_INSTALLED:=$(shell if rpm -q kernel-ib >/dev/null 2>&1; then echo true; else echo false; fi)
26
27 # Whether or not the OFED kernel-ib-devel RPM has been installed.
28 OFED_KERNEL_IB_DEVEL_RPM_INSTALLED:=$(shell if rpm -q kernel-ib-devel >/dev/null 2>&1; then echo true; else echo false; fi)
29
30 ifeq ($(OFED_KERNEL_IB_DEVEL_RPM_INSTALLED),true)
31 # Read OFED's config.mk, which contains the definition of the variable
32 # BACKPORT_INCLUDES.
33 include /usr/src/ofa_kernel/config.mk
34 endif
35
36 OFED_CFLAGS:=$(shell if $(OFED_KERNEL_IB_DEVEL_RPM_INSTALLED); then echo $(BACKPORT_INCLUDES) -I/usr/src/ofa_kernel/include; fi)
37
38 # Path of the OFED ib_srpt.ko kernel module.
39 OFED_SRPT_PATH:=/lib/modules/$(KVER)/updates/kernel/drivers/infiniband/ulp/srpt/ib_srpt.ko
40
41 # Whether or not the OFED ib_srpt.ko kernel module has been installed.
42 OFED_SRPT_INSTALLED:=$(shell if [ -e $(OFED_SRPT_PATH) ]; then echo true; else echo false; fi)
43
44
45 all: src/$(MODULE_SYMVERS)
46         $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/src \
47         EXTRA_PRE_CFLAGS="$(OFED_CFLAGS)" modules
48
49 install: all src/ib_srpt.ko
50         @eval `sed -n 's/#define UTS_RELEASE /KERNELRELEASE=/p' $(KDIR)/include/linux/version.h $(KDIR)/include/linux/utsrelease.h 2>/dev/null`; \
51         install -vD -m 644 src/ib_srpt.ko \
52         $(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/$(KVER)/extra/ib_srpt.ko
53         -/sbin/depmod -aq $(KVER)
54
55 src/Module.symvers src/Modules.symvers: $(SCST_DIR)/$(MODULE_SYMVERS)
56         if $(OFED_KERNEL_IB_RPM_INSTALLED); then                            \
57           if ! $(OFED_KERNEL_IB_DEVEL_RPM_INSTALLED); then                  \
58             echo "Error: the OFED package kernel-ib-devel has not yet been" \
59                  "installed.";                                              \
60             false;                                                          \
61           elif [ -e /lib/modules/$(KVER)/kernel/drivers/infiniband ]; then  \
62             echo "Error: OFED has not been installed correctly.";           \
63             false;                                                          \
64           elif $(OFED_SRPT_INSTALLED); then                                 \
65             echo "Error: OFED has been built with srpt=y in ofed.conf.";    \
66             echo "Rebuild OFED with srpt=n.";                               \
67             false;                                                          \
68           else                                                              \
69             (                                                               \
70               grep -v drivers/infiniband/ $<;                               \
71               cat /usr/src/ofa_kernel/Module.symvers                        \
72             ) >$@;                                                          \
73           fi                                                                \
74         else                                                                \
75           cp $< $@;                                                         \
76         fi
77
78 clean:
79         $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/src clean
80         rm -f src/Modules.symvers src/Module.symvers src/Module.markers \
81                 src/modules.order
82
83 extraclean: clean
84
85 .PHONY: all install clean extraclean