naccyde / rpms / iproute

Forked from rpms/iproute 7 months ago
Clone

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

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