From d4632a43573ff451f90fb702c824030b4bdfa734 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Tue, 12 May 2026 15:52:47 +1000 Subject: Makefile: Use common binary compilation rule Each of our binaries (passt, passt.avx2, qrap and passt-repair) has a separate Make rule instructing how to compile it, but they're all basically identical. Combine these all into a single pattern rule, just using different dependencies and variable overrides where necessary. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- Makefile | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index d489a86..88c8a15 100644 --- a/Makefile +++ b/Makefile @@ -76,9 +76,14 @@ docdir ?= $(datarootdir)/doc/passt mandir ?= $(datarootdir)/man man1dir ?= $(mandir)/man1 -BIN := passt pasta qrap passt-repair pesto +BASEBIN := passt qrap passt-repair pesto ifeq ($(TARGET_ARCH),x86_64) -BIN += passt.avx2 pasta.avx2 +BASEBIN += passt.avx2 +endif + +BIN = $(BASEBIN) pasta +ifeq ($(TARGET_ARCH),x86_64) +BIN += pasta.avx2 endif all: $(BIN) $(MANPAGES) docs @@ -95,27 +100,24 @@ seccomp_repair.h: seccomp.sh $(PASST_REPAIR_SRCS) seccomp_pesto.h: seccomp.sh $(PESTO_SRCS) @ ARCH="$(TARGET_ARCH)" CC="$(CC)" ./seccomp.sh seccomp_pesto.h $(PESTO_SRCS) +$(BASEBIN): %: + $(CC) $(FLAGS) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(filter %.c,$^) -o $@ + passt: $(PASST_SRCS) $(HEADERS) - $(CC) $(FLAGS) $(CFLAGS) $(CPPFLAGS) $(PASST_SRCS) -o passt $(LDFLAGS) passt.avx2: FLAGS += -Ofast -mavx2 -ftree-vectorize -funroll-loops passt.avx2: $(PASST_SRCS) $(HEADERS) - $(CC) $(filter-out -O2,$(FLAGS)) $(CFLAGS) $(CPPFLAGS) \ - $(PASST_SRCS) -o passt.avx2 $(LDFLAGS) - -passt.avx2: passt pasta.avx2 pasta.1 pasta: pasta%: passt% ln -sf $< $@ +qrap: FLAGS += -DARCH=\"$(TARGET_ARCH)\" qrap: $(QRAP_SRCS) passt.h - $(CC) $(FLAGS) $(CFLAGS) $(CPPFLAGS) -DARCH=\"$(TARGET_ARCH)\" $(QRAP_SRCS) -o qrap $(LDFLAGS) passt-repair: $(PASST_REPAIR_SRCS) seccomp_repair.h - $(CC) $(FLAGS) $(CFLAGS) $(CPPFLAGS) $(PASST_REPAIR_SRCS) -o passt-repair $(LDFLAGS) +pesto: FLAGS += -DPESTO pesto: $(PESTO_SRCS) $(PESTO_HEADERS) seccomp_pesto.h - $(CC) $(FLAGS) $(CFLAGS) $(CPPFLAGS) -DPESTO $(PESTO_SRCS) -o pesto $(LDFLAGS) valgrind: EXTRA_SYSCALLS += rt_sigprocmask rt_sigtimedwait rt_sigaction \ rt_sigreturn getpid gettid kill clock_gettime \ -- cgit v1.2.3