68ac0f6dafe6279cdbf5b482c661f2b2e173d834
[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 # DPDK_DIR is the top directory for dpdk source tree
26 # it can be passed in from Makefile command
27 # if it is not set, try to read it in from environment
28 # if it is still not set, then set it using relative path
29
30 DPDK_DIR ?= $(shell echo $$DPDK_DIR)
31 ifeq ($(DPDK_DIR),)
32 DPDK_DIR = ../../dpdk/dpdk
33 endif
34
35 ifeq ($(DPDK_TARGET),)
36 DPDK_TARGET = x86_64-native-linuxapp-gcc
37 endif
38
39
40 .PHONY: install force_install config force_make
41
42 # install depends on make
43 force_install: force_make
44
45 WORK_DIR = ovs
46 TAG_DONE_FLAG = $(WORK_DIR)/.$(OVS_TAG).done
47 CONFIG_CMD =
48 CONFIG_CMD += ./configure
49 CONFIG_CMD += --with-dpdk=$(DPDK_DIR)/$(DPDK_TARGET)
50
51
52 all: force_make
53         @echo "Finished making $(WORK_DIR) "
54
55 config $(WORK_DIR)/Makefile: $(WORK_DIR)/configure
56         $(AT)cd $(WORK_DIR); $(CONFIG_CMD)
57         @echo "Configure done"
58
59 INSTALL_TARGET = force_install force_make
60
61 force_make: $(WORK_DIR)/Makefile
62         $(AT)$(MAKE) -C $(WORK_DIR) $(MORE_MAKE_FLAGS)
63         @echo "Make done"
64
65 force_install:
66         $(AT)sudo make -C $(WORK_DIR) modules_install
67         $(AT)sudo $(MAKE) -C $(WORK_DIR) install
68
69 install: $(INSTALL_TARGET)
70
71 # hard way to clean and clobber
72 clean:
73 clobber:
74         $(AT)rm -rf $(WORK_DIR)
75
76 # cleanse is for developer who would like to keep the
77 # clone git repo, saving time to fetch again from url
78 cleanse:
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 .PHONY: boot
88 # boot ovs is the process to produce the script 'configure'
89 boot $(WORK_DIR)/configure:
90         @echo "booting up ovs"
91         $(AT)cd $(WORK_DIR); ./boot.sh
92         @echo "done booting ovs"
93
94 boot $(WORK_DIR)/configure: $(TAG_DONE_FLAG)
95
96 $(WORK_DIR):
97         $(AT)git clone $(OVS_URL)
98
99 $(TAG_DONE_FLAG): $(WORK_DIR)
100         $(AT)cd ovs; git checkout $(OVS_TAG)
101 ifneq ($(PATCH_FILE),)
102         $(AT)cd $(WORK_DIR); patch -p1 < ../$(PATCH_FILE)
103 endif
104         $(AT)touch $@