Check usability of inotify before selecting it

A libinotify compatibility library exists for BSD systems. If this
was installed, configure would find sys/inotify.h but the build
would fail to link unless the library was added to the link line.
By also checking for inotify_init() this problem can be avoided.

Given that there is native support for kqueue, there is no need
to handle linking with libinotify.
This commit is contained in:
Oliver Kiddle
2020-04-15 12:31:11 +02:00
parent 697bd07441
commit 1eaa510c05
2 changed files with 26 additions and 18 deletions

View File

@@ -5476,10 +5476,17 @@ if test "$wxUSE_FSWATCHER" = "yes"; then
dnl includes OS X which does have kqueue but no other platforms)
if test "$USE_WIN32" != 1; then
if test "$wxUSE_UNIX" = "yes"; then
AC_CHECK_HEADERS(sys/inotify.h,,, [AC_INCLUDES_DEFAULT()])
if test "$ac_cv_header_sys_inotify_h" = "yes"; then
AC_DEFINE(wxHAS_INOTIFY)
else
dnl inotify header may be present from a compatibility library so
dnl check that the function is usable. We don't try to link with,
dnl e.g. -linotify so native kqueue support is used in preference.
AC_MSG_CHECKING([whether inotify is usable])
AC_LINK_IFELSE(
[AC_LANG_SOURCE([int main() { return inotify_init(); }])],
[wx_cv_inotify_usable=yes; AC_DEFINE(wxHAS_INOTIFY) ],
[wx_cv_inotify_usable=no]
)
AC_MSG_RESULT($wx_cv_inotify_usable)
if test "$wx_cv_inotify_usable" = "no"; then
AC_CHECK_HEADERS(sys/event.h,,, [AC_INCLUDES_DEFAULT()])
if test "$ac_cv_header_sys_event_h" = "yes"; then
AC_DEFINE(wxHAS_KQUEUE)