Fix Make, Make clean and when the src directories are cloned
[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_VANILLA = ../../src_vanilla/dpdk
33 DPDK_CUSE = ../../src_cuse/dpdk
34
35 # the name has been changed from version to version
36 ifeq ($(DPDK_TAG),v1.6.0r0)
37     DPDK_TARGET = x86_64-default-linuxapp-gcc
38     CONFIG_FILE = $(WORK_DIR)/config/defconfig_x86_64-default-linuxapp-gcc
39 else
40     DPDK_TARGET = x86_64-native-linuxapp-gcc
41     CONFIG_FILE = $(WORK_DIR)/config/common_linuxapp
42 endif
43
44 all: force_make
45         @echo "Finished making $(WORK_DIR) "
46
47 INSTALL_TARGET = force_make
48
49 # modify CONFIG_FILE to enable VHOST_USER build and restore original CONFIG_FILE after the build
50 force_make: $(TAG_DONE_FLAG)
51         $(AT)cd $(WORK_DIR) && git pull $(DPDK_URL) $(DPDK_TAG)
52         $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_VHOST_USER=.\+/CONFIG_RTE_LIBRTE_VHOST_USER=$(VHOST_USER)/g' $(CONFIG_FILE)
53         $(AT)sed -i -e 's/CONFIG_RTE_BUILD_COMBINE_LIBS=./CONFIG_RTE_BUILD_COMBINE_LIBS=y/g' $(CONFIG_FILE)
54         $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_VHOST=./CONFIG_RTE_LIBRTE_VHOST=y/g' $(CONFIG_FILE)
55         $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_KNI=./CONFIG_RTE_LIBRTE_KNI=n/g' $(CONFIG_FILE)
56         $(AT)cd $(WORK_DIR); make install T=$(DPDK_TARGET) -j
57         $(AT)cd `dirname $(CONFIG_FILE)` && git checkout `basename $(CONFIG_FILE)` && cd -
58         $(AT)echo "VHOST_USER = $(VHOST_USER)"
59 ifeq ($(VHOST_USER),n)
60         $(AT)cd $(WORK_DIR)/lib/librte_vhost/eventfd_link; make
61 endif
62         @echo "Make done"
63
64 install: $(INSTALL_TARGET)
65         $(AT)sudo cp -a $(WORK_DIR)/$(DPDK_TARGET)/kmod $(INSTALL_DIR)/lib/modules/$(KERNEL_VERSION)
66         @echo "install done"
67
68 # hard way to clean and clobber
69 clean:
70         $(AT)cd $(WORK_DIR) && git clean -xfd *.o
71 clobber:
72         $(AT)rm -rf $(WORK_DIR)
73         $(AT)rm -rf $(DPDK_VANILLA)
74         $(AT)rm -rf $(DPDK_CUSE)
75
76 # distclean is for developer who would like to keep the
77 # clone git repo, saving time to fetch again from url
78 distclean:
79         $(AT)cd $(WORK_DIR) && git clean -xfd && git checkout -f
80
81 test:
82         @echo "Make test in $(WORK_DIR) (stub) "
83
84 sanity:
85         @echo "Make sanity in $(WORK_DIR) (stub) "
86
87 $(WORK_DIR):
88         $(AT)git clone $(DPDK_URL)
89         $(AT)mkdir -p $(DPDK_VANILLA)
90         $(AT)cp -rf ./* $(DPDK_VANILLA)
91         $(AT)mkdir -p $(DPDK_CUSE)
92         $(AT)cp -rf ./* $(DPDK_CUSE)
93
94 $(TAG_DONE_FLAG): $(WORK_DIR)
95         $(AT)cd $(WORK_DIR); git checkout $(DPDK_TAG)
96         $(AT)touch $@