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