#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT([unicap],[1.0],[arne@unicap-imaging.org])
AM_CONFIG_HEADER(config.h)

#   1. Start with version information of `0:0:0' for each libtool library.
#   2. Update the version information only immediately before a public release of your software. More frequent updates are unnecessary, and only guarantee that the current interface number gets larger faster.
#   3. If the library source code has changed at all since the last update, then increment revision (`c:r:a' becomes `c:r+1:a').
#   4. If any interfaces have been added, removed, or changed since the last update, increment current, and set revision to 0.
#   5. If any interfaces have been added since the last public release, then increment age.
#   6. If any interfaces have been removed since the last public release, then set age to 0. 
lt_major=3
lt_revision=8
lt_age=1

unicap_major_version=0
unicap_minor_version=9
unicap_micro_version=3
unicap_prerelease=
dist_version=$unicap_major_version.$unicap_minor_version.$unicap_micro_version$unicap_prerelease

#lt_major - lt_age
pkg_version=2

AM_INIT_AUTOMAKE(unicap, $dist_version)

AC_SUBST(lt_major)
AC_SUBST(lt_revision)
AC_SUBST(lt_age)
AC_SUBST(unicap_major_version)
AC_SUBST(unicap_minor_version)
AC_SUBST(unicap_micro_version)
AC_SUBST(dist_version)
AC_SUBST(pkg_version)
	
AC_CONFIG_MACRO_DIR(m4)

# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_LIBTOOL
AM_PROG_LIBTOOL

# Checks for header files.
#AC_HEADER_DIRENT
#AC_HEADER_STDC
#AC_CHECK_HEADERS([fcntl.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/time.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
#AC_C_CONST
#AC_TYPE_SIZE_T
#AC_HEADER_TIME
#AC_C_VOLATILE



# Checks for library functions.
#AC_FUNC_CLOSEDIR_VOID
#AC_PROG_GCC_TRADITIONAL
#AC_FUNC_MALLOC
#AC_FUNC_MMAP
#AC_CHECK_FUNCS([atexit bzero gettimeofday memset munmap strerror strncasecmp strstr])


#
# Intltool
#
IT_PROG_INTLTOOL([0.35.0])

#
# Gettext
#
GETTEXT_PACKAGE=unicap
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Gettext Package])

AM_GNU_GETTEXT([external])


GTK_DOC_CHECK(1.4)

pkg_modules="gtk+-2.0 >= 2.6.0"
PKG_CHECK_MODULES(GTK_PACKAGE, [$pkg_modules], HAVE_GTK2="yes", HAVE_GTK2="no" )

pkg_modules="glib-2.0"
PKG_CHECK_MODULES(GLIB_PACKAGE, [$pkg_modules], HAVE_GLIB="yes", HAVE_GLIB="no")

# Disable deprecated APIs

GTK_CPPFLAGS="-Wall"

AC_MSG_CHECKING([if GLib is version 2.11.0 or newer])
if $PKG_CONFIG --atleast-version=2.11.0 glib-2.0; then
  have_glib_2_11=yes
else
  have_glib_2_11=no
fi
AC_MSG_RESULT($have_glib_2_11)

if test "x$have_glib_2_11" != "xyes"; then
  GTK_CPPFLAGS="${GTK_CPPFLAGS} -DG_DISABLE_DEPRECATED"
fi

AC_MSG_CHECKING([if GTK+ is version 2.9.0 or newer])
if $PKG_CONFIG --atleast-version=2.9.0 gtk+-2.0; then
  have_gtk_2_9=yes
else
  have_gtk_2_9=no
fi
AC_MSG_RESULT($have_gtk_2_9)

if test "x$have_gtk_2_9" != "xyes"; then
  GTK_CPPFLAGS="${GTK_CPPFLAGS} -DGDK_PIXBUF_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
fi

# Require multihead safe API
GTK_CPPFLAGS="${GTK_CPPFLAGS} -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE"

AC_SUBST(GTK_CPPFLAGS)

PKG_CHECK_MODULES(PANGO_PACKAGE, "pangoft2", HAVE_PANGOFT2=yes, HAVE_PANGOFT2=no)

UCIL_CODEC_NONE="none"

UCIL_AVCODEC=""


AC_ARG_ENABLE(ucil-avcodec, 
		     AS_HELP_STRING( [--enable-ucil-avcodec],
				     [Enable avcodec support] ), 
	      {
		if test "x$enableval" != "xno"; then
		   USE_AVCODEC=true
		else
		   USE_AVCODEC=
		fi
	      }, 
	      USE_AVCODEC= )

UCIL_AVCODEC=""
if [[ $USE_AVCODEC ]] ; then
   PKG_CHECK_MODULES( AVCODEC_PACKAGE, "libavcodec", HAVE_AVCODEC=1, HAVE_AVCODEC= )
   
   if [[ $HAVE_AVCODEC ]]; then
      UCIL_AVCODEC="avcodec"
      UCIL_CODEC_NONE=""
      AC_DEFINE( [HAVE_AVCODEC], 1, Define to use avcodec )
   else
      AC_DEFINE( [HAVE_AVCODEC], 0, Define to use avcodec )
   fi
else
   AC_DEFINE( [HAVE_AVCODEC], 0, Define to use avcodec )
fi
AM_CONDITIONAL(HAVE_AVCODEC, test x$UCIL_AVCODEC == "xavcodec" )


AC_ARG_ENABLE(ucil-theora, 
		     AS_HELP_STRING( [--enable-ucil-theora],
				     [Enable ogg/theora support] ), 
	      {
		if test "x$enableval" != "xno"; then
		   USE_THEORA=true
		else
		   USE_THEORA=
		fi
	      }, 
	      USE_THEORA=true )

UCIL_THEORA=""
if [[ $USE_THEORA ]] ; then
   PKG_CHECK_MODULES(THEORA_PACKAGE, "ogg theora vorbis vorbisenc", HAVE_THEORA=1, HAVE_THEORA= )
   
   if [[ $HAVE_THEORA ]]; then
      UCIL_THEORA="ogg/theora"
      UCIL_CODEC_NONE=""
      AC_DEFINE( HAVE_THEORA, 1, Define to use theora video support )
   else
      AC_DEFINE( HAVE_THEORA, 0, Define to use theora video support )
   fi
else
   AC_DEFINE( HAVE_THEORA, 0, Define to use theora video support )
fi
AM_CONDITIONAL(HAVE_THEORA, test x$UCIL_THEORA == "xogg/theora" )


AC_ARG_ENABLE(ucil-alsa, 
		     AS_HELP_STRING( [--enable-ucil-alsa],
				     [Enable alsa sound support] ), 
	      {
		if test "x$enableval" != "xno"; then
		   USE_ALSA=true
		else
		   USE_ALSA=
		fi
	      }, 
	      USE_ALSA=true )

UCIL_ALSA=""
if [[ $USE_ALSA ]] ; then
   PKG_CHECK_MODULES(ALSA_PACKAGE, "alsa", HAVE_ALSA=1, HAVE_ALSA= )
   
   if [[ $HAVE_ALSA ]]; then
      UCIL_ALSA="alsa"
      UCIL_CODEC_NONE=""
      AC_DEFINE( HAVE_ALSA, 1, Define to use alsa sound support )
   else
      AC_DEFINE( HAVE_ALSA, 0, Define to use alsa sound support )
   fi
else
   AC_DEFINE( HAVE_ALSA, 0, Define to use alsa sound support )
fi
AM_CONDITIONAL(HAVE_ALSA, test x$UCIL_ALSA == "xalsa" )



AC_ARG_ENABLE(ucil-png, 
		     AS_HELP_STRING( [--enable-ucil-png],
				     [Enable PNG support] ), 
	      {
		if test "x$enableval" != "xno"; then
		   USE_PNG=true
		else
		   USE_PNG=
		fi
	      }, 
	      USE_PNG=true )

UCIL_PNG=""
if [[ $USE_PNG ]] ; then
   PKG_CHECK_MODULES(PNG_PACKAGE, "libpng", HAVE_PNG=1, HAVE_PNG= )
   
   if [[ $HAVE_PNG ]]; then
      UCIL_PNG="png"
      AC_DEFINE( HAVE_PNG, 1, Define to compile in PNG support )
   else
      AC_DEFINE( HAVE_PNG, 0, Define to compile in PNG support )
   fi
else
   AC_DEFINE( HAVE_PNG, 0, Define to compile in PNG support )
fi
AM_CONDITIONAL(HAVE_PNG, test x$UCIL_PNG == "xpng" )





# X11 checks



AC_PATH_XTRA
if test "-DX_DISPLAY_MISSING" = "$X_CFLAGS"; then
  AC_MSG_ERROR(cannot find X11)
fi
# Force inclusion of the common path
if test "x`echo $X_LIBS | grep /usr/X11R6/lib`" = "x"; then
  X_LIBS="$X_LIBS -L/usr/X11R6/lib"
fi
AC_SUBST(X_CFLAGS)
AC_SUBST(X_PRE_LIBS)
AC_SUBST(X_EXTRA_LIBS)
AC_SUBST(X_LIBS)
AC_SUBST(x_libraries)

# Check for the Xv extension
XV_PRESENT=""
AC_CHECK_LIB(Xv, XvShmPutImage, XV_PRESENT="yes",, $X_LIBS -lXext)
if test "x$XV_PRESENT" = "xyes"; then
  AC_DEFINE(HAVE_LIBXV, 1, [Define if XVideo lib is present])
  X_XV_LIBS="-lXv -lXext"
  AC_SUBST(X_XV_LIBS)
fi

# Check for SDL
#SDL_PRESENT=""
#AC_CHECK_LIB( SDL, SDL_Init, SDL_PRESENT="yes",, $SDL_LIBS -lSDL )
#if test "x$SDL_PRESENT" = "xyes"; then
#  AC_DEFINE(HAVE_LIBSDL, 1, [Define if SDL lib is present])
#  SDL_LIBS="-lSDL"
#  AC_SUBST(SDL_LIBS)
#fi

# Check for dl
DL_PRESENT=""
AC_CHECK_LIB( dl, dlopen, DL_PRESENT="yes",, $DL_LIBS -ldl )
if test "x$DL_PRESENT" = "xyes"; then
  AC_DEFINE(HAVE_LIBDL, 1, [Define if DL lib is present])
  DL_LIBS="-ldl"
  AC_SUBST(DL_LIBS)
fi

# Check for libm
M_PRESENT=""
AC_CHECK_LIB( m, sin, M_PRESENT="yes",, $M_LIBS -lm )
if test "x$M_PRESENT" = "xyes"; then
  AC_DEFINE(HAVE_LIBM, 1, [Define if libm is present])
  M_LIBS="-lm"
  AC_SUBST(M_LIBS)
fi

# Check for pthread
PTHREAD_PRESENT=""
AC_CHECK_LIB( pthread, pthread_create, PTHREAD_PRESENT="yes",, $PTHREAD_LIBS -lpthread )
if test "x$PTHREAD_PRESENT" = "xyes"; then
  AC_DEFINE(HAVE_LIBPTHREAD, 1, [Define if libpthread is present])
  PTHREAD_LIBS="-lpthread"
  AC_SUBST(PTHREAD_LIBS)
fi

# Check for rt
RT_PRESENT=""
AC_CHECK_LIB( rt, shm_open, RT_PRESENT="yes",, $RT_LIBS -lrt )
if test "x$RT_PRESENT" = "xyes"; then
  AC_DEFINE(HAVE_LIBRT, 1, [Define if librt is present])
  RT_LIBS="-lrt"
  AC_SUBST(RT_LIBS)
fi


# Check for raw1394
pkg_modules="libraw1394 <= 1.0.0"
PKG_CHECK_MODULES(LIBRAW1394_PACKAGE, [$pkg_modules], HAVE_LIBRAW1394="yes";LIBRAW1394_VERSION="RAW1394_1_0_API", HAVE_LIBRAW1394="no" )

if( test "$HAVE_LIBRAW1394" != "yes" ); then
    pkg_modules="libraw1394 >= 1.1.0"
    PKG_CHECK_MODULES(LIBRAW1394_PACKAGE, [$pkg_modules], HAVE_LIBRAW1394="yes";LIBRAW1394_VERSION="RAW1394_1_1_API", HAVE_LIBRAW1394="no" )
    if( test "$HAVE_LIBRAW1394" == "yes" ); then
	AC_DEFINE(RAW1394_1_1_API, 1, [Define if using the new raw1394 API])
    fi
else
    AC_DEFINE(RAW1394_1_0_API, 1, [Define if using the old raw1394 API])
fi
AC_SUBST(LIBRAW1394_PACKAGE_CFLAGS)
AC_SUBST(LIBRAW1394_PACKAGE_LIBS)
AC_SUBST(LIBRAW1394_VERSION)

AC_ARG_ENABLE(debug-vid21394, 
		     AS_HELP_STRING( [--enable-debug-vid21394],
				     [Enable debug output] ), 
	      {
		if test "x$enableval" != "xno"; then
		   AC_DEFINE( VID21394_DEBUG, 1, [Define to enable debug output] )
		else
		   AC_DEFINE( VID21394_DEBUG, 0, [Define to enable debug output] )
		fi
	      }, 
	      AC_DEFINE( VID21394_DEBUG, 0, [Define to enable debug output] ) )

AC_ARG_ENABLE(vid21394-bootload, 
				 AS_HELP_STRING( [--enable-vid21394-bootload], 
						 [Enable vid21394 bootload support ( dangerous! )] ), 
	      {
	        if test "x$enableval" != "xno"; then
		   AC_DEFINE( VID21394_BOOTLOAD, 1, [Define to enable bootload support] )
		else
		   AC_DEFINE( VID21394_BOOTLOAD, 0, [Define to enable bootload support] )
		fi
	      }, 
       	      AC_DEFINE( VID21394_BOOTLOAD, 0, [Define to enable bootload support] ) )

VID21394_VISCA="no"

AC_ARG_ENABLE(vid21394-visca, 
				 AS_HELP_STRING( [--enable-vid21394-visca], 
						 [Enable vid21394 visca protocol support] ), 
	      {
	        if test "x$enableval" != "xno"; then
		   AC_DEFINE( VID21394_VISCA, 1, [Define to enable vid21394 visca support] )
		   VID21394_VISCA="yes"
		else
		   AC_DEFINE( VID21394_VISCA, 0, [Define to enable vid21394 visca support] )
		fi
	      }, 
       	      AC_DEFINE( VID21394_VISCA, 0, [Define to enable vid21394 visca support] ) )

AM_CONDITIONAL(VID21394_VISCA, test x$VID21394_VISCA = xyes )

VID21394_21CF04="no"

AC_ARG_ENABLE(vid21394-21cf04, 
				 AS_HELP_STRING( [--enable-vid21394-21cf04], 
						 [Enable autodetection of DFK 21CF04 camera module ( default=yes )] ), 
	      {
	        if test "x$enableval" != "xno"; then
		   AC_DEFINE( VID21394_DETECT_21CF04, 1, [Define to enable autodetection of DFK 21CF04 camera module] )
		else
		   AC_DEFINE( VID21394_DETECT_21CF04, 0, [Define to enable autodetection of DFK 21CF04 camera module] )
		fi
	      }, 
       	      AC_DEFINE( VID21394_DETECT_21CF04, 1, [Define to enable autodetection of DFK 21CF04 camera module] ) )



AC_ARG_ENABLE(debug-dcam, 
		     AS_HELP_STRING( [--enable-debug-dcam],
				     [Enable debug output] ), 
	      {
		if test "x$enableval" != "xno"; then
		   AC_DEFINE( DCAM_DEBUG, 1, [Define to enable debug output] )
		else
		   AC_DEFINE( DCAM_DEBUG, 0, [Define to enable debug output] )
		fi
	      }, 
	      AC_DEFINE( DCAM_DEBUG, 0, [Define to enable debug output] ) )

AC_ARG_ENABLE(debug-v4l, 
		     AS_HELP_STRING( [--enable-debug-v4l],
				     [Enable debug output] ), 
	      {
		if test "x$enableval" != "xno"; then
		   AC_DEFINE( V4L_DEBUG, 1, [Define to enable debug output] )
		else
		   AC_DEFINE( V4L_DEBUG, 0, [Define to enable debug output] )
		fi
	      }, 
	      AC_DEFINE( V4L_DEBUG, 0, [Define to enable debug output] ) )

AC_ARG_ENABLE(debug-v4l2, 
		     AS_HELP_STRING( [--enable-debug-v4l2],
				     [Enable debug output] ), 
	      {
		if test "x$enableval" != "xno"; then
		   AC_DEFINE( V4L2_DEBUG, 1, [Define to enable debug output] )
		else
		   AC_DEFINE( V4L2_DEBUG, 0, [Define to enable debug output] )
		fi
	      }, 
	      AC_DEFINE( V4L2_DEBUG, 0, [Define to enable debug output] ) )

AC_ARG_ENABLE(debug-thing, 
		     AS_HELP_STRING( [--enable-debug-thing],
				     [Enable debug output] ), 
	      {
		if test "x$enableval" != "xno"; then
		   AC_DEFINE( THING_DEBUG, 1, [Define to enable debug output] )
		else
		   AC_DEFINE( THING_DEBUG, 0, [Define to enable debug output] )
		fi
	      }, 
	      AC_DEFINE( THING_DEBUG, 0, [Define to enable debug output] ) )

AC_ARG_ENABLE(debug-unicap, 
		     AS_HELP_STRING( [--enable-debug-unicap],
				     [Enable debug output] ), 
	      {
		if test "x$enableval" != "xno"; then
		   AC_DEFINE( UNICAP_DEBUG, 1, [Define to enable debug output] )
		else
		   AC_DEFINE( UNICAP_DEBUG, 0, [Define to enable debug output] )
		fi
	      }, 
	      AC_DEFINE( UNICAP_DEBUG, 0, [Define to enable debug output] ) )

AC_ARG_ENABLE(debug-unicapgtk, 
		     AS_HELP_STRING( [--enable-debug-unicapgtk],
				     [Enable debug output] ), 
	      {
		if test "x$enableval" != "xno"; then
		   AC_DEFINE( UNICAPGTK_DEBUG, 1, [Define to enable debug output] )
		else
		   AC_DEFINE( UNICAPGTK_DEBUG, 0, [Define to enable debug output] )
		fi
	      }, 
	      AC_DEFINE( UNICAPGTK_DEBUG, 0, [Define to enable debug output] ) )

AC_ARG_ENABLE(debug-ucil, 
		     AS_HELP_STRING( [--enable-debug-ucil],
				     [Enable debug output] ), 
	      {
		if test "x$enableval" != "xno"; then
		   AC_DEFINE( UCIL_DEBUG, 1, [Define to enable debug output] )
		else
		   AC_DEFINE( UCIL_DEBUG, 0, [Define to enable debug output] )
		fi
	      }, 
	      AC_DEFINE( UCIL_DEBUG, 0, [Define to enable debug output] ) )

AC_ARG_ENABLE(unicapgtk, 
	      AS_HELP_STRING( [--enable-unicapgtk], 
			      [build libunicapgtk: A widget set for easy GTK+ integration \[default=yes\]] ), 
	      {
		if test "x$enableval" != "xno"; then
			UNICAPGTK="yes";
		else
			UNICAPGTK="no";
		fi
	       },
	       UNICAPGTK="yes" )

if test "$UNICAPGTK" = "yes"; then
#	if test "$HAVE_GCONF" != "yes"; then
#		UNICAPGTK="no ( required GConf not found )"
#	fi
	if test "$HAVE_GTK2" != "yes"; then
		UNICAPGTK="no ( required GTK+ not found )"
	fi
	if test "x$XV_PRESENT" != "xyes"; then
		UNICAPGTK="no ( required Xv extensions not found )"
	fi

	if test "x$HAVE_PANGOFT2" != "xyes"; then
		UNICAPGTK="no ( required pangoft2 package not found )"
	fi
fi


AC_ARG_ENABLE(ucil, 
	      AS_HELP_STRING( [--enable-ucil], 
			      [build libucil: unicap imaging library \[default=yes\]] ), 
	      {
		if test "x$enableval" != "xno"; then
			UCIL="yes";
		else
			UCIL="no";
		fi
	       },
	       UCIL="yes" )

if test "$UCIL" = "yes"; then 
	if test "$HAVE_GLIB" != "yes" ; then
	   UCIL="no ( missing glib )"
	fi
	if test "x$HAVE_PANGOFT2" != "xyes"; then
		UCIL="no ( required pangoft2 package not found )"
	fi
fi

AC_ARG_ENABLE(vid21394, 
	      AS_HELP_STRING( [--enable-vid21394], 
		              [build plugin for video-2-1394 capture device \[default=yes\]] ),
	      {
	      	if test "x$enableval" != "xno"; then
			VID21394="yes";
	      	else
			VID21394="no";
	      	fi
	      },
	      VID21394="yes" )
if test "$VID21394" = "yes"; then
	if test "$HAVE_LIBRAW1394" != "yes"; then
		AC_MSG_RESULT([ video-to-1394 plugin requires recent libraw1394! ])
		VID21394="no ( missing libraw1394 )"
	fi
fi

if test "x$VID21394" == "xyes"; then
   AC_DEFINE( BUILD_VID21394, 1, [Define to build vid21394 cpi] )
fi

AC_ARG_ENABLE(dcam, 
	      AS_HELP_STRING( [--enable-dcam], 
		              [build plugin for IIDC 1394 cameras \[default=yes\]] ),
	      {
	      	if test "x$enableval" != "xno"; then
			DCAM="yes";
	      	else
			DCAM="no";
	      	fi
	      },
	      DCAM="yes" )
if test "$DCAM" = "yes"; then
	if test "$HAVE_LIBRAW1394" != "yes"; then
		AC_MSG_RESULT([ IIDC 1394 camera plugin requires recent libraw1394! ])
		DCAM="no ( missing libraw1394 )"
	fi
fi

if test "x$DCAM" == "xyes"; then
   AC_DEFINE( BUILD_DCAM, 1, [Define to build dcam cpi] )
fi


AC_ARG_ENABLE(v4l, 
	      AS_HELP_STRING( [--enable-v4l], 
		              [build plugin for video-4-linux ( version 1 ) interface \[default=yes\]] ),
	      {
	      	if test "x$enableval" != "xno"; then
			V4L="yes";
	      	else
			V4L="no";
	      	fi
	      },
	      V4L="yes" )

if test "x$V4L" == "xyes"; then
   AC_DEFINE( BUILD_V4L, 1, [Define to build v4l cpi] )
fi


AC_ARG_ENABLE(v4l2, 
	      AS_HELP_STRING( [--enable-v4l2], 
		              [build plugin for video-4-linux ( version 2 ) interface \[default=yes\]] ),
	      {
	      	if test "x$enableval" != "xno"; then
			V4L2="yes";
	      	else
			V4L2="no";
	      	fi
	      },
	      V4L2="yes" )

if test "x$V4L2" == "xyes"; then
   AC_DEFINE( BUILD_V4L2, 1, [Define to build v4l2 cpi] )
fi

AC_ARG_ENABLE(libv4l, 
	      AS_HELP_STRING( [--enable-libv4l],
	      		      [use libv4l to communicate with v4l2 devices \[default=no\]] ),
	      {
		if test "x$enableval" != "xno"; then
		   USE_LIBV4L="yes";
		else
		   USE_LIBV4L="no";
		fi
	      },
	      USE_LIBV4L="no" )

if test "x$USE_LIBV4L" == "xyes"; then
   PKG_CHECK_MODULES(LIBV4L, libv4l2, HAVE_LIBV4L="yes", HAVE_LIBV4L="no")
   if test "x$HAVE_LIBV4L" == "xyes"; then
      AC_MSG_RESULT( enable enable enable )
      AC_DEFINE( [USE_LIBV4L], 1, Define to enable libv4l support )
   else
      AC_DEFINE( [USE_LIBV4L], 0, Define to enable libv4l support )
   fi
fi
AM_CONDITIONAL(HAVE_LIBV4L, test x$HAVE_LIBV4L == "xyes" )

AC_ARG_ENABLE(thing, 
	      AS_HELP_STRING( [--enable-thing], 
		              [build plugin for a dummy device ( usefull for debugging ) \[default=no\]] ),
	      {
	      	if test "x$enableval" != "xno"; then
			THING="yes"
			THING_SUBDIR="thing"
	      	else
			THING="no";
	      	fi
	      },
	      THING="no" )

AC_ARG_ENABLE(static-cpi, 
			      AS_HELP_STRING( [--enable-static-cpi],  
					      [Static link the cpi modules ( default=no )] ),
	      {
	        if test "x$enableval" == "xyes"; then
		   AC_DEFINE( ENABLE_STATIC_CPI, 1, [Define to enable static cpi])
		   ENABLE_STATIC_CPI="yes";
		fi   
	      }, ENABLE_STATIC_CPI="no" )

AM_CONDITIONAL(ENABLE_STATIC_CPI, test x$ENABLE_STATIC_CPI = xyes )

AC_ARG_ENABLE(thread-locking, 
			       AS_HELP_STRING( [--enable-thread-locking],
					       [ (default=yes) ] ), 
	       {
	         if test "x$enableval" == "xyes"; then
		    AC_DEFINE( UNICAP_THREAD_LOCKING, 1, [Define to enable thread locking] )
		 fi
	       }, AC_DEFINE( UNICAP_THREAD_LOCKING, 1, [Define to enable thread locking] ) )

AC_ARG_ENABLE(unicap-threads, 
			      AS_HELP_STRING( [--enable-unicap-threads], 
					      [ (default=yes) ] ), 
	       {
	         if test "x$enableval" == "xyes"; then
		    AC_DEFINE( UNICAP_THREADS, 1, [Define to enable threads] )
		 fi
	       }, AC_DEFINE( UNICAP_THREADS, 1, [Define to enable threads] ) )


AM_CONDITIONAL(BUILD_VID21394, test x$VID21394 = xyes )
AM_CONDITIONAL(BUILD_DCAM, test x$DCAM = xyes )
AM_CONDITIONAL(BUILD_V4L, test x$V4L = xyes )
AM_CONDITIONAL(BUILD_V4L2, test x$V4L2 = xyes )
AM_CONDITIONAL(BUILD_THING, test x$THING = xyes )
AM_CONDITIONAL(BUILD_UNICAPGTK, test x$UNICAPGTK = xyes )
AM_CONDITIONAL(BUILD_UCIL, test x$UCIL = xyes )

AC_CONFIG_FILES([ include/unicap_version.h libunicapgtk/unicapgtk_version.h libucil/ucil_version.h  po/Makefile.in])
AC_CONFIG_FILES([ libucil/Makefile libucil/libucil.pc ])
AC_CONFIG_FILES([ libunicap/Makefile libunicap/libunicap.pc ])
AC_CONFIG_FILES([ libunicapgtk/Makefile libunicapgtk/libunicapgtk.pc ])
AC_CONFIG_FILES([ cpi/vid21394/Makefile ])
AC_CONFIG_FILES([ cpi/dcam/Makefile ])
AC_CONFIG_FILES([ cpi/v4l/Makefile ])
AC_CONFIG_FILES([ cpi/v4l2cpi/Makefile ])
AC_CONFIG_FILES([ cpi/thing/Makefile ])
AC_CONFIG_FILES([ Makefile include/Makefile ])
AC_CONFIG_FILES([ cpi/Makefile cpi/include/Makefile ])
AC_CONFIG_FILES([ tests/Makefile ])
AC_CONFIG_FILES([ doc/Makefile doc/reference/libunicapgtk/Makefile doc/reference/libunicap/Makefile doc/reference/libucil/Makefile])
AC_OUTPUT

if test x$VID21394_VISCA = xyes; then
	VID21394="$VID21394 with visca support"
fi

if test x$HAVE_LIBV4L == xyes && test x$V4L2 == xyes; then
   V4L2="yes, with libv4l2 support"
fi
   

AC_MSG_RESULT([ ****************************************************** ])
AC_MSG_RESULT([              Unicap $dist_version     ])
AC_MSG_RESULT([ ****************************************************** ])
AC_MSG_RESULT([  This software is distributed under the terms and ])
AC_MSG_RESULT([  conditions of the GNU GENERAL PUBLIC LICENSE ( GPL ). ])
AC_MSG_RESULT([  See the file COPYING for the full license text. ])
AC_MSG_RESULT([ ****************************************************** ])
AC_MSG_RESULT([])
AC_MSG_RESULT([Configuration: ])
AC_MSG_RESULT([  libraw1394 version: $LIBRAW1394_VERSION ])
AC_MSG_RESULT([  installation goes to: $prefix ])
#AC_MSG_RESULT([  static cpi: $ENABLE_STATIC_CPI ])
AC_MSG_RESULT([])
AC_MSG_RESULT([Plugins: ])
AC_MSG_RESULT([  video-to-1394:      $VID21394 ])
AC_MSG_RESULT([  IIDC 1394 camera:   $DCAM ])
AC_MSG_RESULT([  video-4-linux:      $V4L ])
AC_MSG_RESULT([  video-4-linux v2:   $V4L2 ])
AC_MSG_RESULT([])
AC_MSG_RESULT([Additional libraries: ])
AC_MSG_RESULT([  libunicapgtk:       $UNICAPGTK ])
AC_MSG_RESULT([  libucil:            $UCIL ])
AC_MSG_RESULT([  UCIL modules: $UCIL_CODEC_NONE $UCIL_THEORA $UCIL_AVCODEC $UCIL_ALSA $UCIL_PNG ])
AC_MSG_RESULT([])
AC_MSG_RESULT([ ****************************************************** ])
AC_MSG_RESULT([ ***  Please read the file README.troubleshooting   *** ])
AC_MSG_RESULT([ ***  if you have any trouble using this software.  *** ])
AC_MSG_RESULT([ ****************************************************** ])
AC_MSG_RESULT([])

