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