blob: 3aeea8feaa0e8dc84623c44fbc566ffc68414613 [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
Damjan Marione17fdb52016-02-10 00:36:06 +010017GDB?=gdb
Damjan Marione6f90232016-03-16 22:49:05 +010018PLATFORM?=vpp
Damjan Marione17fdb52016-02-10 00:36:06 +010019
Damjan Marion7a2a3782016-04-15 20:24:55 +020020MINIMAL_STARTUP_CONF="unix { interactive }"
Damjan Marione17fdb52016-02-10 00:36:06 +010021
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
Marek Gradzki60c63c72016-04-26 08:01:31 +020025DEB_DEPENDS += debhelper dkms openjdk-8-jdk git libtool libganglia1-dev libapr1-dev dh-systemd
Damjan Marione6f90232016-03-16 22:49:05 +010026DEB_DEPENDS += libconfuse-dev git-review exuberant-ctags cscope
Damjan Marione17fdb52016-02-10 00:36:06 +010027
Ed Warnicke84eda9d2016-03-22 16:09:29 -050028RPM_DEPENDS_GROUPS = 'Development Tools'
Thomas F Herbert473bf232016-04-27 16:19:03 -040029RPM_DEPENDS = redhat-lsb glibc-static java-1.8.0-openjdk-devel yum-utils
Ed Warnicke3c79e652016-03-28 14:53:19 -050030RPM_DEPENDS += openssl-devel https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm apr-devel
Ed Warnicke84eda9d2016-03-22 16:09:29 -050031EPEL_DEPENDS = libconfuse-devel ganglia-devel
32
Damjan Marion0df78dd2016-03-29 22:37:02 +020033ifneq ($(wildcard $(STARTUP_DIR)/startup.conf),)
Damjan Marioneef4d992016-02-23 22:04:50 +010034 STARTUP_CONF ?= $(STARTUP_DIR)/startup.conf
35endif
Damjan Marione17fdb52016-02-10 00:36:06 +010036
37.PHONY: help bootstrap wipe wipe-release build build-release rebuild rebuild-release
38.PHONY: run run-release debug debug-release build-vat run-vat pkg-deb pkg-rpm
Damjan Marione6f90232016-03-16 22:49:05 +010039.PHONY: ctags cscope
Damjan Marione17fdb52016-02-10 00:36:06 +010040
41help:
42 @echo "Make Targets:"
43 @echo " bootstrap - prepare tree for build"
Damjan Marionebb27fb2016-02-25 16:26:01 +010044 @echo " install-dep - install software dependencies"
Damjan Marione17fdb52016-02-10 00:36:06 +010045 @echo " wipe - wipe all products of debug build "
46 @echo " wipe-release - wipe all products of release build "
47 @echo " build - build debug binaries"
48 @echo " build-release - build release binaries"
49 @echo " rebuild - wipe and build debug binares"
50 @echo " rebuild-release - wipe and build release binares"
51 @echo " run - run debug binary"
52 @echo " run-release - run release binary"
53 @echo " debug - run debug binary with debugger"
54 @echo " debug-release - run release binary with debugger"
55 @echo " build-vat - build vpp-api-test tool"
56 @echo " run-vat - run vpp-api-test tool"
57 @echo " pkg-deb - build DEB packages"
58 @echo " pkg-rpm - build RPM packages"
Damjan Marione6f90232016-03-16 22:49:05 +010059 @echo " ctags - (re)generate ctags database"
60 @echo " cscope - (re)generate cscope database"
Damjan Marione17fdb52016-02-10 00:36:06 +010061 @echo ""
62 @echo "Make Arguments:"
63 @echo " V=[0|1] - set build verbosity level"
64 @echo " STARTUP_CONF=<path> - startup configuration file"
65 @echo " (e.g. /etc/vpp/startup.conf)"
Damjan Marioneef4d992016-02-23 22:04:50 +010066 @echo " STARTUP_DIR=<path> - startup drectory (e.g. /etc/vpp)"
67 @echo " It also sets STARTUP_CONF if"
68 @echo " startup.conf file is present"
Damjan Marione17fdb52016-02-10 00:36:06 +010069 @echo " GDB=<path> - gdb binary to use for debugging"
Damjan Marione6f90232016-03-16 22:49:05 +010070 @echo " PLATFORM=<name> - target platform. default is vpp"
Damjan Marione17fdb52016-02-10 00:36:06 +010071 @echo ""
72 @echo "Current Argumernt Values:"
73 @echo " V = $(V)"
74 @echo " STARTUP_CONF = $(STARTUP_CONF)"
Damjan Marioneef4d992016-02-23 22:04:50 +010075 @echo " STARTUP_DIR = $(STARTUP_DIR)"
Damjan Marione17fdb52016-02-10 00:36:06 +010076 @echo " GDB = $(GDB)"
Damjan Marione6f90232016-03-16 22:49:05 +010077 @echo " PLATFORM = $(PLATFORM)"
Damjan Marion0df78dd2016-03-29 22:37:02 +020078 @echo " DPDK_VERSION = $(DPDK_VERSION)"
Damjan Marione17fdb52016-02-10 00:36:06 +010079
Marek Gradzki60c63c72016-04-26 08:01:31 +020080# openjdk-8-jdk is not available in 14.04 repos by default
81define use_ppa_for_jdk8
82if [ "$(shell lsb_release -r | awk '{print $$2}')"=="14.04" ]; then \
83 sudo apt install software-properties-common; \
84 sudo add-apt-repository -y ppa:openjdk-r/ppa; \
85 sudo apt update; \
86fi;
87endef
88
Damjan Marione17fdb52016-02-10 00:36:06 +010089$(BR)/.bootstrap.ok:
90ifeq ("$(shell lsb_release -si)", "Ubuntu")
Marek Gradzki60c63c72016-04-26 08:01:31 +020091 $(use_ppa_for_jdk8)
92
Damjan Marione17fdb52016-02-10 00:36:06 +010093 @MISSING=$$(apt-get install -y -qq -s $(DEB_DEPENDS) | grep "^Inst ") ; \
94 if [ -n "$$MISSING" ] ; then \
95 echo "\nPlease install missing packages: \n$$MISSING\n" ; \
Damjan Marionebb27fb2016-02-25 16:26:01 +010096 echo "by executing \"make install-dep\"\n" ; \
Damjan Marione17fdb52016-02-10 00:36:06 +010097 exit 1 ; \
98 fi ; \
99 exit 0
100endif
101 @echo "SOURCE_PATH = $(WS_ROOT)" > $(BR)/build-config.mk
102 @echo "#!/bin/bash\n" > $(BR)/path_setup
103 @echo 'export PATH=$(BR)/tools/ccache-bin:$$PATH' >> $(BR)/path_setup
104 @echo 'export PATH=$(BR)/tools/bin:$$PATH' >> $(BR)/path_setup
105 @echo 'export CCACHE_DIR=$(CCACHE_DIR)' >> $(BR)/path_setup
Ole Troan6855f6c2016-04-09 03:16:30 +0200106
Damjan Marione17fdb52016-02-10 00:36:06 +0100107ifeq ("$(wildcard /usr/bin/ccache )","")
108 @echo "WARNING: Please install ccache AYEC and re-run this script"
109else
110 @rm -rf $(BR)/tools/ccache-bin
111 @mkdir -p $(BR)/tools/ccache-bin
112 @ln -s /usr/bin/ccache $(BR)/tools/ccache-bin/gcc
113 @ln -s /usr/bin/ccache $(BR)/tools/ccache-bin/g++
114endif
115 @make -C $(BR) V=$(V) is_build_tool=yes vppapigen-install
116 @touch $@
117
118bootstrap: $(BR)/.bootstrap.ok
119
Damjan Marionebb27fb2016-02-25 16:26:01 +0100120install-dep:
121ifeq ("$(shell lsb_release -si)", "Ubuntu")
Marek Gradzki60c63c72016-04-26 08:01:31 +0200122 $(use_ppa_for_jdk8)
Ed Warnicke76a66c12016-03-17 20:37:27 -0700123 @sudo apt-get -y install $(DEB_DEPENDS)
Ed Warnicke84eda9d2016-03-22 16:09:29 -0500124else ifneq ("$(wildcard /etc/redhat-release)","")
125 @sudo yum groupinstall -y $(RPM_DEPENDS_GROUPS)
126 @sudo yum install -y $(RPM_DEPENDS)
127 @sudo yum install -y --enablerepo=epel $(EPEL_DEPENDS)
Thomas F Herbert473bf232016-04-27 16:19:03 -0400128 @sudo debuginfo-install glibc-2.17-106.el7_2.4.x86_64 openssl-libs-1.0.1e-51.el7_2.4.x86_64 zlib-1.2.7-15.el7.x86_64
Damjan Marionebb27fb2016-02-25 16:26:01 +0100129else
Ed Warnicke84eda9d2016-03-22 16:09:29 -0500130 $(error "This option currently works only on Ubuntu or Centos systems")
Damjan Marionebb27fb2016-02-25 16:26:01 +0100131endif
132
Damjan Marione17fdb52016-02-10 00:36:06 +0100133define make
Damjan Marion6b1d7c52016-04-26 18:19:47 +0200134 @make -C $(BR) PLATFORM=$(PLATFORM) TAG=$(1) $(2)
Damjan Marione17fdb52016-02-10 00:36:06 +0100135endef
136
137build: $(BR)/.bootstrap.ok
Damjan Marione6f90232016-03-16 22:49:05 +0100138 $(call make,$(PLATFORM)_debug,vpp-install)
Damjan Marione17fdb52016-02-10 00:36:06 +0100139
140wipe: $(BR)/.bootstrap.ok
Damjan Marione6f90232016-03-16 22:49:05 +0100141 $(call make,$(PLATFORM)_debug,vpp-wipe)
Damjan Marione17fdb52016-02-10 00:36:06 +0100142
143rebuild: wipe build
144
145build-release: $(BR)/.bootstrap.ok
Damjan Marione6f90232016-03-16 22:49:05 +0100146 $(call make,$(PLATFORM),vpp-install)
Damjan Marione17fdb52016-02-10 00:36:06 +0100147
148wipe-release: $(BR)/.bootstrap.ok
Damjan Marione6f90232016-03-16 22:49:05 +0100149 $(call make,$(PLATFORM),vpp-wipe)
Damjan Marione17fdb52016-02-10 00:36:06 +0100150
151rebuild-release: wipe-release build-release
152
Damjan Marioneef4d992016-02-23 22:04:50 +0100153STARTUP_DIR ?= $(PWD)
Damjan Marione17fdb52016-02-10 00:36:06 +0100154ifeq ("$(wildcard $(STARTUP_CONF))","")
155define run
156 @echo "WARNING: STARTUP_CONF not defined or file doesn't exist."
157 @echo " Running with minimal startup config: $(MINIMAL_STARTUP_CONF)\n"
Damjan Marioneef4d992016-02-23 22:04:50 +0100158 @cd $(STARTUP_DIR) && sudo $(1) $(MINIMAL_STARTUP_CONF)
Damjan Marione17fdb52016-02-10 00:36:06 +0100159endef
160else
161define run
Damjan Marioneef4d992016-02-23 22:04:50 +0100162 @cd $(STARTUP_DIR) && sudo $(1) -c $(STARTUP_CONF)
Damjan Marione17fdb52016-02-10 00:36:06 +0100163endef
164endif
165
Damjan Marione6f90232016-03-16 22:49:05 +0100166%.files: .FORCE
167 @find . \( -name '*\.[chyS]' -o -name '*\.java' -o -name '*\.lex' \) -and \
168 \( -not -path './build-root*' -o -path \
169 './build-root/build-vpp_debug-native/dpdk*' \) > $@
170
171.FORCE:
172
Damjan Marione17fdb52016-02-10 00:36:06 +0100173run:
Damjan Marione6f90232016-03-16 22:49:05 +0100174 $(call run, $(BR)/install-$(PLATFORM)_debug-native/vpp/bin/vpp)
Damjan Marione17fdb52016-02-10 00:36:06 +0100175
176run-release:
Damjan Marione6f90232016-03-16 22:49:05 +0100177 $(call run, $(BR)/install-$(PLATFORM)-native/vpp/bin/vpp)
Damjan Marione17fdb52016-02-10 00:36:06 +0100178
179debug:
Damjan Marione6f90232016-03-16 22:49:05 +0100180 $(call run, $(GDB) $(GDB_ARGS) --args $(BR)/install-$(PLATFORM)_debug-native/vpp/bin/vpp)
Damjan Marione17fdb52016-02-10 00:36:06 +0100181
182debug-release:
Damjan Marione6f90232016-03-16 22:49:05 +0100183 $(call run, $(GDB) $(GDB_ARGS) --args $(BR)/install-$(PLATFORM)-native/vpp/bin/vpp)
Damjan Marione17fdb52016-02-10 00:36:06 +0100184
185build-vat:
Damjan Marione6f90232016-03-16 22:49:05 +0100186 $(call make,$(PLATFORM)_debug,vpp-api-test-install)
Damjan Marione17fdb52016-02-10 00:36:06 +0100187
188run-vat:
Damjan Marione6f90232016-03-16 22:49:05 +0100189 @sudo $(BR)/install-$(PLATFORM)_debug-native/vpp-api-test/bin/vpp_api_test
Damjan Marione17fdb52016-02-10 00:36:06 +0100190
191pkg-deb:
Damjan Marione6f90232016-03-16 22:49:05 +0100192 $(call make,$(PLATFORM),install-deb)
Damjan Marione17fdb52016-02-10 00:36:06 +0100193
194pkg-rpm:
Damjan Marione6f90232016-03-16 22:49:05 +0100195 $(call make,$(PLATFORM),install-rpm)
196
197ctags: ctags.files
198 @ctags --totals --tag-relative -L $<
199 @rm $<
200
201cscope: cscope.files
202 @cscope -b -q -v
Marek Gradzki60c63c72016-04-26 08:01:31 +0200203