naccyde / rpms / iproute

Forked from rpms/iproute 5 months ago
Clone

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

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