[ansible][fedora] Update package name
[barometer.git] / src / dpdk / Makefile
1 # makefile to manage dpdk package
2 #
3
4 # Copyright 2015-2019 Intel Corporation and OPNFV. All rights reserved.
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18
19 #
20 # Contributors:
21 #   Aihua Li, Huawei Technologies.
22 #   Martin Klozik, Intel Corporation.
23 #   Christian Trautman, Red Hat Inc.
24 #   Maryam Tahhan, Intel Corporation.
25 #   Jabir Kanhira Kadavathu, Intel Corporation.
26
27 include ../mk/master.mk
28 include ../package-list.mk
29 include /etc/os-release
30
31 .PHONY: install force_make
32
33 WORK_DIR = dpdk
34 TAG_DONE_FLAG = $(WORK_DIR)/.$(DPDK_TAG).tag.done
35
36 # VHOST configuration options are stored in different files based on DPDK version
37 # v1.2.3r0-v1.6.0r2 - configuration inside config/defconfig_x86_64-default-linuxapp-gcc
38 # v1.7.0-rc1-v2.2.0 - configuration inside config/common_linux
39 # v16 and newer - configuration split between config/common_linux and config/common_base
40 DPDK_TAG_MAJOR = $(shell echo $(DPDK_TAG) | cut -d. -f1)
41 DPDK_TAG_MINOR = $(shell echo $(DPDK_TAG) | cut -d. -f2)
42 ifeq ($(DPDK_TAG_MAJOR),v1)
43 ifeq ($(DPDK_TAG_MINOR), $(filter $(DPDK_TAG_MINOR), 7 8))
44     DPDK_TARGET = x86_64-native-linuxapp-gcc
45     CONFIG_FILE_LINUXAPP = $(WORK_DIR)/config/common_linux
46 else
47     DPDK_TARGET = x86_64-default-linuxapp-gcc
48     CONFIG_FILE_LINUXAPP = $(WORK_DIR)/config/defconfig_x86_64-default-linuxapp-gcc
49 endif
50 else
51 ifeq ($(DPDK_TAG_MAJOR),v2)
52     DPDK_TARGET = x86_64-native-linuxapp-gcc
53     CONFIG_FILE_LINUXAPP = $(WORK_DIR)/config/common_linux
54 else
55     DPDK_TARGET = x86_64-native-linuxapp-gcc
56     CONFIG_FILE_BASE = $(WORK_DIR)/config/common_base
57     CONFIG_FILE_LINUXAPP = $(WORK_DIR)/config/common_linux
58 endif
59 endif
60
61 all: force_make install
62         @echo "Finished making $(WORK_DIR) "
63
64 INSTALL_TARGET = force_make
65
66 # modify CONFIG_FILE to enable SHARED_LIB build and restore original CONFIG_FILE after the build
67 # DPDK v16 comments:
68 ## CONFIG_RTE_BUILD_COMBINE_LIBS has been obsoleted
69 ## CONFIG_RTE_LIBRTE_KNI is listed in both config_base and config_linuxapp,
70 ## values from config_linuxapp will be used, but options are modified at both places to avoid confusion.
71 force_make: $(TAG_DONE_FLAG)
72         $(AT)cd $(WORK_DIR) && git pull $(DPDK_URL) $(DPDK_TAG)
73 ifdef CONFIG_FILE_BASE
74         $(AT)sed -i -e 's/CONFIG_RTE_BUILD_SHARED_LIB=./CONFIG_RTE_BUILD_SHARED_LIB=y/g' $(CONFIG_FILE_BASE)
75         $(AT)sed -i -e 's/CONFIG_RTE_EAL_PMD_PATH=.*/CONFIG_RTE_EAL_PMD_PATH=\"\/usr\/lib\/dpdk-pmd\/\"/g' $(CONFIG_FILE_BASE)
76         $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_KNI=./CONFIG_RTE_LIBRTE_KNI=n/g' $(CONFIG_FILE_BASE)
77 else
78         $(AT)sed -i -e 's/CONFIG_RTE_BUILD_SHARED_LIB=./CONFIG_RTE_BUILD_SHARED_LIB=y/g' $(CONFIG_FILE_LINUXAPP)
79         $(AT)sed -i -e 's/CONFIG_RTE_EAL_PMD_PATH=.*/CONFIG_RTE_EAL_PMD_PATH=\"\/usr\/lib\/dpdk-pmd\/\"/g' $(CONFIG_FILE_LINUXAPP)
80         $(AT)sed -i -e 's/CONFIG_RTE_BUILD_COMBINE_LIBS=./CONFIG_RTE_BUILD_COMBINE_LIBS=y/g' $(CONFIG_FILE_LINUXAPP)
81 endif
82 # do not build kernel module under docker
83 ifdef DOCKER
84         $(AT)sed -i -e 's/CONFIG_RTE_EAL_IGB_UIO=y/CONFIG_RTE_EAL_IGB_UIO=n/' $(CONFIG_FILE_LINUXAPP)
85         $(AT)sed -i -e 's/CONFIG_RTE_KNI_KMOD=y/CONFIG_RTE_KNI_KMOD=n/' $(CONFIG_FILE_LINUXAPP)
86 endif
87 # CentOS 7.3 specific config changes to compile
88 ifeq ($(ID),"centos")
89 ifeq ($(VERSION_ID),"7")
90         $(AT)sed -i.bak s@'SRCS-y += ethtool/igb/igb_main.c'@'#SRCS-y += ethtool/igb/igb_main.c'@g $(WORK_DIR)/kernel/linux/kni/Makefile
91 endif
92 endif
93 # RHEL 7.3 specific config changes to compile
94 ifeq ($(ID),"rhel")
95 ifeq ($(VERSION_ID),"7.3")
96         $(AT)sed -i.bak s@'SRCS-y += ethtool/igb/igb_main.c'@'#SRCS-y += ethtool/igb/igb_main.c'@g $(WORK_DIR)/kernel/linux/kni/Makefile
97 endif
98 endif
99         $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_KNI=./CONFIG_RTE_LIBRTE_KNI=n/g' $(CONFIG_FILE_LINUXAPP)
100         $(AT)cd $(WORK_DIR); make config T=$(DPDK_TARGET) -j; make -j DESTDIR=$(WORK_DIR)
101         $(AT)cd `dirname $(CONFIG_FILE_LINUXAPP)` && git checkout `basename $(CONFIG_FILE_LINUXAPP)` && cd -
102         @echo "Make done"
103
104 install: $(INSTALL_TARGET)
105         $(AT)cd $(WORK_DIR); sudo make -j install prefix=/usr; cd -
106         $(AT)sudo mkdir -p /usr/lib/dpdk-pmd
107         $(AT)find /usr/lib -type f -name 'librte_pmd*' | while read path; do sudo ln -fs $$path /usr/lib/dpdk-pmd/$$(echo $$path | grep -o 'librte_.*so'); done
108 # under docker there won't be kernel module available
109 ifndef DOCKER
110         $(AT)sudo cp -a $(WORK_DIR)/build/kmod $(INSTALL_DIR)/lib/modules/$(KERNEL_VERSION)
111 endif
112         @echo "install done"
113
114 # hard way to clean and clobber
115 clean:
116         $(AT)cd $(WORK_DIR) && git clean -xfd *.o
117 clobber:
118         $(AT)rm -rf $(WORK_DIR)
119
120 # distclean is for developer who would like to keep the
121 # clone git repo, saving time to fetch again from url
122 distclean:
123         $(AT)cd $(WORK_DIR) && git clean -xfd && git checkout -f
124
125 test:
126         @echo "Make test in $(WORK_DIR) (stub) "
127
128 sanity:
129         @echo "Make sanity in $(WORK_DIR) (stub) "
130
131 $(WORK_DIR):
132         $(AT)git clone $(DPDK_URL)
133
134 $(TAG_DONE_FLAG): $(WORK_DIR)
135         $(AT)cd $(WORK_DIR); git checkout $(DPDK_TAG)
136         $(AT)touch $@