ehlo, 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. Two patches are attached. 1st is for master (1.10) and 2nd is for branch 1.9 LS
>From 2f88248c97a46a305e358c38104ffc48a2e871ea Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <[email protected]> Date: Fri, 30 Aug 2013 23:13:26 +0200 Subject: [PATCH 2/2] 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. --- Makefile.am | 1 + configure.ac | 3 ++- src/external/inotify.m4 | 32 ++++++++++++++++++++++++++++++++ src/monitor/monitor.c | 8 ++++---- 4 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 src/external/inotify.m4 diff --git a/Makefile.am b/Makefile.am index 4981ed94df8def239532dced88e95b7cc52e73e7..9e68ad9b3a16c9106311eb833a97b01714656a61 100644 --- a/Makefile.am +++ b/Makefile.am @@ -627,6 +627,7 @@ sssd_SOURCES = \ src/util/nscd.c sssd_LDADD = \ $(SSSD_LIBS) \ + $(INOTIFY_LIBS) \ $(LIBNL_LIBS) \ $(KEYUTILS_LIBS) \ $(SSSD_INTERNAL_LTLIBS) diff --git a/configure.ac b/configure.ac index 511e8d6c8afbfb0cbf5aca076b460aa4c881e252..19bd1928f8a2149d3bf8e8f7a8d46ab7343a0bd6 100644 --- a/configure.ac +++ b/configure.ac @@ -152,6 +152,7 @@ m4_include([src/external/libnl.m4]) m4_include([src/external/systemd.m4]) m4_include([src/external/pac_responder.m4]) m4_include([src/external/signal.m4]) +m4_include([src/external/inotify.m4]) m4_include([src/external/libndr_nbt.m4]) WITH_UNICODE_LIB @@ -251,7 +252,7 @@ if test x$cryptolib = xlibcrypto; then AM_CHECK_LIBCRYPTO fi -AC_CHECK_HEADERS([sys/inotify.h]) +AM_CHECK_INOTIFY AC_CHECK_HEADERS([sasl/sasl.h],,AC_MSG_ERROR([Could not find SASL headers])) diff --git a/src/external/inotify.m4 b/src/external/inotify.m4 new file mode 100644 index 0000000000000000000000000000000000000000..9572f6d2fefedf8a1d6a2468c712a83e7db2969f --- /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 495f31e3487027884313c3eef87ea8d8a3f15028..d8bbfbcbe7666cef43fcc3597103beabea634800 100644 --- a/src/monitor/monitor.c +++ b/src/monitor/monitor.c @@ -1642,7 +1642,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); @@ -1867,7 +1867,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, @@ -1917,7 +1917,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; @@ -1986,7 +1986,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, -- 1.8.3.1
>From 1ce8ecace41af27e4dc780adcd61dddd8d2c4008 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <[email protected]> Date: Fri, 30 Aug 2013 23:13:26 +0200 Subject: [PATCH 2/2] 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. --- Makefile.am | 1 + configure.ac | 3 ++- src/external/inotify.m4 | 32 ++++++++++++++++++++++++++++++++ src/monitor/monitor.c | 8 ++++---- 4 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 src/external/inotify.m4 diff --git a/Makefile.am b/Makefile.am index 2e107304780802fa1ed797d02c15921ce7439289..cb4bea7a7bc4672e45d63236eed940180872227d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -568,6 +568,7 @@ sssd_SOURCES = \ src/confdb/confdb_setup.c sssd_LDADD = \ $(SSSD_LIBS) \ + $(INOTIFY_LIBS) \ $(LIBNL_LIBS) \ $(KEYUTILS_LIBS) \ libsss_util.la diff --git a/configure.ac b/configure.ac index f3355a0ac0aedcadc34ffb917dade207c5eab700..ac19d66b2197ab2a86f86afa449d1846d33657a8 100644 --- a/configure.ac +++ b/configure.ac @@ -152,6 +152,7 @@ m4_include([src/external/libnl.m4]) m4_include([src/external/systemd.m4]) m4_include([src/external/pac_responder.m4]) m4_include([src/util/signal.m4]) +m4_include([src/external/inotify.m4]) WITH_UNICODE_LIB if test x$unicode_lib = xlibunistring; then @@ -247,7 +248,7 @@ if test x$cryptolib = xlibcrypto; then AM_CHECK_LIBCRYPTO fi -AC_CHECK_HEADERS([sys/inotify.h]) +AM_CHECK_INOTIFY AC_CHECK_HEADERS([sasl/sasl.h],,AC_MSG_ERROR([Could not find SASL headers])) diff --git a/src/external/inotify.m4 b/src/external/inotify.m4 new file mode 100644 index 0000000000000000000000000000000000000000..9572f6d2fefedf8a1d6a2468c712a83e7db2969f --- /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 baeb48687429372d54e5eedc911aaefcda3c8165..dbe0587451e264bf727b408b73499306f7e405b7 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, -- 1.8.3.1
_______________________________________________ sssd-devel mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/sssd-devel
