aboutsummaryrefslogtreecommitdiffstats
path: root/dpdk/Makefile
blob: a4abac8753c2c18c3b8fa871733dfb7713e1f3a4 (plain)
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
# Copyright (c) 2015 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Scripts require non-POSIX parts of bash
SHELL := /bin/bash

RTE_OUTPUT ?= $(O)

DOWNLOAD_DIR := $(CURDIR)/downloads
MESON_DIR := $(CURDIR)/meson

DPDK_VERSION          ?= 20.11
DPDK_SRC_DIR          ?= $(RTE_OUTPUT)-src
DPDK_BUILD_DIR        ?= $(RTE_OUTPUT)-build
DPDK_INSTALL_DIR      ?= $(RTE_OUTPUT)
DPDK_MARCH            ?= native
DPDK_BUILD            ?= release

S := $(DPDK_SRC_DIR)
B := $(DPDK_BUILD_DIR)
I := $(DPDK_INSTALL_DIR)

DPDK_GIT_REPO ?= http://dpdk.org/git/dpdk-stable

JOBS := $(shell grep processor /proc/cpuinfo | wc -l)

all: build

$(S)/.download.ok:
	@if [ -e $(S) ] ; \
		then rm -rf $(S) ; \
	fi
	$(Q)git clone $(DPDK_GIT_REPO) --branch $(DPDK_VERSION) $(S)
	@touch $@

.PHONY: download
download: $(S)/.download.ok

$(S)/.patch.ok: $(S)/.download.ok
ifneq ($(wildcard $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch),)
	@echo --- patching ---
	for f in $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch ; do \
		echo Applying patch: $$(basename $$f) ; \
		patch -p1 -d $(S) < $$f ; \
	done
endif
	@touch $@

.PHONY: patch
patch: $(S)/.patch.ok

$(MESON_DIR)/meson.ok:
	$(Q)mkdir -p $(DOWNLOAD_DIR)
	$(Q)mkdir -p $(MESON_DIR)
	$(Q)python3 --version
	$(Q)python3 -m venv $(MESON_DIR)
	$(Q)source $(MESON_DIR)/bin/activate && \
	$(Q)pip3 download -d $(DOWNLOAD_DIR) \
		meson==0.55 setuptools wheel pyelftools && \
	deactivate
	$(Q)source $(MESON_DIR)/bin/activate && \
	pip3 install --no-index \
		--find-links=$(DOWNLOAD_DIR) --target=$(MESON_DIR) wheel && \
	deactivate
	$(Q)source $(MESON_DIR)/bin/activate && \
	pip3 install --no-index \
		--find-links=$(DOWNLOAD_DIR) --target=$(MESON_DIR) \
		meson==0.55 pyelftools && \
	deactivate
	@touch $@

.PHONY: config
config: patch $(MESON_DIR)/meson.ok
	$(Q)source $(MESON_DIR)/bin/activate && \
	meson --prefix=$(I) --werror -Dtests=false \
		-Dbuildtype=$(DPDK_BUILD) -Dmachine=$(DPDK_MARCH) $(B) $(S) && \
	deactivate

.PHONY: build
build: config $(B)/build.ninja
	$(Q)source $(MESON_DIR)/bin/activate && \
	meson install -C $(B) && \
	deactivate

.PHONY: clean
clean:
	$(Q)rm -rf $(B) $(I) $(S)