Conditionally build inotify support. Disable on freebsd. Index: configure.in =================================================================== RCS file: /cvs/gnome/beagle/configure.in,v retrieving revision 1.183 diff -u -B -p -r1.183 configure.in --- configure.in 5 Oct 2005 14:36:30 -0000 1.183 +++ configure.in 17 Oct 2005 19:20:01 -0000 @@ -50,11 +50,13 @@ done case "$target" in *-*-linux*) os=linux + os_has_inotify=yes AC_CHECK_LIB(attr, lsetxattr, XATTR_LIB="libattr",) AC_CHECK_FUNC(lsetxattr, XATTR_LIB="libc",) ;; *-*-freebsd*) os=freebsd + os_has_inotify=no AC_CHECK_FUNC(extattr_set_link, XATTR_LIB="libc") ;; *) @@ -329,6 +331,36 @@ AM_CONDITIONAL(USE_LOCAL_SQLITE, test "x dnl ---------------------------------------------- +dnl inotify + +AC_ARG_ENABLE([inotify], + AC_HELP_STRING([--disable-inotify], [Disable inotify filesystem monitoring support (default auto)]), + enable_inotify=$enableval, + enable_inotify=auto) + +if test "x$os_has_inotify" = "xno"; then + + dnl error out if user has explicitly requested inotify + if test "x$enable_inotify" = "xyes"; then + AC_MSG_ERROR([inotify is unavailable on your system architecture]) + fi + + enable_inotify="no (unavailable)" + +else + + if test "x$enable_inotify" != "xno"; then + enable_inotify="yes" + else + enable_inotify="no (disabled)" + fi + +fi + +AM_CONDITIONAL(ENABLE_INOTIFY, test "x$enable_inotify" = "xyes") + +dnl ---------------------------------------------- + dnl beagled PKG_CHECK_MODULES(GSF_SHARP, gsf-sharp >= 0.4, enable_gsf_sharp=yes, enable_gsf_sharp=no) @@ -608,6 +640,7 @@ po/Makefile.in echo " Target OS: ${os} Extended Attributes: ${XATTR_LIB} + inotify? ${enable_inotify} Prefix: ${prefix} GNOME Prefix: ${GNOME_PREFIX} Index: Util/Inotify.cs =================================================================== RCS file: /cvs/gnome/beagle/Util/Inotify.cs,v retrieving revision 1.55 diff -u -B -p -r1.55 Inotify.cs --- Util/Inotify.cs 5 Oct 2005 14:33:15 -0000 1.55 +++ Util/Inotify.cs 17 Oct 2005 19:20:09 -0000 @@ -42,6 +42,10 @@ namespace Beagle.Util { public delegate void InotifyCallback (Watch watch, string path, string subitem, string srcpath, EventType type); + public interface Watch { + void Unsubscribe (); + void ChangeSubscription (EventType new_mask); + } ///////////////////////////////////////////////////////////////////////////////////// [Flags] @@ -112,6 +116,62 @@ namespace Beagle.Util { ///////////////////////////////////////////////////////////////////////////////////// + static public bool Verbose = false; + static private int inotify_fd = -1; + + static Inotify () + { + log = Logger.Get ("Inotify"); + + if (Environment.GetEnvironmentVariable ("BEAGLE_DISABLE_INOTIFY") != null) { + Logger.Log.Debug ("BEAGLE_DISABLE_INOTIFY is set"); + return; + } + + if (Environment.GetEnvironmentVariable ("BEAGLE_INOTIFY_VERBOSE") != null) + Inotify.Verbose = true; + + try { + inotify_fd = inotify_glue_init (); + } catch (EntryPointNotFoundException) { + Logger.Log.Info ("Inotify not available on system."); + return; + } + + if (inotify_fd == -1) + Logger.Log.Warn ("Could not initialize inotify"); + } + + static public bool Enabled { + get { return inotify_fd >= 0; } + } + + ///////////////////////////////////////////////////////////////////////////////////// + +#if ! ENABLE_INOTIFY + + // Stubs for systems where inotify is unavailable + + static public Watch Subscribe (string path, InotifyCallback callback, EventType mask) + { + return null; + } + + static public void Start () + { + return; + } + + static public void Stop () + { + return; + } + +#else // ENABLE_INOTIFY + + ///////////////////////////////////////////////////////////////////////////////////// + static private ArrayList event_queue = new ArrayList (); + private class QueuedEvent { public int Wd; public EventType Type; @@ -150,37 +210,6 @@ namespace Beagle.Util { ///////////////////////////////////////////////////////////////////////////////////// - static private int inotify_fd = -1; - static private ArrayList event_queue = new ArrayList (); - - static Inotify () - { - log = Logger.Get ("Inotify"); - - if (Environment.GetEnvironmentVariable ("BEAGLE_DISABLE_INOTIFY") != null) { - Logger.Log.Debug ("BEAGLE_DISABLE_INOTIFY is set"); - return; - } - - if (Environment.GetEnvironmentVariable ("BEAGLE_INOTIFY_VERBOSE") != null) - Inotify.Verbose = true; - - inotify_fd = inotify_glue_init (); - if (inotify_fd == -1) - Logger.Log.Warn ("Could not initialize inotify"); - } - - static public bool Enabled { - get { return inotify_fd >= 0; } - } - - ///////////////////////////////////////////////////////////////////////////////////// - - public interface Watch { - void Unsubscribe (); - void ChangeSubscription (EventType new_mask); - } - private class WatchInternal : Watch { private InotifyCallback callback; private EventType mask; @@ -532,8 +561,6 @@ namespace Beagle.Util { } - static public bool Verbose = false; - // Update the watched_by_path hash and the path stored inside the watch // in response to a move event. static private void MoveWatch (WatchInfo watch, string name) @@ -823,6 +850,8 @@ namespace Beagle.Util { Inotify.Stop (); } #endif + +#endif // ENABLE_INOTIFY } } Index: Util/Makefile.am =================================================================== RCS file: /cvs/gnome/beagle/Util/Makefile.am,v retrieving revision 1.71 diff -u -B -p -r1.71 Makefile.am --- Util/Makefile.am 20 Sep 2005 18:38:36 -0000 1.71 +++ Util/Makefile.am 17 Oct 2005 19:20:11 -0000 @@ -110,14 +110,20 @@ ASSEMBLIES += \ $(GALAGO_LIBS) endif +if ENABLE_INOTIFY +INOTIFY_EXE = Inotify.exe +CSFLAGS += -define:ENABLE_INOTIFY +else +INOTIFY_EXE = +endif $(TARGET): $(CSFILES) $(GOOGLE_CS) $(EXTSTR) $(CSC) -unsafe -out:$@ $(CSFLAGS) $^ $(ASSEMBLIES) Inotify.exe: $(srcdir)/Inotify.cs $(srcdir)/Logger.cs $(srcdir)/DirectoryWalker.cs - $(CSC) -unsafe -out:$@ $^ -r:Mono.Posix -define:INOTIFY_TEST + $(CSC) -unsafe -out:$@ $^ -r:Mono.Posix -define:INOTIFY_TEST -define:ENABLE_INOTIFY -all: $(TARGET) Inotify.exe +all: $(TARGET) $(INOTIFY_EXE) install-data-local: $(TARGET) $(mkinstalldirs) $(DESTDIR)$(pkglibdir) Index: glue/Makefile.am =================================================================== RCS file: /cvs/gnome/beagle/glue/Makefile.am,v retrieving revision 1.15 diff -u -B -p -r1.15 Makefile.am --- glue/Makefile.am 7 Oct 2005 11:03:31 -0000 1.15 +++ glue/Makefile.am 17 Oct 2005 19:20:14 -0000 @@ -21,10 +21,12 @@ EXTRA_GLUE_LIBADD = BEAGLED_GLUE_SOURCES = \ beagled-utils.c -INOTIFY_GLUE_SOURCES = \ +if ENABLE_INOTIFY +EXTRA_GLUE_SOURCES += \ inotify.h \ inotify-syscalls.h \ inotify-glue.c +endif IOPRIO_GLUE_SOURCES = \ ioprio-glue.c @@ -62,7 +64,6 @@ endif libbeagleglue_la_SOURCES = \ $(BEAGLED_GLUE_SOURCES) \ - $(INOTIFY_GLUE_SOURCES) \ $(IOPRIO_GLUE_SOURCES) \ $(SYSINFO_GLUE_SOURCES) \ $(EXTRA_GLUE_SOURCES) @@ -86,7 +87,10 @@ gluelib_LTLIBRARIES = \ libbeagleuiglue.la COND_SOURCES = \ - wv1-glue.c + wv1-glue.c \ + inotify.h \ + inotify-syscalls.h \ + inotify-glue.c EXTRA_DIST = \ $(COND_SOURCES)