b8524322e3baad21758fb895f2381a813ca6f83a
[barometer.git] / src / dpdk / Makefile
1 # makefile to manage dpdk package
2 #
3
4 # Copyright 2015-2016 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 #   Martin Klozik, Intel Corporation.
22
23 include ../mk/master.mk
24 include ../package-list.mk
25
26 .PHONY: install force_make
27
28 WORK_DIR = dpdk
29 TAG_DONE_FLAG = $(WORK_DIR)/.$(DPDK_TAG).tag.done
30
31 DPDK_TARGET = x86_64-native-linuxapp-gcc
32 CONFIG_FILE_LINUXAPP = $(WORK_DIR)/config/common_base
33
34 all: force_make install
35         @echo "Finished making $(WORK_DIR) "
36
37 INSTALL_TARGET = force_make
38
39 # modify CONFIG_FILE to enable SHARED_LIB build and restore original CONFIG_FILE after the build
40 # DPDK v16 comments:
41 ## CONFIG_RTE_BUILD_COMBINE_LIBS has been obsoleted
42 ## CONFIG_RTE_LIBRTE_VHOST and CONFIG_RTE_LIBRTE_KNI are listed in both config_base and config_linuxapp,
43 ## values from config_linuxapp will be used, but options are modified at both places to avoid confusion.
44 force_make: $(TAG_DONE_FLAG)
45         $(AT)cd $(WORK_DIR) && git pull $(DPDK_URL) $(DPDK_TAG)
46         $(AT)sed -i -e 's/CONFIG_RTE_BUILD_SHARED_LIB=./CONFIG_RTE_BUILD_SHARED_LIB=y/g' $(CONFIG_FILE_LINUXAPP)
47         $(AT)sed -i -e 's/CONFIG_RTE_LIBRTE_KNI=./CONFIG_RTE_LIBRTE_KNI=n/g' $(CONFIG_FILE_LINUXAPP)
48         $(AT)cd $(WORK_DIR); make config T=$(DPDK_TARGET) -j; make -j
49         $(AT)cd `dirname $(CONFIG_FILE_LINUXAPP)` && git checkout `basename $(CONFIG_FILE_LINUXAPP)` && cd -
50         @echo "Make done"
51
52 install: $(INSTALL_TARGET)
53         $(AT)cd $(WORK_DIR); sudo make -j install prefix=/usr; cd -
54         $(AT)sudo cp -a $(WORK_DIR)/build/kmod $(INSTALL_DIR)/lib/modules/$(KERNEL_VERSION)
55         @echo "install done"
56
57 # hard way to clean and clobber
58 clean:
59         $(AT)cd $(WORK_DIR) && git clean -xfd *.o
60 clobber:
61         $(AT)rm -rf $(WORK_DIR)
62
63 # distclean is for developer who would like to keep the
64 # clone git repo, saving time to fetch again from url
65 distclean:
66         $(AT)cd $(WORK_DIR) && git clean -xfd && git checkout -f
67
68 test:
69         @echo "Make test in $(WORK_DIR) (stub) "
70
71 sanity:
72         @echo "Make sanity in $(WORK_DIR) (stub) "
73
74 $(WORK_DIR):
75         $(AT)git clone $(DPDK_URL)
76
77 $(TAG_DONE_FLAG): $(WORK_DIR)
78         $(AT)cd $(WORK_DIR); git checkout $(DPDK_TAG)
79         $(AT)touch $@