2 # Makefile for the Linux Kernel iSCSI Initiator
4 # This Makefile invokes KBuild from outside the kernel directory when
5 # used from the main open-iscsi package. It also contains all of the
6 # KBuild stuff needed to build the modules.
9 # Kbuild stuff, the following is the only part of this file that KBuild
10 # actually uses itself.
11 EXTRA_CFLAGS
+= -I
$(obj
) -I
$(obj
)/..
/include
13 ifeq ($(DEBUG_SCSI
), 1)
14 EXTRA_CFLAGS
+= -DDEBUG_SCSI
=1
17 ifeq ($(DEBUG_TCP
), 1)
18 EXTRA_CFLAGS
+= -DDEBUG_TCP
=1
21 obj-m
+= scsi_transport_iscsi.o
23 obj-m
+= libiscsi_tcp.o
26 # Everything beyond this point is used to call KBuild or handle support
27 # for multiple kernel versions.
32 # allow users to override these
33 # eg to compile for a kernel that you aren't currently running
34 KERNELRELEASE ?
= $(shell uname
-r
)
35 KSRC ?
= /lib
/modules
/$(KERNELRELEASE
)/build
37 # this is the basic Kbuild invocation, just append your make target
38 KBUILD_BASE
= +$(MAKE
) -C
$(KSRC
) M
=`pwd` KBUILD_OUTPUT
=$(KBUILD_OUTPUT
) $(KARCH
) V
=$(V
)
41 $(KBUILD_BASE
) modules
43 # ============ BEGIN code for kernel_check and source patching ================
44 # We calculate the Linux version for compilation. Than according to version,
45 # if needed, we patch source-code to match the compiling kernel.
46 # if you need a new kernel sub-version just add a target below.
48 # IMPORTANT: do "make clean" before submitting to SVN so source is in unpatched
52 14to23_patch
=2.6.14-23_compat.patch
53 24_patch
=2.6.24_compat.patch
54 26_patch
=2.6.26_compat.patch
55 27_patch
=2.6.27_compat.patch
56 28to32_patch
=2.6.28-32_compat.patch
57 33to34_patch
=2.6.33-34_compat.patch
58 all_patches
=14to21_patch
20to21_patch
24_patch
26_patch
27_patch
28to32_patch
33to34_patch
59 cur_patched
=cur_patched
61 ## fun stuff for maintaining multiple versions
63 # check to see if code is unpatched
64 unpatch_code
=$(shell test -e
$(cur_patched
) && echo do_unpatch_code
)
66 KSUBLEVEL
= $(shell cat
$(KSRC
)/Makefile | awk
-F
= '/^SUBLEVEL =/ {print $$2}' | \
67 sed
's/^[ \t]*//;s/[ \t]*$$//')
70 KERNEL_TARGET
=linux_2_6_
$(KSUBLEVEL
)
71 kernel_check
: $(KERNEL_TARGET
)
73 linux_2_6_14
: has_14to23_patch
75 linux_2_6_15
: has_14to23_patch
77 linux_2_6_16
: has_14to23_patch
79 linux_2_6_17
: has_14to23_patch
81 linux_2_6_18
: has_14to23_patch
83 linux_2_6_19
: has_14to23_patch
85 linux_2_6_20
: has_14to23_patch
87 linux_2_6_21
: has_14to23_patch
89 linux_2_6_22
: has_14to23_patch
91 linux_2_6_23
: has_14to23_patch
93 linux_2_6_24
: has_24_patch
95 linux_2_6_25
: has_24_patch
97 linux_2_6_26
: has_26_patch
99 linux_2_6_27
: has_27_patch
101 linux_2_6_28
: has_28to32_patch
103 linux_2_6_29
: has_28to32_patch
105 linux_2_6_30
: has_28to32_patch
107 linux_2_6_31
: has_28to32_patch
109 linux_2_6_32
: has_28to32_patch
111 linux_2_6_33
: has_33to34_patch
113 linux_2_6_34
: has_33to34_patch
115 linux_2_6_35
: $(unpatch_code
)
118 echo
"Un-patching source code for use with linux-2.6.14 and up ..."
119 patch
-R
-E
-p1
< $(cur_patched
)
120 rm -f
`readlink $(cur_patched)`
123 # these below targets must be the same as the variable name prefixed by has_
124 # otherwise below compat_patch: target will not work
125 has_14to23_patch
: $(14to23_patch
)
126 echo
"Patching source code for linux-2.6.14-23 ..."
127 if
[ -e
$(cur_patched
) ]; then \
130 patch
-p1
< $(14to23_patch
)
131 cp
$(14to23_patch
) $@
132 ln
-s
$@
$(cur_patched
)
134 has_24_patch
: $(24_patch
)
135 echo
"Patching source code for linux-2.6.24-25 ..."
136 if
[ -e
$(cur_patched
) ]; then \
139 patch
-p1
< $(24_patch
)
141 ln
-s
$@
$(cur_patched
)
143 has_26_patch
: $(26_patch
)
144 echo
"Patching source code for linux-2.6.26 ..."
145 if
[ -e
$(cur_patched
) ]; then \
148 patch
-p1
< $(26_patch
)
150 ln
-s
$@
$(cur_patched
)
152 has_27_patch
: $(27_patch
)
153 echo
"Patching source code for linux-2.6.27 ..."
154 if
[ -e
$(cur_patched
) ]; then \
157 patch
-p1
< $(27_patch
)
159 ln
-s
$@
$(cur_patched
)
161 has_28to32_patch
: $(28to32_patch
)
162 echo
"Patching source code for linux-2.6.28-33 ..."
163 if
[ -e
$(cur_patched
) ]; then \
166 patch
-p1
< $(28to32_patch
)
167 cp
$(28to32_patch
) $@
168 ln
-s
$@
$(cur_patched
)
170 has_33to34_patch
: $(33to34_patch
)
171 echo
"Patching source code for linux-2.6.33-34 ..."
172 if
[ -e
$(cur_patched
) ]; then \
175 patch
-p1
< $(33to34_patch
)
176 cp
$(33to34_patch
) $@
177 ln
-s
$@
$(cur_patched
)
180 # ============ END code for kernel_check and source patching =================
182 clean: $(unpatch_code
)
186 ## The folowing compat_patch target is what we need to do to prepare a clean
187 # compat_patch set after new code is check-in to svn. To keep patches fuzzless.
188 # the new patches are writen into .new files so svn diff of next file will
190 compat_patch
: $(unpatch_code
)
191 test -z
"$(svn diff|head)" ||
{ \
192 echo
"please run make compat_patch after changse are submited to svn"; \
195 for the_patch in all_patches
; do \
196 make
-C . has_
$(the_patch
); \
197 svn diff
> ${!the_patch
}.new
; \
200 # the following is only for convienience
201 # do not submit to Linus
202 # it's also called from the toplevel makefile
204 # INSTALL_MOD_DIR is set so that the drivers go into the correct location using Kbuild
205 # it defaults to 'extra' otherwise
206 INSTALL_MOD_DIR ?
= kernel
/drivers
/scsi
208 # this allows packaging of modules
210 INSTALL_MOD_PATH
=$(DESTDIR
)
215 # this evil rule ensures that the modules get build if you specify $(ko)
217 ko
= $(patsubst %.o
,%.ko
,$(obj-m
))
220 # now the actual command
221 install_kernel
: $(ko
)
222 $(KBUILD_BASE
) modules_install INSTALL_MOD_DIR
=$(INSTALL_MOD_DIR
) INSTALL_MOD_PATH
=$(INSTALL_MOD_PATH
)
225 for module in
$(ko
) ; do \
226 dpkg-divert
--rename
/lib
/modules
/$(KERNELRELEASE
)/$(INSTALL_MOD_DIR
)/$$module ; \
229 # vim: ft=make tw=72 sw=4 ts=4: