]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdkbuild/Makefile
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / dpdkbuild / Makefile
1 #
2 # BSD LICENSE
3 #
4 # Copyright (c) Intel Corporation.
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 #
11 # * Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # * Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in
15 # the documentation and/or other materials provided with the
16 # distribution.
17 # * Neither the name of Intel Corporation nor the names of its
18 # contributors may be used to endorse or promote products derived
19 # from this software without specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #
33
34 SPDK_ROOT_DIR := $(abspath $(CURDIR)/..)
35 include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
36
37 .PHONY: all clean install uninstall
38
39 DPDK_OPTS = -Denable_docs=false
40 DPDK_CFLAGS =
41
42 DPDK_KMODS = false
43 ifeq ($(CONFIG_IGB_UIO_DRIVER),y)
44 DPDK_KMODS = true
45 endif
46 ifeq ($(OS),FreeBSD)
47 DPDK_KMODS = true
48 endif
49 DPDK_OPTS += -Denable_kmods=$(DPDK_KMODS)
50
51 # the drivers we use
52 DPDK_DRIVERS = bus bus/pci bus/vdev mempool/ring
53
54 ifeq ($(CONFIG_CRYPTO),y)
55 # crypto/qat is just a stub, the compress/qat pmd is used instead
56 DPDK_DRIVERS += crypto crypto/aesni_mb crypto/qat compress/qat common/qat
57 DPDK_CFLAGS += -I$(IPSEC_MB_DIR)
58 DPDK_LDFLAGS += -L$(IPSEC_MB_DIR)
59 endif
60
61 ifeq ($(CONFIG_REDUCE),y)
62 DPDK_DRIVERS += compress compress/isal compress/qat common/qat
63 DPDK_CFLAGS += -I$(ISAL_DIR)
64 DPDK_LDFLAGS += -L$(ISAL_DIR)/.libs -lisal
65 endif
66
67 DPDK_OPTS += -Dmachine=$(TARGET_ARCHITECTURE)
68
69 ifneq ($(CONFIG_CROSS_PREFIX),)
70 $(error Automatic DPDK cross build is not supported. Please compile DPDK manually \
71 with e.g. `meson build --cross-file config/arm/arm64_armv8_linux_gcc`)
72 endif
73
74 DPDK_CFLAGS += -fPIC
75
76 ifeq ($(CONFIG_DEBUG),y)
77 DPDK_CFLAGS += -O0 -g
78 endif
79
80 ifeq ($(CONFIG_WERROR),y)
81 DPDK_CFLAGS += -Werror
82 else
83 DPDK_CFLAGS += -Wno-error
84 endif
85
86 ifdef EXTRA_DPDK_CFLAGS
87 $(warning EXTRA_DPDK_CFLAGS defined, possibly to work around an unsupported compiler version)
88 $(shell sleep 1)
89 endif
90
91 # Allow users to specify EXTRA_DPDK_CFLAGS if they want to build DPDK using unsupported compiler versions
92 DPDK_CFLAGS += $(EXTRA_DPDK_CFLAGS)
93
94 ifeq ($(CC_TYPE),gcc)
95 GCC_MAJOR = $(shell echo __GNUC__ | $(CC) -E -x c - | tail -n 1)
96 ifeq ($(shell test $(GCC_MAJOR) -ge 10 && echo 1), 1)
97 #1. gcc 10 complains on operations with zero size arrays in rte_cryptodev.c, so
98 #disable this warning
99 #2. gcc 10 disables fcommon by default and complains on multiple definition of
100 #aesni_mb_logtype_driver symbol which is defined in header file and presented in sevral
101 #translation units
102 DPDK_CFLAGS += -Wno-stringop-overflow -fcommon
103 endif
104 endif
105
106 # Force-disable scan-build
107 SUB_CC = $(patsubst %ccc-analyzer,$(DEFAULT_CC),$(CC))
108
109 DPDK_ALL_DRIVER_DIRS = $(shell find $(SPDK_ROOT_DIR)/dpdk/drivers -mindepth 1 -type d)
110 DPDK_ALL_DRIVERS = $(DPDK_ALL_DRIVER_DIRS:$(SPDK_ROOT_DIR)/dpdk/drivers/%=%)
111 DPDK_DISABLED_DRVERS = $(filter-out $(DPDK_DRIVERS),$(DPDK_ALL_DRIVERS))
112
113 ifeq ($(OS),Linux)
114 SED_INPLACE_FLAG = "-i"
115 MESON_PREFIX = $(SPDK_ROOT_DIR)/dpdk/build
116 else
117 SED_INPLACE_FLAG = "-i ''"
118 MESON_PREFIX = "/"
119 endif
120
121 # Some ninja versions come with a (broken?) jobserver which defaults to use
122 # only 1 thread for the build. We workaround this by specifying -j to ninja
123 # with the same value as top-makefile. This is OK as long as DPDK is not built
124 # in parralel with anything else, which is the case for now.
125 ifeq ($(MAKE_PID),)
126 MAKE_PID := $(shell echo $$PPID)
127 endif
128
129 MAKE_NUMJOBS := $(shell ps T | sed -nE 's/\s*$(MAKE_PID)\s.* (-j|--jobs=)( *[0-9]+).*/\1\2/p')
130
131 all: $(SPDK_ROOT_DIR)/dpdk/build-tmp
132 $(Q)# DPDK doesn't handle nested make calls, so unset MAKEFLAGS
133 $(Q)env -u MAKEFLAGS ninja -C $(SPDK_ROOT_DIR)/dpdk/build-tmp $(MAKE_NUMJOBS)
134 $(Q) \
135 # Meson on FreeBSD sometimes appends --prefix value to the default DESTDIR (which is e.g. \
136 # /usr/local) instead of replacing it. --prefix needs to be an absolute path, so we set \
137 # it to / and then set DESTDIR directly, so libs and headers are copied to "DESTDIR//". \
138 # DPDK kernel modules are set to install in $DESTDIR/boot/modules, but we move them \
139 # to DESTDIR/kmod to be consistent with the makefile build.
140 $(Q)if [ "$(OS)" = "FreeBSD" ]; then \
141 env -u MAKEFLAGS DESTDIR=$(SPDK_ROOT_DIR)/dpdk/build ninja -C $(SPDK_ROOT_DIR)/dpdk/build-tmp $(MAKE_NUMJOBS) install > /dev/null && \
142 mv $(SPDK_ROOT_DIR)/dpdk/build/boot/modules $(SPDK_ROOT_DIR)/dpdk/build/kmod; \
143 else \
144 env -u MAKEFLAGS ninja -C $(SPDK_ROOT_DIR)/dpdk/build-tmp $(MAKE_NUMJOBS) install > /dev/null; \
145 fi
146
147 $(SPDK_ROOT_DIR)/dpdk/build-tmp: $(SPDK_ROOT_DIR)/mk/cc.mk $(SPDK_ROOT_DIR)/include/spdk/config.h
148 $(Q)rm -rf $(SPDK_ROOT_DIR)/dpdk/build $(SPDK_ROOT_DIR)/dpdk/build-tmp
149 $(Q)cd "$(SPDK_ROOT_DIR)/dpdk"; CC="$(SUB_CC)" meson --prefix="$(MESON_PREFIX)" --libdir lib -Dc_args="$(DPDK_CFLAGS)" -Dc_link_args="$(DPDK_LDFLAGS)" $(DPDK_OPTS) -Ddisable_drivers="$(shell echo $(DPDK_DISABLED_DRVERS) | sed -E "s/ +/,/g")" build-tmp
150 $(Q)sed $(SED_INPLACE_FLAG) 's/#define RTE_EAL_PMD_PATH .*/#define RTE_EAL_PMD_PATH ""/g' $(SPDK_ROOT_DIR)/dpdk/build-tmp/rte_build_config.h
151 $(Q) \
152 # TODO Meson build adds libbsd dependency when it's available. This means any app will be \
153 # forced to link with -lbsd, but only if it's available on the system. The clean way to \
154 # handle this would be to rely on DPDK's pkg-config file which will contain the -lbsd when \
155 # required. For now just remove the libbsd dependency. DPDK will fallback to its internal \
156 # functions.
157 $(Q)sed $(SED_INPLACE_FLAG) 's/#define RTE_USE_LIBBSD .*//g' $(SPDK_ROOT_DIR)/dpdk/build-tmp/rte_build_config.h
158
159 clean:
160 $(Q)rm -rf $(SPDK_ROOT_DIR)/dpdk/build $(SPDK_ROOT_DIR)/dpdk/build-tmp
161
162 install:
163 @:
164
165 uninstall:
166 @: