From 7b710946b152fabab0f3c838e5518576beb9020c Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Sun, 21 Aug 2022 11:23:54 +0200 Subject: Makefile: Use more GNU-style directory variables, explicit docdir for OpenSUSE It turns out that, while on most distributions "docdir" would be /usr/share/doc, it's /usr/share/doc/packages/ on OpenSUSE Tumbleweed. Use an explicit docdir as shown in: https://en.opensuse.org/openSUSE:Build_Service_cross_distribution_howto and don't unnecessarily hardcode directory variables in the Makefile. Otherwise, RPM builds for OpenSUSE will fail now that we have a README there. Signed-off-by: Stefano Brivio --- Makefile | 28 +++++++++++++++++----------- contrib/fedora/passt.spec | 4 ++++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 81b997e..26e64d5 100644 --- a/Makefile +++ b/Makefile @@ -82,7 +82,13 @@ ifeq ($(shell :|$(CC) -fstack-protector-strong -S -xc - -o - >/dev/null 2>&1; ec CFLAGS += -fstack-protector-strong endif -prefix ?= /usr/local +prefix ?= /usr/local +exec_prefix ?= $(prefix) +bindir ?= $(exec_prefix)/bin +datarootdir ?= $(prefix)/share +docdir ?= $(datarootdir)/doc/passt +mandir ?= $(datarootdir)/man +man1dir ?= $(mandir)/man1 ifeq ($(TARGET_ARCH),X86_64) BIN := passt passt.avx2 pasta pasta.avx2 qrap @@ -126,19 +132,19 @@ clean: passt.pid README.plain.md install: $(BIN) $(MANPAGES) docs - mkdir -p $(DESTDIR)$(prefix)/bin $(DESTDIR)$(prefix)/share/man/man1 - cp -d $(BIN) $(DESTDIR)$(prefix)/bin - cp -d $(MANPAGES) $(DESTDIR)$(prefix)/share/man/man1 - mkdir -p $(DESTDIR)$(prefix)/share/doc/passt - cp -d README.plain.md $(DESTDIR)$(prefix)/share/doc/passt/README.md - cp -d doc/demo.sh $(DESTDIR)$(prefix)/share/doc/passt + mkdir -p $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir) + cp -d $(BIN) $(DESTDIR)$(bindir) + cp -d $(MANPAGES) $(DESTDIR)$(man1dir) + mkdir -p $(DESTDIR)$(docdir) + cp -d README.plain.md $(DESTDIR)$(docdir)/README.md + cp -d doc/demo.sh $(DESTDIR)$(docdir) uninstall: $(RM) $(BIN:%=$(DESTDIR)$(prefix)/bin/%) - $(RM) $(MANPAGES:%=$(DESTDIR)$(prefix)/share/man/man1/%) - $(RM) $(DESTDIR)$(prefix)/share/doc/passt/README.md - $(RM) $(DESTDIR)$(prefix)/share/doc/passt/demo.sh - -rmdir $(DESTDIR)$(prefix)/share/doc/passt + $(RM) $(MANPAGES:%=$(DESTDIR)$(man1dir)/%) + $(RM) $(DESTDIR)$(docdir)/README.md + $(RM) $(DESTDIR)$(docdir)/demo.sh + -rmdir $(DESTDIR)$(docdir) pkgs: static tar cf passt.tar -P --xform 's//\/usr\/bin\//' $(BIN) diff --git a/contrib/fedora/passt.spec b/contrib/fedora/passt.spec index 8bbe0d0..87c3e93 100644 --- a/contrib/fedora/passt.spec +++ b/contrib/fedora/passt.spec @@ -51,7 +51,11 @@ This package adds SELinux enforcement to passt(1) and pasta(1). %make_build %install +%if 0%{?suse_version} > 910 +%make_install DESTDIR=%{buildroot} prefix=%{_prefix} docdir=%{_prefix}/share/doc/packages/passt +%else %make_install DESTDIR=%{buildroot} prefix=%{_prefix} +%endif %ifarch x86_64 ln -sr %{buildroot}%{_mandir}/man1/passt.1 %{buildroot}%{_mandir}/man1/passt.avx2.1 ln -sr %{buildroot}%{_mandir}/man1/pasta.1 %{buildroot}%{_mandir}/man1/pasta.avx2.1 -- cgit v1.2.3