From 81d6ad1d57236d458d6ce41ed4f970ea42ac89fb Mon Sep 17 00:00:00 2001 From: Alberto Leiva Popper Date: Mon, 17 Jan 2022 10:27:54 -0600 Subject: [PATCH] Autotools: Add --with-xtables Turns out including a dependency depending on installedness is not standard practice. Manually includes and excludes xtables from the userspace binaries: ./configure # xtables included ./configure --with-xtables # xtables included ./configure --with-xtables=yes # xtables included ./configure --with-xtables=no # xtables excluded Took a while, but I think I finally landed optional iptables properly. Progress on #273. --- configure.ac | 24 ++++++++++++++++-------- src/usr/argp/wargp/instance.c | 6 ++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 13273270..986994aa 100644 --- a/configure.ac +++ b/configure.ac @@ -33,22 +33,30 @@ AC_SEARCH_LIBS([pow], [m]) AC_SEARCH_LIBS([pthread_create], [pthread]) AC_CHECK_LIB([argp], [argp_parse]) -# Checks for dependencies. +# Dependency: libnlgenl (mandatory) PKG_CHECK_MODULES(LIBNLGENL3, libnl-genl-3.0 >= 3.2.22) -# xtables will only be included if available. -PKG_CHECK_MODULES(XTABLES, xtables, - WITH_XTABLES="yes", - WITH_XTABLES="no") -AM_CONDITIONAL([XTABLES_ENABLED], [test "x$WITH_XTABLES" = "xyes"]) +# Dependency: xtables (optional) +AC_ARG_WITH( + [xtables], + AS_HELP_STRING( + [--with-xtables@<:@=yes|no@:>@], + [Include xtables dependency? @<:@default=yes@:>@] + ) +) +AS_IF([test "x$with_xtables" != "xno"], [ + PKG_CHECK_MODULES(XTABLES, xtables) +]) +AM_CONDITIONAL([XTABLES_ENABLED], [test "x$with_xtables" != "xno"]) # Bash autocompletion option (https://www.swansontec.com/bash-completion.html): # 1. Offer the user the `--with-bash-completion-dir` configure option, # which can be set to a directory, "yes" (default; means autodetect # directory) or "no" (disable autocompletion). AC_ARG_WITH([bash-completion-dir], - AS_HELP_STRING([--with-bash-completion-dir[=PATH]], - [Install the bash auto-completion script. @<:@default=yes@:>@]), + AS_HELP_STRING([--with-bash-completion-dir@<:@=yes|no|PATH@:>@], + [Directory where the bash auto-completion script will be installed. + ("yes" attempts to guess.) @<:@default=yes@:>@]), [], [with_bash_completion_dir=yes]) diff --git a/src/usr/argp/wargp/instance.c b/src/usr/argp/wargp/instance.c index 944a3b13..fe93c3bd 100644 --- a/src/usr/argp/wargp/instance.c +++ b/src/usr/argp/wargp/instance.c @@ -165,6 +165,12 @@ struct add_args { struct wargp_prefix6 pool6; }; +#ifdef XTABLES_DISABLED +#pragma message("Xtables disabled") +#else +#pragma message("Xtables enabled") +#endif + static struct wargp_option add_opts[] = { WARGP_INAME(struct add_args, iname, "add"), {