INCLUDE(CheckIncludeFile)
INCLUDE(CheckFunctionExists)
INCLUDE(CheckIncludeFileCXX)

CHECK_INCLUDE_FILE_CXX(unistd.h UNIX_HAVE_UNISTD)
CHECK_INCLUDE_FILE_CXX(sys/stat.h UNIX_HAVE_SYS_STAT)
CHECK_INCLUDE_FILE_CXX(fcntl.h UNIX_HAVE_FCNTL)
CHECK_INCLUDE_FILE_CXX(sys/prctl.h UNIX_HAVE_SYS_PRCTL)
CHECK_INCLUDE_FILE_CXX(sys/inotify.h UNIX_HAVE_SYS_INOTIFY)
CHECK_INCLUDE_FILE_CXX(sys/mman.h UNIX_HAVE_SYS_MMAN)

CHECK_FUNCTION_EXISTS(read UNIX_HAVE_READ)
CHECK_FUNCTION_EXISTS(write UNIX_HAVE_WRITE)
CHECK_FUNCTION_EXISTS(stat UNIX_HAVE_STAT)
CHECK_FUNCTION_EXISTS(getopt_long UNIX_HAVE_GETOPTLONG)
CHECK_FUNCTION_EXISTS(strerror UNIX_HAVE_STRERROR)
CHECK_FUNCTION_EXISTS(open UNIX_HAVE_OPEN)
CHECK_FUNCTION_EXISTS(prctl UNIX_HAVE_PRCTL)
CHECK_FUNCTION_EXISTS(mmap UNIX_HAVE_MMAP)

CHECK_FUNCTION_EXISTS(inotify_init UNIX_HAVE_INOTIFY_INIT)
CHECK_FUNCTION_EXISTS(inotify_rm_watch UNIX_HAVE_INOTIFY_RM_WATCH)
CHECK_FUNCTION_EXISTS(inotify_add_watch UNIX_HAVE_INOTIFY_ADD_WATCH)

IF ((${UNIX_HAVE_SYS_INOTIFY}) AND (${UNIX_HAVE_INOTIFY_INIT}) AND (${UNIX_HAVE_INOTIFY_RM_WATCH}) AND (${UNIX_HAVE_INOTIFY_ADD_WATCH}))
  SET(USE_INOTIFY 1)
  MESSAGE(STATUS "Enable Inotify.")
ENDIF()
