]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
configure: add the --color option
authorAndrea Claudi <aclaudi@redhat.com>
Wed, 13 Sep 2023 17:58:25 +0000 (19:58 +0200)
committerDavid Ahern <dsahern@kernel.org>
Thu, 14 Sep 2023 15:20:24 +0000 (09:20 -0600)
This commit allows users/packagers to choose a default for the color
output feature provided by some iproute2 tools.

The configure script option is documented in the script itself and it is
pretty much self-explanatory. The default value is set to "never" to
avoid changes to the current ip, tc, and bridge behaviour.

Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
Makefile
configure

index 7d1819ced6f8cfdc2cba5eb35d12cdf5f5f5ca9e..a24844cf0fce60d7a91c804601871427027dee39 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -41,7 +41,8 @@ endif
 DEFINES+=-DCONF_USR_DIR=\"$(CONF_USR_DIR)\" \
          -DCONF_ETC_DIR=\"$(CONF_ETC_DIR)\" \
          -DNETNS_RUN_DIR=\"$(NETNS_RUN_DIR)\" \
-         -DNETNS_ETC_DIR=\"$(NETNS_ETC_DIR)\"
+         -DNETNS_ETC_DIR=\"$(NETNS_ETC_DIR)\" \
+         -DCONF_COLOR=$(CONF_COLOR)
 
 #options for AX.25
 ADDLIB+=ax25_ntop.o
index 18be5a03f55361e429089a8442ad85193722ea7b..eb689341d17d0d053553f74aa1165c5f2bf499c2 100755 (executable)
--- a/configure
+++ b/configure
@@ -5,6 +5,7 @@
 INCLUDE="$PWD/include"
 PREFIX="/usr"
 LIBDIR="\${prefix}/lib"
+COLOR="never"
 
 # Output file which is input to Makefile
 CONFIG=config.mk
@@ -479,6 +480,24 @@ check_cap()
        fi
 }
 
+check_color()
+{
+       case "$COLOR" in
+               never)
+                       echo 'CONF_COLOR:=COLOR_OPT_NEVER' >> $CONFIG
+                       echo 'never'
+                       ;;
+               auto)
+                       echo 'CONF_COLOR:=COLOR_OPT_AUTO' >> $CONFIG
+                       echo 'auto'
+                       ;;
+               always)
+                       echo 'CONF_COLOR:=COLOR_OPT_ALWAYS' >> $CONFIG
+                       echo 'always'
+                       ;;
+       esac
+}
+
 quiet_config()
 {
        cat <<EOF
@@ -509,6 +528,10 @@ usage()
 {
        cat <<EOF
 Usage: $0 [OPTIONS]
+       --color <never|auto|always>     Default color output configuration. Available options:
+                                         never: color output is disabled (default)
+                                         auto: color output is enabled if stdout is a terminal
+                                         always: color output is enabled regardless of stdout state
        --include_dir <dir>             Path to iproute2 include dir
        --libdir <dir>                  Path to iproute2 lib dir
        --libbpf_dir <dir>              Path to libbpf DESTDIR
@@ -527,6 +550,11 @@ if [ $# -eq 1 ] && [ "$(echo $1 | cut -c 1)" != '-' ]; then
 else
        while [ "$#" -gt 0 ]; do
                case "$1" in
+                       --color)
+                               shift
+                               COLOR="$1" ;;
+                       --color=*)
+                               COLOR="${1#*=}" ;;
                        --include_dir)
                                shift
                                INCLUDE="$1" ;;
@@ -563,6 +591,12 @@ else
        done
 fi
 
+case "$COLOR" in
+       never) ;;
+       auto) ;;
+       always) ;;
+       *) usage 1 ;;
+esac
 [ -d "$INCLUDE" ] || usage 1
 if [ "${LIBBPF_DIR-unused}" != "unused" ]; then
        [ -d "$LIBBPF_DIR" ] || usage 1
@@ -634,6 +668,9 @@ check_strlcpy
 echo -n "libcap support: "
 check_cap
 
+echo -n "color output: "
+check_color
+
 echo >> $CONFIG
 echo "%.o: %.c" >> $CONFIG
 echo ' $(QUIET_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CPPFLAGS) -c -o $@ $<' >> $CONFIG