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