]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
build: allow disabling libreadline-support
authorSteven Barth <cyrus@openwrt.org>
Thu, 9 Oct 2014 20:48:27 +0000 (22:48 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 10 Oct 2014 10:20:02 +0000 (12:20 +0200)
This makes nftables a bit more embedded-friendly.

Signed-off-by: Steven Barth <cyrus@openwrt.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
configure.ac
include/nftables.h
src/Makefile.in
src/main.c

index 3a7647f2b709a6b899203c0a248f73980e257d52..ea13cf8c88d32305d77f696635825ea835d7822a 100644 (file)
@@ -71,8 +71,14 @@ AC_CHECK_LIB([nftnl], [nft_rule_alloc], ,
 AC_CHECK_LIB([gmp], [__gmpz_init], ,
             AC_MSG_ERROR([No suitable version of libgmp found]))
 
+AC_ARG_WITH([cli], [AS_HELP_STRING([--without-cli],
+            [disable interactive CLI (libreadline support)])],
+            [], [with_cli=yes])
+AS_IF([test "x$with_cli" != xno], [
 AC_CHECK_LIB([readline], [readline], ,
             AC_MSG_ERROR([No suitable version of libreadline found]))
+])
+AC_SUBST(with_cli)
 
 # Checks for header files.
 AC_HEADER_STDC
index 3394e3247dd7f88f0c738d1584f6862ec1dab812..c3d3dbfb0f673ecc582b8baa0b21c06d85a7bc3d 100644 (file)
@@ -31,7 +31,14 @@ extern unsigned int debug_level;
 extern const char *include_paths[INCLUDE_PATHS_MAX];
 
 struct parser_state;
+#ifdef HAVE_LIBREADLINE
 extern int cli_init(struct parser_state *state);
+#else
+static inline int cli_init(struct parser_state *state)
+{
+       return -1;
+}
+#endif
 extern void cli_exit(void);
 extern void cli_display(const char *fmt, va_list ap) __fmtstring(1, 0);
 
index 8ac2b460f136c8609355a8789e7cfb213e87d7fc..7ecc5f2e01ad88bdaf9570cb0c4f31ecd0081e57 100644 (file)
@@ -3,7 +3,9 @@ PROGRAMS                += nft
 nft-destdir            := @sbindir@
 
 nft-obj                        += main.o
+ifeq (@with_cli@,yes)
 nft-obj                        += cli.o
+endif
 nft-obj                        += rule.o
 nft-obj                        += statement.o
 nft-obj                        += datatype.o
index 2685b0db8a95326f774562cf8ad0a9254c37f639..3607bd5844af8aa61d11d6f7b703e40143da9535 100644 (file)
@@ -335,7 +335,11 @@ int main(int argc, char * const *argv)
                if (scanner_read_file(scanner, filename, &internal_location) < 0)
                        goto out;
        } else if (interactive) {
-               cli_init(&state);
+               if (cli_init(&state) < 0) {
+                       fprintf(stderr, "%s: interactive CLI not supported in this build\n",
+                               argv[0]);
+                       exit(NFT_EXIT_FAILURE);
+               }
                return 0;
        } else {
                fprintf(stderr, "%s: no command specified\n", argv[0]);