[go: up one dir, main page]

Menu

[r105]: / trunk / configure.ac  Maximize  Restore  History

Download this file

198 lines (160 with data), 5.2 kB

dnl Process this file with autoconf to produce a configure script.
AC_INIT(scanbd, 1.2.1, wilhelm.meier@fh-kl.de)

# allow check that we are really in the source directory
AC_CONFIG_SRCDIR([src/scanbd/scanbd.c])
AC_CONFIG_MACRO_DIR([m4])

# Do not enforce GNU file conventions like ChangeLog README etc.
AM_INIT_AUTOMAKE( foreign )

# Initialize libtool support
LT_INIT

# Determine host information 
AC_CANONICAL_HOST

# Check for programs
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_CXX
AM_PROG_CC_C_O
# autoscan complains about this being missing, but autoreconf thinks it is superfluous
# AC_PROG_RANLIB

# The dlopen() function is in the C library for *BSD and in
# libdl on GLIBC-based systems

AC_SEARCH_LIBS([dlopen], [dl dld], [], [
  AC_MSG_ERROR([unable to find the dlopen() function])
])

# Check for required functions
AC_CHECK_FUNCS([alarm dup2 ftruncate getcwd memset putenv regcomp strdup strerror],
		[], AC_MSG_ERROR([Required function is missing ]))

# Check for required header files
AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netinet/in.h sys/socket.h sys/time.h syslog.h],
		[], AC_MSG_ERROR([Required header file is missing ]))

#  check for required types

AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
AC_TYPE_PID_T

# We define these to make autoscan happy, but we do not use the results
AC_FUNC_CHOWN
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_HEADER_STDBOOL


OS_CFLAGS="-Wall -Wextra -std=c99 -g"

dnl check for optional headers
AC_CHECK_HEADERS(linux/limits.h \
		 utmp.h \
		 utmpx.h) 

# check for mandatory dependencies 
#=================================

# check for libconfuse
PKG_CHECK_MODULES([CONFUSE], [libconfuse])

# check for dbus
PKG_CHECK_MODULES([DBUS], [dbus-1])

dnl Check for udev and if we do not have it, check for hal
PKG_CHECK_MODULES([UDEV],[libudev],
	[AC_DEFINE([USE_UDEV], [1], [Use UDEV])],
	[PKG_CHECK_MODULES([HAL], [hal],
		[AC_DEFINE([USE_HAL], [1], [Use HAL])],
		[AC_MSG_WARN([Neither Udev nor Hal are found, dynamic detection of scanners is not supported!])]
	)]
)

# check configuration options 
#============================

# scanbd configurationdir
AC_ARG_WITH(scanbdconfdir,
	AC_HELP_STRING([--with-scanbdconfdir=DIR],
		[ scanbd configuration directory (PREFIX/etc/scanbd)]),
	[SCANBD_CFG_DIR="${withval}"],
	[SCANBD_CFG_DIR="${sysconfdir}/scanbd"])
AC_SUBST(SCANBD_CFG_DIR)

# scanbuttond configurationdir
AC_ARG_WITH(scanbuttondconfdir,
	AC_HELP_STRING([--with-scanbuttondconfdir=DIR],
		[ scanbuttond backend configuration directory (SCANBDCONFDIR/scanbuttond/backend)]),
	[SCANBUTTOND_CFG_DIR="${withval}"],
	[SCANBUTTOND_CFG_DIR="$SCANBD_CFG_DIR/scanbuttond/backend"])
AC_SUBST(SCANBUTTOND_CFG_DIR)

# check for Werror
EXTRA_CFLAGS=""
AC_ARG_ENABLE(Werror,
        AC_HELP_STRING([--disable-Werror], [don't use gcc's -Werror option when building]))

if test x"${enable_Werror}" != "xno"
then
        EXTRA_CFLAGS+="-Werror"
fi

# shall we set NDEBUG?
AC_ARG_ENABLE(debug,
	AC_HELP_STRING([--disable-debug], [disable debugging code (NDEBUG)]))

if test x"${enable_debug}" == "xno"
then
	EXTRA_CFLAGS+=" -DNDEBUG"
fi

# check for enable-scanbuttond
AC_ARG_ENABLE(scanbuttond,
	AC_HELP_STRING([--enable-scanbuttond], [Use scanbuttond instead of Sane]))

if test x"${enable_scanbuttond}" == "xyes"
then
	use_scanbuttond=yes
	# Check for libusb except for FreeBSD that does not have libusb.pc
	if test `uname` == "FreeBSD"
	then
		if test x"${LIBUSB_CFLAGS}" == "x"
		then
			LIBUSB_CFLAGS="-I/usr/include "
		fi
		if test x"${LIBUSB_LIBS}" == "x"
		then
			LIBUSB_LIBS="-L/usr/lib -lusb "
		fi
		AC_SUBST(LIBUSB_CFLAGS)
		AC_SUBST(LIBUSB_LIBS)
	else
		PKG_CHECK_MODULES([LIBUSB], [libusb])
	fi

	SCANNER_CFLAGS="-DUSE_SCANBUTTOND"

	AC_DEFINE([USE_SCANBUTTOND], [1], ["Use scanbuttond"])
	
else
	use_sane=yes
	AC_DEFINE([USE_SANE], [1], [Use Sane])
	PKG_CHECK_MODULES([SANE], [sane-backends >= 1.0],
		[test_sane_config=no],
		[test_sane_config=yes])
fi

# fallback to usage of sane-config if pkg-config fails
if test x"${use_sane}" == "xyes" -a x"${test_sane_config}" == "xyes" 
then
	if test x"${SANE_LIBS}" == "x" -a  x"${SANE_CFLAGS}" = "x"
	then
		AC_CHECK_PROG([SANE_CONFIG], [sane-config], sane-config, no)
		if test x"${SANE_CONFIG}" = "xno"
		then
			AC_MSG_ERROR([Cannot find configuration for sane using pkg-config and sane-config does not exist])
		fi

		SANE_LIBS=`sane-config --libs`
		SANE_CFLAGS=`sane-config --cflags`
	fi
fi

AM_CONDITIONAL(USE_SANE, test "x$use_sane" == "xyes")
AM_CONDITIONAL(USE_SCANBUTTOND, test "x$use_scanbuttond" == xyes)

# define substitutions to be applied in the output
AC_SUBST([OS_CFLAGS])
AC_SUBST([OS_CPPFLAGS])
AC_SUBST([EXTRA_CFLAGS])

# header file that contains output from configure
# We do not use it now, so all flags are set as -D on the compiler command line
# AC_CONFIG_HEADERS([config.h])

# Generate the output files
AC_OUTPUT([
		Makefile 
		src/scanbd/Makefile 
		src/scanbuttond/Makefile 
		src/scanbuttond/backends/Makefile 
		src/scanbuttond/interface/Makefile 
		src/scanbuttond/include/Makefile
		integration/Makefile
		contrib/Makefile
		doc/Makefile
		conf/Makefile
		scripts/Makefile
])