Files
scst/mpt/Makefile
Bart Van Assche d3e2f5ab99 Makefiles: Stop using $(SUBDIRS)
This patch avoids that the following warning is reported when building
against kernel v4.21:

================= WARNING ================
'SUBDIRS' will be removed after Linux 5.3
Please use 'M=' or 'KBUILD_EXTMOD' instead
==========================================


A quote from an upstream kernel patch:

commit 07e5823127155b3a29003aca926f87c9843f6810
Author: Andrew Morton <akpm@osdl.org>
Date:   Mon Apr 12 01:05:40 2004 -0700

    [PATCH] kbuild: external module support
    
    From: Sam Ravnborg <sam@ravnborg.org>
    
    Based on initial patch from Andreas Gruenbacher there is now better support
    for building external modules with kbuild.
    
    The preferred syntax is now:
    make -C $KERNELSRC M=$PWD
    
    but the old syntax:
    make -C $KERNELSRC SUBDIRS=$PWD modules
    will remain supported.


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7851 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2018-12-31 19:03:14 +00:00

113 lines
2.9 KiB
Makefile

# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, version 2
# of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# Main targets:
# all (the default) : make all
# clean : clean files
# extraclean : clean + clean dependencies
# install : install
# uninstall : uninstall
#
# Notes :
# - install and uninstall must be made as root
#
ifndef PREFIX
PREFIX=/usr/local
endif
#SCST_INC_DIR := $(PREFIX)/include/scst
#SCST_DIR := $(SCST_INC_DIR)
SCST_INC_DIR := $(KBUILD_EXTMOD)/../scst/include
SCST_DIR := $(shell pwd)/../scst/src
EXTRA_CFLAGS += -I$(SCST_INC_DIR)
EXTRA_CFLAGS += -DCONFIG_SCST_EXTRACHECKS
#EXTRA_CFLAGS += -DCONFIG_SCST_TRACING
EXTRA_CFLAGS += -DCONFIG_SCST_DEBUG
#EXTRA_CFLAGS += -DDEBUG_WORK_IN_THREAD
ifeq ($(KVER),)
ifeq ($(KDIR),)
KVER := $(shell uname -r)
KDIR := /lib/modules/$(KVER)/build
else
ifeq ($(KERNELRELEASE),)
KVER := $(strip $(shell \
cat $(KDIR)/include/config/kernel.release 2>/dev/null || \
make -s -C $(KDIR) kernelversion))
else
KVER := $(KERNELRELEASE)
endif
endif
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)
ifneq ($(PATCHLEVEL),)
obj-m += mpt_scst.o
else
######### BEGIN OUT-OF-TREE RULES #########
all: Modules.symvers Module.symvers
$(MAKE) -C $(KDIR) M=$(shell pwd) BUILD_INI=m
tgt: Modules.symvers Module.symvers
$(MAKE) -C $(KDIR) M=$(shell pwd) BUILD_INI=n
install: all
$(MAKE) -C $(KDIR) M=$(shell pwd) BUILD_INI=m \
$$([ -n "$(DESTDIR)$(INSTALL_MOD_PATH)" ] && echo DEPMOD=true) \
modules_install
SCST_MOD_VERS := $(shell ls $(SCST_DIR)/Modules.symvers 2>/dev/null)
ifneq ($(SCST_MOD_VERS),)
Modules.symvers: $(SCST_DIR)/Modules.symvers
cp $(SCST_DIR)/Modules.symvers .
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 .
else
.PHONY: Module.symvers
endif
uninstall:
rm -f $(INSTALL_DIR)/mpt_scst.ko
-/sbin/depmod -b $(INSTALL_MOD_PATH)/ -a $(KVER)
########## END OUT-OF-TREE RULES ##########
endif
clean:
rm -f *.o *.ko .*.cmd *.mod.c .*.d .depend *~ Modules.symvers \
Module.symvers Module.markers modules.order
rm -rf .tmp_versions
extraclean: clean
rm -f *.orig *.rej
.PHONY: all tgt install uninstall clean extraclean