Merge "makefile: Remove obsolete copy operations"
[vswitchperf.git] / src / dpdk / Makefile
1 # makefile to manage dpdk package
2 #
3
4 # Copyright 2015 OPNFV
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 # Contributors:
20 #   Aihua Li, Huawei Technologies.
21
22 include ../mk/master.mk
23 include ../package-list.mk
24
25 .PHONY: install force_make
26
27 ifndef VHOST_USER
28     VHOST_USER = n
29 endif
30 WORK_DIR = dpdk
31 TAG_DONE_FLAG = $(WORK_DIR)/.$(DPDK_TAG).tag.done
32 DPDK_CUSE = ../../src_cuse/dpdk
33
34 # the name has been changed from version to version
35 ifeq ($(DPDK_TAG),v1.6.0r0)
36     DPDK_TARGET = x86_64-default-linuxapp-gcc
37     CONFIG_FILE = $(WORK_DIR)/config/defconfig_x86_64-default-linuxapp-gcc
38 else
39     DPDK_TARGET = x86_64-native-linuxapp-gcc
40     CONFIG_FILE = $(WORK_DIR)/config/common_linuxapp
41 endif
42
43 all: force_make
44         @echo "Finished making $(WORK_DIR) "
45
46 INSTALL_TARGET = force_make
47
48 # modify CONFIG_FILE to enable VHOST_USER build and restore original CONFIG_FILE after the build
49 force_make: $(TAG_DONE_FLAG)
50         $(AT)cd $(WORK_DIR) && git pull $(DPDK_URL) $(DPDK_TAG)
51         $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_VHOST_USER=.\+/CONFIG_RTE_LIBRTE_VHOST_USER=$(VHOST_USER)/g' $(CONFIG_FILE)
52         $(AT)sed -i -e 's/CONFIG_RTE_BUILD_COMBINE_LIBS=./CONFIG_RTE_BUILD_COMBINE_LIBS=y/g' $(CONFIG_FILE)
53         $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_VHOST=./CONFIG_RTE_LIBRTE_VHOST=y/g' $(CONFIG_FILE)
54         $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_KNI=./CONFIG_RTE_LIBRTE_KNI=n/g' $(CONFIG_FILE)
55         $(AT)cd $(WORK_DIR); make install T=$(DPDK_TARGET) -j DESTDIR=$(WORK_DIR)
56         $(AT)cd `dirname $(CONFIG_FILE)` && git checkout `basename $(CONFIG_FILE)` && cd -
57         $(AT)echo "VHOST_USER = $(VHOST_USER)"
58 ifeq ($(VHOST_USER),n)
59         $(AT)cd $(WORK_DIR)/lib/librte_vhost/eventfd_link; make
60 endif
61         @echo "Make done"
62
63 install: $(INSTALL_TARGET)
64         $(AT)sudo cp -a $(WORK_DIR)/$(DPDK_TARGET)/kmod $(INSTALL_DIR)/lib/modules/$(KERNEL_VERSION)
65         @echo "install done"
66
67 # hard way to clean and clobber
68 clean:
69         $(AT)cd $(WORK_DIR) && git clean -xfd *.o
70 clobber:
71         $(AT)rm -rf $(WORK_DIR)
72         $(AT)rm -rf $(DPDK_CUSE)
73
74 # distclean is for developer who would like to keep the
75 # clone git repo, saving time to fetch again from url
76 distclean:
77         $(AT)cd $(WORK_DIR) && git clean -xfd && git checkout -f
78
79 test:
80         @echo "Make test in $(WORK_DIR) (stub) "
81
82 sanity:
83         @echo "Make sanity in $(WORK_DIR) (stub) "
84
85 $(WORK_DIR):
86         $(AT)git clone $(DPDK_URL)
87         $(AT)mkdir -p $(DPDK_CUSE)
88         $(AT)cp -rf ./* $(DPDK_CUSE)
89
90 $(TAG_DONE_FLAG): $(WORK_DIR)
91         $(AT)cd $(WORK_DIR); git checkout $(DPDK_TAG)
92         $(AT)touch $@