]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
libnftables: Split code into frontend and library
authorPhil Sutter <phil@nwl.cc>
Tue, 14 Nov 2017 20:17:10 +0000 (21:17 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 16 Nov 2017 13:35:35 +0000 (14:35 +0100)
This finally creates the libnftables shared object.

For some reason, this causes two compiler warnings to appear:

| parser_bison.y: In function 'nft_parse':
| parser_bison.y:131:3: warning: implicit declaration of function 'nft_set_debug' [-Wimplicit-function-declaration]
|    nft_set_debug(1, scanner);
|    ^~~~~~~~~~~~~
| parser_bison.c:64:25: warning: implicit declaration of function 'nft_lex' [-Wimplicit-function-declaration]
|  #define yylex           nft_lex
|                          ^
| parser_bison.c:4745:16: note: in expansion of macro 'yylex'
|        yychar = yylex (&yylval, &yylloc, scanner);

So this patch contains a workaround, namely declaring both functions
in src/parser_bison.y. During linking the objects are found, so this is
rather a matter of cosmetics.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
.gitignore
Makefile.am
configure.ac
libnftables.pc.in [new file with mode: 0644]
src/.gitignore
src/Makefile.am
src/parser_bison.y

index 009f7d005afa19cff080b386807f0eb6383f5d3a..64af328e0abf9be51af39e11a45e2590dfdfa3b4 100644 (file)
@@ -1,5 +1,6 @@
 # Dependency and object files
 .*.d
+*.lo
 *.o
 
 # Generated by autoconf/configure/automake
@@ -8,6 +9,7 @@ Makefile
 Makefile.in
 src/Makefile.in
 src/.deps/
+src/.libs/
 stamp-h1
 config.h
 config.h.in
@@ -17,6 +19,7 @@ config.status
 configure
 autom4te.cache
 build-aux/
+libnftables.pc
 libtool
 missing
 depcomp
index 10aa40f14127fc03f050ad333f27d065b4a53279..9af25ded836b856e51fbd1cd3bf6ff53d14ec87d 100644 (file)
@@ -6,3 +6,6 @@ SUBDIRS =       src     \
                files
 
 EXTRA_DIST =   tests
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libnftables.pc
index 099a4a5e81ec69e917c2fd9c2a411785490da675..a97d9e73270dc64f4b2e138b0747c91a0d10df59 100644 (file)
@@ -56,6 +56,9 @@ then
         exit 1
 fi
 
+AM_PROG_AR
+AM_PROG_LIBTOOL
+
 AC_CHECK_PROG(DOCBOOK2X_MAN, [docbook2x-man], [docbook2x-man], [no])
 AC_CHECK_PROG(DOCBOOK2MAN, [docbook2man], [docbook2man], [no])
 AC_CHECK_PROG(DB2X_DOCBOOK2MAN, [db2x_docbook2man], [db2x_docbook2man], [no])
@@ -138,6 +141,7 @@ AC_CHECK_FUNCS([memmove memset strchr strdup strerror strtoull])
 
 AC_CONFIG_FILES([                                      \
                Makefile                                \
+               libnftables.pc                          \
                src/Makefile                            \
                include/Makefile                        \
                include/nftables/Makefile               \
diff --git a/libnftables.pc.in b/libnftables.pc.in
new file mode 100644 (file)
index 0000000..6431d48
--- /dev/null
@@ -0,0 +1,15 @@
+# libnftables pkg-config file
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libnftables
+Description: Netfilter nf_tables user library
+URL: http://netfilter.org/projects/nftables/
+Version: @VERSION@
+Requires:
+Conflicts:
+Libs: -L${libdir} -lnftables
+Cflags: -I${includedir}
index 23e6ae030f107c2aac135a698f99000960c853f0..36d6acd1e4d0138cd16a0c03f3c4e451c8edd9c8 100644 (file)
@@ -1,3 +1,4 @@
+libnftables.la
 parser.c
 parser.h
 scanner.c
index 4d613a731dfb93ed99de457efa87f63b3afaf4ff..9f7a4bfbb90a4f75bac18e0556f06674729b36bb 100644 (file)
@@ -27,7 +27,9 @@ parser_bison.o scanner.o: AM_CFLAGS += -Wno-missing-prototypes -Wno-missing-decl
 
 BUILT_SOURCES = parser_bison.h
 
-nft_SOURCES =  main.c                          \
+lib_LTLIBRARIES = libnftables.la
+
+libnftables_la_SOURCES =                       \
                rule.c                          \
                statement.c                     \
                datatype.c                      \
@@ -59,19 +61,23 @@ nft_SOURCES =       main.c                          \
                parser_bison.y                  \
                libnftables.c
 
-if BUILD_CLI
-nft_SOURCES += cli.c
-endif
-
 if BUILD_MINIGMP
 mini-gmp.o: AM_CFLAGS += -Wno-sign-compare
 
-nft_SOURCES += mini-gmp.c
+libnftables_la_SOURCES += mini-gmp.c
 endif
 
-nft_LDADD      = ${LIBMNL_LIBS} ${LIBNFTNL_LIBS}
+libnftables_la_LIBADD = ${LIBMNL_LIBS} ${LIBNFTNL_LIBS}
 
 if BUILD_XTABLES
-nft_SOURCES += xt.c
-nft_LDADD   +=  ${XTABLES_LIBS}
+libnftables_la_SOURCES += xt.c
+libnftables_la_LIBADD += ${XTABLES_LIBS}
 endif
+
+nft_SOURCES = main.c
+
+if BUILD_CLI
+nft_SOURCES += cli.c
+endif
+
+nft_LDADD = libnftables.la
index 2c59fa784585a843b2807a7e7952ae8feba10f8e..c64c3979eb04155941a37311dbe00932615c3c97 100644 (file)
@@ -105,6 +105,10 @@ static void location_update(struct location *loc, struct location *rhs, int n)
 
 #define symbol_value(loc, str) \
        symbol_expr_alloc(loc, SYMBOL_VALUE, current_scope(state), str)
+
+/* Declare those here to avoid compiler warnings */
+void nft_set_debug(int, void *);
+int nft_lex(void *, void *, void *);
 %}
 
 /* Declaration section */