Files
scst/scst_local/Makefile
Bart Van Assche 22f1132073 Makefiles: Rework build mode switching
Move the build_mode file from the top level into the scst directory. Write
build mode defines into scst/include/build_mode.h and include that file
directly or indirectly in all source files that depend on these #defines.
This approach has the advantage that "make clean" does no longer has to
be run when switching between build modes because the kernel build system
recognizes build_mode.h as a dependency and triggers a rebuild of all
source files that directly or indirectly include the build_mode.h header
file.


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8347 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2019-05-05 18:19:38 +00:00

80 lines
1.9 KiB
Makefile

#
# A Makefile for the scst-local ...
#
SHELL=/bin/bash
KMOD := $(shell pwd)/kernel
ifneq ($(PATCHLEVEL),)
ccflags-y += -I$(KBUILD_EXTMOD)/../scst/include
ccflags-y += $(call cc-option,-Wextra) -Wno-unused-parameter\
-Wno-missing-field-initializers
#ccflags-y += -DCONFIG_SCST_LOCAL_DIRECT_PROCESSING
obj-m := scst_local.o
else
######### BEGIN OUT-OF-TREE RULES #########
ifndef PREFIX
PREFIX=/usr/local
endif
ifeq ($(KVER),)
ifeq ($(KDIR),)
KVER := $(shell uname -r)
KDIR := /lib/modules/$(KVER)/build
else
KVER := $(strip $(shell \
cat $(KDIR)/include/config/kernel.release 2>/dev/null || \
make -s -C $(KDIR) kernelversion))
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
SCST_DIR := $(shell echo "$$PWD")/../scst/src
# 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)/Modules.symvers" ]; then \
echo Modules.symvers; else echo Module.symvers; fi)
all: $(MODULE_SYMVERS)
$(MAKE) -C $(KDIR) M=$(shell pwd) BUILD_INI=m
install: all
$(MAKE) -C $(KDIR) M=$(shell pwd) BUILD_INI=m \
$$([ -n "$(DESTDIR)$(INSTALL_MOD_PATH)" ] && echo DEPMOD=true) \
modules_install
$(MODULE_SYMVERS): $(SCST_DIR)/$(MODULE_SYMVERS)
cp $< $@
uninstall:
rm -f $(INSTALL_DIR)/scst_local.ko
-/sbin/depmod -b $(INSTALL_MOD_PATH)/ -a $(KVER)
########## END OUT-OF-TREE RULES ##########
endif
clean:
@$(MAKE) -C $(KDIR) M=$(shell pwd) clean
@$(RM) tags $(MODULE_SYMVERS) Module.markers modules.order
extraclean: clean
rm -f *.orig *.rej
release-archive:
../scripts/generate-release-archive scst_local "$$(sed -n 's/^#define[[:blank:]]SCST_LOCAL_VERSION[[:blank:]]*\"\([^\"]*\)\".*/\1/p' scst_local.c)"
.PHONY: all tgt install uninstall clean extraclean