netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* libsnet: build sys
@ 2011-10-03 20:10 Jan Engelhardt
  2011-10-03 20:10 ` [PATCH 1/3] build: provide buildsys with automake and pkgconfig Jan Engelhardt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jan Engelhardt @ 2011-10-03 20:10 UTC (permalink / raw)
  To: sam; +Cc: netfilter-devel


I see that your libsnet-0.1.tar contains a git tree, so I used that
as a base for now.

With the three patches here, distro packaging is stress-free
(means $developer does not have to read the Makefile to figure out
what variables to set :-).

Please add header notices to the .c files to refer to the particular
license that they are under, and a LICENSE/COPYING file for the
particular license you will be choosing for the package.

thanks,
Jan

----

The following changes since commit 83884836dc5f636b4f46c75d372ec47ed7a9c98e:

  snetd: fix netlink attributs (2009-12-29 17:49:03 +0100)

are available in the git repository at:
  git://dev.medozas.de/libsnet master

Jan Engelhardt (3):
      build: provide buildsys with automake and pkgconfig
      build: resolve compiler warnings
      src: put include files into their own directory

 .gitignore                       |   19 +++++++++++++++++++
 Makefile                         |   38 --------------------------------------
 Makefile.am                      |   20 ++++++++++++++++++++
 autogen.sh                       |    4 ++++
 configure.ac                     |   17 +++++++++++++++++
 include/{ => libsnet}/snet.h     |    0
 include/{ => libsnet}/snet_lib.h |    2 +-
 include/{ => libsnet}/sql.h      |    0
 include/{ => libsnet}/utils.h    |    0
 libsnet.pc.in                    |   10 ++++++++++
 m4/.gitignore                    |    2 ++
 snet.c                           |    5 +++--
 snet_lib.c                       |    7 ++++---
 utils.c                          |    5 +++--
 14 files changed, 83 insertions(+), 46 deletions(-)
 create mode 100644 .gitignore
 delete mode 100644 Makefile
 create mode 100644 Makefile.am
 create mode 100755 autogen.sh
 create mode 100644 configure.ac
 rename include/{ => libsnet}/snet.h (100%)
 rename include/{ => libsnet}/snet_lib.h (95%)
 rename include/{ => libsnet}/sql.h (100%)
 rename include/{ => libsnet}/utils.h (100%)
 create mode 100644 libsnet.pc.in
 create mode 100644 m4/.gitignore

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] build: provide buildsys with automake and pkgconfig
  2011-10-03 20:10 libsnet: build sys Jan Engelhardt
@ 2011-10-03 20:10 ` Jan Engelhardt
  2011-10-03 20:10 ` [PATCH 2/3] build: resolve compiler warnings Jan Engelhardt
  2011-10-03 20:10 ` [PATCH 3/3] src: put include files into their own directory Jan Engelhardt
  2 siblings, 0 replies; 4+ messages in thread
From: Jan Engelhardt @ 2011-10-03 20:10 UTC (permalink / raw)
  To: sam; +Cc: netfilter-devel

---
 .gitignore    |   19 +++++++++++++++++++
 Makefile      |   38 --------------------------------------
 Makefile.am   |   19 +++++++++++++++++++
 autogen.sh    |    4 ++++
 configure.ac  |   17 +++++++++++++++++
 libsnet.pc.in |   10 ++++++++++
 m4/.gitignore |    2 ++
 7 files changed, 71 insertions(+), 38 deletions(-)
 create mode 100644 .gitignore
 delete mode 100644 Makefile
 create mode 100644 Makefile.am
 create mode 100755 autogen.sh
 create mode 100644 configure.ac
 create mode 100644 libsnet.pc.in
 create mode 100644 m4/.gitignore

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4c556c2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,19 @@
+.deps
+.libs
+Makefile
+Makefile.in
+*.la
+*.lo
+*.o
+*.pc
+
+/aclocal.m4
+/autom4te.cache
+/config.*
+/configure
+/depcomp
+/install-sh
+/libtool
+/ltmain.sh
+/missing
+/stamp-h1
diff --git a/Makefile b/Makefile
deleted file mode 100644
index c7dc237..0000000
--- a/Makefile
+++ /dev/null
@@ -1,38 +0,0 @@
-NAME	:= snetd
-VERSION	:= 0.1
-SRC	:= $(wildcard *.c)
-
-CC	:= gcc
-RM	:= rm -f
-LN	:= ln
-
-libdir = lib/
-includedir = include/
-bindir = bin/
-
-CFLAGS  := -g -O2
-INCLUDES := -I./$(includedir) $$(pkg-config --cflags sqlite3)
-LIBS     := $$(pkg-config --libs libnl-1 sqlite3) -lpthread
-OBJS     := $(SRC:.c=.o)
-
-all:	$(NAME)
-
-.c.o:
-	@echo " CC $@"; $(CC) $(INCLUDES) $(CFLAGS) -c $<
-
-$(NAME): $(OBJS)
-	@echo " CC $@"; $(CC) $(CFLAGS) $(LIBS) -o $@ $(OBJS)
-	@echo " LD lib$(NAME).so.$(VERSION)"; $(CC) -shared -Wl,-soname,lib$(NAME).so.1 -o lib$(NAME).so.$(VERSION) snet.o snet_lib.o utils.o
-	mv $(NAME) $(bindir)
-	mv lib$(NAME).so.$(VERSION) $(libdir)
-	@echo " LN lib$(NAME).so.$(VERSION) lib$(NAME).so.1"; rm -f $(libdir)lib$(NAME).so.1 ; $(LN) -s lib$(NAME).so.$(VERSION) $(libdir)/lib$(NAME).so.1
-	@echo " LN lib$(NAME).so.1 lib$(NAME).so"; rm -f $(libdir)/lib$(NAME).so ; $(LN) -s lib$(NAME).so.1 $(libdir)/lib$(NAME).so
-
-clean:
-	@echo " RM *~ *.o"; $(RM) *~ *.o
-
-distclean: clean
-	@echo " RM $(NAME)"; $(RM) $(bindir)$(NAME)
-	@echo " RM lib$(NAME).so.$(VERSION)"; $(RM) $(libdir)lib$(NAME).so.$(VERSION)
-	@echo " RM lib$(NAME).so.1"; $(RM) $(libdir)lib$(NAME).so.1
-	@echo " RM lib$(NAME).so"; $(RM) $(libdir)lib$(NAME).so
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..143390a
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,19 @@
+# -*- Makefile -*-
+
+# toplevel-specific
+ACLOCAL_AMFLAGS = -I m4
+
+# build pieces.
+AM_CPPFLAGS = -I${top_srcdir}/include
+AM_CFLAGS   = ${libnl_CFLAGS}
+
+lib_LTLIBRARIES = libsnet.la
+
+libsnet_la_SOURCES = snet.c snet_lib.c utils.c
+libsnet_la_LIBADD  = ${libnl_LIBS}
+
+include_HEADERS = include/snet.h include/snet_lib.h include/utils.h
+
+pkgconfig_DATA = libsnet.pc
+
+libsnet.pc: ${top_builddir}/config.status
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..a52be65
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,4 @@
+#!/bin/sh -ex
+
+mkdir -p m4;
+autoreconf -fi;
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..2ecef24
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,17 @@
+AC_INIT([libsnet], [0.1])
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIR([m4])
+AM_INIT_AUTOMAKE([-Wall foreign 1.10])
+AC_PROG_CC
+AC_DISABLE_STATIC
+LT_INIT
+
+PKG_CHECK_MODULES([libnl], [libnl-1])
+
+AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=PATH],
+	[Path to the pkgconfig directory [[LIBDIR/pkgconfig]]]),
+	[pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig'])
+AC_SUBST([pkgconfigdir])
+
+AC_CONFIG_FILES([Makefile libsnet.pc])
+AC_OUTPUT
diff --git a/libsnet.pc.in b/libsnet.pc.in
new file mode 100644
index 0000000..4ded898
--- /dev/null
+++ b/libsnet.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name:		libsnet
+Version:	@PACKAGE_VERSION@
+Description:	TBD
+Cflags:		-I${includedir}
+Libs:		-L${libdir} -lsnet
diff --git a/m4/.gitignore b/m4/.gitignore
new file mode 100644
index 0000000..64d9bbc
--- /dev/null
+++ b/m4/.gitignore
@@ -0,0 +1,2 @@
+/libtool.m4
+/lt*.m4
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] build: resolve compiler warnings
  2011-10-03 20:10 libsnet: build sys Jan Engelhardt
  2011-10-03 20:10 ` [PATCH 1/3] build: provide buildsys with automake and pkgconfig Jan Engelhardt
@ 2011-10-03 20:10 ` Jan Engelhardt
  2011-10-03 20:10 ` [PATCH 3/3] src: put include files into their own directory Jan Engelhardt
  2 siblings, 0 replies; 4+ messages in thread
From: Jan Engelhardt @ 2011-10-03 20:10 UTC (permalink / raw)
  To: sam; +Cc: netfilter-devel

utils.c: In function 'get_taskname':
utils.c:62:2: warning: implicit declaration of function
	'read' [-Wimplicit-function-declaration]
utils.c:63:2: warning: implicit declaration of function
	'close' [-Wimplicit-function-declaration]
snet.c: In function 'snet_get':
snet.c:607:1: warning: control reaches end of non-void
	function [-Wreturn-type]
snet_lib.c: In function 'snet_destroy':
snet_lib.c:63:1: warning: control reaches end of non-void
	function [-Wreturn-type]
---
 snet.c     |    1 +
 snet_lib.c |    1 +
 utils.c    |    1 +
 3 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/snet.c b/snet.c
index 3d94846..ff5267a 100644
--- a/snet.c
+++ b/snet.c
@@ -604,6 +604,7 @@ int snet_get(struct nl_handle *nl_handle)
 		return -1;
 	}
 	snet_dbg(fout, 1, "exiting\n");
+	return 0;
 }
 
 int snet_verdict_delay(struct nl_handle *nl_handle, int family,
diff --git a/snet_lib.c b/snet_lib.c
index 0a2390e..97fd44c 100644
--- a/snet_lib.c
+++ b/snet_lib.c
@@ -60,4 +60,5 @@ int snet_destroy(struct snet_lib *sl)
 
 	nl_close(sl->snet_sock);
 	nl_handle_destroy(sl->snet_sock);
+	return 0;
 }
diff --git a/utils.c b/utils.c
index 51b029a..87572f6 100644
--- a/utils.c
+++ b/utils.c
@@ -2,6 +2,7 @@
 #include <utils.h>
 #include <snet.h>
 #include <fcntl.h>
+#include <unistd.h>
 
 const char *snet_syscall_name(const __u8 syscall)
 {
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] src: put include files into their own directory
  2011-10-03 20:10 libsnet: build sys Jan Engelhardt
  2011-10-03 20:10 ` [PATCH 1/3] build: provide buildsys with automake and pkgconfig Jan Engelhardt
  2011-10-03 20:10 ` [PATCH 2/3] build: resolve compiler warnings Jan Engelhardt
@ 2011-10-03 20:10 ` Jan Engelhardt
  2 siblings, 0 replies; 4+ messages in thread
From: Jan Engelhardt @ 2011-10-03 20:10 UTC (permalink / raw)
  To: sam; +Cc: netfilter-devel

It is better when include files get their own directory, i.e. in this
case, utils.h will go to /usr/include/libsnet, where it is less prone
to clashes than in /usr/include.
---
 Makefile.am                      |    3 ++-
 include/{ => libsnet}/snet.h     |    0
 include/{ => libsnet}/snet_lib.h |    2 +-
 include/{ => libsnet}/sql.h      |    0
 include/{ => libsnet}/utils.h    |    0
 snet.c                           |    4 ++--
 snet_lib.c                       |    6 +++---
 utils.c                          |    4 ++--
 8 files changed, 10 insertions(+), 9 deletions(-)
 rename include/{ => libsnet}/snet.h (100%)
 rename include/{ => libsnet}/snet_lib.h (95%)
 rename include/{ => libsnet}/sql.h (100%)
 rename include/{ => libsnet}/utils.h (100%)

diff --git a/Makefile.am b/Makefile.am
index 143390a..81ac2d3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,7 +12,8 @@ lib_LTLIBRARIES = libsnet.la
 libsnet_la_SOURCES = snet.c snet_lib.c utils.c
 libsnet_la_LIBADD  = ${libnl_LIBS}
 
-include_HEADERS = include/snet.h include/snet_lib.h include/utils.h
+pkginclude_HEADERS = include/libsnet/snet.h include/libsnet/snet_lib.h \
+                     include/libsnet/utils.h
 
 pkgconfig_DATA = libsnet.pc
 
diff --git a/include/snet.h b/include/libsnet/snet.h
similarity index 100%
rename from include/snet.h
rename to include/libsnet/snet.h
diff --git a/include/snet_lib.h b/include/libsnet/snet_lib.h
similarity index 95%
rename from include/snet_lib.h
rename to include/libsnet/snet_lib.h
index b01fffd..61ee09f 100644
--- a/include/snet_lib.h
+++ b/include/libsnet/snet_lib.h
@@ -1,7 +1,7 @@
 #ifndef _SNET_LIB_H
 #define _SNET_LIB_H
 
-#include <snet.h>
+#include <libsnet/snet.h>
 #include <netlink/netlink.h>
 
 struct snet_lib {
diff --git a/include/sql.h b/include/libsnet/sql.h
similarity index 100%
rename from include/sql.h
rename to include/libsnet/sql.h
diff --git a/include/utils.h b/include/libsnet/utils.h
similarity index 100%
rename from include/utils.h
rename to include/libsnet/utils.h
diff --git a/snet.c b/snet.c
index ff5267a..5a4e4f0 100644
--- a/snet.c
+++ b/snet.c
@@ -20,12 +20,12 @@
 #include <netlink/genl/ctrl.h>
 #include <netlink/netlink.h>
 #include <netlink/utils.h>
-#include <snet.h>
+#include <libsnet/snet.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <netdb.h>
-#include <utils.h>
+#include <libsnet/utils.h>
 
 extern int nl_debug;
 extern FILE *fout;
diff --git a/snet_lib.c b/snet_lib.c
index 97fd44c..5b5a6e9 100644
--- a/snet_lib.c
+++ b/snet_lib.c
@@ -1,7 +1,7 @@
 #include <stdio.h>
-#include <snet.h>
-#include <snet_lib.h>
-#include <utils.h>
+#include <libsnet/snet.h>
+#include <libsnet/snet_lib.h>
+#include <libsnet/utils.h>
 
 int snet_attach(struct snet_lib *sl,
 		unsigned int (*snet_cb)(uint32_t, uint8_t, uint8_t,
diff --git a/utils.c b/utils.c
index 87572f6..cfca08f 100644
--- a/utils.c
+++ b/utils.c
@@ -1,6 +1,6 @@
 #include <stdio.h>
-#include <utils.h>
-#include <snet.h>
+#include <libsnet/utils.h>
+#include <libsnet/snet.h>
 #include <fcntl.h>
 #include <unistd.h>
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-10-03 20:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-03 20:10 libsnet: build sys Jan Engelhardt
2011-10-03 20:10 ` [PATCH 1/3] build: provide buildsys with automake and pkgconfig Jan Engelhardt
2011-10-03 20:10 ` [PATCH 2/3] build: resolve compiler warnings Jan Engelhardt
2011-10-03 20:10 ` [PATCH 3/3] src: put include files into their own directory Jan Engelhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).