From 292ac38165c3594505a2491dea0a5efeee0c7bd9 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Sat, 24 Jul 2010 03:49:03 +0200 Subject: [PATCH] examples: support libev and fix build on Fedora Check for and prefer libev over libevent and check for the location of the event.h file, which is contained in libev/event.h on Fedora. Signed-off-by: Patrick McHardy --- Makefile.defs.in | 3 +++ configure.ac | 16 ++++++++++++++++ example/Makefile.in | 3 ++- example/event_ops.c | 1 - 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Makefile.defs.in b/Makefile.defs.in index 2b77d43..1c48a98 100644 --- a/Makefile.defs.in +++ b/Makefile.defs.in @@ -41,3 +41,6 @@ CFLAGS += -Waggregate-return -Wunused -Wwrite-strings ifeq ($(DEBUG),y) CFLAGS += -g -DDEBUG endif + +EVENT_CFLAGS += @EVENT_CFLAGS@ +EVENT_LDFLAGS += @EVENT_LDFLAGS@ diff --git a/configure.ac b/configure.ac index e8cc903..ab12a40 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,14 @@ AC_CHECK_LIB([nl], [nl_socket_alloc], , AC_CHECK_LIB([nl-dect], [nl_dect_cluster_alloc], , AC_MSG_ERROR([No suitable version of libnl-dect found])) +AC_CHECK_LIB(ev, event_init, + [EVENTLIB="-lev"], + AC_CHECK_LIB(event, event_init, + [EVENTLIB="-levent"], + AC_ERROR(libev or libevent not found))) +EVENT_LDFLAGS=$EVENTLIB +AC_SUBST(EVENT_LDFLAGS) + # Checks for header files. AC_HEADER_STDC AC_HEADER_ASSERT @@ -43,6 +51,14 @@ AC_CHECK_HEADERS([linux/dect.h linux/dect_netlink.h], , AC_MSG_ERROR([DECT kernel header files not found]), [#include ]) +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]))) +EVENT_CFLAGS=$EVENTINC +AC_SUBST(EVENT_CFLAGS) + # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL AC_C_CONST diff --git a/example/Makefile.in b/example/Makefile.in index db9576f..80f59d6 100644 --- a/example/Makefile.in +++ b/example/Makefile.in @@ -1,4 +1,5 @@ -LDFLAGS += -Wl,-rpath $(PWD)/src -Lsrc -ldect -levent +CFLAGS += $(EVENT_CFLAGS) +LDFLAGS += -Wl,-rpath $(PWD)/src -Lsrc -ldect $(EVENT_LDFLAGS) PROGRAMS += cc ss mm-fp mm-pp discover hijack destdir := usr/share/dect/examples diff --git a/example/event_ops.c b/example/event_ops.c index bf834f6..08b93be 100644 --- a/example/event_ops.c +++ b/example/event_ops.c @@ -2,7 +2,6 @@ #include #include #include -#include #include #include "common.h"