Makefile: Use $(BIN) and $(MANPAGES) variable to simplify several targets

There are several places which explicitly list the various generated
binaries, even though a $(BIN) variable already lists them.  There are
several more places that list all the manpage files, introduce a
$(MANPAGES) variable to remove that repetition as well.

Tweak the generation of pasta.1 as a link to passt.1 so it's not just made
as a side effect of the pasta target.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
[sbrivio: add passt.1 and qrap.1 to guest files for distro tests]
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson 2022-06-14 15:12:22 +10:00 committed by Stefano Brivio
parent 08007d0b25
commit 25f515831c
5 changed files with 16 additions and 18 deletions

View file

@ -37,6 +37,8 @@ PASST_SRCS = arch.c arp.c checksum.c conf.c dhcp.c dhcpv6.c icmp.c igmp.c \
QRAP_SRCS = qrap.c QRAP_SRCS = qrap.c
SRCS = $(PASST_SRCS) $(QRAP_SRCS) SRCS = $(PASST_SRCS) $(QRAP_SRCS)
MANPAGES = passt.1 pasta.1 qrap.1
PASST_HEADERS = arch.h arp.h checksum.h conf.h dhcp.h dhcpv6.h icmp.h \ PASST_HEADERS = arch.h arp.h checksum.h conf.h dhcp.h dhcpv6.h icmp.h \
ndp.h netlink.h packet.h passt.h pasta.h pcap.h siphash.h \ ndp.h netlink.h packet.h passt.h pasta.h pcap.h siphash.h \
tap.h tcp.h tcp_splice.h udp.h util.h tap.h tcp.h tcp_splice.h udp.h util.h
@ -83,13 +85,13 @@ endif
prefix ?= /usr/local prefix ?= /usr/local
ifeq ($(TARGET_ARCH),X86_64) ifeq ($(TARGET_ARCH),X86_64)
all: passt passt.avx2 pasta pasta.avx2 qrap
BIN := passt passt.avx2 pasta pasta.avx2 qrap BIN := passt passt.avx2 pasta pasta.avx2 qrap
else else
all: passt pasta qrap
BIN := passt pasta qrap BIN := passt pasta qrap
endif endif
all: $(BIN) $(MANPAGES)
static: CFLAGS += -static -DGLIBC_NO_STATIC_NSS static: CFLAGS += -static -DGLIBC_NO_STATIC_NSS
static: clean all static: clean all
@ -110,6 +112,8 @@ pasta.avx2: passt.avx2
pasta: passt pasta: passt
ln -s passt pasta ln -s passt pasta
pasta.1: passt.1
ln -s passt.1 pasta.1 ln -s passt.1 pasta.1
qrap: $(QRAP_SRCS) passt.h qrap: $(QRAP_SRCS) passt.h
@ -123,28 +127,22 @@ valgrind: all
.PHONY: clean .PHONY: clean
clean: clean:
-${RM} passt passt.avx2 *.o seccomp.h qrap pasta pasta.avx2 pasta.1 \ -${RM} $(BIN) *.o seccomp.h pasta.1 \
passt.tar passt.tar.gz *.deb *.rpm passt.tar passt.tar.gz *.deb *.rpm
install: $(BIN) install: $(BIN) $(MANPAGES)
mkdir -p $(DESTDIR)$(prefix)/bin $(DESTDIR)$(prefix)/share/man/man1 mkdir -p $(DESTDIR)$(prefix)/bin $(DESTDIR)$(prefix)/share/man/man1
cp -d $(BIN) $(DESTDIR)$(prefix)/bin cp -d $(BIN) $(DESTDIR)$(prefix)/bin
cp -d passt.1 pasta.1 qrap.1 $(DESTDIR)$(prefix)/share/man/man1 cp -d $(MANPAGES) $(DESTDIR)$(prefix)/share/man/man1
uninstall: uninstall:
-${RM} $(DESTDIR)$(prefix)/bin/passt -${RM} $(BIN:%=$(DESTDIR)$(prefix)/bin/%)
-${RM} $(DESTDIR)$(prefix)/bin/passt.avx2 -${RM} $(MANPAGES:%=$(DESTDIR)$(prefix)/share/man/man1/%)
-${RM} $(DESTDIR)$(prefix)/bin/pasta
-${RM} $(DESTDIR)$(prefix)/bin/pasta.avx2
-${RM} $(DESTDIR)$(prefix)/bin/qrap
-${RM} $(DESTDIR)$(prefix)/share/man/man1/passt.1
-${RM} $(DESTDIR)$(prefix)/share/man/man1/pasta.1
-${RM} $(DESTDIR)$(prefix)/share/man/man1/qrap.1
pkgs: static pkgs: static
tar cf passt.tar -P --xform 's//\/usr\/bin\//' $(BIN) tar cf passt.tar -P --xform 's//\/usr\/bin\//' $(BIN)
tar rf passt.tar -P --xform 's//\/usr\/share\/man\/man1\//' \ tar rf passt.tar -P --xform 's//\/usr\/share\/man\/man1\//' \
passt.1 pasta.1 qrap.1 $(MANPAGES)
gzip passt.tar gzip passt.tar
EMAIL="sbrivio@redhat.com" fakeroot alien --to-deb \ EMAIL="sbrivio@redhat.com" fakeroot alien --to-deb \
--description="User-mode networking for VMs and namespaces" \ --description="User-mode networking for VMs and namespaces" \

View file

@ -39,7 +39,7 @@ endef
hostb ./passt -P __PIDFILE__ & hostb ./passt -P __PIDFILE__ &
sleep 1 sleep 1
host echo host echo
hout GUEST_FILES ls -1 *.c *.h *.sh Makefile | tr '\n' ' '; echo hout GUEST_FILES ls -1 *.c *.h *.sh passt.1 qrap.1 Makefile | tr '\n' ' '; echo
test Debian GNU/Linux 8 (jessie), amd64 test Debian GNU/Linux 8 (jessie), amd64

View file

@ -60,7 +60,7 @@ hostb ./passt -P __PIDFILE__ &
sleep 1 sleep 1
host echo host echo
hout DNS6 sed -n 's/^nameserver \([^:]*:\)\([^%]*\).*/\1\2/p' /etc/resolv.conf | head -1 hout DNS6 sed -n 's/^nameserver \([^:]*:\)\([^%]*\).*/\1\2/p' /etc/resolv.conf | head -1
hout GUEST_FILES ls -1 *.c *.h *.sh Makefile | tr '\n' ' '; echo hout GUEST_FILES ls -1 *.c *.h *.sh passt.1 qrap.1 Makefile | tr '\n' ' '; echo
test Fedora 26, x86_64 test Fedora 26, x86_64

View file

@ -39,7 +39,7 @@ hostb ./passt -P __PIDFILE__ &
sleep 1 sleep 1
host echo host echo
hout DNS6 sed -n 's/^nameserver \([^:]*:\)\([^%]*\).*/\1\2/p' /etc/resolv.conf | head -1 hout DNS6 sed -n 's/^nameserver \([^:]*:\)\([^%]*\).*/\1\2/p' /etc/resolv.conf | head -1
hout GUEST_FILES ls -1 *.c *.h *.sh Makefile | tr '\n' ' '; echo hout GUEST_FILES ls -1 *.c *.h *.sh passt.1 qrap.1 Makefile | tr '\n' ' '; echo
test OpenSUSE Leap 15.1 test OpenSUSE Leap 15.1

View file

@ -38,7 +38,7 @@ endef
hostb ./passt -P __PIDFILE__ & hostb ./passt -P __PIDFILE__ &
sleep 1 sleep 1
host echo host echo
hout GUEST_FILES ls -1 *.c *.h *.sh Makefile | tr '\n' ' '; echo hout GUEST_FILES ls -1 *.c *.h *.sh passt.1 qrap.1 Makefile | tr '\n' ' '; echo
test Ubuntu 14.04.5 LTS (Trusty Tahr), amd64 test Ubuntu 14.04.5 LTS (Trusty Tahr), amd64