Skip to content

Commit

Permalink
Autotools: Add --with-xtables
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ydahhrk committed Jan 17, 2022
1 parent a036f08 commit 81d6ad1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
24 changes: 16 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down
6 changes: 6 additions & 0 deletions src/usr/argp/wargp/instance.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
{
Expand Down

0 comments on commit 81d6ad1

Please sign in to comment.