checkout_files: Added drivers/net/ethernet/hisilicon/Kconfig
[compat-rdma/compat-rdma.git] / makefile.in
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 ?= 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) M="$(CWD)" \
76                 V=$(V) KBUILD_NOCMDDEP=1 $(WITH_MAKE_PARAMS) \
77                 @CONFIG_VALUES@ \
78                 LINUXINCLUDE=' \
79                 -D__OFED_BUILD__ \
80                 -D__KERNEL__ \
81                 $(CFLAGS) \
82                 -include $(autoconf_h) \
83                 $(KCONFIG_H) \
84                 -include $(CWD)/include/linux/compat-2.6.h \
85                 $(BACKPORT_INCLUDES) \
86                 $(KERNEL_MEMTRACK_CFLAGS) \
87                 $(OPENIB_KERNEL_EXTRA_CFLAGS) \
88                 -I$(CWD)/include \
89                 -I$(CWD)/include/uapi \
90                 -I$(CWD)/drivers/infiniband/debug \
91                 -I/usr/local/include/scst \
92                 -I$(CWD)/drivers/infiniband/ulp/srpt \
93                 $$(if $$(CONFIG_XEN),-D__XEN_INTERFACE_VERSION__=$$(CONFIG_XEN_INTERFACE_VERSION)) \
94                 $$(if $$(CONFIG_XEN),-I$$(srctree)/arch/x86/include/mach-xen) \
95                 -I$$(srctree)/arch/$$(SRCARCH)/include \
96                 -Iarch/$$(SRCARCH)/include/generated \
97                 -Iinclude \
98                 -I$$(srctree)/arch/$$(SRCARCH)/include/uapi \
99                 -Iarch/$$(SRCARCH)/include/generated/uapi \
100                 -I$$(srctree)/include \
101                 -I$$(srctree)/include/uapi \
102                 -Iinclude/generated/uapi \
103                 $$(if $$(KBUILD_SRC),-Iinclude2 -I$$(srctree)/include) \
104                 -I$$(srctree)/arch/$$(SRCARCH)/include \
105                 -Iarch/$$(SRCARCH)/include/generated \
106                 ' \
107                 modules
108
109
110 #########################
111 #       Install kernel  #
112 #########################
113 install_modules:
114         @echo "Installing kernel modules"
115
116         $(MAKE) -C $(KSRC_OBJ) M="$(CWD)" \
117                 INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) \
118                 INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \
119                 $(WITH_MAKE_PARAMS) modules_install;
120         if [ ! -n "$(INSTALL_MOD_PATH)" ]; then $(DEPMOD) $(KVERSION);fi;
121
122 clean: clean_kernel
123
124 clean_kernel:
125         $(MAKE) -C $(KSRC_OBJ) rm-files= M="$(CWD)" $(WITH_MAKE_PARAMS) \
126                 @CONFIG_VALUES@ \
127                 clean
128
129 distclean: clean_kernel
130         @/bin/rm -f $(clean-files)
131
132 clean-files := Module.symvers modules.order Module.markers compat/modules.order compat/configure
133 clean-files += $(COMPAT_CONFIG) $(COMPAT_AUTOCONF)
134 clean-files += include/linux/autoconf.h include/generated/autoconf.h
135 clean-files += allconfigs makefile
136
137 help:
138         @echo
139         @echo kernel:                   build kernel modules
140         @echo all:                      build kernel modules
141         @echo
142         @echo install_kernel:           install kernel modules under $(INSTALL_MOD_PATH)/$(MODULES_DIR)
143         @echo install:                  run install_kernel
144         @echo
145         @echo clean:                    delete kernel modules binaries
146         @echo clean_kernel:             delete kernel modules binaries
147         @echo