nftables: bump to 2014-09-30, disable gmp
[openwrt/staging/chunkeey.git] / package / network / utils / nftables / patches / 101-build-allow-disabling-libreadline-support.patch
1 From ace4c5eb69ee7dace955acdb23e30e8229b18619 Mon Sep 17 00:00:00 2001
2 From: Steven Barth <cyrus@openwrt.org>
3 Date: Wed, 1 Oct 2014 22:40:31 +0200
4 Subject: [PATCH 1/2] build: allow disabling libreadline-support
5
6 This makes nftables a bit more embedded-friendly.
7
8 Signed-off-by: Steven Barth <cyrus@openwrt.org>
9 ---
10 configure.ac | 11 +++++++++--
11 src/Makefile.in | 2 ++
12 src/main.c | 6 ++++++
13 3 files changed, 17 insertions(+), 2 deletions(-)
14
15 --- a/configure.ac
16 +++ b/configure.ac
17 @@ -71,8 +71,15 @@ AC_CHECK_LIB([nftnl], [nft_rule_alloc],
18 AC_CHECK_LIB([gmp], [__gmpz_init], ,
19 AC_MSG_ERROR([No suitable version of libgmp found]))
20
21 -AC_CHECK_LIB([readline], [readline], ,
22 - AC_MSG_ERROR([No suitable version of libreadline found]))
23 +
24 +AC_ARG_WITH([libreadline], [AS_HELP_STRING([--without-libreadline],
25 + [Disable libreadline support (no interactive CLI)])], [],
26 + [with_libreadline=yes])
27 +AS_IF([test "x$with_libreadline" != xno], [
28 +AC_CHECK_LIB([readline],[readline], , AC_MSG_ERROR([No suitable version of libreadline found]))
29 +])
30 +AC_SUBST(with_libreadline)
31 +
32
33 # Checks for header files.
34 AC_HEADER_STDC
35 --- a/src/Makefile.in
36 +++ b/src/Makefile.in
37 @@ -3,7 +3,9 @@ PROGRAMS += nft
38 nft-destdir := @sbindir@
39
40 nft-obj += main.o
41 +ifeq (@with_libreadline@,yes)
42 nft-obj += cli.o
43 +endif
44 nft-obj += rule.o
45 nft-obj += statement.o
46 nft-obj += datatype.o
47 --- a/src/main.c
48 +++ b/src/main.c
49 @@ -335,8 +335,14 @@ int main(int argc, char * const *argv)
50 if (scanner_read_file(scanner, filename, &internal_location) < 0)
51 goto out;
52 } else if (interactive) {
53 +#ifdef HAVE_LIBREADLINE
54 cli_init(&state);
55 return 0;
56 +#else
57 + fprintf(stderr, "%s: interactive CLI not supported in this build\n",
58 + argv[0]);
59 + exit(NFT_EXIT_FAILURE);
60 +#endif
61 } else {
62 fprintf(stderr, "%s: no command specified\n", argv[0]);
63 exit(NFT_EXIT_FAILURE);