Blame SOURCES/0007-configure-add-the-libdir-option.patch

7570e2
From 935d2e39c8341178adbfcf7ae037b9f64dbc2d6e Mon Sep 17 00:00:00 2001
7570e2
Message-Id: <935d2e39c8341178adbfcf7ae037b9f64dbc2d6e.1637749821.git.aclaudi@redhat.com>
7570e2
In-Reply-To: <cef782ca658d695c5ca2d174ba1f89cba6bd84e5.1637749821.git.aclaudi@redhat.com>
7570e2
References: <cef782ca658d695c5ca2d174ba1f89cba6bd84e5.1637749821.git.aclaudi@redhat.com>
7570e2
From: Andrea Claudi <aclaudi@redhat.com>
7570e2
Date: Wed, 24 Nov 2021 11:28:09 +0100
7570e2
Subject: [PATCH] configure: add the --libdir option
7570e2
7570e2
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2009355
7570e2
Upstream Status: iproute2.git commit cee0cf84
7570e2
7570e2
commit cee0cf84bd32c8d9215f0c155187ad99d52a69b1
7570e2
Author: Andrea Claudi <aclaudi@redhat.com>
7570e2
Date:   Thu Oct 14 10:50:55 2021 +0200
7570e2
7570e2
    configure: add the --libdir option
7570e2
7570e2
    This commit allows users/packagers to choose a lib directory to store
7570e2
    iproute2 lib files.
7570e2
7570e2
    At the moment iproute2 ship lib files in /usr/lib and offers no way to
7570e2
    modify this setting. However, according to the FHS, distros may choose
7570e2
    "one or more variants of the /lib directory on systems which support
7570e2
    more than one binary format" (e.g. /usr/lib64 on Fedora).
7570e2
7570e2
    As Luca states in commit a3272b93725a ("configure: restore backward
7570e2
    compatibility"), packaging systems may assume that 'configure' is from
7570e2
    autotools, and try to pass it some parameters.
7570e2
7570e2
    Allowing the '--libdir=/path/to/libdir' syntax, we can use this to our
7570e2
    advantage, and let the lib directory to be chosen by the distro
7570e2
    packaging system.
7570e2
7570e2
    Note that LIBDIR uses "\${prefix}/lib" as default value because autoconf
7570e2
    allows this to be expanded to the --prefix value at configure runtime.
7570e2
    "\${prefix}" is replaced with the PREFIX value in check_lib_dir().
7570e2
7570e2
    Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
7570e2
    Acked-by: Phil Sutter <phil@nwl.cc>
7570e2
    Signed-off-by: David Ahern <dsahern@kernel.org>
7570e2
---
7570e2
 Makefile  |  7 ++++---
7570e2
 configure | 18 ++++++++++++++++++
7570e2
 2 files changed, 22 insertions(+), 3 deletions(-)
7570e2
7570e2
diff --git a/Makefile b/Makefile
7570e2
index 5bc11477..45655ca4 100644
7570e2
--- a/Makefile
7570e2
+++ b/Makefile
7570e2
@@ -1,6 +1,8 @@
7570e2
 # SPDX-License-Identifier: GPL-2.0
7570e2
 # Top level Makefile for iproute2
7570e2
 
7570e2
+-include config.mk
7570e2
+
7570e2
 ifeq ("$(origin V)", "command line")
7570e2
 VERBOSE = $(V)
7570e2
 endif
7570e2
@@ -13,7 +15,6 @@ MAKEFLAGS += --no-print-directory
7570e2
 endif
7570e2
 
7570e2
 PREFIX?=/usr
7570e2
-LIBDIR?=$(PREFIX)/lib
7570e2
 SBINDIR?=/sbin
7570e2
 CONFDIR?=/etc/iproute2
7570e2
 NETNS_RUN_DIR?=/var/run/netns
7570e2
@@ -60,7 +61,7 @@ SUBDIRS=lib ip tc bridge misc netem genl tipc devlink rdma dcb man vdpa
7570e2
 LIBNETLINK=../lib/libutil.a ../lib/libnetlink.a
7570e2
 LDLIBS += $(LIBNETLINK)
7570e2
 
7570e2
-all: config
7570e2
+all: config.mk
7570e2
 	@set -e; \
7570e2
 	for i in $(SUBDIRS); \
7570e2
 	do echo; echo $$i; $(MAKE) -C $$i; done
7570e2
@@ -80,7 +81,7 @@ help:
7570e2
 	@echo "Make Arguments:"
7570e2
 	@echo " V=[0|1]             - set build verbosity level"
7570e2
 
7570e2
-config:
7570e2
+config.mk:
7570e2
 	@if [ ! -f config.mk -o configure -nt config.mk ]; then \
7570e2
 		sh configure $(KERNEL_INCLUDE); \
7570e2
 	fi
7570e2
diff --git a/configure b/configure
7570e2
index 05e23eff..8ddff43c 100755
7570e2
--- a/configure
7570e2
+++ b/configure
7570e2
@@ -4,6 +4,7 @@
7570e2
 
7570e2
 INCLUDE="$PWD/include"
7570e2
 PREFIX="/usr"
7570e2
+LIBDIR="\${prefix}/lib"
7570e2
 
7570e2
 # Output file which is input to Makefile
7570e2
 CONFIG=config.mk
7570e2
@@ -149,6 +150,15 @@ EOF
7570e2
 	rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
7570e2
 }
7570e2
 
7570e2
+check_lib_dir()
7570e2
+{
7570e2
+	LIBDIR=$(echo $LIBDIR | sed "s|\${prefix}|$PREFIX|")
7570e2
+
7570e2
+	echo -n "lib directory: "
7570e2
+	echo "$LIBDIR"
7570e2
+	echo "LIBDIR:=$LIBDIR" >> $CONFIG
7570e2
+}
7570e2
+
7570e2
 check_ipt()
7570e2
 {
7570e2
 	if ! grep TC_CONFIG_XT $CONFIG > /dev/null; then
7570e2
@@ -487,6 +497,7 @@ usage()
7570e2
 	cat <
7570e2
 Usage: $0 [OPTIONS]
7570e2
 	--include_dir <dir>		Path to iproute2 include dir
7570e2
+	--libdir <dir>			Path to iproute2 lib dir
7570e2
 	--libbpf_dir <dir>		Path to libbpf DESTDIR
7570e2
 	--libbpf_force <on|off>		Enable/disable libbpf by force. Available options:
7570e2
 					  on: require link against libbpf, quit config if no libbpf support
7570e2
@@ -508,6 +519,11 @@ else
7570e2
 				INCLUDE="$1" ;;
7570e2
 			--include_dir=*)
7570e2
 				INCLUDE="${1#*=}" ;;
7570e2
+			--libdir)
7570e2
+				shift
7570e2
+				LIBDIR="$1" ;;
7570e2
+			--libdir=*)
7570e2
+				LIBDIR="${1#*=}" ;;
7570e2
 			--libbpf_dir)
7570e2
 				shift
7570e2
 				LIBBPF_DIR="$1" ;;
7570e2
@@ -544,6 +560,7 @@ if [ "${LIBBPF_FORCE-unused}" != "unused" ]; then
7570e2
 	fi
7570e2
 fi
7570e2
 [ -z "$PREFIX" ] && usage 1
7570e2
+[ -z "$LIBDIR" ] && usage 1
7570e2
 
7570e2
 echo "# Generated config based on" $INCLUDE >$CONFIG
7570e2
 quiet_config >> $CONFIG
7570e2
@@ -568,6 +585,7 @@ if ! grep -q TC_CONFIG_NO_XT $CONFIG; then
7570e2
 fi
7570e2
 
7570e2
 echo
7570e2
+check_lib_dir
7570e2
 if ! grep -q TC_CONFIG_NO_XT $CONFIG; then
7570e2
 	echo -n "iptables modules directory: "
7570e2
 	check_ipt_lib_dir
7570e2
-- 
7570e2
2.31.1
7570e2