blob: c94412f395e8872e9ece0b40360601ef106d077e [file] [log] [blame]
Dave Wallace79c8f992024-05-15 18:16:40 -04001# 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 Wallace8ba08722024-11-21 16:00:12 -050014PKG_SUFFIX ?= $(shell git log --oneline v$(PKG_VERSION)-rc0.. . | wc -l)
15
Dave Wallace79c8f992024-05-15 18:16:40 -040016include ../build_common.mk
17include ../packages_common.mk
18
19ifneq ($(shell uname), FreeBSD)
20include packages/openssl.mk
21endif # ! FreeBSD
22
23.PHONY: clean
24clean:
25 @rm -rf $(B) $(I)
26
27.PHONY: install
28ifeq ($(shell uname), FreeBSD)
29install:
30else
31install: openssl-install
32endif # FreeBSD
33
34.PHONY: config
35ifeq ($(shell uname), FreeBSD)
36config:
37else
38config: openssl-config
39endif # FreeBSD
40
41##############################################################################
42# .deb packaging
43##############################################################################
44
45DEB_VER := $(PKG_VERSION)
46DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
47DEV_DEB=vpp-opt-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
48INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-opt-deps 2> /dev/null)
49
50.PHONY: build-deb install-deb check-deb
51
52deb/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
63build-deb: $(DEV_DEB)
64
65install-deb:
66ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
67 @$(MAKE) $(DEV_DEB)
68 @sudo dpkg -i $(DEV_DEB)
69else
70 @echo "=========================================================="
71 @echo " Up-to-date vpp-opt-deps package already installed"
72 @echo "=========================================================="
73endif
74
75check-deb:
76ifneq ($(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 "=========================================================="
85endif
86
87##############################################################################
88# .rpm packaging
89##############################################################################
90
91RPM_VER := $(PKG_VERSION)
92RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
93DEV_RPM=vpp-opt-deps-$(RPM_VER)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
94INSTALLED_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
107build-rpm: $(DEV_RPM)
108
109install-rpm:
110ifneq ($(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)
114else
115 @echo "=========================================================="
116 @echo " Up-to-date vpp-opt-deps package already installed"
117 @echo "=========================================================="
118endif
119
120check-rpm:
121ifneq ($(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 "=========================================================="
130endif
131
132##############################################################################
133# ebuild support
134##############################################################################
135
136.PHONY: ebuild-build ebuild-install
137
138ebuild-build:
139ifeq ($(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
146else
147ifneq ($(INSTALLED_VER),)
148 $(MAKE) check-deb
149endif
150ifneq ($(INSTALLED_RPM_VER),)
151 $(MAKE) check-rpm
152endif
153endif
154
155ebuild-install:
156ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
157 $(MAKE) install
158endif