configure.ac 2.99 KB
AC_PREREQ(2.68)
AC_INIT([checkout_files],
	[0.0.1],
	[georg@steffers.org])
LT_INIT
AM_INIT_AUTOMAKE
AM_SILENT_RULES([no])
AC_COPYRIGHT([Copyright © 2000 Georg Hopp])
AC_REVISION([0.0.1])
AC_CONFIG_SRCDIR([inotify1.c])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_MACRO_DIR([m4])

AC_CANONICAL_HOST

use_inotify="yes"

# Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET

# Checks for header files.
AC_HEADER_STDC

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

# Checks for library functions.
AC_CHECK_FUNCS([memset malloc free read ioctl syscall select perror printf])

dnl We need to check if the right inotify version is accessible
AC_MSG_CHECKING([whether inotify is to be used for filemonitoring])
AC_ARG_ENABLE(inotify, 
 [  --disable-inotify             disable inotify in the ecore_file module],
 [
	if test "$enableval" == "yes"; then  
	  AC_MSG_RESULT([yes])
	else
	  AC_MSG_RESULT([no - but we need it])
	  use_inotify="no"
	fi
 ], [
	AC_MSG_RESULT([yes])
 ]
)

dnl It's hard to find a good test on how to check the correct
dnl inotify version. They changed the headers a lot.
dnl in kernel 2.6.13 __NR_inotify_init was added to the defined syscalls
dnl in asm/unistd.h and IN_MOVE_SELF was added to linux/inotify.h
dnl so with this check you need a very new kernel and kernel-headers!
dnl On my gentoo, /usr/include/asm and /usr/include/linux are no symlinks
dnl into the current kernel tree....so i also try to find the includes
dnl under /usr/src/linux or under /usr/include/linux-`uname -r`
linux_rev=`uname -r`
INOTIFY_INCLUDES=
if test "x$use_inotify" = "xyes"; then
 AC_MSG_CHECKING([for sufficient inotify includes])
 AC_TRY_COMPILE(
	[
	  #include <asm/unistd.h>
	  #include <linux/inotify.h>
	],
	[ int a = __NR_inotify_init; int b = IN_MOVE_SELF; ],
	[
	  AC_DEFINE(HAVE_INOTIFY, 1, [ File monitoring with Inotify ])
	  an_inc=/usr/include
	], 
	[
     AC_TRY_COMPILE(
	    [
	      #include "/usr/src/linux/include/asm/unistd.h"
	      #include "/usr/src/linux/include/linux/inotify.h"
	    ],
	    [ int a = __NR_inotify_init; int b = IN_MOVE_SELF; ],
	    [
	      AC_DEFINE(HAVE_INOTIFY, 1, [ File monitoring with Inotify ])
			AC_DEFINE(IN_KERNEL, 1, [ blablabla ])
	      INOTIFY_INCLUDES=-I/usr/src/linux/include
			an_inc=/usr/src/linux/include
		 ],
	    [
         AC_TRY_COMPILE(
	        [
	          #include </usr/src/linux-$linux_rev/include/asm/unistd.h>
	          #include </usr/src/linux-$linux_rev/include/linux/inotify.h>
	        ],
	        [ int a = __NR_inotify_init; int b = IN_MOVE_SELF; ],
	        [
	          AC_DEFINE(HAVE_INOTIFY, 1, [ File monitoring with Inotify ])
				 AC_DEFINE(IN_KERNEL_UNAME, 1, [ blablabla ])
	          INOTIFY_INCLUDES=-I/usr/src/linux-$linux_rev/include
				 an_inc=/usr/src/linux-$linux_rev/include
			  ],
	        [
	          use_inotify="no"
				 an_inc="not found"
		     ]
			)
		 ]
	  )
	]
 )
 AC_MSG_RESULT([$an_inc])
 test "x$an_inc" == "xnot found" && exit
else
  exit
fi

AC_SUBST(INOTIFY_INCLUDES)

AC_CONFIG_FILES([Makefile])

AC_OUTPUT