configure.ac 4.47 KB
AC_PREREQ(2.59)
AC_INIT(scot, 0.0.3, BUG-REPORT-ADDRESS)
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_SRCDIR([src/cmdla.c])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE

AC_CANONICAL_HOST

# Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([getopt.h libintl.h locale.h stdlib.h string.h unistd.h wchar.h])
AX_CREATE_STDINT_H([include/scot/scot_int.h])


# Checks for libraries.
AM_GNU_GETTEXT([external])
AC_MSG_CHECKING([intl])
AC_MSG_RESULT([$LIBINTL])
AM_GNU_GETTEXT_VERSION(0.13.1)
localedir=`eval echo $datadir/locale`
AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir", [Name of gettext locale directory])
THREAD_LIB=
THREAD_CFLAGS=
AC_MSG_CHECKING([for Win32])
case "$host" in
   *-*-mingw*)
      win32="yes, use windows threads"
      pthread="pthreadGC2"
      SOCK_LIB="-lws2_32"
      ;;
   *)
      win32="no"
      pthread="pthread"
      SOCK_LIB=""
      ;;
esac
AC_MSG_RESULT([$win32])

AC_CHECK_LIB($pthread,pthread_create,
             THREAD_LIB=-l$pthread
             THREAD_CFLAGS="-DUSE_PTHREAD -DREENTRANT"
	     thread="PTHREAD",
	     THREAD_CFLAGS="-DUSE_WTHREAD"
	     thread="WTHREAD",)

AC_SUBST(SOCK_LIB)
AC_SUBST(THREAD_LIB)
AC_SUBST(THREAD_CFLAGS)

AM_PROG_CC_C_O

AM_CONDITIONAL(USE_THREADS, test "x$thread" != "x")
AM_CONDITIONAL(PTHREAD,     test "x$thread" == "xPTHREAD")
AM_CONDITIONAL(WTHREAD,     test "x$thread" == "xWTHREAD")
AM_CONDITIONAL(WIN32,       test "x$win32" != "xno")

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

# Checks for library functions.
AC_CHECK_FUNCS([memset setlocale])

dnl We need to check if the right inotify version is accessible
use_inotify="yes"
AC_MSG_CHECKING([whether inotify is to be used for filemonitoring])

if test "x$win32" == "xno"
then
 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=
 AC_MSG_CHECKING([for sufficient inotify includes])
 if test "x$use_inotify" = "xyes"; then
  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
  AC_MSG_RESULT(["Not used"])
 fi

 AC_SUBST(INOTIFY_INCLUDES)
else
 use_inotify="no"
 AC_MSG_RESULT([no])
fi

AM_CONDITIONAL(USE_INOTIFY, test "x$use_inotify" != "xno")


AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([src/Makefile])
AC_CONFIG_FILES([include/Makefile])
AC_CONFIG_FILES([test/Makefile])
AC_CONFIG_FILES([m4/Makefile])
AC_CONFIG_FILES([src/po/Makefile.in])
AC_CONFIG_FILES([test/po/Makefile.in])

AC_OUTPUT