forked from intel/ethernet-linux-idpf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
190 lines (164 loc) · 6.12 KB
/
Makefile
File metadata and controls
190 lines (164 loc) · 6.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (C) 2021 Intel Corporation
TARGETS := idpf auxiliary
VERSION := 1.0.6
# Shortcut version target
ifneq ($(filter version,${MAKECMDGOALS}),)
.PHONY: ${MAKECMDGOALS}
version:
@echo ${VERSION}
$(filter-out version,${MAKECMDGOALS}):
@true
else # version target handling
ifneq (${KERNELRELEASE},)
# Kbuild part of makefile
obj-y := $(strip $(addsuffix /src/,${TARGETS}))
ccflags-y += -I$(src)
subdir-ccflags-y += -I$(src)
# Apply build modifier flags
ifeq (${BUILD_UPLINK_PORT_STATS},YES)
ccflags-y += -DCONFIG_UPLINK_PORT_STATS
subdir-ccflags-y += -DCONFIG_UPLINK_PORT_STATS
endif
ifeq (${BUILD_RCA},YES)
ccflags-y += -DCONFIG_RCA_SUPPORT -DCONFIG_OEM_CAPS
subdir-ccflags-y += -DCONFIG_RCA_SUPPORT -DCONFIG_OEM_CAPS
endif
else # ifneq (${KERNELRELEASE},)
# normal make
# Default to using updates/drivers/net/ethernet/intel/ path, since depmod since
# v3.1 defaults to checking updates folder first, and only checking kernels/
# and extra afterwards. We use updates instead of kernel/* due to desire to
# prevent over-writing built-in modules files.
export INSTALL_MOD_DIR ?= updates/drivers/net/ethernet/intel/
ifeq (${BUILD_KERNEL},)
BUILD_KERNEL=$(shell uname -r)
endif
# Kernel Search Path
# All the places we look for kernel source
KSP := /lib/modules/${BUILD_KERNEL}/source \
/lib/modules/${BUILD_KERNEL}/build \
/usr/src/linux-${BUILD_KERNEL} \
/usr/src/linux-$(${BUILD_KERNEL} | sed 's/-.*//') \
/usr/src/kernel-headers-${BUILD_KERNEL} \
/usr/src/kernel-source-${BUILD_KERNEL} \
/usr/src/linux-$(${BUILD_KERNEL} | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/') \
/usr/src/linux \
/usr/src/kernels/${BUILD_KERNEL} \
/usr/src/kernels
# prune the list down to only values that exist and have an include/linux
# sub-directory. We can't use include/config because some older kernels don't
# have this.
test_dir = $(shell [ -e ${dir}/include/linux ] && echo ${dir})
KSP := $(foreach dir, ${KSP}, ${test_dir})
# We will use this first valid entry in the search path, unless KSRC was set
# by the caller, in which case we assume a custom build and will skip depmod
# and initramfs update.
ifeq (,${KSRC})
KSRC := $(firstword ${KSP})
else
CUSTOM_BUILD := 1
endif
ifeq (,${KSRC})
$(warning *** Kernel header files not in any of the expected locations.)
$(warning *** Install the appropriate kernel development package, e.g.)
$(error kernel-devel, for building kernel modules and try again)
endif
CHECK_AUX_BUS := $(realpath ./scripts/check_aux_bus)
$(shell chmod +x ${CHECK_AUX_BUS})
include idpf/src/common.mk
# 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.
ifneq ($(shell grep HAVE_PASID_SUPPORT idpf/src/kcompat_generated_defs.h),)
export ENABLE_SIOV_SUPPORT := 1
else
# Force SIOV support on ARM, which is needed by ACC. Since we cannot
# distinguish between IMC and ACC, IMC may also include this code, but
# the users will not be able to use mdevs.
ifneq ($(findstring aarch64-intel-linux-,$(CC)),)
export ENABLE_SIOV_SUPPORT := 1
override CFLAGS_EXTRA += -DENABLE_ACC_PASID_WA
endif
endif # HAVE_PASID_SUPPORT is in kcompat_generated_defs.h
ifneq ($(shell grep HAVE_DEVLINK_PORT_NEW idpf/src/kcompat_generated_defs.h),)
export ENABLE_DEVLINK_SUPPORT := 1
endif # HAVE_DEVLINK_PORT_NEW is in kcompat_generated_defs.h
# Construct CONFIG_<DRIVER>=m directives for all the targets. Define a
# 'to_upper' function to translate targets to uppercase.
to_upper = $(shell echo '$1' | tr '[:lower:]' '[:upper:]')
CONFIG_DRIVERS := $(strip $(addsuffix =m,$(addprefix CONFIG_,$(call to_upper,${TARGETS}))))
ifeq (${SPARSE_CHECK},YES)
EXTRA_OPTS += C=2 W=1 CF="-D__CHECK_ENDIAN__"
endif
# Wrapper around kcompat's cmd_initrd, with checks for module signing.
ifeq (${CUSTOM_BUILD},1)
define cmd_initrd_check
@echo "Custom build detected. Skipping initramfs update."
endef
else ifeq (${cmd_initrd},)
define cmd_initrd_check
@echo "Unable to update initramfs. You may need to do this manually."
endef
else ifeq (${DISABLE_MODULE_SIGNING},Yes)
define cmd_initrd_check
@echo "Skipping initramfs update because idpf module cannot be signed."
endef
else
define cmd_initrd_check
@echo "Updating initramfs..."
$(call cmd_initrd)
endef
endif
#Wrapper around kcompat's cmd_depmod. In some build environments, depmod may not be present.
ifeq (${CUSTOM_BUILD},1)
define cmd_initrd_check
@echo "Custom build detected. Skipping depmod update."
endef
else ifeq (${cmd_depmod},)
define cmd_depmod_check
@echo "Unable to run depmod. You may need to do this manually."
endef
else ifeq (,$(wildcard /sbin/depmod))
define cmd_depmod_check
@echo "Unable to run depmod. You may need to do this manually."
endef
else
define cmd_depmod_check
@echo "Calling post install depmod..."
$(call cmd_depmod)
endef
endif
# Set default goal to compile (must be set before the first target is defined)
.DEFAULT_GOAL := compile
# Ensure kcompat_generated_defs.h exists for all targets before compiling
# This is done by invoking a simple target in each module's Makefile which
# will cause common.mk to be included and generate the kcompat file
.PHONY: prepare_kcompat
prepare_kcompat:
@for target in ${TARGETS}; do \
if [ -f $$target/src/Makefile ]; then \
${MAKE} -C $$target/src --no-print-directory -s version 2>/dev/null || true; \
fi; \
done
compile: prepare_kcompat
@${MAKE} -C ${KSRC} M=$$PWD ${CONFIG_DRIVERS} ccflags-y="${CFLAGS_EXTRA} ${EXTRA_CFLAGS}" modules \
NEED_AUX_BUS=${NEED_AUX_BUS} \
BUILD_UPLINK_PORT_STATS=${BUILD_UPLINK_PORT_STATS} \
BUILD_RCA=${BUILD_RCA} \
${EXTRA_OPTS}
.PHONY: install
install: compile
$(call kernelbuild,${CONFIG_DRIVERS},modules_install)
$(call cmd_depmod_check)
$(call cmd_initrd_check)
INSTALLED_MODS := $(strip $(addprefix ${INSTALL_MOD_PATH}/lib/modules/${KVER}/${INSTALL_MOD_DIR}/,${TARGETS}))
.PHONY: uninstall
uninstall:
rm -rf ${INSTALLED_MODS}
.PHONY: clean
clean:
@${MAKE} -C ${KSRC} M=$$PWD clean
@rm -f idpf/src/kcompat_generated_defs.h auxiliary/src/kcompat_generated_defs.h
endif # ifneq (${KERNELRELEASE},)
endif # version target handling