# DKMS module name and version
PACKAGE_NAME="mlnx-nvme"
PACKAGE_VERSION="4.0"

is_conf_set() {
	grep -q "^$1=[ym]" "$kernel_source_dir/.config" 2>/dev/null
}

kernelver=${kernelver:-$(uname -r)}
kernel_source_dir=${kernel_source_dir:-/lib/modules/$kernelver/build}

# Module name, source and destination directories, and build command-line
BUILT_MODULE_NAME=()
BUILT_MODULE_LOCATION=()
DEST_MODULE_LOCATION=()

#
# host
#
BUILT_MODULE_NAME+=("nvme-core")
BUILT_MODULE_LOCATION+=("./host/")
DEST_MODULE_LOCATION+=("/kernel/../updates/")

BUILT_MODULE_NAME+=("nvme")
BUILT_MODULE_LOCATION+=("./host/")
DEST_MODULE_LOCATION+=("/kernel/../updates/")

BUILT_MODULE_NAME+=("nvme-fabrics")
BUILT_MODULE_LOCATION+=("./host/")
DEST_MODULE_LOCATION+=("/kernel/../updates/")

BUILT_MODULE_NAME+=("nvme-rdma")
BUILT_MODULE_LOCATION+=("./host/")
DEST_MODULE_LOCATION+=("/kernel/../updates/")

BUILT_MODULE_NAME+=("nvme-fc")
BUILT_MODULE_LOCATION+=("./host/")
DEST_MODULE_LOCATION+=("/kernel/../updates/")

if is_conf_set CONFIG_NVME_TCP; then
BUILT_MODULE_NAME+=("nvme-tcp")
BUILT_MODULE_LOCATION+=("./host/")
DEST_MODULE_LOCATION+=("/kernel/../updates/")
fi

if is_conf_set CONFIG_NVME_APPLE; then
BUILT_MODULE_NAME+=("nvme-apple")
BUILT_MODULE_LOCATION+=("./host/")
DEST_MODULE_LOCATION+=("/kernel/../updates/")
fi
#
# target
#
BUILT_MODULE_NAME+=("nvmet")
BUILT_MODULE_LOCATION+=("./target/")
DEST_MODULE_LOCATION+=("/kernel/../updates/")

BUILT_MODULE_NAME+=("nvme-loop")
BUILT_MODULE_LOCATION+=("./target/")
DEST_MODULE_LOCATION+=("/kernel/../updates/")

BUILT_MODULE_NAME+=("nvmet-rdma")
BUILT_MODULE_LOCATION+=("./target/")
DEST_MODULE_LOCATION+=("/kernel/../updates/")

BUILT_MODULE_NAME+=("nvmet-fc")
BUILT_MODULE_LOCATION+=("./target/")
DEST_MODULE_LOCATION+=("/kernel/../updates/")

if is_conf_set CONFIG_NVME_TCP; then
BUILT_MODULE_NAME+=("nvmet-tcp")
BUILT_MODULE_LOCATION+=("./target/")
DEST_MODULE_LOCATION+=("/kernel/../updates/")
fi

BUILT_MODULE_NAME+=("nvme-fcloop")
BUILT_MODULE_LOCATION+=("./target/")
DEST_MODULE_LOCATION+=("/kernel/../updates/")


MAKE="make -j`MLXNUMC=$(grep ^processor /proc/cpuinfo | wc -l) && echo $(($MLXNUMC<16?$MLXNUMC:16))` KVER=$kernelver K_BUILD=$kernel_source_dir CONFIG_NVME_HOST_WITHOUT_FC="

# Cleanup command-line
CLEAN="make clean"

# disable autoinstall since this module depends on mlnx-ofed-kernel-dkms
# mlnx-ofed-kernel-dkms will build this module on POST_INSTALL
AUTOINSTALL=
