[libdispatch-dev] [PATCH] use libkqueue if sys/event.h is missing

Mark Heily mark at heily.com
Sun Nov 15 15:04:22 PST 2009


Robert Watson wrote:
> 
> On Wed, 11 Nov 2009, Mark Heily wrote:
> 
>> Attached is a patch that uses pkg-config(1) to determine the installed 
>> location of libkqueue and set the appropriate Makefile variables. I'm 
>> not 100% sure the LIBADD and LDFLAGS variables are correct, but I 
>> can't test it until libdispatch compiles cleanly on Linux.
> 
> Is there a reason not to use PKG_CHECK_MODULES(), which will define 
> _LIBS and _FLAGS variables automatically?  This would avoid encoding the 
> use of pkg-config in the makefiles, limiting it to a configuration-time 
> step.  

No reason, other than that my initial attempts to use PKG_CHECK_MODULES() 
were unsuccessful. I think I figured out it out now. The following patch has 
been tested on Linux and FreeBSD 8-STABLE and seems to work.

Regards,

  - Mark


Index: configure.ac
===================================================================
--- configure.ac	(revision 159)
+++ configure.ac	(working copy)
@@ -136,10 +136,19 @@
  # Find libraries we will need
  #
  AC_SEARCH_LIBS(clock_gettime, rt)
-AC_SEARCH_LIBS(kqueue, kqueue)
  AC_SEARCH_LIBS(pthread_create, pthread)

+
  #
+# Use either the native kqueue(2) or libkqueue
+#
+AC_CHECK_HEADER(sys/event.h,
+  [],
+    [PKG_CHECK_MODULES(KQUEUE, libkqueue)]
+)
+
+
+#
  # Checks for header files.
  #
  AC_HEADER_STDC
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 159)
+++ src/Makefile.am	(working copy)
@@ -25,15 +25,15 @@
  INCLUDES=-I$(top_builddir) -I$(top_srcdir) \
  	@APPLE_LIBC_SOURCE_PATH@ @APPLE_XNU_SOURCE_PATH@

-libdispatch_la_CFLAGS+=$(MARCH_FLAGS) $(CBLOCKS_FLAGS)
+libdispatch_la_CFLAGS+=$(MARCH_FLAGS) $(CBLOCKS_FLAGS) $(KQUEUE_CFLAGS)

  if USE_LEGACY_API
  libdispatch_la_SOURCES+=	\
  	legacy.c
  endif

-libdispatch_la_LIBADD=libshims.la
-libdispatch_la_DEPENDENCIES=libshims.la
+libdispatch_la_LIBADD=libshims.la $(KQUEUE_LIBS)
+libdispatch_la_DEPENDENCIES=libshims.la $(KQUEUE_LIBS)

  if USE_MIG
  libdispatch_la_SOURCES+=	\



More information about the libdispatch-dev mailing list