2 # Makefile for ib_srpt.ko.
5 SCST_DIR := $(shell pwd)/../scst/src
6 SUBDIRS := $(shell pwd)
10 KVER = $(shell uname -r)
11 KDIR ?= /lib/modules/$(KVER)/build
13 KVER = $$KERNELRELEASE
16 KDIR ?= /lib/modules/$(KVER)/build
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)
24 # Whether or not the OFED kernel modules have been installed.
25 OFED_KERNEL_IB_RPM_INSTALLED:=$(shell if rpm -q kernel-ib 2>/dev/null | grep -q $$(uname -r | sed 's/-/_/g'); then echo true; else echo false; fi)
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 2>/dev/null | grep -q $$(uname -r | sed 's/-/_/g'); then echo true; else echo false; fi)
30 ifeq ($(OFED_KERNEL_IB_DEVEL_RPM_INSTALLED),true)
31 # Read OFED's config.mk, which contains the definition of the variable
33 include /usr/src/ofa_kernel/config.mk
36 OFED_CFLAGS:=$(shell if $(OFED_KERNEL_IB_DEVEL_RPM_INSTALLED); then echo $(BACKPORT_INCLUDES) -I/usr/src/ofa_kernel/include; fi)
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
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)
45 all: src/$(MODULE_SYMVERS)
46 $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/src \
47 PRE_CFLAGS="$(OFED_CFLAGS)" modules
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)
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" \
61 elif [ -e /lib/modules/$(KVER)/kernel/drivers/infiniband ]; then \
62 echo "Error: the distro-provided InfiniBand kernel drivers" \
63 "must be removed first."; \
65 elif $(OFED_SRPT_INSTALLED); then \
66 echo "Error: OFED has been built with srpt=y in ofed.conf."; \
67 echo "Rebuild OFED with srpt=n."; \
69 elif [ -e $(KDIR)/scripts/Makefile.lib ] \
70 && ! grep -wq '^c_flags .*PRE_CFLAGS' \
71 $(KDIR)/scripts/Makefile.lib \
72 && ! grep -wq '^LINUXINCLUDE .*PRE_CFLAGS' \
73 $(KDIR)/Makefile; then \
74 echo "Error: the kernel build system has not yet been patched.";\
77 echo " Building against OFED InfiniBand kernel headers."; \
79 grep -v drivers/infiniband/ $<; \
80 cat /usr/src/ofa_kernel/Module.symvers \
84 if $(OFED_KERNEL_IB_DEVEL_RPM_INSTALLED); then \
85 echo "Error: the OFED package kernel-ib has not yet been" \
89 echo " Building against non-OFED InfiniBand kernel headers."; \
95 $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/src clean
96 rm -f src/Modules.symvers src/Module.symvers src/Module.markers \
101 .PHONY: all install clean extraclean