diff --git a/Makefile b/Makefile index 8eb812c..167138f 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ etcdir = /etc initddir = $(etcdir)/init.d MANPAGES = doc/iscsid.8 doc/iscsiadm.8 doc/iscsi_discovery.8 -PROGRAMS = usr/iscsid usr/iscsiadm utils/iscsi_discovery utils/iscsi-iname +PROGRAMS = usr/iscsid usr/iscsiadm utils/iscsi_discovery utils/iscsi-iname utils/fwparam_ibft/fwparam_ibft INSTALL = install ETCFILES = etc/iscsid.conf IFACEFILES = etc/iface.example @@ -54,7 +54,7 @@ clean: install_etc install_iface install_doc install_kernel install_iname install: install_kernel install_programs install_doc install_etc \ - install_initd install_iname install_iface + install_initd install_usr: install_programs install_doc install_etc \ install_initd install_iname install_iface diff --git a/kernel/Makefile b/kernel/Makefile index bf67fec..268758d 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -32,11 +32,16 @@ V ?= 0 # eg to compile for a kernel that you aren't currently running KERNELRELEASE ?= $(shell uname -r) KSRC ?= /lib/modules/$(KERNELRELEASE)/build +KSRC := $(shell test -f $(KSRC)/Makefile || echo "") KBUILD_OUTPUT ?= # this is the basic Kbuild invocation, just append your make target KBUILD_BASE = +$(MAKE) -C $(KSRC) M=`pwd` KBUILD_OUTPUT=$(KBUILD_OUTPUT) $(KARCH) V=$(V) -all: kernel_check +all: kernel_src + +kernel_src: $(shell test -n "$(KSRC)" && echo has_kernel_src) + +has_kernel_src: kernel_check $(KBUILD_BASE) modules # ============ BEGIN code for kernel_check and source patching ================ @@ -58,9 +63,11 @@ cur_patched=cur_patched # check to see if code is unpatched unpatch_code=$(shell test -e $(cur_patched) && echo do_unpatch_code ) -KSUBLEVEL = $(shell cat $(KSRC)/Makefile | awk -F= '/^SUBLEVEL =/ {print $$2}' | \ +KSUBLEVEL = $(shell cat $(KSRC)/Makefile 2> /dev/null | awk -F= '/^SUBLEVEL =/ {print $$2}' | \ sed 's/^[ \t]*//;s/[ \t]*$$//') +KSUBLEVEL?=$(shell echo $(KERNELRELEASE) | sed -n 's/.\..\.\([[:digit:]]*\)\..*/\1/p') + KERNEL_TARGET=linux_2_6_$(KSUBLEVEL) kernel_check: $(KERNEL_TARGET) @@ -114,7 +121,11 @@ has_20to21_patch: $(20to21_patch) # ============ END code for kernel_check and source patching ================= -clean: $(unpatch_code) +clean: clean_kernel_src + +clean_kernel_src: $(shell test -n "$(KSRC)" && echo has_clean_kernel_src) + +has_clean_kernel_src: $(unpatch_code) $(KBUILD_BASE) clean rm -f Module.symvers @@ -164,7 +164,9 @@ ko = $(patsubst %.o,%.ko,$(obj-m)) $(ko): all # now the actual command -install_kernel: $(ko) +install_kernel: $(shell test -n "$(KSRC)" && echo install_kernel_obj); + +install_kernel_obj: $(ko) $(KBUILD_BASE) modules_install INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) # vim: ft=make tw=72 sw=4 ts=4: diff --git a/usr/Makefile b/usr/Makefile index bf67fec..268758d 100644 --- a/usr/Makefile +++ b/usr/Makefile @@ -7,9 +7,11 @@ OSNAME=$(shell uname -s) KERNELRELEASE ?= $(shell uname -r) KSRC ?= /lib/modules/$(KERNELRELEASE)/build -KSUBLEVEL=$(shell cat $(KSRC)/Makefile | awk -F= '/^SUBLEVEL =/ {print $$2}' | \ +KSUBLEVEL=$(shell cat $(KSRC)/Makefile 2> /dev/null | awk -F= '/^SUBLEVEL =/ {print $$2}' | \ sed 's/^[ \t]*//;s/[ \t]*$$//') +KSUBLEVEL?=$(shell echo $OSNAME | sed -n 's/.\..\.\([[:digit:]]*\)\..*/\1/p') + ifeq ($(OSNAME),Linux) ifeq ($(KSUBLEVEL),11) IPC_CFLAGS=-DNETLINK_ISCSI=12 -D_GNU_SOURCE