blob: 024a139330d28eb59b6b674c76c1e6d95f2a33b1 [file] [log] [blame]
Damjan Marione17fdb52016-02-10 00:36:06 +01001# 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
14WS_ROOT=$(CURDIR)
15BR=$(WS_ROOT)/build-root
16CCACHE_DIR?=$(BR)/.ccache
17V?=0
18GDB?=gdb
19
20MINIMAL_STARTUP_CONF="unix { interactive } dpdk { no-pci socket-mem 1024 }"
21
Damjan Marioneef4d992016-02-23 22:04:50 +010022GDB_ARGS= -ex "handle SIGUSR1 noprint nostop"
23
Damjan Marione17fdb52016-02-10 00:36:06 +010024DEB_DEPENDS = curl build-essential autoconf automake bison libssl-dev ccache
25DEB_DEPENDS += debhelper dkms openjdk-7-jdk git libtool libganglia1-dev libapr1-dev
26DEB_DEPENDS += libconfuse-dev git-review
27
Damjan Marioneef4d992016-02-23 22:04:50 +010028ifneq ("$(wildcard $(STARTUP_DIR)/startup.conf),"")
29 STARTUP_CONF ?= $(STARTUP_DIR)/startup.conf
30endif
Damjan Marione17fdb52016-02-10 00:36:06 +010031
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
35help:
36 @echo "Make Targets:"
37 @echo " bootstrap - prepare tree for build"
Damjan Marionebb27fb2016-02-25 16:26:01 +010038 @echo " install-dep - install software dependencies"
Damjan Marione17fdb52016-02-10 00:36:06 +010039 @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)"
Damjan Marioneef4d992016-02-23 22:04:50 +010058 @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"
Damjan Marione17fdb52016-02-10 00:36:06 +010061 @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)"
Damjan Marioneef4d992016-02-23 22:04:50 +010066 @echo " STARTUP_DIR = $(STARTUP_DIR)"
Damjan Marione17fdb52016-02-10 00:36:06 +010067 @echo " GDB = $(GDB)"
68
69$(BR)/.bootstrap.ok:
70ifeq ("$(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" ; \
Damjan Marionebb27fb2016-02-25 16:26:01 +010074 echo "by executing \"make install-dep\"\n" ; \
Damjan Marione17fdb52016-02-10 00:36:06 +010075 exit 1 ; \
76 fi ; \
77 exit 0
78endif
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
85ifeq ("$(wildcard /usr/bin/ccache )","")
86 @echo "WARNING: Please install ccache AYEC and re-run this script"
87else
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++
92endif
93 @make -C $(BR) V=$(V) is_build_tool=yes vppapigen-install
94 @touch $@
95
96bootstrap: $(BR)/.bootstrap.ok
97
Damjan Marionebb27fb2016-02-25 16:26:01 +010098install-dep:
99ifeq ("$(shell lsb_release -si)", "Ubuntu")
100 @sudo apt-get install $(DEB_DEPENDS)
101else
102 $(error "This option currently works only on Ubuntu systems")
103endif
104
Damjan Marione17fdb52016-02-10 00:36:06 +0100105define make
106 @make -C $(BR) V=$(V) PLATFORM=vpp TAG=$(1) $(2)
107endef
108
109build: $(BR)/.bootstrap.ok
110 $(call make,vpp_debug,vpp-install)
111
112wipe: $(BR)/.bootstrap.ok
113 $(call make,vpp_debug,vpp-wipe)
114
115rebuild: wipe build
116
117build-release: $(BR)/.bootstrap.ok
118 $(call make,vpp,vpp-install)
119
120wipe-release: $(BR)/.bootstrap.ok
121 $(call make,vpp,vpp-wipe)
122
123rebuild-release: wipe-release build-release
124
Damjan Marioneef4d992016-02-23 22:04:50 +0100125STARTUP_DIR ?= $(PWD)
Damjan Marione17fdb52016-02-10 00:36:06 +0100126ifeq ("$(wildcard $(STARTUP_CONF))","")
127define run
128 @echo "WARNING: STARTUP_CONF not defined or file doesn't exist."
129 @echo " Running with minimal startup config: $(MINIMAL_STARTUP_CONF)\n"
Damjan Marioneef4d992016-02-23 22:04:50 +0100130 @cd $(STARTUP_DIR) && sudo $(1) $(MINIMAL_STARTUP_CONF)
Damjan Marione17fdb52016-02-10 00:36:06 +0100131endef
132else
133define run
Damjan Marioneef4d992016-02-23 22:04:50 +0100134 @cd $(STARTUP_DIR) && sudo $(1) -c $(STARTUP_CONF)
Damjan Marione17fdb52016-02-10 00:36:06 +0100135endef
136endif
137
138run:
139 $(call run, $(BR)/install-vpp_debug-native/vpp/bin/vpp)
140
141run-release:
142 $(call run, $(BR)/install-vpp-native/vpp/bin/vpp)
143
144debug:
Damjan Marioneef4d992016-02-23 22:04:50 +0100145 $(call run, $(GDB) $(GDB_ARGS) --args $(BR)/install-vpp_debug-native/vpp/bin/vpp)
Damjan Marione17fdb52016-02-10 00:36:06 +0100146
147debug-release:
Damjan Marioneef4d992016-02-23 22:04:50 +0100148 $(call run, $(GDB) $(GDB_ARGS) --args $(BR)/install-vpp-native/vpp/bin/vpp)
Damjan Marione17fdb52016-02-10 00:36:06 +0100149
150build-vat:
151 $(call make,vpp_debug,vpp-api-test-install)
152
153run-vat:
154 @sudo $(BR)/install-vpp_debug-native/vpp-api-test/bin/vpp_api_test
155
156pkg-deb:
157 $(call make,vpp,install-deb)
158
159pkg-rpm:
160 $(call make,vpp,install-rpm)