1# Process this file with autoconf to produce a configure script. 2# You may need to use autoconf 2.56 or newer 3 4# $Id: configure.ac 6795 2013-11-25 18:09:17Z rousseau $ 5 6# Require autoconf 2.61 7AC_PREREQ([2.69]) 8 9AC_INIT([ccid],[1.4.14]) 10AC_CONFIG_SRCDIR(src/ifdhandler.c) 11AC_CONFIG_AUX_DIR([.]) 12AM_INIT_AUTOMAKE(1.8 dist-bzip2 no-dist-gzip subdir-objects) 13AC_CONFIG_MACRO_DIR([m4]) 14 15# silent build by default 16m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 17 18# Default install dir 19AC_PREFIX_DEFAULT(/usr/local) 20 21# Automake boilerplate. 22AC_CANONICAL_HOST 23 24# create a config.h file (Automake will add -DHAVE_CONFIG_H) 25AC_CONFIG_HEADERS([config.h]) 26 27# Options 28AM_MAINTAINER_MODE 29 30# Checks for programs. 31AC_PROG_CC 32AM_PROG_CC_C_O 33AC_PROG_CPP 34AC_PROG_INSTALL 35AC_PROG_MAKE_SET 36AC_PROG_LN_S 37AM_PROG_LEX 38AM_PROG_AR 39PKG_PROG_PKG_CONFIG 40 41# check pcsc-lite version 42PCSC_NEEDED_VERSION="1.8.3" 43PKG_CHECK_EXISTS([libpcsclite], 44 [PKG_CHECK_MODULES(PCSC, libpcsclite >= $PCSC_NEEDED_VERSION, [], 45 [ 46 if test -f /usr/local/lib/pkgconfig/libpcsclite.pc -a "x$PKG_CONFIG" != x ; then 47 AC_MSG_ERROR([use PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure]) 48 else 49 AC_MSG_WARN([install pcsc-lite $PCSC_NEEDED_VERSION or later]) 50 fi 51 ])], 52 [AC_MSG_WARN([libpcsclite not found by pkg-config])] 53) 54 55saved_CPPFLAGS="$CPPFLAGS" 56CPPFLAGS="$CPPFLAGS $PCSC_CFLAGS" 57PCSC_ERROR_MSG="install pcsc-lite $PCSC_NEEDED_VERSION or later, or use ./configure PCSC_CFLAGS=..." 58AC_CHECK_HEADER(ifdhandler.h,, [AC_MSG_ERROR([$PCSC_ERROR_MSG])]) 59AC_CHECK_HEADER(reader.h,, [AC_MSG_ERROR([$PCSC_ERROR_MSG])]) 60CPPFLAGS="$saved_CPPFLAGS" 61 62# Add libtool support. 63# Static lib is disabled by default. Use --enable-static if needed 64LT_INIT(disable-static) 65LT_INIT 66 67# Automatically update the libtool script if it becomes out-of-date. 68AC_SUBST(LIBTOOL_DEPS) 69 70# Checks for header files. 71AC_HEADER_STDC 72AC_CHECK_HEADERS(errno.h fcntl.h stdlib.h unistd.h termios.h string.h sys/time.h sys/types.h stdarg.h arpa/inet.h,, 73 [AC_MSG_ERROR([some header files not found])]) 74 75# Checks for typedefs, structures, and compiler characteristics. 76AC_C_CONST 77AC_TYPE_SIZE_T 78AC_HEADER_TIME 79 80# Checks for library functions. 81AC_CHECK_FUNCS(select strerror strncpy memcpy strlcpy strlcat) 82 83# Select OS specific versions of source files. 84AC_SUBST(BUNDLE_HOST) 85AC_SUBST(DYN_LIB_EXT) 86BUNDLE_HOST=`uname | sed -e s,/,_,` 87DYN_LIB_EXT="so" 88case "$BUNDLE_HOST" in 89Darwin) 90 BUNDLE_HOST=MacOS 91 DYN_LIB_EXT="dylib" 92 ;; 93SunOS) 94 BUNDLE_HOST=Solaris 95 ;; 96 esac 97 98# --disable-libusb 99AC_ARG_ENABLE(libusb, 100 AS_HELP_STRING([--disable-libusb],[do not use libusb]), 101 [ use_libusb="${enableval}" ], [ use_libusb=yes ] ) 102 103# check if libusb is used 104LIBUSB_NEEDED_VERSION="1.0.8" 105if test "x$use_libusb" != xno ; then 106 PKG_CHECK_EXISTS([libusb-1.0], [ 107 PKG_CHECK_MODULES(LIBUSB, libusb-1.0 >= $LIBUSB_NEEDED_VERSION, [], 108 [ 109 AC_MSG_WARN([install libusb $LIBUSB_NEEDED_VERSION or later]) 110 PKG_CHECK_MODULES(LIBUSB, libusb-1.0) 111 ]) 112 ]) 113 114 saved_CPPFLAGS="$CPPFLAGS" 115 saved_LIBS="$LIBS" 116 117 CPPFLAGS="$CPPFLAGS $LIBUSB_CFLAGS" 118 LIBS="$LDFLAGS $LIBUSB_LIBS" 119 120 AC_CHECK_HEADERS(libusb.h, [], 121 [ AC_MSG_ERROR([libusb.h not found, install libusb or use ./configure LIBUSB_CFLAGS=...]) ]) 122 123 AC_MSG_CHECKING([for libusb_init]) 124 AC_TRY_LINK_FUNC(libusb_init, [ AC_MSG_RESULT([yes]) ], 125 [ AC_MSG_ERROR([libusb not found, use ./configure LIBUSB_LIBS=...]) ]) 126 127 CPPFLAGS="$saved_CPPFLAGS" 128 LIBS="$saved_LIBS" 129 130 use_libusb=yes 131fi 132AC_SUBST(LIBUSB_CFLAGS) 133AC_SUBST(LIBUSB_LIBS) 134AM_CONDITIONAL(WITH_LIBUSB, test "${use_libusb}" != "no") 135 136# --enable-composite-as-multislot 137use_composite_as_multislot=no 138AC_ARG_ENABLE(composite-as-multislot, 139 AS_HELP_STRING([--enable-composite-as-multislot],[composite device are seen as multi-slots]), 140 [ use_composite_as_multislot="${enableval}" ] ) 141 142if test "x$use_composite_as_multislot" = xyes; then 143 AC_DEFINE(USE_COMPOSITE_AS_MULTISLOT, 1, [composite device are seen as multi-slots]) 144fi 145 146# check if the compiler support -fvisibility=hidden (GCC >= 4) 147saved_CFLAGS="$CFLAGS" 148CFLAGS="$CFLAGS -fvisibility=hidden" 149AC_MSG_CHECKING([for -fvisibility=hidden]) 150AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])], 151 [ AC_MSG_RESULT([yes]) 152 SYMBOL_VISIBILITY="-fvisibility=hidden" ], 153 AC_MSG_RESULT([no])) 154CFLAGS="$saved_CFLAGS" 155AC_SUBST(SYMBOL_VISIBILITY) 156 157# --disable-multi-thread 158AC_ARG_ENABLE(multi-thread, 159 AS_HELP_STRING([--disable-multi-thread],[disable multi threading]), 160 [ multithread="${enableval}" ], [ multithread=yes ] ) 161 162if test "${multithread}" != no ; then 163 AX_PTHREAD( 164 [ AC_DEFINE(HAVE_PTHREAD, 1, 165 [Define if you have POSIX threads libraries and header files.]) 166 ], [ AC_MSG_ERROR([POSIX thread support required]) ]) 167 168 multithread=yes 169fi 170 171# --enable-bundle=NAME 172AC_ARG_ENABLE(bundle, 173 AS_HELP_STRING([--enable-bundle=NAME],[bundle directory name 174 (default ifd-ccid.bundle)]), 175 [bundle="${enableval}"], [bundle=false]) 176if test "${bundle}" = false ; then 177 bundle="ifd-ccid.bundle" 178fi 179AC_DEFINE_UNQUOTED(BUNDLE, "$bundle", [bundle directory name]) 180 181# --enable-usbdropdir=DIR 182AC_ARG_ENABLE(usbdropdir, 183 AS_HELP_STRING([--enable-usbdropdir=DIR],[directory containing USB 184 drivers (default to pcscd config or $(prefix)/pcsc/drivers)]), 185 [usbdropdir="${enableval}"], [usbdropdir=false]) 186if test "${usbdropdir}" = false ; then 187 usbdropdir=`$PKG_CONFIG libpcsclite --variable=usbdropdir` 188fi 189AC_DEFINE_UNQUOTED(PCSCLITE_HP_DROPDIR, "$usbdropdir", [directory containing USB drivers]) 190if test "${usbdropdir}" = "" ; then 191 AC_MSG_ERROR([use --enable-usbdropdir=DIR]) 192fi 193 194# --enable-twinserial 195AC_ARG_ENABLE(twinserial, 196 AS_HELP_STRING([--enable-twinserial],[also compile and install the serial Twin driver]), 197 [twinserial="${enableval}"], [twinserial=no]) 198AM_CONDITIONAL(WITH_TWIN_SERIAL, test "${twinserial}" != "no") 199 200# --enable-ccidtwindir=DIR 201AC_ARG_ENABLE(ccidtwindir, 202 AS_HELP_STRING([--enable-ccidtwindir=DIR],[directory to install the 203 serial Twin driver (default to pcscd config or $(prefix)/pcsc/drivers/serial)]), 204 [ccidtwindir="${enableval}"], [ccidtwindir=false]) 205if test "${ccidtwindir}" = false ; then 206 ccidtwindir=$usbdropdir/serial 207fi 208 209# --enable-serialconfdir=DIR 210AC_ARG_ENABLE(serialconfdir, 211 AS_HELP_STRING([--enable-serialconfdir=dir],[directory containing 212 serial drivers (default to pcscd config)]), 213 [serialconfdir="${enableval}"], [serialconfdir=false]) 214if test "${serialconfdir}" = false ; then 215 serialconfdir=`$PKG_CONFIG libpcsclite --variable=serialconfdir` 216fi 217 218# --disable-pcsclite 219AC_ARG_ENABLE(pcsclite, 220 AS_HELP_STRING([--disable-pcsclite],[do not use pcsc-lite debug support]), 221 [ pcsclite="${enableval}" ], [ pcsclite=yes ] ) 222 223if test "${pcsclite}" != no ; then 224 # check that pcsc-lite is installed 225 OLD_LIBS="$LIBS" 226 OLD_CFLAGS="$CFLAGS" 227 LIBS="$LIBS $PCSC_LIBS" 228 CFLAGS="$CFLAGS $PCSC_CFLAGS" 229 AC_MSG_CHECKING([for SCardEstablishContext]) 230 AC_TRY_LINK_FUNC(SCardEstablishContext, 231 [ AC_MSG_RESULT([yes]) ], 232 [ AC_MSG_ERROR([SCardEstablishContext() not found, install pcsc-lite 1.2.9-beta9 or later,or use PCSC_LIBS=... ./configure]) ]) 233 LIBS="$OLD_LIBS" 234 CFLAGS="$OLD_CFLAGS" 235 236 pcsclite=yes 237fi 238AM_CONDITIONAL(WITHOUT_PCSC, test "${pcsclite}" != "yes") 239 240# --disable-class 241AC_ARG_ENABLE(class, 242 AS_HELP_STRING([--disable-class],[remove the CCIDCLASSDRIVER from Info.plist]), 243 [class="${enableval}"], [class=yes]) 244if test "${class}" != yes ; then 245 NOCLASS="--no-class" 246fi 247AC_SUBST(NOCLASS) 248 249# --enable-embedded 250AC_ARG_ENABLE(embedded, 251 AS_HELP_STRING([--enable-embedded],[limit RAM and CPU ressources by disabling features (log)]), 252 [ use_embedded="${enableval}" ]) 253 254if test x$use_embedded = xyes; then 255 AC_DEFINE(NO_LOG, 1, [Disable logging support]) 256fi 257 258# Setup dist stuff 259AC_SUBST(ac_aux_dir) 260AC_SUBST(bundle) 261AC_SUBST(usbdropdir) 262AC_SUBST(ccidtwindir) 263AC_SUBST(serialconfdir) 264AS_AC_EXPAND(bindir_exp,$bindir) 265AS_AC_EXPAND(sysconfdir_exp,$sysconfdir) 266 267cat << EOF 268 269libccid has been configured with following options: 270 271Version: ${PACKAGE_VERSION} 272User binaries: $(eval eval eval echo "${bindir_exp}") 273Configuration files: $(eval eval eval echo "${sysconfdir_exp}") 274 275 276Host: ${host} 277Compiler: ${CC} 278Preprocessor flags: ${CPPFLAGS} 279Compiler flags: ${CFLAGS} 280Preprocessor flags: ${CPPFLAGS} 281Linker flags: ${LDFLAGS} 282Libraries: ${LIBS} 283 284PCSC_CFLAGS: ${PCSC_CFLAGS} 285PCSC_LIBS: ${PCSC_LIBS} 286PTHREAD_CFLAGS: ${PTHREAD_CFLAGS} 287PTHREAD_LIBS: ${PTHREAD_LIBS} 288BUNDLE_HOST: ${BUNDLE_HOST} 289DYN_LIB_EXT: ${DYN_LIB_EXT} 290LIBUSB_CFLAGS: ${LIBUSB_CFLAGS} 291LIBUSB_LIBS: ${LIBUSB_LIBS} 292SYMBOL_VISIBILITY: ${SYMBOL_VISIBILITY} 293NOCLASS: ${NOCLASS} 294 295libusb support: ${use_libusb} 296composite as multislot: ${use_composite_as_multislot} 297multi threading: ${multithread} 298bundle directory name: ${bundle} 299USB drop directory: ${usbdropdir} 300serial Twin support: ${twinserial} 301serial twin install dir: ${ccidtwindir} 302serial config directory: ${serialconfdir} 303compiled for pcsc-lite: ${pcsclite} 304class driver: ${class} 305 306EOF 307 308# Write Makefiles. 309AC_CONFIG_FILES(Makefile 310 src/Makefile 311 readers/Makefile 312 contrib/Makefile 313 contrib/Kobil_mIDentity_switch/Makefile 314 contrib/RSA_SecurID/Makefile 315 examples/Makefile) 316 317AC_OUTPUT 318 319