# -*- mode: m4; -*- # Process this file with autoconf to produce a configure script AC_PREREQ(2.58) AC_INIT(pcsc-lite, 1.4.102) AC_CONFIG_SRCDIR(src/pcscdaemon.c) AM_INIT_AUTOMAKE(1.8) AM_CONFIG_HEADER(config.h) AC_CONFIG_MACRO_DIR(m4) AC_CANONICAL_HOST AC_PROG_CC AC_C_BIGENDIAN # Check for some target-specific stuff case "$host" in *-*-hpux*) CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE_EXTENDED" ;; *-*-solaris*) CPPFLAGS="$CPPFLAGS -I/usr/local/include" LDFLAGS="$LDFLAGS -L/usr/local/lib -R/usr/local/lib" need_dash_r=1 ;; *-*-sunos4*) CPPFLAGS="$CPPFLAGS -DSUNOS4" ;; *-*-aix*) CPPFLAGS="$CPPFLAGS -I/usr/local/include" LDFLAGS="$LDFLAGS -L/usr/local/lib" if (test "$LD" != "gcc" && test -z "$blibpath"); then blibpath="/usr/lib:/lib:/usr/local/lib" fi ;; *-*-osf*) CPPFLAGS="$CPPFLAGS -D_POSIX_PII_SOCKET" ;; *-*-darwin*) AC_SUBST(COREFOUNDATION) COREFOUNDATION="-Wl,-framework,CoreFoundation" AC_SUBST(IOKIT) IOKIT="-Wl,-framework,IOKit" if test "$GCC" = "yes"; then CFLAGS="$CFLAGS -no-cpp-precomp" fi use_libusb=no AC_MSG_WARN([libusb disabled on Darwin for pcsc-lite]) ;; esac # Options AM_MAINTAINER_MODE # Checks for programs AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET AM_PROG_LEX PKG_PROG_PKG_CONFIG AM_PROG_CC_C_O # Special check for pthread support ACX_PTHREAD( [ AC_DEFINE(HAVE_PTHREAD, 1, [Define if you have POSIX threads libraries and header files.]) ], [ AC_MSG_ERROR([POSIX thread support required]) ]) CC="$PTHREAD_CC" AC_SUBST(PTHREAD_LIBS) AC_SUBST(PTHREAD_CFLAGS) # Add libtool support AM_PROG_LIBTOOL # Automatically update the libtool script if it becomes out-of-date #AC_SUBST(LIBTOOL_DEPS) # Checks for header files AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_CHECK_HEADERS([getopt.h sys/filio.h syslog.h dl.h fcntl.h ]) # Checks for typedefs, structures, and compiler characteristics AC_C_CONST AC_TYPE_UID_T AC_TYPE_SIZE_T AC_HEADER_TIME # Checks for library functions AC_FUNC_ERROR_AT_LINE AC_FUNC_STAT AC_FUNC_VPRINTF AC_CHECK_FUNCS(daemon flock getopt_long nanosleep strerror vsnprintf) # strlcpy, strlcat from OpenBSD AC_CHECK_FUNCS(strlcpy strlcat) # C Compiler features AC_C_INLINE if test "$GCC" = "yes"; then CFLAGS="-Wall -fno-common $CFLAGS" fi # check if the compiler support -fvisibility=hidden (GCC >= 4) saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fvisibility=hidden" AC_MSG_CHECKING([for -fvisibility=hidden]) AC_COMPILE_IFELSE([char foo;], [ AC_MSG_RESULT([yes]) SYMBOL_VISIBILITY="-fvisibility=hidden" ], AC_MSG_RESULT([no])) CFLAGS="$saved_CFLAGS" AC_SUBST(SYMBOL_VISIBILITY) AC_SUBST(LIBDL) AC_CHECK_LIB(dl, dlopen, [LIBDL="$LIBDL -ldl" ac_cv_func_dlopen_ldl=yes], ac_cv_func_dlopen_ldl=no) # Use 'uname' output as an architecture define PCSC_ARCH=`uname` case "$PCSC_ARCH" in Darwin) PCSC_ARCH=MacOS ;; SunOS) PCSC_ARCH=Solaris ;; esac AC_DEFINE_UNQUOTED(PCSC_ARCH, "$PCSC_ARCH", [PC/SC target architecture]) PCSCLITE_FEATURES="${PCSCLITE_FEATURES} $PCSC_ARCH" # See if socket() is found from libsocket AC_CHECK_LIB(socket, socket, [LIBS="$LIBS -lsocket"]) # --enable-libhal AC_ARG_ENABLE(libhal, AC_HELP_STRING([--disable-libhal],[do not use libhal]), [ use_libhal="${enableval}" ], [ use_libhal="${use_libhal-yes}" ] ) # check if libhal is used if test "x$use_libhal" != xno ; then PKG_CHECK_MODULES(LIBHAL, hal, [], [ AC_MSG_ERROR([install libhal-dev or use --disable-libhal]) ]) saved_CPPFLAGS="$CPPFLAGS" saved_LIBS="$LIBS" CPPFLAGS="$CPPFLAGS $LIBHAL_CFLAGS" LIBS="$LDFLAGS $LIBHAL_LIBS" AC_CHECK_HEADERS(libhal.h, [], [ AC_MSG_ERROR([libhal.h not found, use ./configure LIBHAL_CFLAGS=...]) ]) LIBS="$LIBS $COREFOUNDATION $IOKIT" AC_MSG_CHECKING([for libhal_ctx_new]) AC_TRY_LINK_FUNC(libhal_ctx_new, [ AC_MSG_RESULT([yes]) ], [ AC_MSG_ERROR([libhal not found, use ./configure LIBHAL_LIBS=...]) ]) # everything needed for libhal support is present use_libhal=yes CPPFLAGS="$saved_CPPFLAGS" LIBS="$saved_LIBS" fi AC_SUBST(LIBHAL_CFLAGS) AC_SUBST(LIBHAL_LIBS) if test x$use_libhal = xyes; then AC_DEFINE(HAVE_LIBHAL, 1, [Libhal is available]) PCSCLITE_FEATURES="${PCSCLITE_FEATURES} libhal" fi # --enable-libusb AC_ARG_ENABLE(libusb, AC_HELP_STRING([--enable-libusb],[use libusb]), [ use_libusb="${enableval}" ], [ if test "x$use_libhal" = xyes ; then use_libusb="${use_libusb-no}" ; else use_libusb="${use_libusb-yes}" ; fi ] ) # check if libusb is used if test "x$use_libusb" != xno ; then if test "x$use_libhal" != xno ; then AC_MSG_ERROR([You can't use libhal _and_ libusb. Select only one.]) fi PKG_CHECK_MODULES(LIBUSB, libusb, [], [ AC_MSG_RESULT([no]) AC_CHECK_PROG([LIBUSBCONFIG], [libusb-config], [yes]) if test "$LIBUSBCONFIG" = "yes" ; then LIBUSB_CFLAGS="$LIBUSB_CFLAGS `libusb-config --cflags`" LIBUSB_LIBS="$LIBUSB_LIBS `libusb-config --libs`" else AC_MSG_WARN([libusb-config not found.]) fi ]) saved_CPPFLAGS="$CPPFLAGS" saved_LIBS="$LIBS" CPPFLAGS="$CPPFLAGS $LIBUSB_CFLAGS" LIBS="$LDFLAGS $LIBUSB_LIBS" AC_CHECK_HEADERS(usb.h, [], [ AC_MSG_ERROR([usb.h not found, use ./configure LIBUSB_CFLAGS=...]) ]) LIBS="$LIBS $COREFOUNDATION $IOKIT" AC_MSG_CHECKING([for usb_init]) AC_TRY_LINK_FUNC(usb_init, [ AC_MSG_RESULT([yes]) ], [ AC_MSG_ERROR([libusb not found, use ./configure LIBUSB_LIBS=...]) ]) AC_MSG_CHECKING([for usb_get_string_simple]) AC_TRY_LINK_FUNC(usb_get_string_simple, [ AC_MSG_RESULT([yes]) ], [ AC_MSG_ERROR([your libusb is too old. install version 0.1.7 or above]) ]) # everything needed for libusb support is present use_libusb=yes CPPFLAGS="$saved_CPPFLAGS" LIBS="$saved_LIBS" fi AC_SUBST(LIBUSB_CFLAGS) AC_SUBST(LIBUSB_LIBS) if test x$use_libusb = xyes; then AC_DEFINE(HAVE_LIBUSB, 1, [Libusb is available]) PCSCLITE_FEATURES="${PCSCLITE_FEATURES} libusb" fi # --enable-usbdropdir=DIR AC_ARG_ENABLE(usbdropdir, AC_HELP_STRING([--enable-usbdropdir=DIR],[directory containing USB drivers (default /usr/local/pcsc/drivers)]), [usbdropdir="${enableval}"], [usbdropdir=false]) if test x${usbdropdir} = xfalse ; then if test "x$prefix" != xNONE; then usbdropdir="$prefix/pcsc/drivers" else usbdropdir="$ac_default_prefix/pcsc/drivers" fi fi AC_DEFINE_UNQUOTED(PCSCLITE_HP_DROPDIR, "$usbdropdir", [directory containing USB drivers]) PCSCLITE_FEATURES="${PCSCLITE_FEATURES} usbdropdir=${usbdropdir}" # --enable-debugatr AC_ARG_ENABLE(debugatr, AC_HELP_STRING([--enable-debugatr],[enable ATR debug messages from pcscd]), [ case "${enableval}" in yes) debugatr=true ;; no) debugatr=false ;; *) AC_MSG_ERROR([bad value ${enableval} for --enable-debugatr]) ;; esac], [debugatr=false]) if test x${debugatr} = xtrue ; then AC_DEFINE(ATR_DEBUG, 1, [display ATR parsing debug messages.]) PCSCLITE_FEATURES="${PCSCLITE_FEATURES} debugatr" fi # --enable-scf AC_ARG_ENABLE(scf, AC_HELP_STRING([--enable-scf],[use SCF for reader support]), [ case "${enableval}" in yes) scf=true ;; no) scf=false ;; *) AC_MSG_ERROR([bad value ${enableval} for --enable-scf]) ;; esac], [scf=false]) AC_SUBST(LIBSMARTCARD) if test x$scf = xtrue -a x$ac_cv_header_smartcard_scf_h = xyes; then AC_CHECK_LIB(smartcard, SCF_strerror, [LIBSMARTCARD="$LIBSMARTCARD -lsmartcard" scf=true], scf=false) else scf=false fi AM_CONDITIONAL(HAVE_SCF, test x$scf = xtrue) # --enable-confdir=DIR AC_ARG_ENABLE(confdir, AC_HELP_STRING([--enable-confdir=DIR],[directory containing reader.conf (default /etc)]), [confdir="${enableval}"], [confdir=false]) if test x${confdir} = xfalse ; then confdir="/etc" fi PCSCLITE_FEATURES="${PCSCLITE_FEATURES} confdir=${confdir}" # --enable-ipcdir=DIR AC_ARG_ENABLE(ipcdir, AC_HELP_STRING([--enable-ipcdir=DIR],[directory containing IPC files (default /var/run/pcscd)]), [ipcdir="${enableval}"], [ipcdir=false]) if test x${ipcdir} = xfalse ; then ipcdir="/var/run/pcscd" fi AC_DEFINE_UNQUOTED(USE_IPCDIR, "$ipcdir", [directory containing IPC files]) PCSCLITE_FEATURES="${PCSCLITE_FEATURES} ipcdir=${ipcdir}" CPPFLAGS="-I\${top_srcdir}/src $CPPFLAGS" # HOST_TO_CCID if test "x$ac_cv_c_bigendian" = "xyes"; then AC_SUBST(host_to_ccid_16, ['((((x) >> 8) & 0xFF) + ((x & 0xFF) << 8))']) AC_SUBST(host_to_ccid_32, ['((((x) >> 24) & 0xFF) + (((x) >> 8) & 0xFF00) + ((x & 0xFF00) << 8) + (((x) & 0xFF) << 24))']) AC_MSG_RESULT([plateform endianess : big endian]) else AC_SUBST(host_to_ccid_16, ['(x)']) AC_SUBST(host_to_ccid_32, ['(x)']) AC_MSG_RESULT([plateform endianess : little endian]) fi # Setup dist stuff AC_SUBST(usbdropdir) AC_SUBST(confdir) AC_SUBST(ipcdir) AC_SUBST(host_to_ccid_16) AC_SUBST(host_to_ccid_32) AS_AC_EXPAND(confdir_exp,$confdir) AS_AC_EXPAND(sysconfdir_exp,$sysconfdir) AS_AC_EXPAND(sbindir_exp,$sbindir) AS_AC_EXPAND(localstatedir_exp,$localstatedir) AC_DEFINE_UNQUOTED([PCSCLITE_FEATURES], ["${PCSCLITE_FEATURES}"], [Enabled PC/SC lite features]) cat << EOF PC/SC lite has been configured with following options: Version: ${PACKAGE_VERSION} System binaries: $(eval eval eval echo "${sbindir_exp}") Configuration files: $(eval eval eval echo "${sysconfdir_exp}") Host: ${host} Compiler: ${CC} Preprocessor flags: ${CPPFLAGS} Compiler flags: ${CFLAGS} Preprocessor flags: ${CPPFLAGS} Linker flags: ${LDFLAGS} Libraries: ${LIBS} PTHREAD_CFLAGS: ${PTHREAD_CFLAGS} PTHREAD_LIBS: ${PTHREAD_LIBS} PCSC_ARCH: ${PCSC_ARCH} libhal support: ${use_libhal} libusb support: ${use_libusb} SCF reader support: ${scf} USB drop directory: ${usbdropdir} ATR parsing messages: ${debugatr} confdir: ${confdir} ipcdir: ${ipcdir} EOF # Write Makefiles AC_CONFIG_FILES([ Makefile m4/Makefile doc/Makefile doc/doxygen.conf doc/pcscd.8 doc/reader.conf.5 doc/update-reader.conf.8 doc/example/Makefile etc/Makefile etc/pcscd.init etc/reader.conf etc/update-reader.conf src/Makefile src/libpcsclite.pc src/pcscd.h src/PCSC/pcsclite.h src/PCSC/reader.h ]) AC_OUTPUT