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 |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 22 | PKG_VERSION ?= $(shell git describe --abbrev=0 | cut -d- -f1 | cut -dv -f2) |
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 | |
Damjan Marion | 561f273 | 2018-09-21 12:27:45 +0200 | [diff] [blame] | 30 | include packages.mk |
| 31 | include packages/nasm.mk |
| 32 | include packages/ipsec-mb.mk |
| 33 | include packages/dpdk.mk |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 34 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 35 | .PHONY: clean |
| 36 | clean: |
| 37 | @rm -rf $(B) $(I) |
| 38 | |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 39 | ############################################################################## |
| 40 | # .deb packaging |
| 41 | ############################################################################## |
| 42 | |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 43 | DEB_VER := $(PKG_VERSION) |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 44 | DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null) |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 45 | DEV_DEB=vpp-ext-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb |
| 46 | 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] | 47 | |
| 48 | .PHONY: build-deb install-deb check-deb |
| 49 | |
| 50 | deb/debian/changelog: Makefile |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 51 | @echo "vpp-ext-deps ($(DEB_VER)-$(PKG_SUFFIX)) unstable; urgency=low" > $@ |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 52 | @echo "" >> $@ |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 53 | @echo " * Version $(DEB_VER)" >> $@ |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 54 | @echo "" >> $@ |
| 55 | @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R)" >> $@ |
| 56 | |
| 57 | $(DEV_DEB): deb/debian/changelog |
| 58 | @cd deb && dpkg-buildpackage -b -uc -us |
| 59 | git clean -fdx deb |
| 60 | |
| 61 | build-deb: $(DEV_DEB) |
| 62 | |
| 63 | install-deb: |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 64 | ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX)) |
Ed Warnicke | 798150b | 2017-11-08 13:39:31 -0700 | [diff] [blame] | 65 | @echo "==========================================================" |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 66 | @echo " Out of date vpp-ext-deps package installed." |
| 67 | @echo " Installed: $(INSTALLED_VER)" |
| 68 | @echo " Needed: $(DEB_VER)-$(PKG_SUFFIX)" |
Ed Warnicke | 798150b | 2017-11-08 13:39:31 -0700 | [diff] [blame] | 69 | @echo "==========================================================" |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 70 | @make $(DEV_DEB) |
| 71 | @sudo dpkg -i $(DEV_DEB) |
| 72 | else |
| 73 | @echo "==========================================================" |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 74 | @echo " Up-to-date vpp-ext-deps package already installed" |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 75 | @echo "==========================================================" |
| 76 | endif |
| 77 | |
| 78 | check-deb: |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 79 | ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX)) |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 80 | @echo "==========================================================" |
| 81 | @echo " Outdated DPDK package detected:" |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 82 | @echo " Installed: vpp-ext-deps $(INSTALLED_VER)" |
| 83 | @echo " Current: vpp-ext-deps $(DEB_VER)-$(PKG_SUFFIX)" |
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 " Please upgrade by invoking 'make install-ext-deps'" |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 86 | @echo " from the top level directory." |
| 87 | @echo "==========================================================" |
| 88 | endif |
| 89 | |
| 90 | ############################################################################## |
| 91 | # .rpm packaging |
| 92 | ############################################################################## |
| 93 | |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 94 | RPM_VER := $(PKG_VERSION) |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 95 | RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null) |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 96 | DEV_RPM=vpp-ext-deps-$(RPM_VER)-$(PKG_SUFFIX).$(RPM_ARCH).rpm |
| 97 | 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] | 98 | |
| 99 | .PHONY: build-rpm install-rpm check-rpm |
| 100 | |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 101 | $(DEV_RPM): Makefile rpm/vpp-ext-deps.spec |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 102 | @rpmbuild -bb \ |
| 103 | --define "_topdir $(CURDIR)/rpm" \ |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 104 | --define "_version $(RPM_VER)" \ |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 105 | --define "_release $(PKG_SUFFIX)" \ |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 106 | $(CURDIR)/rpm/vpp-ext-deps.spec |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 107 | mv rpm/RPMS/$(RPM_ARCH)/*.rpm . |
Damjan Marion | 561f273 | 2018-09-21 12:27:45 +0200 | [diff] [blame] | 108 | @git clean -fdx rpm |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 109 | |
| 110 | build-rpm: $(DEV_RPM) |
| 111 | |
| 112 | install-rpm: |
Damjan Marion | 74447d4 | 2018-09-27 14:04:43 +0200 | [diff] [blame] | 113 | ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX)) |
Sergio Gonzalez Monroy | 3b12cdc | 2017-06-06 15:29:16 +0100 | [diff] [blame] | 114 | @$(MAKE) $(DEV_RPM) |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 115 | sudo rpm -Uih $(DEV_RPM) |
| 116 | else |
| 117 | @echo "==========================================================" |
| 118 | @echo " Up-to-date DPDK package already installed" |
| 119 | @echo "==========================================================" |
| 120 | endif |
| 121 | |
| 122 | check-rpm: |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 123 | ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX)) |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 124 | @echo "==========================================================" |
| 125 | @echo " Outdated DPDK package detected:" |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 126 | @echo " Installed: vpp-ext-deps $(INSTALLED_RPM_VER)" |
| 127 | @echo " Current: vpp-ext-deps $(RPM_VER)-$(PKG_SUFFIX)" |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 128 | @echo "" |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 129 | @echo " Please upgrade by invoking 'make install-ext-deps'" |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 130 | @echo " from the top level directory." |
| 131 | @echo "==========================================================" |
| 132 | endif |
| 133 | |
| 134 | ############################################################################## |
| 135 | # ebuild support |
| 136 | ############################################################################## |
| 137 | |
| 138 | .PHONY: ebuild-build ebuild-install |
| 139 | |
| 140 | ebuild-build: |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 141 | ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),) |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 142 | @echo "==========================================================" |
| 143 | @echo "Building DPDK from source. Consider installing development" |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 144 | @echo "package by invoking 'make install-ext-deps' from the" |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 145 | @echo "top level directory" |
| 146 | @echo "==========================================================" |
| 147 | make config |
| 148 | else |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 149 | ifneq ($(INSTALLED_VER),) |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 150 | make check-deb |
| 151 | endif |
| 152 | ifneq ($(INSTALLED_RPM_VER),) |
| 153 | make check-rpm |
| 154 | endif |
| 155 | endif |
| 156 | |
| 157 | ebuild-install: |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 158 | ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),) |
Damjan Marion | 2ce7f98 | 2017-01-09 20:24:50 +0100 | [diff] [blame] | 159 | make install |
| 160 | endif |