summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2016-02-10 00:36:06 +0100
committerGerrit Code Review <gerrit@fd.io>2016-02-10 13:14:39 +0000
commite17fdb5ddfdd4275e785bf4266653243e76e000d (patch)
tree9c8519ce21726247bae496ea15aeaa6325ae1fbc
parentb8f45b37292fcb3b19c4ffcdb91947a9eec03500 (diff)
Add Top-Level Wrapper Makefile
Change-Id: Ie3431986ddb42db8d331fcb3d34250a6ec9d9a02 Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r--Makefile141
1 files changed, 141 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000000..b7c3e27fd22
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,141 @@
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+WS_ROOT=$(CURDIR)
+BR=$(WS_ROOT)/build-root
+CCACHE_DIR?=$(BR)/.ccache
+V?=0
+GDB?=gdb
+
+MINIMAL_STARTUP_CONF="unix { interactive } dpdk { no-pci socket-mem 1024 }"
+
+DEB_DEPENDS = curl build-essential autoconf automake bison libssl-dev ccache
+DEB_DEPENDS += debhelper dkms openjdk-7-jdk git libtool libganglia1-dev libapr1-dev
+DEB_DEPENDS += libconfuse-dev git-review
+
+
+.PHONY: help bootstrap wipe wipe-release build build-release rebuild rebuild-release
+.PHONY: run run-release debug debug-release build-vat run-vat pkg-deb pkg-rpm
+
+help:
+ @echo "Make Targets:"
+ @echo " bootstrap - prepare tree for build"
+ @echo " wipe - wipe all products of debug build "
+ @echo " wipe-release - wipe all products of release build "
+ @echo " build - build debug binaries"
+ @echo " build-release - build release binaries"
+ @echo " rebuild - wipe and build debug binares"
+ @echo " rebuild-release - wipe and build release binares"
+ @echo " run - run debug binary"
+ @echo " run-release - run release binary"
+ @echo " debug - run debug binary with debugger"
+ @echo " debug-release - run release binary with debugger"
+ @echo " build-vat - build vpp-api-test tool"
+ @echo " run-vat - run vpp-api-test tool"
+ @echo " pkg-deb - build DEB packages"
+ @echo " pkg-rpm - build RPM packages"
+ @echo ""
+ @echo "Make Arguments:"
+ @echo " V=[0|1] - set build verbosity level"
+ @echo " STARTUP_CONF=<path> - startup configuration file"
+ @echo " (e.g. /etc/vpp/startup.conf)"
+ @echo " GDB=<path> - gdb binary to use for debugging"
+ @echo ""
+ @echo "Current Argumernt Values:"
+ @echo " V = $(V)"
+ @echo " STARTUP_CONF = $(STARTUP_CONF)"
+ @echo " GDB = $(GDB)"
+
+$(BR)/.bootstrap.ok:
+ifeq ("$(shell lsb_release -si)", "Ubuntu")
+ @MISSING=$$(apt-get install -y -qq -s $(DEB_DEPENDS) | grep "^Inst ") ; \
+ if [ -n "$$MISSING" ] ; then \
+ echo "\nPlease install missing packages: \n$$MISSING\n" ; \
+ exit 1 ; \
+ fi ; \
+ exit 0
+endif
+ @echo "SOURCE_PATH = $(WS_ROOT)" > $(BR)/build-config.mk
+ @echo "#!/bin/bash\n" > $(BR)/path_setup
+ @echo 'export PATH=$(BR)/tools/ccache-bin:$$PATH' >> $(BR)/path_setup
+ @echo 'export PATH=$(BR)/tools/bin:$$PATH' >> $(BR)/path_setup
+ @echo 'export CCACHE_DIR=$(CCACHE_DIR)' >> $(BR)/path_setup
+
+ifeq ("$(wildcard /usr/bin/ccache )","")
+ @echo "WARNING: Please install ccache AYEC and re-run this script"
+else
+ @rm -rf $(BR)/tools/ccache-bin
+ @mkdir -p $(BR)/tools/ccache-bin
+ @ln -s /usr/bin/ccache $(BR)/tools/ccache-bin/gcc
+ @ln -s /usr/bin/ccache $(BR)/tools/ccache-bin/g++
+endif
+ @make -C $(BR) V=$(V) is_build_tool=yes vppapigen-install
+ @touch $@
+
+bootstrap: $(BR)/.bootstrap.ok
+
+define make
+ @make -C $(BR) V=$(V) PLATFORM=vpp TAG=$(1) $(2)
+endef
+
+build: $(BR)/.bootstrap.ok
+ $(call make,vpp_debug,vpp-install)
+
+wipe: $(BR)/.bootstrap.ok
+ $(call make,vpp_debug,vpp-wipe)
+
+rebuild: wipe build
+
+build-release: $(BR)/.bootstrap.ok
+ $(call make,vpp,vpp-install)
+
+wipe-release: $(BR)/.bootstrap.ok
+ $(call make,vpp,vpp-wipe)
+
+rebuild-release: wipe-release build-release
+
+ifeq ("$(wildcard $(STARTUP_CONF))","")
+define run
+ @echo "WARNING: STARTUP_CONF not defined or file doesn't exist."
+ @echo " Running with minimal startup config: $(MINIMAL_STARTUP_CONF)\n"
+ @sudo $(1) $(MINIMAL_STARTUP_CONF)
+endef
+else
+define run
+ @sudo $(1) -c $(STARTUP_CONF)
+endef
+endif
+
+run:
+ $(call run, $(BR)/install-vpp_debug-native/vpp/bin/vpp)
+
+run-release:
+ $(call run, $(BR)/install-vpp-native/vpp/bin/vpp)
+
+debug:
+ $(call run, $(GDB) --args $(BR)/install-vpp_debug-native/vpp/bin/vpp)
+
+debug-release:
+ $(call run, $(GDB) --args $(BR)/install-vpp-native/vpp/bin/vpp)
+
+build-vat:
+ $(call make,vpp_debug,vpp-api-test-install)
+
+run-vat:
+ @sudo $(BR)/install-vpp_debug-native/vpp-api-test/bin/vpp_api_test
+
+pkg-deb:
+ $(call make,vpp,install-deb)
+
+pkg-rpm:
+ $(call make,vpp,install-rpm)