diff mbox series

[Draft,iproute2-next] configure: add options ability

Message ID 20210528123543.3836-1-liuhangbin@gmail.com
State New
Headers show
Series [Draft,iproute2-next] configure: add options ability | expand

Commit Message

Hangbin Liu May 28, 2021, 12:35 p.m. UTC
From: Hangbin Liu <haliu@redhat.com>

Hi David,

As we talked in my previous libbpf support patchset. You'd like to make
configure with option settings. Here is a draft patch. Not sure if this
is what you want.

There are also a lot variables that I not sure if we should add options
for them. e.g. PKG_CONFIG, CC, IPTC, IPT_LIB_DIR, etc. Do you have any
suggestions?

---
As there are more and more global environment variables in configures.
it would be more clear with options for users. Add related options for
variables. Keep using the same name so the old way (set global env) is
still working.

Signed-off-by: Hangbin Liu <haliu@redhat.com>
---
 configure | 45 +++++++++++++++++++++++++++++++++++++++------
 1 file changed, 39 insertions(+), 6 deletions(-)

Comments

David Ahern May 29, 2021, 5:48 p.m. UTC | #1
On 5/28/21 6:35 AM, Hangbin Liu wrote:
> From: Hangbin Liu <haliu@redhat.com>

> 

> Hi David,

> 

> As we talked in my previous libbpf support patchset. You'd like to make

> configure with option settings. Here is a draft patch. Not sure if this

> is what you want.

> 

> There are also a lot variables that I not sure if we should add options

> for them. e.g. PKG_CONFIG, CC, IPTC, IPT_LIB_DIR, etc. Do you have any

> suggestions?


I think it is better to have command line options vs environment
variables. Command line options can be used with a usage / help function
to make it easier for users to learn or remember the config options.

That said, the environment variable approach should continue to work for
existing build scripts.

Your RFC looks fine to me. It would be easier to review if options are
converted with separate patches vs one big one.



> +while true; do

> +	case "$1" in

> +		--libbpf_force)

> +			if [ "$2" != 'on' ] && [ "$2" != 'off' ]; then

> +				usage 1

> +			fi

> +			LIBBPF_FORCE=$2

> +			shift 2 ;;

> +                --libbpf_dir)

> +			LIBBPF_DIR="$2"

> +                        shift 2 ;;

> +                --include_dir)

> +			# How to deal with the old INCLUDE usage?


if number of input arguments is just 1 and it does not start with '-',
then guess that it is old style INCLUDE.

Thanks for working on this.
diff mbox series

Patch

diff --git a/configure b/configure
index 179eae08..aae324c9 100755
--- a/configure
+++ b/configure
@@ -1,13 +1,8 @@ 
 #!/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=${1:-"$PWD/include"}
+INCLUDE="$PWD/include"
 
 # Output file which is input to Makefile
 CONFIG=config.mk
@@ -486,6 +481,44 @@  endif
 EOF
 }
 
+usage()
+{
+        cat <<EOF
+Usage: $0 [OPTIONS]
+  --libbpf_force                enable/disable libbpf by force.
+                                on: require link against libbpf, quite config if no libbpf support
+                                off: disable libbpf probing
+  --libbpf_dir                  Path to libbpf DESTDIR to use
+  --include_dir                 Path to iproute2 include dir
+  -h | --help                   Show this usage info
+EOF
+        exit $1
+}
+
+while true; do
+	case "$1" in
+		--libbpf_force)
+			if [ "$2" != 'on' ] && [ "$2" != 'off' ]; then
+				usage 1
+			fi
+			LIBBPF_FORCE=$2
+			shift 2 ;;
+                --libbpf_dir)
+			LIBBPF_DIR="$2"
+                        shift 2 ;;
+                --include_dir)
+			# How to deal with the old INCLUDE usage?
+			INCLUDE=$2
+                        shift 2 ;;
+                -h | --help)
+                        usage 0 ;;
+                "")
+                        break ;;
+                *)
+                        usage 1 ;;
+        esac
+done
+
 echo "# Generated config based on" $INCLUDE >$CONFIG
 quiet_config >> $CONFIG