summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Slebodnik <lukas.slebodnik@intrak.sk>2013-08-30 23:13:26 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-09-09 17:20:52 +0200
commit9c393e2c39e8d3a00a1ba399a80c4c3291857242 (patch)
tree223786ebd790f3c974fb6753f7014772cc17ba89 /src
parente64a66e620aad51c1fada6138362c5a186af178a (diff)
downloadsssd-9c393e2c39e8d3a00a1ba399a80c4c3291857242.tar.gz
sssd-9c393e2c39e8d3a00a1ba399a80c4c3291857242.tar.xz
sssd-9c393e2c39e8d3a00a1ba399a80c4c3291857242.zip
AUTOTOOLS: More robust detection of inotify.
We checked only header file "sys/inotify" for detection whether inotify works. Some platforms do not have built in inotify, but contain library, which provides inotify-compatible interface. This patch adds more robust detection of inotify in configuration time and appends linker flags to Makefile if inotify is provided by library.
Diffstat (limited to 'src')
-rw-r--r--src/external/inotify.m432
-rw-r--r--src/monitor/monitor.c8
2 files changed, 36 insertions, 4 deletions
diff --git a/src/external/inotify.m4 b/src/external/inotify.m4
new file mode 100644
index 000000000..9572f6d2f
--- /dev/null
+++ b/src/external/inotify.m4
@@ -0,0 +1,32 @@
+dnl A macro to check if inotify works
+AC_DEFUN([AM_CHECK_INOTIFY],
+[
+ AC_CHECK_HEADERS([sys/inotify.h])
+
+ AC_MSG_CHECKING([whether sys/inotify.h actually works])
+ AC_LINK_IFELSE(
+ [AC_LANG_SOURCE([
+#ifdef HAVE_SYS_INOTITY_H
+#include <sys/inotify.h>,
+#endif
+int main () {
+ return (-1 == inotify_init());
+}])],
+ [AC_MSG_RESULT([yes]); inotify_works=yes],
+ [AC_MSG_RESULT([no])]
+ )
+
+ SSS_AC_EXPAND_LIB_DIR()
+ AS_IF([test x"$inotify_works" != xyes],
+ [AC_CHECK_LIB([inotify],
+ [inotify_init],
+ [INOTIFY_LIBS="$sss_extra_libdir -linotify"
+ inotify_works=yes],
+ [inotify_works=no],
+ [$sss_extra_libdir])]
+ )
+
+ AS_IF([test x"$inotify_works" = xyes],
+ [AC_DEFINE_UNQUOTED([HAVE_INOTIFY], [1], [Inotify works])])
+ AC_SUBST(INOTIFY_LIBS)
+])
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index baeb48687..dbe058745 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -1644,7 +1644,7 @@ errno_t monitor_config_file_fallback(TALLOC_CTX *mem_ctx,
monitor_reconf_fn fn,
bool ignore_missing);
-#ifdef HAVE_SYS_INOTIFY_H
+#ifdef HAVE_INOTIFY
static void process_config_file(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval t, void *ptr);
@@ -1869,7 +1869,7 @@ static void rewatch_config_file(struct tevent_context *ev,
talloc_free(rw_ctx);
file_ctx->needs_update = 0;
}
-#endif
+#endif /* HAVE_INOTIFY */
static void poll_config_file(struct tevent_context *ev,
struct tevent_timer *te,
@@ -1919,7 +1919,7 @@ static void poll_config_file(struct tevent_context *ev,
static int try_inotify(struct config_file_ctx *file_ctx, const char *filename,
monitor_reconf_fn fn)
{
-#ifdef HAVE_SYS_INOTIFY_H
+#ifdef HAVE_INOTIFY
int err, fd_args, ret;
struct tevent_fd *tfd;
struct config_file_callback *cb;
@@ -1988,7 +1988,7 @@ static int try_inotify(struct config_file_ctx *file_ctx, const char *filename,
return EOK;
#else
return EINVAL;
-#endif
+#endif /* HAVE_INOTIFY */
}
static int monitor_config_file(TALLOC_CTX *mem_ctx,