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:
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 BR=$(WS_ROOT)/build-root
16 CCACHE_DIR?=$(BR)/.ccache
20 MINIMAL_STARTUP_CONF="unix { interactive } dpdk { no-pci socket-mem 1024 }"
22 GDB_ARGS= -ex "handle SIGUSR1 noprint nostop"
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
28 ifneq ("$(wildcard $(STARTUP_DIR)/startup.conf),"")
29 STARTUP_CONF ?= $(STARTUP_DIR)/startup.conf
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
37 @echo " bootstrap - prepare tree for build"
38 @echo " wipe - wipe all products of debug build "
39 @echo " wipe-release - wipe all products of release build "
40 @echo " build - build debug binaries"
41 @echo " build-release - build release binaries"
42 @echo " rebuild - wipe and build debug binares"
43 @echo " rebuild-release - wipe and build release binares"
44 @echo " run - run debug binary"
45 @echo " run-release - run release binary"
46 @echo " debug - run debug binary with debugger"
47 @echo " debug-release - run release binary with debugger"
48 @echo " build-vat - build vpp-api-test tool"
49 @echo " run-vat - run vpp-api-test tool"
50 @echo " pkg-deb - build DEB packages"
51 @echo " pkg-rpm - build RPM packages"
53 @echo "Make Arguments:"
54 @echo " V=[0|1] - set build verbosity level"
55 @echo " STARTUP_CONF=<path> - startup configuration file"
56 @echo " (e.g. /etc/vpp/startup.conf)"
57 @echo " STARTUP_DIR=<path> - startup drectory (e.g. /etc/vpp)"
58 @echo " It also sets STARTUP_CONF if"
59 @echo " startup.conf file is present"
60 @echo " GDB=<path> - gdb binary to use for debugging"
62 @echo "Current Argumernt Values:"
64 @echo " STARTUP_CONF = $(STARTUP_CONF)"
65 @echo " STARTUP_DIR = $(STARTUP_DIR)"
69 ifeq ("$(shell lsb_release -si)", "Ubuntu")
70 @MISSING=$$(apt-get install -y -qq -s $(DEB_DEPENDS) | grep "^Inst ") ; \
71 if [ -n "$$MISSING" ] ; then \
72 echo "\nPlease install missing packages: \n$$MISSING\n" ; \
77 @echo "SOURCE_PATH = $(WS_ROOT)" > $(BR)/build-config.mk
78 @echo "#!/bin/bash\n" > $(BR)/path_setup
79 @echo 'export PATH=$(BR)/tools/ccache-bin:$$PATH' >> $(BR)/path_setup
80 @echo 'export PATH=$(BR)/tools/bin:$$PATH' >> $(BR)/path_setup
81 @echo 'export CCACHE_DIR=$(CCACHE_DIR)' >> $(BR)/path_setup
83 ifeq ("$(wildcard /usr/bin/ccache )","")
84 @echo "WARNING: Please install ccache AYEC and re-run this script"
86 @rm -rf $(BR)/tools/ccache-bin
87 @mkdir -p $(BR)/tools/ccache-bin
88 @ln -s /usr/bin/ccache $(BR)/tools/ccache-bin/gcc
89 @ln -s /usr/bin/ccache $(BR)/tools/ccache-bin/g++
91 @make -C $(BR) V=$(V) is_build_tool=yes vppapigen-install
94 bootstrap: $(BR)/.bootstrap.ok
97 @make -C $(BR) V=$(V) PLATFORM=vpp TAG=$(1) $(2)
100 build: $(BR)/.bootstrap.ok
101 $(call make,vpp_debug,vpp-install)
103 wipe: $(BR)/.bootstrap.ok
104 $(call make,vpp_debug,vpp-wipe)
108 build-release: $(BR)/.bootstrap.ok
109 $(call make,vpp,vpp-install)
111 wipe-release: $(BR)/.bootstrap.ok
112 $(call make,vpp,vpp-wipe)
114 rebuild-release: wipe-release build-release
116 STARTUP_DIR ?= $(PWD)
117 ifeq ("$(wildcard $(STARTUP_CONF))","")
119 @echo "WARNING: STARTUP_CONF not defined or file doesn't exist."
120 @echo " Running with minimal startup config: $(MINIMAL_STARTUP_CONF)\n"
121 @cd $(STARTUP_DIR) && sudo $(1) $(MINIMAL_STARTUP_CONF)
125 @cd $(STARTUP_DIR) && sudo $(1) -c $(STARTUP_CONF)
130 $(call run, $(BR)/install-vpp_debug-native/vpp/bin/vpp)
133 $(call run, $(BR)/install-vpp-native/vpp/bin/vpp)
136 $(call run, $(GDB) $(GDB_ARGS) --args $(BR)/install-vpp_debug-native/vpp/bin/vpp)
139 $(call run, $(GDB) $(GDB_ARGS) --args $(BR)/install-vpp-native/vpp/bin/vpp)
142 $(call make,vpp_debug,vpp-api-test-install)
145 @sudo $(BR)/install-vpp_debug-native/vpp-api-test/bin/vpp_api_test
148 $(call make,vpp,install-deb)
151 $(call make,vpp,install-rpm)