Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 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 |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 17 | GDB?=gdb |
Damjan Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 18 | PLATFORM?=vpp |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 19 | |
Damjan Marion | 7a2a378 | 2016-04-15 20:24:55 +0200 | [diff] [blame] | 20 | MINIMAL_STARTUP_CONF="unix { interactive }" |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 21 | |
Damjan Marion | eef4d99 | 2016-02-23 22:04:50 +0100 | [diff] [blame] | 22 | GDB_ARGS= -ex "handle SIGUSR1 noprint nostop" |
| 23 | |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 24 | DEB_DEPENDS = curl build-essential autoconf automake bison libssl-dev ccache |
Marek Gradzki | 60c63c7 | 2016-04-26 08:01:31 +0200 | [diff] [blame] | 25 | DEB_DEPENDS += debhelper dkms openjdk-8-jdk git libtool libganglia1-dev libapr1-dev dh-systemd |
Damjan Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 26 | DEB_DEPENDS += libconfuse-dev git-review exuberant-ctags cscope |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 27 | |
Ed Warnicke | 84eda9d | 2016-03-22 16:09:29 -0500 | [diff] [blame] | 28 | RPM_DEPENDS_GROUPS = 'Development Tools' |
Thomas F Herbert | 473bf23 | 2016-04-27 16:19:03 -0400 | [diff] [blame] | 29 | RPM_DEPENDS = redhat-lsb glibc-static java-1.8.0-openjdk-devel yum-utils |
Ed Warnicke | 3c79e65 | 2016-03-28 14:53:19 -0500 | [diff] [blame] | 30 | RPM_DEPENDS += openssl-devel https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm apr-devel |
Ed Warnicke | 84eda9d | 2016-03-22 16:09:29 -0500 | [diff] [blame] | 31 | EPEL_DEPENDS = libconfuse-devel ganglia-devel |
| 32 | |
Damjan Marion | 0df78dd | 2016-03-29 22:37:02 +0200 | [diff] [blame] | 33 | ifneq ($(wildcard $(STARTUP_DIR)/startup.conf),) |
Damjan Marion | eef4d99 | 2016-02-23 22:04:50 +0100 | [diff] [blame] | 34 | STARTUP_CONF ?= $(STARTUP_DIR)/startup.conf |
| 35 | endif |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 36 | |
| 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 Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 39 | .PHONY: ctags cscope |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 40 | |
| 41 | help: |
| 42 | @echo "Make Targets:" |
| 43 | @echo " bootstrap - prepare tree for build" |
Damjan Marion | ebb27fb | 2016-02-25 16:26:01 +0100 | [diff] [blame] | 44 | @echo " install-dep - install software dependencies" |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 45 | @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 Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 59 | @echo " ctags - (re)generate ctags database" |
| 60 | @echo " cscope - (re)generate cscope database" |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 61 | @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 Marion | eef4d99 | 2016-02-23 22:04:50 +0100 | [diff] [blame] | 66 | @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 Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 69 | @echo " GDB=<path> - gdb binary to use for debugging" |
Damjan Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 70 | @echo " PLATFORM=<name> - target platform. default is vpp" |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 71 | @echo "" |
| 72 | @echo "Current Argumernt Values:" |
| 73 | @echo " V = $(V)" |
| 74 | @echo " STARTUP_CONF = $(STARTUP_CONF)" |
Damjan Marion | eef4d99 | 2016-02-23 22:04:50 +0100 | [diff] [blame] | 75 | @echo " STARTUP_DIR = $(STARTUP_DIR)" |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 76 | @echo " GDB = $(GDB)" |
Damjan Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 77 | @echo " PLATFORM = $(PLATFORM)" |
Damjan Marion | 0df78dd | 2016-03-29 22:37:02 +0200 | [diff] [blame] | 78 | @echo " DPDK_VERSION = $(DPDK_VERSION)" |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 79 | |
Marek Gradzki | 60c63c7 | 2016-04-26 08:01:31 +0200 | [diff] [blame] | 80 | # openjdk-8-jdk is not available in 14.04 repos by default |
| 81 | define use_ppa_for_jdk8 |
| 82 | if [ "$(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; \ |
| 86 | fi; |
| 87 | endef |
| 88 | |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 89 | $(BR)/.bootstrap.ok: |
| 90 | ifeq ("$(shell lsb_release -si)", "Ubuntu") |
Marek Gradzki | 60c63c7 | 2016-04-26 08:01:31 +0200 | [diff] [blame] | 91 | $(use_ppa_for_jdk8) |
| 92 | |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 93 | @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 Marion | ebb27fb | 2016-02-25 16:26:01 +0100 | [diff] [blame] | 96 | echo "by executing \"make install-dep\"\n" ; \ |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 97 | exit 1 ; \ |
| 98 | fi ; \ |
| 99 | exit 0 |
| 100 | endif |
| 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 Troan | 6855f6c | 2016-04-09 03:16:30 +0200 | [diff] [blame] | 106 | |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 107 | ifeq ("$(wildcard /usr/bin/ccache )","") |
| 108 | @echo "WARNING: Please install ccache AYEC and re-run this script" |
| 109 | else |
| 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++ |
| 114 | endif |
| 115 | @make -C $(BR) V=$(V) is_build_tool=yes vppapigen-install |
| 116 | @touch $@ |
| 117 | |
| 118 | bootstrap: $(BR)/.bootstrap.ok |
| 119 | |
Damjan Marion | ebb27fb | 2016-02-25 16:26:01 +0100 | [diff] [blame] | 120 | install-dep: |
| 121 | ifeq ("$(shell lsb_release -si)", "Ubuntu") |
Marek Gradzki | 60c63c7 | 2016-04-26 08:01:31 +0200 | [diff] [blame] | 122 | $(use_ppa_for_jdk8) |
Ed Warnicke | 76a66c1 | 2016-03-17 20:37:27 -0700 | [diff] [blame] | 123 | @sudo apt-get -y install $(DEB_DEPENDS) |
Ed Warnicke | 84eda9d | 2016-03-22 16:09:29 -0500 | [diff] [blame] | 124 | else 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 Herbert | 473bf23 | 2016-04-27 16:19:03 -0400 | [diff] [blame] | 128 | @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 Marion | ebb27fb | 2016-02-25 16:26:01 +0100 | [diff] [blame] | 129 | else |
Ed Warnicke | 84eda9d | 2016-03-22 16:09:29 -0500 | [diff] [blame] | 130 | $(error "This option currently works only on Ubuntu or Centos systems") |
Damjan Marion | ebb27fb | 2016-02-25 16:26:01 +0100 | [diff] [blame] | 131 | endif |
| 132 | |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 133 | define make |
Damjan Marion | 6b1d7c5 | 2016-04-26 18:19:47 +0200 | [diff] [blame] | 134 | @make -C $(BR) PLATFORM=$(PLATFORM) TAG=$(1) $(2) |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 135 | endef |
| 136 | |
| 137 | build: $(BR)/.bootstrap.ok |
Damjan Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 138 | $(call make,$(PLATFORM)_debug,vpp-install) |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 139 | |
| 140 | wipe: $(BR)/.bootstrap.ok |
Damjan Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 141 | $(call make,$(PLATFORM)_debug,vpp-wipe) |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 142 | |
| 143 | rebuild: wipe build |
| 144 | |
| 145 | build-release: $(BR)/.bootstrap.ok |
Damjan Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 146 | $(call make,$(PLATFORM),vpp-install) |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 147 | |
| 148 | wipe-release: $(BR)/.bootstrap.ok |
Damjan Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 149 | $(call make,$(PLATFORM),vpp-wipe) |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 150 | |
| 151 | rebuild-release: wipe-release build-release |
| 152 | |
Damjan Marion | eef4d99 | 2016-02-23 22:04:50 +0100 | [diff] [blame] | 153 | STARTUP_DIR ?= $(PWD) |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 154 | ifeq ("$(wildcard $(STARTUP_CONF))","") |
| 155 | define 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 Marion | eef4d99 | 2016-02-23 22:04:50 +0100 | [diff] [blame] | 158 | @cd $(STARTUP_DIR) && sudo $(1) $(MINIMAL_STARTUP_CONF) |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 159 | endef |
| 160 | else |
| 161 | define run |
Damjan Marion | eef4d99 | 2016-02-23 22:04:50 +0100 | [diff] [blame] | 162 | @cd $(STARTUP_DIR) && sudo $(1) -c $(STARTUP_CONF) |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 163 | endef |
| 164 | endif |
| 165 | |
Damjan Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 166 | %.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 Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 173 | run: |
Damjan Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 174 | $(call run, $(BR)/install-$(PLATFORM)_debug-native/vpp/bin/vpp) |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 175 | |
| 176 | run-release: |
Damjan Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 177 | $(call run, $(BR)/install-$(PLATFORM)-native/vpp/bin/vpp) |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 178 | |
| 179 | debug: |
Damjan Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 180 | $(call run, $(GDB) $(GDB_ARGS) --args $(BR)/install-$(PLATFORM)_debug-native/vpp/bin/vpp) |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 181 | |
| 182 | debug-release: |
Damjan Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 183 | $(call run, $(GDB) $(GDB_ARGS) --args $(BR)/install-$(PLATFORM)-native/vpp/bin/vpp) |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 184 | |
| 185 | build-vat: |
Damjan Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 186 | $(call make,$(PLATFORM)_debug,vpp-api-test-install) |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 187 | |
| 188 | run-vat: |
Damjan Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 189 | @sudo $(BR)/install-$(PLATFORM)_debug-native/vpp-api-test/bin/vpp_api_test |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 190 | |
| 191 | pkg-deb: |
Damjan Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 192 | $(call make,$(PLATFORM),install-deb) |
Damjan Marion | e17fdb5 | 2016-02-10 00:36:06 +0100 | [diff] [blame] | 193 | |
| 194 | pkg-rpm: |
Damjan Marion | e6f9023 | 2016-03-16 22:49:05 +0100 | [diff] [blame] | 195 | $(call make,$(PLATFORM),install-rpm) |
| 196 | |
| 197 | ctags: ctags.files |
| 198 | @ctags --totals --tag-relative -L $< |
| 199 | @rm $< |
| 200 | |
| 201 | cscope: cscope.files |
| 202 | @cscope -b -q -v |
Marek Gradzki | 60c63c7 | 2016-04-26 08:01:31 +0200 | [diff] [blame] | 203 | |