[PATCH nftlb,v4] build: use autotools

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



- Add configure.ac and Makefile.am files.
- Update .gitignore file to ignore autogenerated scripts by autotools.

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
v4: previous patch was incomplete, really check for ev.h only.

 .gitignore      | 17 +++++++++++++++--
 Make_global.am  |  4 ++++
 Makefile        | 20 --------------------
 Makefile.am     | 11 +++++++++++
 configure.ac    | 30 ++++++++++++++++++++++++++++++
 m4/.gitignore   |  2 ++
 src/.gitignore  |  3 +++
 src/Makefile.am | 10 ++++++++++
 8 files changed, 75 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

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..fbd7e40fb16c
--- /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 = @LIBNFTABLES_LIBS@ @LIBJSON_LIBS@
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 000000000000..03c7c91dd26c
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,30 @@
+AC_INIT([nftlb], [0.1], [netfilter-devel@xxxxxxxxxxxxxxx])
+
+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([LIBNFTABLES], [libnftables >= 0.8.5])
+PKG_CHECK_MODULES([LIBJSON], [jansson >= 2.3])
+
+AC_CHECK_HEADER([ev.h], [EVENTINC="-include ev.h"],
+		[AC_CHECK_HEADER([libev/ev.h],
+				 [EVENTINC="-include libev/ev.h"],
+				 [AC_MSG_ERROR([ev.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..0888add37a1d
--- /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 = ${LIBNFTABLES_LIBS} ${LIBJSON_LIBS}
-- 
2.11.0


--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux