Skip to contentSkip to conversation

configure: convert global env to command-line options

PATCH Applied Hangbin Liu 2 participants 4 messages May 31, 2021 – Jun 3, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover configure: convert global env to command-line options

This path set converts the global environment to command-line options to make it easier for users to learn or remember the config options.

I only convert environment INCLUDE, LIBBPF_DIR, LIBBPF_FORCE at first. The IPTC and IPTL are not converted as I don't know what they stand for.

Hangbin Liu (2):
configure: add options ability
configure: convert LIBBPF environment variables to command-line
options

 configure | 49 +++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 43 insertions(+), 6 deletions(-)
Signature · 1 line
2.26.3
#1 lore raw

PATCH 1/2 configure: add options ability

There are more and more global environment variables that land everywhere in configure, which is making user hard to know which one does what. Using command-line options would make it easier for users to learn or remember the config options.

This patch converts the INCLUDE variable to command option first. Check if the first variable has '-' to compile with the old INCLUDE path setting method.

---
 configure | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)
configure +30 -1
index 179eae08..c58419c2 100755
@@ -7,7 +7,7 @@
 #                           off: disable libbpf probing
 #   LIBBPF_DIR              Path to libbpf DESTDIR to use
 
-INCLUDE=${1:-"$PWD/include"}
+INCLUDE="$PWD/include"
 
 # Output file which is input to Makefile
 CONFIG=config.mk
@@ -486,6 +486,35 @@ endif
 EOF
 }
 
+usage()
+{
+	cat <<EOF
+Usage: $0 [OPTIONS]
+	--include_dir		Path to iproute2 include dir
+	-h | --help		Show this usage info
+EOF
+	exit $1
+}
+
+# Compat with the old INCLUDE path setting method.
+if [ $# -eq 1 ] && [ "$(echo $1 | cut -c 1)" != '-' ]; then
+	INCLUDE="$1"
+else
+	while true; do
+		case "$1" in
+			--include_dir)
+				INCLUDE=$2
+				shift 2 ;;
+			-h | --help)
+				usage 0 ;;
+			"")
+				break ;;
+			*)
+				usage 1 ;;
+		esac
+	done
+fi
+
 echo "# Generated config based on" $INCLUDE >$CONFIG
 quiet_config >> $CONFIG
 
Signature · 1 line
2.26.3
#2 lore raw

PATCH 2/2 configure: convert LIBBPF environment variables to command-line options

In reply to Hangbin Liu
---
 configure | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
configure +13 -5
index c58419c2..0a4a0fc9 100755
@@ -1,11 +1,6 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0
 # This is not an autoconf generated configure
-#
-# Influential LIBBPF environment variables:
-#   LIBBPF_FORCE={on,off}   on: require link against libbpf;
-#                           off: disable libbpf probing
-#   LIBBPF_DIR              Path to libbpf DESTDIR to use
 
 INCLUDE="$PWD/include"
 
@@ -491,6 +486,10 @@ usage()
 	cat <<EOF
 Usage: $0 [OPTIONS]
 	--include_dir		Path to iproute2 include dir
+	--libbpf_dir		Path to libbpf DESTDIR
+	--libbpf_force		Enable/disable libbpf by force. Available options:
+				  on: require link against libbpf, quit config if no libbpf support
+				  off: disable libbpf probing
 	-h | --help		Show this usage info
 EOF
 	exit $1
@@ -505,6 +504,15 @@ else
 			--include_dir)
 				INCLUDE=$2
 				shift 2 ;;
+			--libbpf_dir)
+				LIBBPF_DIR="$2"
+				shift 2 ;;
+			--libbpf_force)
+				if [ "$2" != 'on' ] && [ "$2" != 'off' ]; then
+					usage 1
+				fi
+				LIBBPF_FORCE=$2
+				shift 2 ;;
 			-h | --help)
 				usage 0 ;;
 			"")
Signature · 1 line
2.26.3
Applied
#3 lore raw
In reply to Hangbin Liu
Quoted 7 lines · Hangbin Liu

This path set converts the global environment to command-line options to make it easier for users to learn or remember the config options.

I only convert environment INCLUDE, LIBBPF_DIR, LIBBPF_FORCE at first. The IPTC and IPTL are not converted as I don't know what they stand for.

Quoted 8 lines

Hangbin Liu (2):
configure: add options ability
configure: convert LIBBPF environment variables to command-line
options

 configure | 49 +++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 43 insertions(+), 6 deletions(-)

applied to iproute2-next. Thanks,