Updates/Fix on Legal/License Headers
[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
26 include ../mk/master.mk
27 include ../package-list.mk
28 include /etc/os-release
29
30 .PHONY: install force_make
31
32 WORK_DIR = dpdk
33 TAG_DONE_FLAG = $(WORK_DIR)/.$(DPDK_TAG).tag.done
34
35 # VHOST configuration options are stored in different files based on DPDK version
36 # v1.2.3r0-v1.6.0r2 - configuration inside config/defconfig_x86_64-default-linuxapp-gcc
37 # v1.7.0-rc1-v2.2.0 - configuration inside config/common_linuxapp
38 # v16 and newer - configuration split between config/common_linuxapp and config/common_base
39 DPDK_TAG_MAJOR = $(shell echo $(DPDK_TAG) | cut -d. -f1)
40 DPDK_TAG_MINOR = $(shell echo $(DPDK_TAG) | cut -d. -f2)
41 ifeq ($(DPDK_TAG_MAJOR),v1)
42 ifeq ($(DPDK_TAG_MINOR), $(filter $(DPDK_TAG_MINOR), 7 8))
43     DPDK_TARGET = x86_64-native-linuxapp-gcc
44     CONFIG_FILE_LINUXAPP = $(WORK_DIR)/config/common_linuxapp
45 else
46     DPDK_TARGET = x86_64-default-linuxapp-gcc
47     CONFIG_FILE_LINUXAPP = $(WORK_DIR)/config/defconfig_x86_64-default-linuxapp-gcc
48 endif
49 else
50 ifeq ($(DPDK_TAG_MAJOR),v2)
51     DPDK_TARGET = x86_64-native-linuxapp-gcc
52     CONFIG_FILE_LINUXAPP = $(WORK_DIR)/config/common_linuxapp
53 else
54     DPDK_TARGET = x86_64-native-linuxapp-gcc
55     CONFIG_FILE_BASE = $(WORK_DIR)/config/common_base
56     CONFIG_FILE_LINUXAPP = $(WORK_DIR)/config/common_linuxapp
57 endif
58 endif
59
60 all: force_make install
61         @echo "Finished making $(WORK_DIR) "
62
63 INSTALL_TARGET = force_make
64
65 # modify CONFIG_FILE to enable SHARED_LIB build and restore original CONFIG_FILE after the build
66 # DPDK v16 comments:
67 ## CONFIG_RTE_BUILD_COMBINE_LIBS has been obsoleted
68 ## CONFIG_RTE_LIBRTE_KNI is listed in both config_base and config_linuxapp,
69 ## values from config_linuxapp will be used, but options are modified at both places to avoid confusion.
70 force_make: $(TAG_DONE_FLAG)
71         $(AT)cd $(WORK_DIR) && git pull $(DPDK_URL) $(DPDK_TAG)
72 ifdef CONFIG_FILE_BASE
73         $(AT)sed -i -e 's/CONFIG_RTE_BUILD_SHARED_LIB=./CONFIG_RTE_BUILD_SHARED_LIB=y/g' $(CONFIG_FILE_BASE)
74         $(AT)sed -i -e 's/CONFIG_RTE_EAL_PMD_PATH=.*/CONFIG_RTE_EAL_PMD_PATH=\"\/usr\/lib\/dpdk-pmd\/\"/g' $(CONFIG_FILE_BASE)
75         $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_KNI=./CONFIG_RTE_LIBRTE_KNI=n/g' $(CONFIG_FILE_BASE)
76 else
77         $(AT)sed -i -e 's/CONFIG_RTE_BUILD_SHARED_LIB=./CONFIG_RTE_BUILD_SHARED_LIB=y/g' $(CONFIG_FILE_LINUXAPP)
78         $(AT)sed -i -e 's/CONFIG_RTE_EAL_PMD_PATH=.*/CONFIG_RTE_EAL_PMD_PATH=\"\/usr\/lib\/dpdk-pmd\/\"/g' $(CONFIG_FILE_LINUXAPP)
79         $(AT)sed -i -e 's/CONFIG_RTE_BUILD_COMBINE_LIBS=./CONFIG_RTE_BUILD_COMBINE_LIBS=y/g' $(CONFIG_FILE_LINUXAPP)
80 endif
81 # do not build kernel module under docker
82 ifdef DOCKER
83         $(AT)sed -i -e 's/CONFIG_RTE_EAL_IGB_UIO=y/CONFIG_RTE_EAL_IGB_UIO=n/' $(CONFIG_FILE_LINUXAPP)
84         $(AT)sed -i -e 's/CONFIG_RTE_KNI_KMOD=y/CONFIG_RTE_KNI_KMOD=n/' $(CONFIG_FILE_LINUXAPP)
85 endif
86 # CentOS 7.3 specific config changes to compile
87 ifeq ($(ID),"centos")
88 ifeq ($(VERSION_ID),"7")
89         $(AT)sed -i.bak s@'SRCS-y += ethtool/igb/igb_main.c'@'#SRCS-y += ethtool/igb/igb_main.c'@g $(WORK_DIR)/lib/librte_eal/linuxapp/kni/Makefile
90 endif
91 endif
92 # RHEL 7.3 specific config changes to compile
93 ifeq ($(ID),"rhel")
94 ifeq ($(VERSION_ID),"7.3")
95         $(AT)sed -i.bak s@'SRCS-y += ethtool/igb/igb_main.c'@'#SRCS-y += ethtool/igb/igb_main.c'@g $(WORK_DIR)/lib/librte_eal/linuxapp/kni/Makefile
96 endif
97 endif
98         $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_KNI=./CONFIG_RTE_LIBRTE_KNI=n/g' $(CONFIG_FILE_LINUXAPP)
99         $(AT)cd $(WORK_DIR); make config T=$(DPDK_TARGET) -j; make -j DESTDIR=$(WORK_DIR)
100         $(AT)cd `dirname $(CONFIG_FILE_LINUXAPP)` && git checkout `basename $(CONFIG_FILE_LINUXAPP)` && cd -
101         @echo "Make done"
102
103 install: $(INSTALL_TARGET)
104         $(AT)cd $(WORK_DIR); sudo make -j install prefix=/usr; cd -
105         $(AT)sudo mkdir -p /usr/lib/dpdk-pmd
106         $(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
107 # under docker there won't be kernel module available
108 ifndef DOCKER
109         $(AT)sudo cp -a $(WORK_DIR)/build/kmod $(INSTALL_DIR)/lib/modules/$(KERNEL_VERSION)
110 endif
111         @echo "install done"
112
113 # hard way to clean and clobber
114 clean:
115         $(AT)cd $(WORK_DIR) && git clean -xfd *.o
116 clobber:
117         $(AT)rm -rf $(WORK_DIR)
118
119 # distclean is for developer who would like to keep the
120 # clone git repo, saving time to fetch again from url
121 distclean:
122         $(AT)cd $(WORK_DIR) && git clean -xfd && git checkout -f
123
124 test:
125         @echo "Make test in $(WORK_DIR) (stub) "
126
127 sanity:
128         @echo "Make sanity in $(WORK_DIR) (stub) "
129
130 $(WORK_DIR):
131         $(AT)git clone $(DPDK_URL)
132
133 $(TAG_DONE_FLAG): $(WORK_DIR)
134         $(AT)cd $(WORK_DIR); git checkout $(DPDK_TAG)
135         $(AT)touch $@