summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile25
1 files changed, 24 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 9ac1860..b009bb6 100644
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,7 @@
# Global configuration (file paths and config)
#------------------------------------------------------------------------------
KERNEL_SRC_DIR := $(shell pwd)/implementation/loop
+KERNEL_MOD_PATH := drivers/block/loop/
KERNEL_HDR_DIR := /lib/modules/$(shell uname -r)/build
LOSETUP_SRC_DIR := $(shell pwd)/implementation/losetup
KERNEL_MOD_CONFIG := $(shell pwd)/config/kernel-qcow2_x86-64_module.config
@@ -19,7 +20,7 @@ LOCAL_MOD_CONFIG += CONFIG_BLK_DEV_LOOP_FILE_FMT_QCOW=m
BUILD ?= vanilla
KERNEL_DIR ?= $(KERNEL_SRC_DIR)
CONFIG ?= KCONFIG_CONFIG=$(KERNEL_MOD_CONFIG)
-TARGET_PATH_PREFX ?= drivers/block/loop/
+TARGET_PATH_PREFX ?= $(KERNEL_MOD_PATH)
ifeq ($(BUILD),out-of-tree)
PATCH = patch
@@ -73,6 +74,28 @@ clean_losetup:
@cd $(LOSETUP_SRC_DIR) && \
$(MAKE) --no-print-directory clean
+ifeq ($(BUILD),out-of-tree)
+loop.load: loop.ko
+loop_file_fmt_raw.load: loop_file_fmt_raw.ko loop.load
+loop_file_fmt_qcow.load: loop_file_fmt_qcow.ko loop.load
+
+loop.unload: loop_file_fmt_raw.unload loop_file_fmt_qcow.unload
+loop_file_fmt_raw.unload:
+loop_file_fmt_qcow.unload:
+
+load_modules: loop.load loop_file_fmt_raw.load loop_file_fmt_qcow.load
+
+unload_modules: loop_file_fmt_qcow.unload loop_file_fmt_raw.unload loop.unload
+
+%.load:
+ $(call print_heading,"Load kernel module $(basename $@)")
+ sudo insmod $(KERNEL_SRC_DIR)/$(KERNEL_MOD_PATH)$(basename $@).ko
+
+%.unload:
+ $(call print_heading,"Unload kernel module $(basename $@)")
+ sudo rmmod $(basename $@)
+endif
+
#------------------------------------------------------------------------------
# Function definitions
#------------------------------------------------------------------------------