From 7d89372c534ca520c88b184f9596223b072b7596 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 18 Feb 2014 08:40:36 +0000 Subject: [PATCH] Makefiles: respect DESTDIR when specified Not all SCST components handle DESTDIR properly, or at all. In particular: * INSTALL_MOD_PATH should account for DESTDIR when 'make modules_install' is invoked, so the kernel make infrastructure deploys the modules and runs depmod against the proper directory tree. * depmods must include a '-b' option to reference the proper directory tree. * Drop special ISCSI_DESTDIR. Signed-off-by: Steven J. Magnani git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5289 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- Makefile | 5 ++--- fcst/Makefile | 12 ++++++++---- ibmvstgt/Makefile | 6 ++++++ iscsi-scst/Makefile | 10 ++++++++-- mpt/Makefile | 7 ++++++- mvsas_tgt/Makefile | 2 +- qla2x00t/Makefile | 8 +++++++- qla2x00t/qla2x00-target/Makefile | 12 ++++++++---- scst/src/Makefile | 10 +++++++--- scst/src/dev_handlers/Makefile | 6 +++++- scst_local/Makefile | 11 ++++++++--- srpt/Makefile | 10 ++++++++-- usr/fileio/Makefile | 2 +- 13 files changed, 75 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index 05511f086..1066dd93c 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,6 @@ MVSAS_DIR=mvsas_tgt FCST_DIR=fcst ISCSI_DIR=iscsi-scst -#ISCSI_DESTDIR=../../../iscsi_scst_inst VERSION = $(shell echo -n "$$(sed -n 's/^\#define[[:blank:]]SCST_VERSION_NAME[[:blank:]]*\"\([^-]*\).*\"/\1/p' scst/include/scst_const.h)."; \ if svn info >/dev/null 2>&1; \ @@ -155,7 +154,7 @@ install: # @if [ -d $(QLA_ISP_DIR) ]; then cd $(QLA_ISP_DIR) && $(MAKE) $@; fi # @if [ -d $(LSI_DIR) ]; then cd $(LSI_DIR) && $(MAKE) $@; fi # @if [ -d $(SRP_DIR) ]; then cd $(SRP_DIR) && $(MAKE) $@; fi - @if [ -d $(ISCSI_DIR) ]; then cd $(ISCSI_DIR) && $(MAKE) DESTDIR=$(ISCSI_DESTDIR) $@; fi + @if [ -d $(ISCSI_DIR) ]; then cd $(ISCSI_DIR) && $(MAKE) $@; fi @if [ -d $(USR_DIR) ]; then cd $(USR_DIR) && $(MAKE) $@; fi @if [ -d $(SCST_LOCAL_DIR) ]; then cd $(SCST_LOCAL_DIR) && $(MAKE) $@; fi @@ -273,7 +272,7 @@ iscsi: cd $(ISCSI_DIR) && $(MAKE) all iscsi_install: - cd $(ISCSI_DIR) && $(MAKE) DESTDIR=$(ISCSI_DESTDIR) install + cd $(ISCSI_DIR) && $(MAKE) install iscsi_uninstall: cd $(ISCSI_DIR) && $(MAKE) uninstall diff --git a/fcst/Makefile b/fcst/Makefile index db2a888ff..5939c958a 100644 --- a/fcst/Makefile +++ b/fcst/Makefile @@ -64,13 +64,17 @@ else KDIR := /lib/modules/$(KVER)/build endif -INSTALL_DIR := /lib/modules/$(KVER)/extra +ifeq ($(INSTALL_MOD_PATH),) + export INSTALL_MOD_PATH := $(DESTDIR) +endif + +INSTALL_DIR := $(INSTALL_MOD_PATH)/lib/modules/$(KVER)/extra SCST_INC_DIR := $(shell if [ -e "$$PWD/../scst" ]; \ then echo "$$PWD/../scst/include"; \ - else echo "$(PREFIX)/include/scst"; fi) + else echo "$(DESTDIR)$(PREFIX)/include/scst"; fi) SCST_DIR := $(shell if [ -e "$$PWD/../scst" ]; then echo "$$PWD/../scst/src"; \ - else echo "$(PREFIX)/include/scst"; fi) + else echo "$(DESTDIR)$(PREFIX)/include/scst"; fi) all: Modules.symvers Module.symvers $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) BUILD_INI=m \ @@ -107,7 +111,7 @@ endif uninstall: rm -f $(INSTALL_DIR)/$(MODULE_NAME).ko - -/sbin/depmod -a $(KVER) + -/sbin/depmod -b $(INSTALL_MOD_PATH)/ -a $(KVER) ########## END OUT-OF-TREE RULES ########## endif diff --git a/ibmvstgt/Makefile b/ibmvstgt/Makefile index 6eaf7933e..6c109a972 100644 --- a/ibmvstgt/Makefile +++ b/ibmvstgt/Makefile @@ -22,6 +22,12 @@ else KDIR := /lib/modules/$(KVER)/build endif +ifeq ($(INSTALL_MOD_PATH),) + export INSTALL_MOD_PATH := $(DESTDIR) +endif + +INSTALL_DIR := $(INSTALL_MOD_PATH)/lib/modules/$(KVER)/extra + # The file Modules.symvers has been renamed in the 2.6.18 kernel to # Module.symvers. Find out which name to use by looking in $(KDIR). MODULE_SYMVERS:=$(shell if [ -e $(KDIR)/Module.symvers ]; then \ diff --git a/iscsi-scst/Makefile b/iscsi-scst/Makefile index e14e46402..9290e2f27 100644 --- a/iscsi-scst/Makefile +++ b/iscsi-scst/Makefile @@ -15,9 +15,9 @@ SUBDIRS := $(shell pwd) SCST_INC_DIR := $(shell if [ -e "$$PWD/../scst" ]; \ then echo "$$PWD/../scst/include"; \ - else echo "$(PREFIX)/include/scst"; fi) + else echo "$(DESTDIR)$(PREFIX)/include/scst"; fi) SCST_DIR := $(shell if [ -e "$$PWD/../scst" ]; then echo "$$PWD/../scst/src"; \ - else echo "$(PREFIX)/include/scst"; fi) + else echo "$(DESTDIR)$(PREFIX)/include/scst"; fi) SBINDIR := $(PREFIX)/sbin INITDIR := /etc/init.d RCDIR := /etc/rc.d @@ -42,6 +42,12 @@ else KDIR := /lib/modules/$(KVER)/build endif +ifeq ($(INSTALL_MOD_PATH),) + export INSTALL_MOD_PATH := $(DESTDIR) +endif + +INSTALL_DIR := $(INSTALL_MOD_PATH)/lib/modules/$(KVER)/extra + all: include/iscsi_scst_itf_ver.h progs mods mods: Modules.symvers Module.symvers diff --git a/mpt/Makefile b/mpt/Makefile index 0e32736e5..957c39a1e 100644 --- a/mpt/Makefile +++ b/mpt/Makefile @@ -53,6 +53,11 @@ else KDIR := /lib/modules/$(KVER)/build endif +ifeq ($(INSTALL_MOD_PATH),) + export INSTALL_MOD_PATH := $(DESTDIR) +endif + +INSTALL_DIR := $(INSTALL_MOD_PATH)/lib/modules/$(KVER)/extra LSI_INC_DIR := $(KDIR)/drivers/message/fusion EXTRA_CFLAGS += -I$(LSI_INC_DIR) @@ -90,7 +95,7 @@ endif uninstall: rm -f $(INSTALL_DIR)/mpt_scst.ko - -/sbin/depmod -a $(KVER) + -/sbin/depmod -b $(INSTALL_MOD_PATH)/ -a $(KVER) ########## END OUT-OF-TREE RULES ########## endif diff --git a/mvsas_tgt/Makefile b/mvsas_tgt/Makefile index 4149e899c..331210287 100644 --- a/mvsas_tgt/Makefile +++ b/mvsas_tgt/Makefile @@ -115,7 +115,7 @@ endif uninstall: rm -f $(INSTALL_DIR)/$(MODULE_NAME).ko - -/sbin/depmod -a $(KVER) + -/sbin/depmod -b $(INSTALL_MOD_PATH)/ -a $(KVER) ########## END OUT-OF-TREE RULES ########## endif diff --git a/qla2x00t/Makefile b/qla2x00t/Makefile index 145063c19..32e32fa6f 100644 --- a/qla2x00t/Makefile +++ b/qla2x00t/Makefile @@ -44,6 +44,12 @@ else KDIR := /lib/modules/$(KVER)/build endif +ifeq ($(INSTALL_MOD_PATH),) + export INSTALL_MOD_PATH := $(DESTDIR) +endif + +INSTALL_DIR := $(INSTALL_MOD_PATH)/lib/modules/$(KVER)/extra + ifneq ($(PATCHLEVEL),) obj-m := qla2xxx_scst.o qla2xxx_scst-objs := qla_os.o qla_init.o qla_mbx.o qla_iocb.o qla_isr.o qla_gs.o \ @@ -59,7 +65,7 @@ install: all uninstall: rm -f $(INSTALL_DIR)/qla2xxxt.ko - -/sbin/depmod -a $(KVER) + -/sbin/depmod -b $(INSTALL_MOD_PATH)/ -a $(KVER) ########## END OUT-OF-TREE RULES ########## endif diff --git a/qla2x00t/qla2x00-target/Makefile b/qla2x00t/qla2x00-target/Makefile index 710e1273e..7dbbf0117 100644 --- a/qla2x00t/qla2x00-target/Makefile +++ b/qla2x00t/qla2x00-target/Makefile @@ -56,6 +56,10 @@ else KDIR := /lib/modules/$(KVER)/build endif +ifeq ($(INSTALL_MOD_PATH),) + export INSTALL_MOD_PATH := $(DESTDIR) +endif + ifeq ($(BUILD_2X_MODULE),) QLA2XXX_INC_DIR := $(KDIR)/drivers/scsi/qla2xxx else @@ -77,14 +81,14 @@ ifndef PREFIX PREFIX=/usr/local endif -INSTALL_DIR := /lib/modules/$(KVER)/extra +INSTALL_DIR := $(INSTALL_MOD_PATH)/lib/modules/$(KVER)/extra SCST_INC_DIR := $(shell if [ -e "$$PWD/../../scst" ]; \ then echo "$$PWD/../../scst/include"; \ - else echo "$(PREFIX)/include/scst"; fi) + else echo "$(DESTDIR)$(PREFIX)/include/scst"; fi) SCST_DIR := $(shell if [ -e "$$PWD/../../scst" ]; \ then echo "$$PWD/../../scst/src"; \ - else echo "$(PREFIX)/include/scst"; fi) + else echo "$(DESTDIR)$(PREFIX)/include/scst"; fi) ifneq ($(BUILD_2X_MODULE),) # We need to make qla2xxx_scst before Module.symvers @@ -108,7 +112,7 @@ ifneq ($(BUILD_2X_MODULE),) $(MAKE) SUBDIRS=$(QLA2XXX_DIR) -C $(QLA2XXX_DIR) $@ endif rm -f $(INSTALL_DIR)/qla2[23x]00tgt.ko - -/sbin/depmod -a $(KVER) + -/sbin/depmod -b $(INSTALL_MOD_PATH)/ -a $(KVER) ifneq ($(BUILD_2X_MODULE),) qla2xxx_scst: diff --git a/scst/src/Makefile b/scst/src/Makefile index 84a707774..230dab02e 100644 --- a/scst/src/Makefile +++ b/scst/src/Makefile @@ -69,6 +69,10 @@ else KDIR := /lib/modules/$(KVER)/build endif +ifeq ($(INSTALL_MOD_PATH),) + export INSTALL_MOD_PATH := $(DESTDIR) +endif + all: $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) BUILD_DEV=m @@ -103,7 +107,7 @@ ifneq ($(MOD_VERS),) rm -f $(INSTALL_DIR_H)/Modules.symvers install -m 644 Module.symvers $(INSTALL_DIR_H) endif - -/sbin/depmod -a $(KVER) + -/sbin/depmod -b $(INSTALL_MOD_PATH)/ -a $(KVER) mkdir -p $(DESTDIR)/var/lib/scst/pr @echo "****************************************************************" @echo "*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*" @@ -122,13 +126,13 @@ uninstall: cd $(DEV_HANDLERS_DIR) && $(MAKE) $@ rm -f $(INSTALL_DIR)/scst.ko -rmdir $(INSTALL_DIR) 2>/dev/null - -/sbin/depmod -a $(KVER) + -/sbin/depmod -b $(INSTALL_MOD_PATH)/ -a $(KVER) rm -rf $(INSTALL_DIR_H) ########## END OUT-OF-TREE RULES ########## endif -INSTALL_DIR := $(DESTDIR)/lib/modules/$(KVER)/extra +INSTALL_DIR := $(INSTALL_MOD_PATH)/lib/modules/$(KVER)/extra INSTALL_DIR_H := $(DESTDIR)$(PREFIX)/include/scst enable-Wextra = $(shell uname_r="$$(uname -r)"; if [ "$${uname_r%.el5}" = "$${uname_r}" ]; then echo "$(1)"; fi) diff --git a/scst/src/dev_handlers/Makefile b/scst/src/dev_handlers/Makefile index 286482aaa..3ae5471d6 100644 --- a/scst/src/dev_handlers/Makefile +++ b/scst/src/dev_handlers/Makefile @@ -61,7 +61,11 @@ else KDIR := /lib/modules/$(KVER)/build endif -INSTALL_DIR := /lib/modules/$(KVER)/extra +ifeq ($(INSTALL_MOD_PATH),) + export INSTALL_MOD_PATH := $(DESTDIR) +endif + +INSTALL_DIR := $(INSTALL_MOD_PATH)/lib/modules/$(KVER)/extra all: $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) diff --git a/scst_local/Makefile b/scst_local/Makefile index 04f3b3081..2dee7552a 100644 --- a/scst_local/Makefile +++ b/scst_local/Makefile @@ -42,13 +42,18 @@ else KDIR := /lib/modules/$(KVER)/build endif +ifeq ($(INSTALL_MOD_PATH),) + export INSTALL_MOD_PATH := $(DESTDIR) +endif + +INSTALL_DIR := $(INSTALL_MOD_PATH)/lib/modules/$(KVER)/extra SCST_INC_DIR := $(shell if [ -e "$$PWD/../scst" ]; \ then echo "$$PWD/../scst/include"; \ - else echo "$(PREFIX)/include/scst"; fi) + else echo "$(DESTDIR)$(PREFIX)/include/scst"; fi) SCST_DIR := $(shell if [ -e "$$PWD/../scst" ]; \ then echo "$$PWD/../scst/src"; \ - else echo "$(PREFIX)/include/scst"; fi) + else echo "$(DESTDIR)$(PREFIX)/include/scst"; fi) all: Modules.symvers Module.symvers $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) BUILD_INI=m \ @@ -77,7 +82,7 @@ endif uninstall: rm -f $(INSTALL_DIR)/scst_local.ko - -/sbin/depmod -a $(KVER) + -/sbin/depmod -b $(INSTALL_MOD_PATH)/ -a $(KVER) ########## END OUT-OF-TREE RULES ########## endif diff --git a/srpt/Makefile b/srpt/Makefile index bceb631a4..381dd6890 100644 --- a/srpt/Makefile +++ b/srpt/Makefile @@ -7,10 +7,10 @@ endif SCST_INC_DIR := $(shell if [ -e "$$PWD/../scst" ]; \ then echo "$$PWD/../scst/include"; \ - else echo "$(PREFIX)/include/scst"; fi) + else echo "$(DESTDIR)$(PREFIX)/include/scst"; fi) SCST_SYMVERS_DIR := $(shell if [ -e $$PWD/../scst ]; then \ echo $$PWD/../scst/src; \ - else echo $(PREFIX)/include/scst; fi) + else echo $(DESTDIR)$(PREFIX)/include/scst; fi) SUBDIRS := $(shell pwd) ifeq ($(KVER),) @@ -30,6 +30,12 @@ else KDIR := /lib/modules/$(KVER)/build endif +ifeq ($(INSTALL_MOD_PATH),) + export INSTALL_MOD_PATH := $(DESTDIR) +endif + +INSTALL_DIR := $(INSTALL_MOD_PATH)/lib/modules/$(KVER)/extra + # Set variable $(2) to value $(3) in file $(1). set_var = $(shell { if [ -e "$(1)" ]; then grep -v '^$(2)=' "$(1)"; fi; echo "$(2)=$(3)"; } >/tmp/$(1)-$$$$.tmp && mv /tmp/$(1)-$$$$.tmp $(1)) diff --git a/usr/fileio/Makefile b/usr/fileio/Makefile index 5cdb3e3ed..6b193e219 100644 --- a/usr/fileio/Makefile +++ b/usr/fileio/Makefile @@ -28,7 +28,7 @@ OBJS_F = $(SRCS_F:.c=.o) SCST_INC_DIR := ../../scst/include #SCST_INC_DIR := $(PREFIX)/include/scst -INSTALL_DIR := $(PREFIX)/bin/scst +INSTALL_DIR := $(DESTDIR)$(PREFIX)/bin/scst CFLAGS += -O2 -Wall -Wextra -Wno-unused-parameter -Wstrict-prototypes \ -I$(SCST_INC_DIR) -D_GNU_SOURCE -D__USE_FILE_OFFSET64 \