diff mbox series

[nftlb] build: use autotools

Message ID 20180511102015.32293-1-pablo@netfilter.org
State Changes Requested
Delegated to: Pablo Neira
Headers show
Series [nftlb] build: use autotools | expand

Commit Message

Pablo Neira Ayuso May 11, 2018, 10:20 a.m. UTC
- Add configure.ac and Makefile.am files.
- Update .gitignore file to ignore autogenerated scripts by autotools.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 .gitignore      | 17 +++++++++++++++--
 Make_global.am  |  4 ++++
 Makefile        | 20 --------------------
 Makefile.am     | 11 +++++++++++
 configure.ac    | 32 ++++++++++++++++++++++++++++++++
 m4/.gitignore   |  2 ++
 src/.gitignore  |  3 +++
 src/Makefile.am | 10 ++++++++++
 8 files changed, 77 insertions(+), 22 deletions(-)
 create mode 100644 Make_global.am
 delete mode 100644 Makefile
 create mode 100644 Makefile.am
 create mode 100644 configure.ac
 create mode 100644 m4/.gitignore
 create mode 100644 src/.gitignore
 create mode 100644 src/Makefile.am

Comments

Arturo Borrero Gonzalez May 11, 2018, 10:27 a.m. UTC | #1
On 11 May 2018 at 12:20, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> - Add configure.ac and Makefile.am files.
> - Update .gitignore file to ignore autogenerated scripts by autotools.
>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

It seems we can drop libmnl and libnftnl dependencies.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/.gitignore b/.gitignore
index fe8ba262b141..bf8ac244c5be 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,15 @@ 
-*.o
-nftlb
+# Generated by autoconf/configure/automake
+*.m4
+Makefile
+Makefile.in
+stamp-h1
+config.h
+config.h.in
+config.h.in~
+config.log
+config.status
+configure
+autom4te.cache
+build-aux/
+libnftables.pc
+libtool
diff --git a/Make_global.am b/Make_global.am
new file mode 100644
index 000000000000..64e8e2341156
--- /dev/null
+++ b/Make_global.am
@@ -0,0 +1,4 @@ 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
+AM_CFLAGS = -Wall \
+	${LIBNFTABLES_CFLAGS} ${LIBJSON_CFLAGS} -lev
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 70898d1793c2..000000000000
--- a/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@ 
-IDIR=include
-CC=gcc
-CFLAGS=-Wall -I$(IDIR)
-ODIR=src
-SRCS=main.o server.o config.o model.o nft.o
-LIBS=-lev -ljansson -lgmp -lmnl -lnftnl -lnftables
-PROG=nftlb
-
-all: $(PROG)
-
-$(PROG) : $(SRCS)
-	$(CC) -o $(PROG) $(ODIR)/*.o $(CFLAGS) $(LIBS)
-
-%.o: $(ODIR)/%.c
-	$(CC) -c -o $(ODIR)/$@ $< $(CFLAGS)
-
-.PHONY: clean
-
-clean:
-	rm -f $(PROG) $(ODIR)/*.o *~ $(IDIR)/*~
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 000000000000..b7baea8c22dd
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,11 @@ 
+include Make_global.am
+
+ACLOCAL_AMFLAGS	= -I m4
+
+EXTRA_DIST = include	\
+	     tests	\
+	     Make_global.am
+
+SUBDIRS		= src
+DIST_SUBDIRS	= src
+LIBS = @LIBMNL_LIBS@ @LIBNFTNL_LIBS@ @LIBNFTABLES_LIBS@ @LIBJSON_LIBS@
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 000000000000..09e45eb4079a
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,32 @@ 
+AC_INIT([nftlb], [0.1], [netfilter-devel@vger.kernel.org])
+
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_MACRO_DIR([m4])
+AM_INIT_AUTOMAKE([-Wall foreign subdir-objects
+        tar-pax no-dist-gzip dist-bzip2 1.6])
+
+dnl kernel style compile messages
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+AC_CONFIG_HEADERS([config.h])
+
+AC_PROG_CC
+AC_PROG_MKDIR_P
+AM_PROG_AR
+AM_PROG_LIBTOOL
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_SED
+
+PKG_CHECK_MODULES([LIBMNL], [libmnl >= 1.0.3])
+PKG_CHECK_MODULES([LIBNFTNL], [libnftnl >= 1.1.0])
+PKG_CHECK_MODULES([LIBNFTABLES], [libnftables >= 0.8.5])
+PKG_CHECK_MODULES([LIBJSON], [jansson >= 2.3])
+
+AC_CHECK_HEADER([event.h], [EVENTINC="-include event.h"],
+		[AC_CHECK_HEADER([libev/event.h],
+				 [EVENTINC="-include libev/event.h"],
+				 [AC_MSG_ERROR([event.h not found])])])
+
+AC_CONFIG_FILES([Makefile src/Makefile])
+AC_OUTPUT
diff --git a/m4/.gitignore b/m4/.gitignore
new file mode 100644
index 000000000000..8d0c756305f8
--- /dev/null
+++ b/m4/.gitignore
@@ -0,0 +1,2 @@ 
+/lt*.m4
+/libtool.m4
diff --git a/src/.gitignore b/src/.gitignore
new file mode 100644
index 000000000000..6937cfdc381e
--- /dev/null
+++ b/src/.gitignore
@@ -0,0 +1,3 @@ 
+*.o
+nftlb
+.deps/
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 000000000000..cca36dbe10c9
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,10 @@ 
+include $(top_srcdir)/Make_global.am
+
+sbin_PROGRAMS = nftlb
+
+nftlb_SOURCES = config.c	\
+		main.c		\
+		model.c		\
+		nft.c		\
+		server.c
+nftlb_LDADD = ${LIBMNL_LIBS} ${LIBNFTNL_LIBS} ${LIBNFTABLES_LIBS} ${LIBJSON_LIBS}