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 |
| 17 | V?=0 |
| 18 | GDB?=gdb |
| 19 | |
| 20 | MINIMAL_STARTUP_CONF="unix { interactive } dpdk { no-pci socket-mem 1024 }" |
| 21 | |
| 22 | DEB_DEPENDS = curl build-essential autoconf automake bison libssl-dev ccache |
| 23 | DEB_DEPENDS += debhelper dkms openjdk-7-jdk git libtool libganglia1-dev libapr1-dev |
| 24 | DEB_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 | |
| 30 | help: |
| 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: |
| 60 | ifeq ("$(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 |
| 67 | endif |
| 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 | |
| 74 | ifeq ("$(wildcard /usr/bin/ccache )","") |
| 75 | @echo "WARNING: Please install ccache AYEC and re-run this script" |
| 76 | else |
| 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++ |
| 81 | endif |
| 82 | @make -C $(BR) V=$(V) is_build_tool=yes vppapigen-install |
| 83 | @touch $@ |
| 84 | |
| 85 | bootstrap: $(BR)/.bootstrap.ok |
| 86 | |
| 87 | define make |
| 88 | @make -C $(BR) V=$(V) PLATFORM=vpp TAG=$(1) $(2) |
| 89 | endef |
| 90 | |
| 91 | build: $(BR)/.bootstrap.ok |
| 92 | $(call make,vpp_debug,vpp-install) |
| 93 | |
| 94 | wipe: $(BR)/.bootstrap.ok |
| 95 | $(call make,vpp_debug,vpp-wipe) |
| 96 | |
| 97 | rebuild: wipe build |
| 98 | |
| 99 | build-release: $(BR)/.bootstrap.ok |
| 100 | $(call make,vpp,vpp-install) |
| 101 | |
| 102 | wipe-release: $(BR)/.bootstrap.ok |
| 103 | $(call make,vpp,vpp-wipe) |
| 104 | |
| 105 | rebuild-release: wipe-release build-release |
| 106 | |
| 107 | ifeq ("$(wildcard $(STARTUP_CONF))","") |
| 108 | define 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) |
| 112 | endef |
| 113 | else |
| 114 | define run |
| 115 | @sudo $(1) -c $(STARTUP_CONF) |
| 116 | endef |
| 117 | endif |
| 118 | |
| 119 | run: |
| 120 | $(call run, $(BR)/install-vpp_debug-native/vpp/bin/vpp) |
| 121 | |
| 122 | run-release: |
| 123 | $(call run, $(BR)/install-vpp-native/vpp/bin/vpp) |
| 124 | |
| 125 | debug: |
| 126 | $(call run, $(GDB) --args $(BR)/install-vpp_debug-native/vpp/bin/vpp) |
| 127 | |
| 128 | debug-release: |
| 129 | $(call run, $(GDB) --args $(BR)/install-vpp-native/vpp/bin/vpp) |
| 130 | |
| 131 | build-vat: |
| 132 | $(call make,vpp_debug,vpp-api-test-install) |
| 133 | |
| 134 | run-vat: |
| 135 | @sudo $(BR)/install-vpp_debug-native/vpp-api-test/bin/vpp_api_test |
| 136 | |
| 137 | pkg-deb: |
| 138 | $(call make,vpp,install-deb) |
| 139 | |
| 140 | pkg-rpm: |
| 141 | $(call make,vpp,install-rpm) |