Fixed vxlan link status.
[vpp.git] / Makefile
1 # Copyright (c) 2016 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 WS_ROOT=$(CURDIR)
15 BR=$(WS_ROOT)/build-root
16 CCACHE_DIR?=$(BR)/.ccache
17 V?=0
18 GDB?=gdb
19
20 MINIMAL_STARTUP_CONF="unix { interactive } dpdk { no-pci socket-mem 1024 }"
21
22 GDB_ARGS= -ex "handle SIGUSR1 noprint nostop"
23
24 DEB_DEPENDS  = curl build-essential autoconf automake bison libssl-dev ccache
25 DEB_DEPENDS += debhelper dkms openjdk-7-jdk git libtool libganglia1-dev libapr1-dev
26 DEB_DEPENDS += libconfuse-dev git-review
27
28 ifneq ("$(wildcard $(STARTUP_DIR)/startup.conf),"")
29         STARTUP_CONF ?= $(STARTUP_DIR)/startup.conf
30 endif
31
32 .PHONY: help bootstrap wipe wipe-release build build-release rebuild rebuild-release
33 .PHONY: run run-release debug debug-release build-vat run-vat pkg-deb pkg-rpm
34
35 help:
36         @echo "Make Targets:"
37         @echo " bootstrap           - prepare tree for build"
38         @echo " install-dep         - install software dependencies"
39         @echo " wipe                - wipe all products of debug build "
40         @echo " wipe-release        - wipe all products of release build "
41         @echo " build               - build debug binaries"
42         @echo " build-release       - build release binaries"
43         @echo " rebuild             - wipe and build debug binares"
44         @echo " rebuild-release     - wipe and build release binares"
45         @echo " run                 - run debug binary"
46         @echo " run-release         - run release binary"
47         @echo " debug               - run debug binary with debugger"
48         @echo " debug-release       - run release binary with debugger"
49         @echo " build-vat           - build vpp-api-test tool"
50         @echo " run-vat             - run vpp-api-test tool"
51         @echo " pkg-deb             - build DEB packages"
52         @echo " pkg-rpm             - build RPM packages"
53         @echo ""
54         @echo "Make Arguments:"
55         @echo " V=[0|1]             - set build verbosity level"
56         @echo " STARTUP_CONF=<path> - startup configuration file"
57         @echo "                       (e.g. /etc/vpp/startup.conf)"
58         @echo " STARTUP_DIR=<path>  - startup drectory (e.g. /etc/vpp)"
59         @echo "                       It also sets STARTUP_CONF if"
60         @echo "                       startup.conf file is present"
61         @echo " GDB=<path>          - gdb binary to use for debugging"
62         @echo ""
63         @echo "Current Argumernt Values:"
64         @echo " V            = $(V)"
65         @echo " STARTUP_CONF = $(STARTUP_CONF)"
66         @echo " STARTUP_DIR  = $(STARTUP_DIR)"
67         @echo " GDB          = $(GDB)"
68
69 $(BR)/.bootstrap.ok:
70 ifeq ("$(shell lsb_release -si)", "Ubuntu")
71         @MISSING=$$(apt-get install -y -qq -s $(DEB_DEPENDS) | grep "^Inst ") ; \
72         if [ -n "$$MISSING" ] ; then \
73           echo "\nPlease install missing packages: \n$$MISSING\n" ; \
74           echo "by executing \"make install-dep\"\n" ; \
75           exit 1 ; \
76         fi ; \
77         exit 0
78 endif
79         @echo "SOURCE_PATH = $(WS_ROOT)"                   > $(BR)/build-config.mk
80         @echo "#!/bin/bash\n"                              > $(BR)/path_setup
81         @echo 'export PATH=$(BR)/tools/ccache-bin:$$PATH' >> $(BR)/path_setup
82         @echo 'export PATH=$(BR)/tools/bin:$$PATH'        >> $(BR)/path_setup
83         @echo 'export CCACHE_DIR=$(CCACHE_DIR)'           >> $(BR)/path_setup
84         
85 ifeq ("$(wildcard /usr/bin/ccache )","")
86         @echo "WARNING: Please install ccache AYEC and re-run this script"
87 else
88         @rm -rf $(BR)/tools/ccache-bin
89         @mkdir -p $(BR)/tools/ccache-bin
90         @ln -s /usr/bin/ccache $(BR)/tools/ccache-bin/gcc
91         @ln -s /usr/bin/ccache $(BR)/tools/ccache-bin/g++
92 endif
93         @make -C $(BR) V=$(V) is_build_tool=yes vppapigen-install
94         @touch $@
95
96 bootstrap: $(BR)/.bootstrap.ok
97
98 install-dep:
99 ifeq ("$(shell lsb_release -si)", "Ubuntu")
100         @sudo apt-get install $(DEB_DEPENDS)
101 else
102         $(error "This option currently works only on Ubuntu systems")
103 endif
104
105 define make
106         @make -C $(BR) V=$(V) PLATFORM=vpp TAG=$(1) $(2)
107 endef
108
109 build: $(BR)/.bootstrap.ok
110         $(call make,vpp_debug,vpp-install)
111
112 wipe: $(BR)/.bootstrap.ok
113         $(call make,vpp_debug,vpp-wipe)
114
115 rebuild: wipe build
116
117 build-release: $(BR)/.bootstrap.ok
118         $(call make,vpp,vpp-install)
119
120 wipe-release: $(BR)/.bootstrap.ok
121         $(call make,vpp,vpp-wipe)
122
123 rebuild-release: wipe-release build-release
124
125 STARTUP_DIR ?= $(PWD)
126 ifeq ("$(wildcard $(STARTUP_CONF))","")
127 define run
128         @echo "WARNING: STARTUP_CONF not defined or file doesn't exist."
129         @echo "         Running with minimal startup config: $(MINIMAL_STARTUP_CONF)\n"
130         @cd $(STARTUP_DIR) && sudo $(1) $(MINIMAL_STARTUP_CONF)
131 endef
132 else
133 define run
134         @cd $(STARTUP_DIR) && sudo $(1) -c $(STARTUP_CONF)
135 endef
136 endif
137
138 run:
139         $(call run, $(BR)/install-vpp_debug-native/vpp/bin/vpp)
140
141 run-release:
142         $(call run, $(BR)/install-vpp-native/vpp/bin/vpp)
143
144 debug:
145         $(call run, $(GDB) $(GDB_ARGS) --args $(BR)/install-vpp_debug-native/vpp/bin/vpp)
146
147 debug-release:
148         $(call run, $(GDB) $(GDB_ARGS) --args $(BR)/install-vpp-native/vpp/bin/vpp)
149
150 build-vat:
151         $(call make,vpp_debug,vpp-api-test-install)
152
153 run-vat:
154         @sudo $(BR)/install-vpp_debug-native/vpp-api-test/bin/vpp_api_test
155
156 pkg-deb:
157         $(call make,vpp,install-deb)
158
159 pkg-rpm:
160         $(call make,vpp,install-rpm)