be2net: backport fixes for RHEL 7.2
[~emulex/tmp/compat-rdma/.git] / makefile
1 PHONY += all kernel install_kernel install clean clean_kernel
2         
3 all:
4 .PHONY: $(PHONY)
5
6 .DELETE_ON_ERROR:
7
8 include ./configure.mk.kernel
9
10 export COMPAT_CONFIG=$(CWD)/compat.config
11 export COMPAT_AUTOCONF=$(CWD)/include/linux/compat_autoconf.h
12 export KLIB_BUILD
13 export KVERSION
14 export MAKE
15
16 -include $(COMPAT_CONFIG)
17
18 export CREL=$(shell cat $(CWD)/compat_version)
19 export CREL_PRE:=.compat_autoconf_
20 export CREL_CHECK:=$(CREL_PRE)$(CREL)
21 CFLAGS += \
22         -DCOMPAT_BASE="\"$(shell cat compat_base)\"" \
23         -DCOMPAT_BASE_TREE="\"$(shell cat compat_base_tree)\"" \
24         -DCOMPAT_BASE_TREE_VERSION="\"$(shell cat compat_base_tree_version)\"" \
25         -DCOMPAT_PROJECT="\"Compat-rdma\"" \
26         -DCOMPAT_VERSION="\"$(shell cat compat_version)\"" \
27
28 DEPMOD  = /sbin/depmod
29 INSTALL_MOD_DIR ?= $(shell test -f /etc/redhat-release && echo extra/ofa_kernel || echo updates)
30
31 ifeq ($(CONFIG_MEMTRACK),m)
32         export KERNEL_MEMTRACK_CFLAGS = -include $(CWD)/drivers/infiniband/debug/mtrack.h
33 else
34         export KERNEL_MEMTRACK_CFLAGS =
35 endif
36
37 export OPEN_ISCSI_MODULES = iscsi_tcp.ko libiscsi.ko scsi_transport_iscsi.ko
38
39 $(COMPAT_AUTOCONF): $(COMPAT_CONFIG)
40         +@$(CWD)/ofed_scripts/gen-compat-autoconf.sh $(COMPAT_CONFIG) > $(COMPAT_AUTOCONF)
41
42 $(COMPAT_CONFIG):
43         +@$(CWD)/ofed_scripts/gen-compat-config.sh > $(COMPAT_CONFIG)
44
45 configure.mk.kernel:
46         @echo Please run ./configure
47         @exit 1
48
49 all: kernel
50
51 install: install_kernel
52 install_kernel: install_modules
53
54 autoconf_h=$(shell /bin/ls -1 $(KSRC_OBJ)/include/*/autoconf.h 2> /dev/null | head -1)
55 kconfig_h=$(shell /bin/ls -1 $(KSRC)/include/*/kconfig.h 2> /dev/null | head -1)
56
57 ifneq ($(kconfig_h),)
58 KCONFIG_H = -include $(kconfig_h)
59 endif
60
61 V ?= 0
62
63 #########################
64 #       make kernel     #
65 #########################
66 #NB: The LINUXINCLUDE value comes from main kernel Makefile
67 #    with local directories prepended. This eventually affects
68 #    CPPFLAGS in the kernel Makefile
69 kernel: $(COMPAT_CONFIG) $(COMPAT_AUTOCONF)
70         @echo "Building kernel modules"
71         @echo "Kernel version: $(KVERSION)"
72         @echo "Modules directory: $(INSTALL_MOD_PATH)/$(MODULES_DIR)"
73         @echo "Kernel sources: $(KSRC_OBJ)"
74         env CWD=$(CWD) BACKPORT_INCLUDES=$(BACKPORT_INCLUDES) \
75                 $(MAKE) -C $(KSRC_OBJ) SUBDIRS="$(CWD)" \
76                 V=$(V) KBUILD_NOCMDDEP=1 $(WITH_MAKE_PARAMS) \
77                 CONFIG_MEMTRACK=$(CONFIG_MEMTRACK) \
78                 CONFIG_DEBUG_INFO=$(CONFIG_DEBUG_INFO) \
79                 CONFIG_INFINIBAND=$(CONFIG_INFINIBAND) \
80                 CONFIG_INFINIBAND_IPOIB=$(CONFIG_INFINIBAND_IPOIB) \
81                 CONFIG_INFINIBAND_IPOIB_CM=$(CONFIG_INFINIBAND_IPOIB_CM) \
82                 CONFIG_INFINIBAND_SDP=$(CONFIG_INFINIBAND_SDP) \
83                 CONFIG_INFINIBAND_SRP=$(CONFIG_INFINIBAND_SRP) \
84                 CONFIG_INFINIBAND_SRPT=$(CONFIG_INFINIBAND_SRPT) \
85                 CONFIG_SCSI_SRP_ATTRS=$(CONFIG_SCSI_SRP_ATTRS) \
86                 CONFIG_INFINIBAND_USER_MAD=$(CONFIG_INFINIBAND_USER_MAD) \
87                 CONFIG_INFINIBAND_USER_ACCESS=$(CONFIG_INFINIBAND_USER_ACCESS) \
88                 CONFIG_INFINIBAND_USER_MEM=$(CONFIG_INFINIBAND_USER_MEM) \
89                 CONFIG_INFINIBAND_ADDR_TRANS=$(CONFIG_INFINIBAND_ADDR_TRANS) \
90                 CONFIG_INFINIBAND_MTHCA=$(CONFIG_INFINIBAND_MTHCA) \
91                 CONFIG_INFINIBAND_IPOIB_DEBUG=$(CONFIG_INFINIBAND_IPOIB_DEBUG) \
92                 CONFIG_INFINIBAND_ISERT=$(CONFIG_INFINIBAND_ISERT) \
93                 CONFIG_INFINIBAND_ISER=$(CONFIG_INFINIBAND_ISER) \
94                 CONFIG_SCSI_ISCSI_ATTRS=$(CONFIG_SCSI_ISCSI_ATTRS) \
95                 CONFIG_ISCSI_TCP=$(CONFIG_ISCSI_TCP) \
96                 CONFIG_INFINIBAND_EHCA=$(CONFIG_INFINIBAND_EHCA) \
97                 CONFIG_INFINIBAND_EHCA_SCALING=$(CONFIG_INFINIBAND_EHCA_SCALING) \
98                 CONFIG_RDS=$(CONFIG_RDS) \
99                 CONFIG_RDS_RDMA=$(CONFIG_RDS_RDMA) \
100                 CONFIG_RDS_TCP=$(CONFIG_RDS_TCP) \
101                 CONFIG_RDS_DEBUG=$(CONFIG_RDS_DEBUG) \
102                 CONFIG_INFINIBAND_IPOIB_DEBUG_DATA=$(CONFIG_INFINIBAND_IPOIB_DEBUG_DATA) \
103                 CONFIG_INFINIBAND_SDP_SEND_ZCOPY=$(CONFIG_INFINIBAND_SDP_SEND_ZCOPY) \
104                 CONFIG_INFINIBAND_SDP_RECV_ZCOPY=$(CONFIG_INFINIBAND_SDP_RECV_ZCOPY) \
105                 CONFIG_INFINIBAND_SDP_DEBUG=$(CONFIG_INFINIBAND_SDP_DEBUG) \
106                 CONFIG_INFINIBAND_SDP_DEBUG_DATA=$(CONFIG_INFINIBAND_SDP_DEBUG_DATA) \
107                 CONFIG_INFINIBAND_IPATH=$(CONFIG_INFINIBAND_IPATH) \
108                 CONFIG_INFINIBAND_QIB=$(CONFIG_INFINIBAND_QIB) \
109                 CONFIG_INFINIBAND_MTHCA_DEBUG=$(CONFIG_INFINIBAND_MTHCA_DEBUG) \
110                 CONFIG_INFINIBAND_MADEYE=$(CONFIG_INFINIBAND_MADEYE) \
111                 CONFIG_INFINIBAND_QLGC_VNIC=$(CONFIG_INFINIBAND_QLGC_VNIC) \
112                 CONFIG_INFINIBAND_QLGC_VNIC_DEBUG=$(CONFIG_INFINIBAND_QLGC_VNIC_DEBUG) \
113                 CONFIG_INFINIBAND_QLGC_VNIC_STATS=$(CONFIG_INFINIBAND_QLGC_VNIC_STATS) \
114                 CONFIG_CHELSIO_T3=$(CONFIG_CHELSIO_T3) \
115                 CONFIG_INFINIBAND_CXGB3=$(CONFIG_INFINIBAND_CXGB3) \
116                 CONFIG_INFINIBAND_CXGB3_DEBUG=$(CONFIG_INFINIBAND_CXGB3_DEBUG) \
117                 CONFIG_CHELSIO_T4=$(CONFIG_CHELSIO_T4) \
118                 CONFIG_INFINIBAND_CXGB4=$(CONFIG_INFINIBAND_CXGB4) \
119                 CONFIG_SCSI_CXGB3_ISCSI=$(CONFIG_SCSI_CXGB3_ISCSI) \
120                 CONFIG_SCSI_CXGB4_ISCSI=$(CONFIG_SCSI_CXGB4_ISCSI) \
121                 CONFIG_INFINIBAND_NES=$(CONFIG_INFINIBAND_NES) \
122                 CONFIG_INFINIBAND_NES_DEBUG=$(CONFIG_INFINIBAND_NES_DEBUG) \
123                 CONFIG_MLX4_CORE=$(CONFIG_MLX4_CORE) \
124                 CONFIG_MLX5_CORE=$(CONFIG_MLX5_CORE) \
125                 CONFIG_MLX4_EN=$(CONFIG_MLX4_EN) \
126                 CONFIG_MLX4_EN_DCB=$(CONFIG_MLX4_EN_DCB) \
127                 CONFIG_MLX4_INFINIBAND=$(CONFIG_MLX4_INFINIBAND) \
128                 CONFIG_MLX5_INFINIBAND=$(CONFIG_MLX5_INFINIBAND) \
129                 CONFIG_MLX4_ETHERNET=$(CONFIG_MLX4_ETHERNET) \
130                 CONFIG_MLX4_DEBUG=$(CONFIG_MLX4_DEBUG) \
131                 CONFIG_MLX5_DEBUG=$(CONFIG_MLX5_DEBUG) \
132                 CONFIG_IBP_SERVER=$(CONFIG_IBP_SERVER) \
133                 CONFIG_IBP_DEBUG=$(CONFIG_IBP_DEBUG) \
134                 CONFIG_INFINIBAND_SCIF=$(CONFIG_INFINIBAND_SCIF) \
135                 CONFIG_INFINIBAND_AMSO1100=$(CONFIG_INFINIBAND_AMSO1100) \
136                 CONFIG_SUNRPC_XPRT_RDMA=$(CONFIG_SUNRPC_XPRT_RDMA) \
137                 CONFIG_SUNRPC_XPRT_RDMA_CLIENT=$(CONFIG_SUNRPC_XPRT_RDMA_CLIENT) \
138                 CONFIG_SUNRPC_XPRT_RDMA_SERVER=$(CONFIG_SUNRPC_XPRT_RDMA_SERVER) \
139                 CONFIG_INFINIBAND_OCRDMA=$(CONFIG_INFINIBAND_OCRDMA) \
140                 CONFIG_BE2NET=$(CONFIG_BE2NET) \
141                 CONFIG_INFINIBAND_ISERT=$(CONFIG_INFINIBAND_ISERT) \
142                 CONFIG_INFINIBAND_USNIC=$(CONFIG_INFINIBAND_USNIC) \
143                 LINUXINCLUDE=' \
144                 -D__OFED_BUILD__ \
145                 $(CFLAGS) \
146                 -include $(autoconf_h) \
147                 $(KCONFIG_H) \
148                 -include $(CWD)/include/linux/compat-2.6.h \
149                 $(BACKPORT_INCLUDES) \
150                 $(KERNEL_MEMTRACK_CFLAGS) \
151                 $(OPENIB_KERNEL_EXTRA_CFLAGS) \
152                 -I$(CWD)/include \
153                 -I$(CWD)/include/uapi \
154                 -I$(CWD)/drivers/infiniband/debug \
155                 -I/usr/local/include/scst \
156                 -I$(CWD)/drivers/infiniband/ulp/srpt \
157                 $$(if $$(CONFIG_XEN),-D__XEN_INTERFACE_VERSION__=$$(CONFIG_XEN_INTERFACE_VERSION)) \
158                 $$(if $$(CONFIG_XEN),-I$$(srctree)/arch/x86/include/mach-xen) \
159                 -I$$(srctree)/arch/$$(SRCARCH)/include \
160                 -Iarch/$$(SRCARCH)/include/generated \
161                 -Iinclude \
162                 -I$$(srctree)/arch/$$(SRCARCH)/include/uapi \
163                 -Iarch/$$(SRCARCH)/include/generated/uapi \
164                 -I$$(srctree)/include \
165                 -I$$(srctree)/include/uapi \
166                 -Iinclude/generated/uapi \
167                 $$(if $$(KBUILD_SRC),-Iinclude2 -I$$(srctree)/include) \
168                 -I$$(srctree)/arch/$$(SRCARCH)/include \
169                 -Iarch/$$(SRCARCH)/include/generated \
170                 ' \
171                 modules
172
173
174 #########################
175 #       Install kernel  #
176 #########################
177 install_modules:
178         @echo "Installing kernel modules"
179
180         $(MAKE) -C $(KSRC_OBJ) SUBDIRS="$(CWD)" \
181                 INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) \
182                 INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \
183                 $(WITH_MAKE_PARAMS) modules_install;
184         if [ ! -n "$(INSTALL_MOD_PATH)" ]; then $(DEPMOD) $(KVERSION);fi;
185
186 clean: clean_kernel
187
188 clean_kernel:
189         $(MAKE) -C $(KSRC_OBJ) SUBDIRS="$(CWD)" $(WITH_MAKE_PARAMS) clean
190         @/bin/rm -f $(clean-files)
191
192 clean-files := Module.symvers modules.order Module.markers compat/modules.order
193 clean-files += $(COMPAT_CONFIG) $(COMPAT_AUTOCONF)
194
195 help:
196         @echo
197         @echo kernel:                   build kernel modules
198         @echo all:                      build kernel modules
199         @echo
200         @echo install_kernel:           install kernel modules under $(INSTALL_MOD_PATH)/$(MODULES_DIR)
201         @echo install:                  run install_kernel
202         @echo
203         @echo clean:                    delete kernel modules binaries
204         @echo clean_kernel:             delete kernel modules binaries
205         @echo