trex_stat_packet_counts: Add packet counts to trex reporting
[vswitchperf.git] / src / ovs / Makefile
1 # makefile to manage ovs 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 WORK_DIR = ovs
26 TAG_DONE_FLAG = $(WORK_DIR)/.$(OVS_TAG).done
27 CONFIG_CMD =
28 CONFIG_CMD += ./configure
29 OVS_VANILLA = ../../src_vanilla/ovs
30
31 # If WITH_LINUX is defined, OVS is built without DPDK but with kernel
32 # module
33 # By default, OVS is built with DPDK
34
35 # WITH_LINUX is the Linux kernel build directory used for building
36 # OVS kernel module as documented in OVS --with-linux switch
37 ifneq ($(WITH_LINUX),) # Building with Linux kernel
38 CONFIG_CMD += --with-linux=$(WITH_LINUX)
39
40 else # Building with DPDK
41
42 # DPDK_DIR is the top directory for dpdk source tree
43 # it can be passed in from Makefile command
44 # if it is not set, try to read it in from environment
45 # if it is still not set, then set it using relative path
46 DPDK_DIR ?= $(shell echo $$DPDK_DIR)
47 ifeq ($(DPDK_DIR),)
48 DPDK_DIR = ../../dpdk/dpdk
49 endif
50
51 ifeq ($(DPDK_TARGET),)
52 DPDK_TARGET = x86_64-native-linuxapp-gcc
53 endif
54 CONFIG_CMD += --with-dpdk=$(DPDK_DIR)/$(DPDK_TARGET)
55 CONFIG_CMD += CFLAGS="-g -O2 -Wno-cast-align"
56
57 endif # Kernel vs. DPDK
58
59 .PHONY: install force_install config force_make
60
61 # install depends on make
62 force_install: force_make
63
64 all: force_make
65         @echo "Finished making $(WORK_DIR) "
66
67 config $(WORK_DIR)/Makefile: $(WORK_DIR)/configure
68         $(AT)cd $(WORK_DIR); $(CONFIG_CMD)
69         @echo "Configure done"
70
71 INSTALL_TARGET = force_install force_make
72
73 force_make: $(WORK_DIR)/Makefile
74         $(AT)cd $(WORK_DIR) && git pull $(OVS_URL) $(OVS_TAG)
75         @echo "git pull done"
76         $(AT)echo "WITH_LINUX = $(WITH_LINUX)"
77         $(AT)$(MAKE) -C $(WORK_DIR) $(MORE_MAKE_FLAGS)
78         @echo "Make done"
79
80 force_install:
81         $(AT)sudo make -C $(WORK_DIR) modules_install
82         $(AT)sudo $(MAKE) -C $(WORK_DIR) install
83
84 install: $(INSTALL_TARGET)
85
86 # hard way to clean and clobber
87 clean:
88         $(AT)cd $(WORK_DIR) && git clean -xfd *.o
89 clobber:
90         $(AT)rm -rf $(WORK_DIR)
91         $(AT)rm -rf $(OVS_VANILLA)
92
93 # distclean is for developer who would like to keep the
94 # clone git repo, saving time to fetch again from url
95 distclean:
96         $(AT)cd $(WORK_DIR) && git clean -xfd && git checkout -f
97
98 test:
99         @echo "Make test in $(WORK_DIR) (stub) "
100
101 sanity:
102         @echo "Make sanity in $(WORK_DIR) (stub) "
103
104 .PHONY: boot
105 # boot ovs is the process to produce the script 'configure'
106 boot $(WORK_DIR)/configure:
107         @echo "booting up ovs"
108         $(AT)cd $(WORK_DIR); ./boot.sh
109         @echo "done booting ovs"
110
111 boot $(WORK_DIR)/configure: $(TAG_DONE_FLAG)
112
113 $(WORK_DIR):
114         $(AT)git clone $(OVS_URL) ovs
115         $(AT)mkdir -p $(OVS_VANILLA)
116         $(AT)cp -rf ./* $(OVS_VANILLA)
117
118 $(TAG_DONE_FLAG): $(WORK_DIR)
119         $(AT)cd ovs; git checkout $(OVS_TAG)
120 ifneq ($(PATCH_FILE),)
121         $(AT)cd $(WORK_DIR); patch -p1 < ../$(PATCH_FILE)
122 endif
123         $(AT)touch $@