blob: b7c3e27fd22ff319e27545b940e1201dd0ea8124 [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
22DEB_DEPENDS = curl build-essential autoconf automake bison libssl-dev ccache
23DEB_DEPENDS += debhelper dkms openjdk-7-jdk git libtool libganglia1-dev libapr1-dev
24DEB_DEPENDS += libconfuse-dev git-review
25
26
27.PHONY: help bootstrap wipe wipe-release build build-release rebuild rebuild-release
28.PHONY: run run-release debug debug-release build-vat run-vat pkg-deb pkg-rpm
29
30help:
31 @echo "Make Targets:"
32 @echo " bootstrap - prepare tree for build"
33 @echo " wipe - wipe all products of debug build "
34 @echo " wipe-release - wipe all products of release build "
35 @echo " build - build debug binaries"
36 @echo " build-release - build release binaries"
37 @echo " rebuild - wipe and build debug binares"
38 @echo " rebuild-release - wipe and build release binares"
39 @echo " run - run debug binary"
40 @echo " run-release - run release binary"
41 @echo " debug - run debug binary with debugger"
42 @echo " debug-release - run release binary with debugger"
43 @echo " build-vat - build vpp-api-test tool"
44 @echo " run-vat - run vpp-api-test tool"
45 @echo " pkg-deb - build DEB packages"
46 @echo " pkg-rpm - build RPM packages"
47 @echo ""
48 @echo "Make Arguments:"
49 @echo " V=[0|1] - set build verbosity level"
50 @echo " STARTUP_CONF=<path> - startup configuration file"
51 @echo " (e.g. /etc/vpp/startup.conf)"
52 @echo " GDB=<path> - gdb binary to use for debugging"
53 @echo ""
54 @echo "Current Argumernt Values:"
55 @echo " V = $(V)"
56 @echo " STARTUP_CONF = $(STARTUP_CONF)"
57 @echo " GDB = $(GDB)"
58
59$(BR)/.bootstrap.ok:
60ifeq ("$(shell lsb_release -si)", "Ubuntu")
61 @MISSING=$$(apt-get install -y -qq -s $(DEB_DEPENDS) | grep "^Inst ") ; \
62 if [ -n "$$MISSING" ] ; then \
63 echo "\nPlease install missing packages: \n$$MISSING\n" ; \
64 exit 1 ; \
65 fi ; \
66 exit 0
67endif
68 @echo "SOURCE_PATH = $(WS_ROOT)" > $(BR)/build-config.mk
69 @echo "#!/bin/bash\n" > $(BR)/path_setup
70 @echo 'export PATH=$(BR)/tools/ccache-bin:$$PATH' >> $(BR)/path_setup
71 @echo 'export PATH=$(BR)/tools/bin:$$PATH' >> $(BR)/path_setup
72 @echo 'export CCACHE_DIR=$(CCACHE_DIR)' >> $(BR)/path_setup
73
74ifeq ("$(wildcard /usr/bin/ccache )","")
75 @echo "WARNING: Please install ccache AYEC and re-run this script"
76else
77 @rm -rf $(BR)/tools/ccache-bin
78 @mkdir -p $(BR)/tools/ccache-bin
79 @ln -s /usr/bin/ccache $(BR)/tools/ccache-bin/gcc
80 @ln -s /usr/bin/ccache $(BR)/tools/ccache-bin/g++
81endif
82 @make -C $(BR) V=$(V) is_build_tool=yes vppapigen-install
83 @touch $@
84
85bootstrap: $(BR)/.bootstrap.ok
86
87define make
88 @make -C $(BR) V=$(V) PLATFORM=vpp TAG=$(1) $(2)
89endef
90
91build: $(BR)/.bootstrap.ok
92 $(call make,vpp_debug,vpp-install)
93
94wipe: $(BR)/.bootstrap.ok
95 $(call make,vpp_debug,vpp-wipe)
96
97rebuild: wipe build
98
99build-release: $(BR)/.bootstrap.ok
100 $(call make,vpp,vpp-install)
101
102wipe-release: $(BR)/.bootstrap.ok
103 $(call make,vpp,vpp-wipe)
104
105rebuild-release: wipe-release build-release
106
107ifeq ("$(wildcard $(STARTUP_CONF))","")
108define run
109 @echo "WARNING: STARTUP_CONF not defined or file doesn't exist."
110 @echo " Running with minimal startup config: $(MINIMAL_STARTUP_CONF)\n"
111 @sudo $(1) $(MINIMAL_STARTUP_CONF)
112endef
113else
114define run
115 @sudo $(1) -c $(STARTUP_CONF)
116endef
117endif
118
119run:
120 $(call run, $(BR)/install-vpp_debug-native/vpp/bin/vpp)
121
122run-release:
123 $(call run, $(BR)/install-vpp-native/vpp/bin/vpp)
124
125debug:
126 $(call run, $(GDB) --args $(BR)/install-vpp_debug-native/vpp/bin/vpp)
127
128debug-release:
129 $(call run, $(GDB) --args $(BR)/install-vpp-native/vpp/bin/vpp)
130
131build-vat:
132 $(call make,vpp_debug,vpp-api-test-install)
133
134run-vat:
135 @sudo $(BR)/install-vpp_debug-native/vpp-api-test/bin/vpp_api_test
136
137pkg-deb:
138 $(call make,vpp,install-deb)
139
140pkg-rpm:
141 $(call make,vpp,install-rpm)