Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | # Copyright (c) 2015 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 | # Scripts require non-POSIX parts of bash |
| 15 | SHELL := /bin/bash |
| 16 | |
Damjan Marion | 561f273 | 2018-09-21 12:27:45 +0200 | [diff] [blame] | 17 | DL_CACHE_DIR = $(HOME)/Downloads |
| 18 | MAKE ?= make |
| 19 | MAKE_ARGS ?= -j |
| 20 | BUILD_DIR ?= $(CURDIR)/_build |
| 21 | INSTALL_DIR ?= $(CURDIR)/_install |
Andrew Yourtchenko | e36f44a | 2019-03-27 15:22:40 +0100 | [diff] [blame] | 22 | PKG_VERSION ?= $(shell git describe --abbrev=0 | cut -d- -f1 | cut -dv -f2 | cut -d. -f1,2) |
Damjan Marion | 4f5f8d7 | 2018-10-11 09:18:26 -0700 | [diff] [blame] | 23 | PKG_SUFFIX ?= $(shell git log --oneline v$(PKG_VERSION)-rc0.. . | wc -l) |
Chris Luke | b2861e8 | 2017-06-14 11:24:41 -0400 | [diff] [blame] | 24 | JOBS := $(if $(shell [ -f /proc/cpuinfo ] && head /proc/cpuinfo),\ |
Damjan Marion | 9324284 | 2017-11-13 20:09:21 +0100 | [diff] [blame] | 25 | $(shell grep -c ^processor /proc/cpuinfo), 2) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 26 | |
Damjan Marion | 561f273 | 2018-09-21 12:27:45 +0200 | [diff] [blame] | 27 | B := $(BUILD_DIR) |
| 28 | I := $(INSTALL_DIR) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 29 | |
Thomas F Herbert | dc66aad | 2019-03-29 15:41:48 -0400 | [diff] [blame] | 30 | ifneq ($(shell which cmake3),) |
| 31 | CMAKE?=cmake3 |
| 32 | else |
| 33 | CMAKE?=cmake |
| 34 | endif |
| 35 | |
Damjan Marion | 561f273 | 2018-09-21 12:27:45 +0200 | [diff] [blame] | 36 | include packages.mk |
| 37 | include packages/nasm.mk |
| 38 | include packages/ipsec-mb.mk |
Aloys Augustin | 7cae003 | 2019-04-01 16:43:29 +0200 | [diff] [blame] | 39 | include packages/quicly.mk |
Damjan Marion | 561f273 | 2018-09-21 12:27:45 +0200 | [diff] [blame] | 40 | include packages/dpdk.mk |
Benoît Ganne | fe750c2 | 2019-03-25 11:41:34 +0100 | [diff] [blame] | 41 | include packages/rdma-core.mk |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 42 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 43 | .PHONY: clean |
| 44 | clean: |
| 45 | @rm -rf $(B) $(I) |
| 46 | |
Benoît Ganne | fe750c2 | 2019-03-25 11:41:34 +0100 | [diff] [blame] | 47 | .PHONY: install |
Aloys Augustin | 7cae003 | 2019-04-01 16:43:29 +0200 | [diff] [blame] | 48 | install: dpdk-install rdma-core-install quicly-install |
Benoît Ganne | fe750c2 | 2019-03-25 11:41:34 +0100 | [diff] [blame] | 49 | |
| 50 | .PHONY: config |
| 51 | config: dpdk-config rdma-core-config |
| 52 | |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 53 | ############################################################################## |
| 54 | # .deb packaging |
| 55 | ############################################################################## |
| 56 | |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 57 | DEB_VER := $(PKG_VERSION) |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 58 | DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null) |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 59 | DEV_DEB=vpp-ext-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb |
| 60 | INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-ext-deps 2> /dev/null) |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 61 | |
| 62 | .PHONY: build-deb install-deb check-deb |
| 63 | |
| 64 | deb/debian/changelog: Makefile |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 65 | @echo "vpp-ext-deps ($(DEB_VER)-$(PKG_SUFFIX)) unstable; urgency=low" > $@ |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 66 | @echo "" >> $@ |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 67 | @echo " * Version $(DEB_VER)" >> $@ |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 68 | @echo "" >> $@ |
| 69 | @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R)" >> $@ |
| 70 | |
| 71 | $(DEV_DEB): deb/debian/changelog |
| 72 | @cd deb && dpkg-buildpackage -b -uc -us |
Damjan Marion | d93638e | 2019-03-29 21:22:09 +0100 | [diff] [blame] | 73 | git clean -fdx deb |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 74 | |
| 75 | build-deb: $(DEV_DEB) |
| 76 | |
| 77 | install-deb: |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 78 | ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX)) |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 79 | @make $(DEV_DEB) |
| 80 | @sudo dpkg -i $(DEV_DEB) |
| 81 | else |
| 82 | @echo "==========================================================" |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 83 | @echo " Up-to-date vpp-ext-deps package already installed" |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 84 | @echo "==========================================================" |
| 85 | endif |
| 86 | |
| 87 | check-deb: |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 88 | ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX)) |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 89 | @echo "==========================================================" |
Benoît Ganne | fe750c2 | 2019-03-25 11:41:34 +0100 | [diff] [blame] | 90 | @echo " Out of date vpp-ext-deps package installed." |
| 91 | @echo " Installed: $(INSTALLED_VER)" |
| 92 | @echo " Needed: $(DEB_VER)-$(PKG_SUFFIX)" |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 93 | @echo "" |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 94 | @echo " Please upgrade by invoking 'make install-ext-deps'" |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 95 | @echo " from the top level directory." |
| 96 | @echo "==========================================================" |
| 97 | endif |
| 98 | |
| 99 | ############################################################################## |
| 100 | # .rpm packaging |
| 101 | ############################################################################## |
| 102 | |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 103 | RPM_VER := $(PKG_VERSION) |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 104 | RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null) |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 105 | DEV_RPM=vpp-ext-deps-$(RPM_VER)-$(PKG_SUFFIX).$(RPM_ARCH).rpm |
| 106 | INSTALLED_RPM_VER=$(shell rpm -q --queryformat '%{VERSION}-%{RELEASE}' vpp-ext-deps 2> /dev/null | grep -v "not inst") |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 107 | |
| 108 | .PHONY: build-rpm install-rpm check-rpm |
| 109 | |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 110 | $(DEV_RPM): Makefile rpm/vpp-ext-deps.spec |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 111 | @rpmbuild -bb \ |
| 112 | --define "_topdir $(CURDIR)/rpm" \ |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 113 | --define "_version $(RPM_VER)" \ |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 114 | --define "_release $(PKG_SUFFIX)" \ |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 115 | $(CURDIR)/rpm/vpp-ext-deps.spec |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 116 | mv rpm/RPMS/$(RPM_ARCH)/*.rpm . |
Damjan Marion | d93638e | 2019-03-29 21:22:09 +0100 | [diff] [blame] | 117 | @git clean -fdx rpm |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 118 | |
| 119 | build-rpm: $(DEV_RPM) |
| 120 | |
| 121 | install-rpm: |
Damjan Marion | 74447d4 | 2018-09-27 14:04:43 +0200 | [diff] [blame] | 122 | ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX)) |
Sergio Gonzalez Monroy | 3b12cdc | 2017-06-06 15:29:16 +0100 | [diff] [blame] | 123 | @$(MAKE) $(DEV_RPM) |
Dave Barach | b252848 | 2019-07-01 19:08:33 -0400 | [diff] [blame] | 124 | sudo rpm -e vpp-ext-deps || true |
Marco Varlese | fe7740e | 2018-10-25 11:49:39 +0200 | [diff] [blame] | 125 | sudo rpm -Uih --force $(DEV_RPM) |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 126 | else |
| 127 | @echo "==========================================================" |
Benoît Ganne | fe750c2 | 2019-03-25 11:41:34 +0100 | [diff] [blame] | 128 | @echo " Up-to-date vpp-ext-deps package already installed" |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 129 | @echo "==========================================================" |
| 130 | endif |
| 131 | |
| 132 | check-rpm: |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 133 | ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX)) |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 134 | @echo "==========================================================" |
Benoît Ganne | fe750c2 | 2019-03-25 11:41:34 +0100 | [diff] [blame] | 135 | @echo " Out of date vpp-ext-deps package installed." |
| 136 | @echo " Installed: $(INSTALLED_RPM_VER)" |
| 137 | @echo " Needed: $(RPM_VER)-$(PKG_SUFFIX)" |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 138 | @echo "" |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 139 | @echo " Please upgrade by invoking 'make install-ext-deps'" |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 140 | @echo " from the top level directory." |
| 141 | @echo "==========================================================" |
| 142 | endif |
| 143 | |
| 144 | ############################################################################## |
| 145 | # ebuild support |
| 146 | ############################################################################## |
| 147 | |
| 148 | .PHONY: ebuild-build ebuild-install |
| 149 | |
| 150 | ebuild-build: |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 151 | ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),) |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 152 | @echo "==========================================================" |
Benoît Ganne | fe750c2 | 2019-03-25 11:41:34 +0100 | [diff] [blame] | 153 | @echo "Building vpp-ext-deps from source. Consider installing" |
| 154 | @echo "development package by invoking 'make install-ext-deps'" |
| 155 | @echo "from the top level directory" |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 156 | @echo "==========================================================" |
| 157 | make config |
| 158 | else |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 159 | ifneq ($(INSTALLED_VER),) |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 160 | make check-deb |
| 161 | endif |
| 162 | ifneq ($(INSTALLED_RPM_VER),) |
| 163 | make check-rpm |
| 164 | endif |
| 165 | endif |
| 166 | |
| 167 | ebuild-install: |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 168 | ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),) |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 169 | make install |
| 170 | endif |