From 68e6f83f223ebf3fbf0d94c0f4592e5e6773f0c1 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Fri, 14 Oct 2022 21:14:14 +0200 Subject: [PATCH] Makefile: Fix cross-compilation for 32-bit targets Determining the correct library installation path (lib vs. lib64) using uname(1) breaks in cross compilation scenarios where word widths differ between the host and target system. Instead, source the information from the compilers '-dumpmachine' option (supported by both GCC and Clang). We call this the "host" architecture, using the same nomenclature as Autotools (--host configure option). Upstream: https://github.com/libbpf/libbpf/commit/68e6f83f223ebf3fbf0d94c0f4592e5e6773f0c1 Signed-off-by: Tobias Waldekranz --- src/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 3cd0854..d535f81 100644 --- a/src/Makefile +++ b/src/Makefile @@ -77,7 +77,8 @@ INSTALL = install DESTDIR ?= -ifeq ($(filter-out %64 %64be %64eb %64le %64el s390x, $(shell uname -m)),) +HOSTARCH = $(firstword $(subst -, ,$(shell $(CC) -dumpmachine))) +ifeq ($(filter-out %64 %64be %64eb %64le %64el s390x, $(HOSTARCH)),) LIBSUBDIR := lib64 else LIBSUBDIR := lib -- 2.34.1