Files
scst/iscsi-scst/Makefile
2012-02-17 01:38:16 +00:00

131 lines
5.6 KiB
Makefile

#
# Makefile for iSCSI-SCST
#
# Note! Dependencies are done automatically by 'make dep', which also
# removes any old dependencies. DON'T put your own dependencies here
# unless it's something special (not a .c file).
SHELL=/bin/bash
SUBDIRS := $(shell pwd)
#SCST_INC_DIR := /usr/local/include/scst
SCST_INC_DIR := $(SUBDIRS)/../scst/include
#SCST_DIR := $(SCST_INC_DIR)
SCST_DIR := $(shell pwd)/../scst/src
SBINDIR := /usr/local/sbin
INITDIR := /etc/init.d
RCDIR := /etc/rc.d
MANDIR := /usr/local/man
KMOD := $(shell pwd)/kernel
INCDIR := $(shell pwd)/include
ifeq ($(KVER),)
ifeq ($(KDIR),)
KVER = $(shell uname -r)
KDIR ?= /lib/modules/$(KVER)/build
else
KVER = $$KERNELRELEASE
endif
else
KDIR ?= /lib/modules/$(KVER)/build
endif
all: include/iscsi_scst_itf_ver.h progs mods
mods: Modules.symvers Module.symvers
$(MAKE) -C $(KDIR) SCST_INC_DIR=$(SCST_INC_DIR) SUBDIRS=$(KMOD) modules
progs:
$(MAKE) -C usr
include/iscsi_scst_itf_ver.h: include/iscsi_scst.h
echo "/* Autogenerated, don't edit */" >include/iscsi_scst_itf_ver.h
echo "" >>include/iscsi_scst_itf_ver.h
echo -n "#define ISCSI_SCST_INTERFACE_VERSION " >>include/iscsi_scst_itf_ver.h
echo -n "ISCSI_VERSION_STRING \"_\" " >>include/iscsi_scst_itf_ver.h
echo "\"`sha1sum include/iscsi_scst.h|awk '{printf $$1}'`\"" >>include/iscsi_scst_itf_ver.h
install: all
@install -vD -m 755 usr/iscsi-scstd $(DESTDIR)$(SBINDIR)/iscsi-scstd
@install -vD -m 644 doc/manpages/iscsi-scstd.conf.5 $(DESTDIR)$(MANDIR)/man5/iscsi-scstd.conf.5
@install -vD -m 644 doc/manpages/iscsi-scstd.8 $(DESTDIR)$(MANDIR)/man8/iscsi-scstd.8
@install -vD -m 755 usr/iscsi-scst-adm $(DESTDIR)$(SBINDIR)/iscsi-scst-adm
@install -vD -m 644 doc/manpages/iscsi-scst-adm.8 $(DESTDIR)$(MANDIR)/man8/iscsi-scst-adm.8
@eval `sed -n 's/#define UTS_RELEASE /KERNELRELEASE=/p' $(KDIR)/include/linux/version.h $(KDIR)/include/linux/utsrelease.h 2>/dev/null`; \
install -vD -m 644 kernel/iscsi-scst.ko \
$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/$(KVER)/extra/iscsi-scst.ko
-/sbin/depmod -aq $(KVER)
SCST_MOD_VERS := $(shell ls $(SCST_DIR)/Modules.symvers 2>/dev/null)
ifneq ($(SCST_MOD_VERS),)
Modules.symvers: $(SCST_DIR)/Modules.symvers
echo $(SCST_MOD_VERS)
cp $(SCST_DIR)/Modules.symvers kernel/
else
.PHONY: Modules.symvers
endif
# It's renamed in 2.6.18
SCST_MOD_VERS := $(shell ls $(SCST_DIR)/Module.symvers 2>/dev/null)
ifneq ($(SCST_MOD_VERS),)
Module.symvers: $(SCST_DIR)/Module.symvers
cp $(SCST_DIR)/Module.symvers kernel/
else
.PHONY: Module.symvers
endif
clean:
$(MAKE) -C usr $@
$(MAKE) -C $(KDIR) SUBDIRS=$(KMOD) $@
rm -f kernel/Modules.symvers kernel/Module.symvers \
kernel/Module.markers kernel/modules.order \
include/iscsi_scst_itf_ver.h
extraclean:
$(MAKE) -C usr $@
$(MAKE) -C $(KDIR) SUBDIRS=$(KMOD) clean
rm -f kernel/Modules.symvers kernel/Module.symvers \
kernel/Module.markers kernel/modules.order \
include/iscsi_scst_itf_ver.h \
kernel/*.orig kernel/*.rej
2release:
sed -i.aa s/"^E\?XTRA_CFLAGS += \-DCONFIG_SCST_EXTRACHECKS"/"#EXTRA_CFLAGS += \-DCONFIG_SCST_EXTRACHECKS"/ $(KMOD)/Makefile
grep "^#EXTRA_CFLAGS += \-DCONFIG_SCST_EXTRACHECKS" $(KMOD)/Makefile >/dev/null
sed -i.aa s/"^#\?EXTRA_CFLAGS += \-DCONFIG_SCST_TRACING"/"EXTRA_CFLAGS += \-DCONFIG_SCST_TRACING"/ $(KMOD)/Makefile
grep "^EXTRA_CFLAGS += \-DCONFIG_SCST_TRACING" $(KMOD)/Makefile >/dev/null
sed -i.aa s/"^E\?XTRA_CFLAGS += \-DCONFIG_SCST_DEBUG -g -fno-inline -fno-inline-functions"/"#EXTRA_CFLAGS += \-DCONFIG_SCST_DEBUG -g -fno-inline -fno-inline-functions"/ $(KMOD)/Makefile
grep "^#EXTRA_CFLAGS += \-DCONFIG_SCST_DEBUG -g -fno-inline -fno-inline-functions" $(KMOD)/Makefile >/dev/null
rm $(KMOD)/Makefile.aa
2debug:
sed -i.aa s/"^#\?EXTRA_CFLAGS += \-DCONFIG_SCST_EXTRACHECKS"/"EXTRA_CFLAGS += \-DCONFIG_SCST_EXTRACHECKS"/ $(KMOD)/Makefile
grep "^EXTRA_CFLAGS += \-DCONFIG_SCST_EXTRACHECKS" $(KMOD)/Makefile >/dev/null
sed -i.aa s/"^E\?XTRA_CFLAGS += \-DCONFIG_SCST_TRACING"/"#EXTRA_CFLAGS += \-DCONFIG_SCST_TRACING"/ $(KMOD)/Makefile
grep "^#EXTRA_CFLAGS += \-DCONFIG_SCST_TRACING" $(KMOD)/Makefile >/dev/null
sed -i.aa s/"^#\?EXTRA_CFLAGS += \-DCONFIG_SCST_DEBUG -g -fno-inline -fno-inline-functions"/"EXTRA_CFLAGS += \-DCONFIG_SCST_DEBUG -g -fno-inline -fno-inline-functions"/ $(KMOD)/Makefile
grep "^EXTRA_CFLAGS += \-DCONFIG_SCST_DEBUG -g -fno-inline -fno-inline-functions" $(KMOD)/Makefile >/dev/null
rm $(KMOD)/Makefile.aa
2perf:
sed -i.aa s/"^E\?XTRA_CFLAGS += \-DCONFIG_SCST_EXTRACHECKS"/"#EXTRA_CFLAGS += \-DCONFIG_SCST_EXTRACHECKS"/ $(KMOD)/Makefile
grep "^#EXTRA_CFLAGS += \-DCONFIG_SCST_EXTRACHECKS" $(KMOD)/Makefile >/dev/null
sed -i.aa s/"^E\?XTRA_CFLAGS += \-DCONFIG_SCST_TRACING"/"#EXTRA_CFLAGS += \-DCONFIG_SCST_TRACING"/ $(KMOD)/Makefile
grep "^#EXTRA_CFLAGS += \-DCONFIG_SCST_TRACING" $(KMOD)/Makefile >/dev/null
sed -i.aa s/"^E\?XTRA_CFLAGS += \-DCONFIG_SCST_DEBUG -g -fno-inline -fno-inline-functions"/"#EXTRA_CFLAGS += \-DCONFIG_SCST_DEBUG -g -fno-inline -fno-inline-functions"/ $(KMOD)/Makefile
grep "^#EXTRA_CFLAGS += \-DCONFIG_SCST_DEBUG -g -fno-inline -fno-inline-functions" $(KMOD)/Makefile >/dev/null
rm $(KMOD)/Makefile.aa
disable_proc:
sed -i.aa s/"^#\?define CONFIG_SCST_PROC"/"\/* #define CONFIG_SCST_PROC *\/"/ $(INCDIR)/iscsi_scst_ver.h
grep "^\/\* #define CONFIG_SCST_PROC \*\/" $(INCDIR)/iscsi_scst_ver.h >/dev/null
rm $(INCDIR)/iscsi_scst_ver.h.aa
enable_proc:
sed -i.aa s/"^\/\?\* #define CONFIG_SCST_PROC \*\/"/"#define CONFIG_SCST_PROC"/ $(INCDIR)/iscsi_scst_ver.h
grep "^#define CONFIG_SCST_PROC" $(INCDIR)/iscsi_scst_ver.h >/dev/null
rm $(INCDIR)/iscsi_scst_ver.h.aa
.PHONY: all mods progs install clean extraclean 2release 2debug 2perf disable_proc enable_proc