Dave Wallace | 79c8f99 | 2024-05-15 18:16:40 -0400 | [diff] [blame] | 1 | # Copyright (c) 2024 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 | |
Dave Wallace | 8ba0872 | 2024-11-21 16:00:12 -0500 | [diff] [blame] | 14 | PKG_SUFFIX ?= $(shell git log --oneline v$(PKG_VERSION)-rc0.. . | wc -l) |
| 15 | |
Dave Wallace | 79c8f99 | 2024-05-15 18:16:40 -0400 | [diff] [blame] | 16 | include ../build_common.mk |
| 17 | include ../packages_common.mk |
| 18 | |
| 19 | ifneq ($(shell uname), FreeBSD) |
| 20 | include packages/openssl.mk |
| 21 | endif # ! FreeBSD |
| 22 | |
| 23 | .PHONY: clean |
| 24 | clean: |
| 25 | @rm -rf $(B) $(I) |
| 26 | |
| 27 | .PHONY: install |
| 28 | ifeq ($(shell uname), FreeBSD) |
| 29 | install: |
| 30 | else |
| 31 | install: openssl-install |
| 32 | endif # FreeBSD |
| 33 | |
| 34 | .PHONY: config |
| 35 | ifeq ($(shell uname), FreeBSD) |
| 36 | config: |
| 37 | else |
| 38 | config: openssl-config |
| 39 | endif # FreeBSD |
| 40 | |
| 41 | ############################################################################## |
| 42 | # .deb packaging |
| 43 | ############################################################################## |
| 44 | |
| 45 | DEB_VER := $(PKG_VERSION) |
| 46 | DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null) |
| 47 | DEV_DEB=vpp-opt-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb |
| 48 | INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-opt-deps 2> /dev/null) |
| 49 | |
| 50 | .PHONY: build-deb install-deb check-deb |
| 51 | |
| 52 | deb/debian/changelog: Makefile |
| 53 | @echo "vpp-opt-deps ($(DEB_VER)-$(PKG_SUFFIX)) unstable; urgency=low" > $@ |
| 54 | @echo "" >> $@ |
| 55 | @echo " * Version $(DEB_VER)" >> $@ |
| 56 | @echo "" >> $@ |
| 57 | @echo " -- VPP Dev <vpp-dev@lists.fd.io> $(shell date -R --date=@${SOURCE_DATE_EPOCH})" >> $@ |
| 58 | |
| 59 | $(DEV_DEB): deb/debian/changelog |
| 60 | @cd deb && dpkg-buildpackage -b -uc -us |
| 61 | git clean -fdx deb |
| 62 | |
| 63 | build-deb: $(DEV_DEB) |
| 64 | |
| 65 | install-deb: |
| 66 | ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX)) |
| 67 | @$(MAKE) $(DEV_DEB) |
| 68 | @sudo dpkg -i $(DEV_DEB) |
| 69 | else |
| 70 | @echo "==========================================================" |
| 71 | @echo " Up-to-date vpp-opt-deps package already installed" |
| 72 | @echo "==========================================================" |
| 73 | endif |
| 74 | |
| 75 | check-deb: |
| 76 | ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX)) |
| 77 | @echo "==========================================================" |
| 78 | @echo " Out of date vpp-opt-deps package installed." |
| 79 | @echo " Installed: $(INSTALLED_VER)" |
| 80 | @echo " Needed: $(DEB_VER)-$(PKG_SUFFIX)" |
| 81 | @echo "" |
| 82 | @echo " Please upgrade by invoking 'make install-opt-deps'" |
| 83 | @echo " from the top level directory." |
| 84 | @echo "==========================================================" |
| 85 | endif |
| 86 | |
| 87 | ############################################################################## |
| 88 | # .rpm packaging |
| 89 | ############################################################################## |
| 90 | |
| 91 | RPM_VER := $(PKG_VERSION) |
| 92 | RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null) |
| 93 | DEV_RPM=vpp-opt-deps-$(RPM_VER)-$(PKG_SUFFIX).$(RPM_ARCH).rpm |
| 94 | INSTALLED_RPM_VER=$(shell rpm -q --queryformat '%{VERSION}-%{RELEASE}' vpp-opt-deps 2> /dev/null | grep -v "vpp-opt-deps") |
| 95 | |
| 96 | .PHONY: build-rpm install-rpm check-rpm |
| 97 | |
| 98 | $(DEV_RPM): Makefile rpm/vpp-opt-deps.spec |
| 99 | @rpmbuild -bb \ |
| 100 | --define "_topdir $(CURDIR)/rpm" \ |
| 101 | --define "_version $(RPM_VER)" \ |
| 102 | --define "_release $(PKG_SUFFIX)" \ |
| 103 | $(CURDIR)/rpm/vpp-opt-deps.spec |
| 104 | mv rpm/RPMS/$(RPM_ARCH)/*.rpm . |
| 105 | @git clean -fdx rpm |
| 106 | |
| 107 | build-rpm: $(DEV_RPM) |
| 108 | |
| 109 | install-rpm: |
| 110 | ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX)) |
| 111 | @$(MAKE) $(DEV_RPM) |
| 112 | sudo rpm -e vpp-opt-deps || true |
| 113 | sudo rpm -Uih --force $(DEV_RPM) |
| 114 | else |
| 115 | @echo "==========================================================" |
| 116 | @echo " Up-to-date vpp-opt-deps package already installed" |
| 117 | @echo "==========================================================" |
| 118 | endif |
| 119 | |
| 120 | check-rpm: |
| 121 | ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX)) |
| 122 | @echo "==========================================================" |
| 123 | @echo " Out of date vpp-opt-deps package installed." |
| 124 | @echo " Installed: $(INSTALLED_RPM_VER)" |
| 125 | @echo " Needed: $(RPM_VER)-$(PKG_SUFFIX)" |
| 126 | @echo "" |
| 127 | @echo " Please upgrade by invoking 'make install-opt-deps'" |
| 128 | @echo " from the top level directory." |
| 129 | @echo "==========================================================" |
| 130 | endif |
| 131 | |
| 132 | ############################################################################## |
| 133 | # ebuild support |
| 134 | ############################################################################## |
| 135 | |
| 136 | .PHONY: ebuild-build ebuild-install |
| 137 | |
| 138 | ebuild-build: |
| 139 | ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),) |
| 140 | @echo "==========================================================" |
| 141 | @echo "Building vpp-opt-deps from source. Consider installing" |
| 142 | @echo "development package by invoking 'make install-opt-deps'" |
| 143 | @echo "from the top level directory" |
| 144 | @echo "==========================================================" |
| 145 | $(MAKE) config |
| 146 | else |
| 147 | ifneq ($(INSTALLED_VER),) |
| 148 | $(MAKE) check-deb |
| 149 | endif |
| 150 | ifneq ($(INSTALLED_RPM_VER),) |
| 151 | $(MAKE) check-rpm |
| 152 | endif |
| 153 | endif |
| 154 | |
| 155 | ebuild-install: |
| 156 | ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),) |
| 157 | $(MAKE) install |
| 158 | endif |