Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·283 lines (240 loc) · 7.63 KB
/
Copy pathMakefile
File metadata and controls
executable file
·283 lines (240 loc) · 7.63 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
SHELL = /bin/bash
#
# makefile parameters:
# - KDIR/KSRC/KOBJ=, optional
# - install_path=, override all install directories
# - kernel_install_path=, override install directory for kernel module
# - dev_install_path=, override install directory for development headers
# - apps_install_path=, override install directory for applications
# - docs_install_path=, override install directory for man pages
#
# - enable_cmpt_immediate_data=<0|1> enable immediate data in writeback desc.
# - disable_st_c2h_completion=<0|1> disable completion
# - CROSS_COMPILE=, gcc compiler prefix for architecture eg. aarch64-linux-gnu-
apps_install_path ?= /usr/local/sbin
# Define grep error output to NULL, since -s is not portable.
grep = grep 2>/dev/null
# ALL subdirectories
ALLSUBDIRS := src
DRIVER_SRC_DIR := src
# subdirectories to be build
SUBDIRS := $(ALLSUBDIRS)
# Honor the -s (silent) make option.
verbose := $(if $(filter s,$(MAKEFLAGS)),,-v)
# Define paths.
srcdir := $(shell pwd)
topdir := $(shell cd $(srcdir)/.. && pwd)
bin_dir := $(topdir)/bin
# edit by cxz(24/04/15) used for ubuntu22.04 5.15.0-102-generic
modulesymfile := /usr/src/linux-headers-$(shell uname -r)/Module.symvers
kernel_check = 1
distro_check = 1
ifeq ($(filter clean,$(MAKECMDGOALS)),clean)
kernel_check = 0
distro_check = 0
endif
ifeq ($(filter uninstall,$(MAKECMDGOALS)),uninstall)
distro_check = 0
endif
ifeq ($(kernel_check),1)
include make_rules/kernel_check.mk
ifeq ($(distro_check),1)
include make_rules/distro_check.mk
endif
endif
ifneq ($(wildcard $(KINC)/linux/kconfig.h),)
FLAGS += -DKERNEL_HAS_KCONFIG_H
endif
ifneq ($(wildcard $(KINC)/linux/export.h),)
FLAGS += -DKERNEL_HAS_EXPORT_H
endif
# Debug flags.
ifeq ($(DEBUG),1)
FLAGS += -g -DDEBUG
endif
# Debugfs flags
ifneq ($(DEBUGFS),0)
FLAGS += -DDEBUGFS
endif
# LOOPBACK flags.
ifeq ($(LOOPBACK),1)
FLAGS += -DLOOPBACK_TEST
endif
ifeq ($(DEBUG_THREADS),1)
FLAGS += -DDEBUG -DDEBUG_THREADS
endif
ifeq ($(enable_cmpt_immediate_data),1)
FLAGS += -DXNL_IMM_DATA_EN
endif
ifeq ($(disable_st_c2h_completion),1)
FLAGS += -DXMP_DISABLE_ST_C2H_CMPL
endif
# 64B Descriptor Bypass flags.
ifeq ($(TEST_64B_DESC_BYPASS),1)
FLAGS += -DTEST_64B_DESC_BYPASS_FEATURE
endif
ifeq ($(ERR_DEBUG),1)
EXTRA_FLAGS += -DERR_DEBUG
# FLAGS += -DERR_DEBUG
export EXTRA_FLAGS
endif
ifeq ($(TANDEM_BOOT_SUPPORTED),1)
EXTRA_FLAGS += -DTANDEM_BOOT_SUPPORTED
export EXTRA_FLAGS
endif
ifeq ($(EQDMA_CPM5_VF_GT_256Q_SUPPORTED),1)
EXTRA_FLAGS += -DEQDMA_CPM5_VF_GT_256Q_SUPPORTED
export EXTRA_FLAGS
endif
ifeq ($(EQDMA_CPM5_10BIT_TAG_ENABLE),1)
EXTRA_FLAGS += -DEQDMA_CPM5_10BIT_TAG_ENABLE
export EXTRA_FLAGS
endif
# Don't allow ARCH to overwrite the modified variable when passed to
# the sub-makes.
MAKEOVERRIDES := $(filter-out ARCH=%,$(MAKEOVERRIDES))
# Don't allow CFLAGS/EXTRA_CFLAGS to clobber definitions in sub-make.
MAKEOVERRIDES := $(filter-out CFLAGS=%,$(MAKEOVERRIDES))
MAKEOVERRIDES := $(filter-out EXTRA_CFLAGS=%,$(MAKEOVERRIDES))
# Exports.
export grep
export srcdir
export topdir
export bin_dir
export KERNELRELEASE
export KSRC
export KOBJ
export KINC
# arm64 specific fix to include <ksrc>/arch/<karch> folder properly.
# This hack is motivated by the RHEL7.X/CentOS7.X release where the
# uname Architecture is indicated as "aarch64" but the real Architecture
# source directory is "arm64"
ifeq ($(ARCH),aarch64)
ifeq ($(wildcard $(KOBJ)/arch/$(ARCH)/Makefile),)
override MAKECMDGOALS = $(MAKECMDGOALS) "ARCH=arm64"
export ARCH
else
export ARCH
endif
else
export ARCH
endif
CFLAGS += -I$(srcdir)/src/libqdma/qdma_access
CFLAGS += -I$(srcdir)/src/libqdma
export FLAGS += $(CFLAGS)
#export FLAGS += $(CFLAGS) $(EXTRA_CFLAGS) $(CPPFLAGS)
export verbose
export utsrelease
export kversions
export kseries
export modulesymfile
#export enable_xvc
CROSS_COMPILE_FLAG = $(CROSS_COMPILE)
export CROSS_COMPILE_FLAG
$(info CROSS_COMPILE_FLAG = $(CROSS_COMPILE_FLAG).)
$(info ARCH = $(ARCH).)
# evaluate install paths
ifeq ($(install_path),)
# defaults
kernel_install_path ?= $(PREFIX)/lib/modules/$(utsrelease)/updates/kernel/drivers/qdma
dev_install_path ?= /usr/local/include/qdma
docs_install_path ?= /usr/share/man/man8
else # bundled install
kernel_install_path ?= $(install_path)/modules
dev_install_path ?= $(install_path)/include/qdma
docs_install_path ?= $(install_path)/doc
endif
$(shell rm -f $(srcdir)/src/libqdma; ln -fs $(srcdir)/libqdma $(srcdir)/src;)
.PHONY: eval.mak
.PHONY: default
default: mod_pf post clean
.PHONY: pf
pf: mod_pf
.PHONY: vf
vf: mod_vf
.PHONY: mods
mod: mod_pf mod_vf
.PHONY: mod_pf
mod_pf:
@if [ -n "$(verbose)" ]; then \
echo "#######################";\
printf "#### PF %-8s%5s####\n" $(DRIVER_SRC_DIR);\
echo "#######################";\
fi;
@srcdir=$(shell pwd)/$(DRIVER_SRC_DIR) $(MAKE) VF=0 -C $(DRIVER_SRC_DIR);
.PHONY: mod_vf
mod_vf:
@if [ -n "$(verbose)" ]; then \
echo "#######################";\
printf "#### VF %-8s%5s####\n" $(DRIVER_SRC_DIR);\
echo "#######################";\
fi;
@srcdir=$(shell pwd)/$(DRIVER_SRC_DIR) $(MAKE) VF=1 -C $(DRIVER_SRC_DIR);
.PHONY: post
post:
@if [ -n "$(post_msg)" ]; then \
echo -e "\nWARNING:\n $(post_msg)";\
fi;
.PHONY: clean
clean:
@for dir in $(ALLSUBDIRS); do \
echo "#######################";\
printf "#### %-8s%5s####\n" $$dir;\
echo "#######################";\
srcdir=$(shell pwd)/$$dir $(MAKE) -C $$dir clean;\
done;
@-/bin/rm -f *.symvers eval.mak 2>/dev/null;
@-/bin/rm -rf $(shell pwd)/libqdma/qdma_access/*.o $(shell pwd)/libqdma/qdma_access/.*.o.* $(shell pwd)/libqdma/qdma_access/.*.cmd $(shell pwd)/libqdma/qdma_access/.*.o.cmd
@-/bin/rm -rf $(shell pwd)/src/libqdma
.PHONY: install-mods
install-mods:
@echo "installing kernel modules to $(kernel_install_path) ..."
@mkdir -p -m 755 $(kernel_install_path)
@install -v -m 644 $(bin_dir)/*.ko $(kernel_install_path)
@depmod -a || true
.PHONY: uninstall-mods
uninstall-mods:
@echo "Un-installing $(kernel_install_path) ..."
@/bin/rm -rf $(kernel_install_path)/*
@depmod -a
.PHONY: help
help:
@echo "Build Targets:";\
echo " install-mods - Installs drivers.";\
echo " uninstall-mods - Uninstalls drivers.";\
echo;\
echo "Build Options:";\
echo " KOBJ=<path> - Kernel build (object) path.";\
echo " KSRC=<path> - Kernel source path.";\
echo " - Note: When using KSRC or KOBJ, both";\
echo " variables must be specified.";\
echo " KDIR=<path> - Kernel build and source path. Shortcut";\
echo " for KOBJ=KSRC=<path>.";\
echo " kernel_install_path=<path>";\
echo " - kernel module install path.";\
.PHONY: install-apps
install-apps:
@echo "installing apps to $(apps_install_path) ..."
@mkdir -p -m 755 $(apps_install_path)
@install -v -m 755 bin/dma-ctl* $(apps_install_path)
@install -v -m 755 bin/dma-xfer* $(apps_install_path)
@install -v -m 755 bin/dma-from-device $(apps_install_path)
@install -v -m 755 bin/dma-to-device $(apps_install_path)
@install -v -m 755 bin/dma-perf $(apps_install_path)
@install -v -m 755 bin/dma-latency $(apps_install_path)
@install -v -m 774 src/rc4ml.h /usr/include
.PHONY: uninstall-apps
uninstall-apps:
@echo "Un-installing apps under $(apps_install_path) ..."
@/bin/rm -f $(apps_install_path)/dma-ctl
@/bin/rm -f $(apps_install_path)/dma-xfer
@/bin/rm -f $(apps_install_path)/dma-from-device
@/bin/rm -f $(apps_install_path)/dma-to-device
@/bin/rm -f $(apps_install_path)/dma-perf
@/bin/rm -f $(apps_install_path)/dma-latency
.PHONY: apps
apps:
@echo "#######################";
@echo "#### apps ####";
@echo "#######################";
$(MAKE) -C apps