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:
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
14 # Scripts require non-POSIX parts of bash
15 SHELL := $(shell which bash)
17 DL_CACHE_DIR = $(HOME)/Downloads
19 BUILD_DIR ?= $(CURDIR)/_build
20 INSTALL_DIR ?= $(CURDIR)/_install
21 PKG_VERSION ?= $(shell git describe --abbrev=0 --match 'v[0-9]*' | cut -d- -f1 | cut -dv -f2 | cut -d. -f1,2)
22 PKG_SUFFIX ?= $(shell git log --oneline v$(PKG_VERSION)-rc0.. . | wc -l)
23 SOURCE_DATE_EPOCH ?= $(shell git log -1 --pretty=%ct .)
24 ifeq ($shell(uname), FreeBSD)
25 JOBS := $(shell nproc)
27 JOBS := $(if $(shell [ -f /proc/cpuinfo ] && head /proc/cpuinfo),\
28 $(shell grep -c ^processor /proc/cpuinfo), 2)
34 ifneq ($(shell which cmake3),)
40 ARCH_X86_64=$(filter x86_64,$(shell uname -m))
41 AARCH64=$(filter aarch64,$(shell uname -m))
44 include packages/ipsec-mb.mk
45 include packages/quicly.mk
46 ifneq ($(shell uname), FreeBSD)
47 include packages/rdma-core.mk
48 include packages/dpdk.mk
49 include packages/xdp-tools.mk
50 include packages/octeon-roc.mk
58 ifeq ($(shell uname), FreeBSD)
59 install: $(if $(ARCH_X86_64), ipsec-mb-install) quicly-install
61 install: $(if $(ARCH_X86_64), ipsec-mb-install) dpdk-install rdma-core-install quicly-install xdp-tools-install $(if $(AARCH64), octeon-roc-install)
65 ifeq ($(shell uname), FreeBSD)
66 config: $(if $(ARCH_X86_64), ipsec-mb-config) quicly-build
68 config: $(if $(ARCH_X86_64), ipsec-mb-config) dpdk-config rdma-core-config quicly-build
71 ##############################################################################
73 ##############################################################################
75 DEB_VER := $(PKG_VERSION)
76 DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
77 DEV_DEB=vpp-ext-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
78 INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-ext-deps 2> /dev/null)
80 .PHONY: build-deb install-deb check-deb
82 deb/debian/changelog: Makefile
83 @echo "vpp-ext-deps ($(DEB_VER)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
85 @echo " * Version $(DEB_VER)" >> $@
87 @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R --date=@${SOURCE_DATE_EPOCH})" >> $@
89 $(DEV_DEB): deb/debian/changelog
90 @cd deb && dpkg-buildpackage -b -uc -us
96 ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
98 @sudo dpkg -i $(DEV_DEB)
100 @echo "=========================================================="
101 @echo " Up-to-date vpp-ext-deps package already installed"
102 @echo "=========================================================="
106 ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
107 @echo "=========================================================="
108 @echo " Out of date vpp-ext-deps package installed."
109 @echo " Installed: $(INSTALLED_VER)"
110 @echo " Needed: $(DEB_VER)-$(PKG_SUFFIX)"
112 @echo " Please upgrade by invoking 'make install-ext-deps'"
113 @echo " from the top level directory."
114 @echo "=========================================================="
117 ##############################################################################
119 ##############################################################################
121 RPM_VER := $(PKG_VERSION)
122 RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
123 DEV_RPM=vpp-ext-deps-$(RPM_VER)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
124 INSTALLED_RPM_VER=$(shell rpm -q --queryformat '%{VERSION}-%{RELEASE}' vpp-ext-deps 2> /dev/null | grep -v "vpp-ext-deps")
126 .PHONY: build-rpm install-rpm check-rpm
128 $(DEV_RPM): Makefile rpm/vpp-ext-deps.spec
130 --define "_topdir $(CURDIR)/rpm" \
131 --define "_version $(RPM_VER)" \
132 --define "_release $(PKG_SUFFIX)" \
133 $(CURDIR)/rpm/vpp-ext-deps.spec
134 mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
137 build-rpm: $(DEV_RPM)
140 ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
142 sudo rpm -e vpp-ext-deps || true
143 sudo rpm -Uih --force $(DEV_RPM)
145 @echo "=========================================================="
146 @echo " Up-to-date vpp-ext-deps package already installed"
147 @echo "=========================================================="
151 ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
152 @echo "=========================================================="
153 @echo " Out of date vpp-ext-deps package installed."
154 @echo " Installed: $(INSTALLED_RPM_VER)"
155 @echo " Needed: $(RPM_VER)-$(PKG_SUFFIX)"
157 @echo " Please upgrade by invoking 'make install-ext-deps'"
158 @echo " from the top level directory."
159 @echo "=========================================================="
162 ##############################################################################
164 ##############################################################################
166 .PHONY: ebuild-build ebuild-install
169 ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
170 @echo "=========================================================="
171 @echo "Building vpp-ext-deps from source. Consider installing"
172 @echo "development package by invoking 'make install-ext-deps'"
173 @echo "from the top level directory"
174 @echo "=========================================================="
177 ifneq ($(INSTALLED_VER),)
180 ifneq ($(INSTALLED_RPM_VER),)
186 ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)