167 lines
5.6 KiB
Makefile
167 lines
5.6 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
# When the make command line has the goal 'all' or no goal specified (i.e.
|
|
# when compiling the driver) a sub-make of the kernel's Makefile includes
|
|
# the kernel configuration (include/config/auto.conf), but if any other
|
|
# goal is specified (e.g. install) the kernel configuration does not get
|
|
# included. Set a variable and export it to track over sub-makes.
|
|
ifeq ($(MAKELEVEL),0)
|
|
ifeq ($(filter-out all, $(MAKECMDGOALS)),)
|
|
export KERNEL_CONFIG_INCLUDED=1
|
|
endif
|
|
endif
|
|
|
|
# Explicitly set shell to bash, to avoid issues on distros with a different
|
|
# default shell. Looking at you, Ubuntu.
|
|
SHELL=/bin/bash
|
|
|
|
COMMON_MK ?= $(wildcard $(src)/common.mk)
|
|
ifeq (${COMMON_MK},)
|
|
override src = .
|
|
COMMON_MK = $(wildcard $(src)/common.mk)
|
|
endif
|
|
ifeq (${COMMON_MK},)
|
|
$(error Cannot find common.mk build rules)
|
|
else
|
|
include ${COMMON_MK}
|
|
endif
|
|
|
|
# SIOV support is only supported if the kernel has features for controlling
|
|
# PASID support. Do not even try to build SIOV support if the kernel lacks
|
|
# the necessary infrastructure.
|
|
ifeq ($(call is_kcompat_defined,HAVE_PASID_SUPPORT),1)
|
|
ifeq ($(call is_kcompat_defined,HAVE_IOMMU_DEV_FEAT_AUX),1)
|
|
export ENABLE_SIOV_SUPPORT := 1
|
|
endif
|
|
endif
|
|
|
|
# LM support is only enabled if the kernel has features for LM v1 protocol.
|
|
# If the kernel lacks the necessary infrastructure, LM support will be disabled.
|
|
ifeq ($(call is_kcompat_defined,HAVE_LMV1_SUPPORT),1)
|
|
export ENABLE_LM_SUPPORT := 1
|
|
endif
|
|
|
|
ifneq ($(KERNELRELEASE),)
|
|
# kbuild part of makefile
|
|
#
|
|
ccflags-y += -I$(src)
|
|
subdir-ccflags-y += -I$(src)
|
|
|
|
obj-m += crete_vdpa.o
|
|
|
|
crete_vdpa-y := crete_vdpa_main.o \
|
|
crete_vdpa_dev.o \
|
|
|
|
|
|
else # ifneq($(KERNELRELEASE),)
|
|
# normal makefile
|
|
|
|
DRIVER := crete_vdpa
|
|
EXTRA_CFLAGS += -std=gnu11
|
|
|
|
# ice does not support building on kernels older than 3.10.0
|
|
$(call minimum_kver_check,3,10,0)
|
|
|
|
# Command to update initramfs or display a warning message
|
|
ifeq (${cmd_initrd},)
|
|
define cmd_initramfs
|
|
@echo "Unable to update initramfs. You may need to do this manually."
|
|
endef
|
|
else
|
|
define cmd_initramfs
|
|
@echo "Updating initramfs..."
|
|
$(call cmd_initrd)
|
|
endef
|
|
endif
|
|
|
|
all:
|
|
+$(call kernelbuild,modules)
|
|
#@gzip -c ../${DRIVER}.${MANSECTION} > ${DRIVER}.${MANSECTION}.gz
|
|
ifneq ($(wildcard lttng),)
|
|
$(MAKE) -C lttng
|
|
endif
|
|
|
|
clean:
|
|
+$(call kernelbuild,clean)
|
|
@-rm -rf *.${MANSECTION}.gz *.ko
|
|
ifneq ($(wildcard lttng),)
|
|
$(MAKE) -C lttng clean
|
|
endif
|
|
|
|
# Install kernel module files. This target is called by the RPM specfile when
|
|
# generating binary RPMs, and is not expected to modify files outside of the
|
|
# build root. Thus, it must not update initramfs, or run depmod.
|
|
modules_install: all
|
|
+$(call kernelbuild,modules_install)
|
|
#$(MAKE) auxiliary_install
|
|
|
|
# Install kernel module files without auxiliary. This target is called by the
|
|
# RPM specfile when generating binary RPMs, and is not expected to modify
|
|
# files outside of the build root. Thus, it must not update initramfs, or run depmod.
|
|
modules_install_no_aux:
|
|
@+$(call kernelbuild,modules_install)
|
|
|
|
mandocs_install: all
|
|
install -D -m 644 ${DRIVER}.${MANSECTION}.gz ${INSTALL_MOD_PATH}/${MANDIR}/man${MANSECTION}/${DRIVER}.${MANSECTION}.gz
|
|
|
|
# After installing all the files, perform necessary work to ensure the system
|
|
# will use the new modules. This includes running depmod to update module
|
|
# dependencies and updating the initramfs image in case the module is loaded
|
|
# during early boot.
|
|
install: modules_install
|
|
$(call cmd_depmod)
|
|
$(call cmd_initramfs)
|
|
|
|
# Remove installed module files. This target is called by the RPM specfile when
|
|
# generating binary RPMs, and is not expected to modify files outside of the
|
|
# build root. Thus, it must not update the initramfs image or run depmod.
|
|
modules_uninstall:
|
|
rm -f ${INSTALL_MOD_PATH}/lib/modules/${KVER}/${INSTALL_MOD_DIR}/${DRIVER}.ko
|
|
#$(MAKE) auxiliary_uninstall
|
|
|
|
mandocs_uninstall:
|
|
rm -f ${INSTALL_MOD_PATH}/${MANDIR}/man${MANSECTION}/${DRIVER}.${MANSECTION}.gz 2>/dev/null
|
|
|
|
# After uninstalling all the files, perform necessary work to restore the
|
|
# system back to using the default kernel modules. This includes running depmod
|
|
# to update module dependencies and updating the initramfs image.
|
|
uninstall: modules_uninstall
|
|
$(call cmd_depmod)
|
|
$(call cmd_initramfs)
|
|
|
|
#auxiliary_info:
|
|
# @../scripts/check_aux_bus --verbose --ksrc="${KSRC}" --build-kernel="${BUILD_KERNEL}"
|
|
|
|
#auxiliary_install:
|
|
# ${auxiliary_post_install}
|
|
|
|
#auxiliary_uninstall:
|
|
# ${auxiliary_post_uninstall}
|
|
|
|
#ifeq (${NEED_AUX_BUS},1)
|
|
#all: auxiliary_info
|
|
#endif
|
|
|
|
help:
|
|
@echo 'Building external (out-of-tree) modules:'
|
|
@echo ' all - default target, build the module(s) and manpage'
|
|
@echo ' clean - remove generated files'
|
|
@echo ' modules_install - install the module(s) only'
|
|
@echo ' install - install the module(s) and manpage, and update initramfs'
|
|
@echo ' modules_uninstall - uninstall the module(s) only'
|
|
@echo ' uninstall - uninstall the module(s) and manpage, and update initramfs'
|
|
@echo ''
|
|
@echo 'Command-line options:'
|
|
@echo ' KSRC=<path> - Path to kernel source (defaults to running kernel)'
|
|
@echo ' LINUX_VERSION=<x.y.z> - Debug tool to force kernel LINUX_VERSION_CODE for'
|
|
@echo ' external module(s). *** Use at your own risk! ***'
|
|
@echo ' INSTALL_MOD_PATH=<path> - Prefix added to default module(s) installation path'
|
|
@echo ' (/lib/modules/$$(KERNELRELEASE)/)'
|
|
@echo ' INSTALL_MOD_DIR=<path> - Install module(s) in subdirectory other than default'
|
|
@echo ' (.../updates/drivers/net/ethernet/jm/${DRIVER}/)'
|
|
@echo ''
|
|
|
|
.PHONY: all clean modules_install install modules_uninstall uninstall help
|
|
|
|
endif # ifneq($(KERNELRELEASE),)
|