You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

450 lines
12 KiB

  1. # -*- mode: m4; -*-
  2. # Process this file with autoconf to produce a configure script
  3. AC_PREREQ([2.69])
  4. AC_INIT([pcsc-lite],[1.8.13])
  5. AC_CONFIG_SRCDIR(src/pcscdaemon.c)
  6. AM_INIT_AUTOMAKE(1.8 dist-bzip2 no-dist-gzip)
  7. AC_CONFIG_HEADERS([config.h])
  8. AC_CONFIG_MACRO_DIR(m4)
  9. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  10. AC_CANONICAL_HOST
  11. AC_PROG_CC
  12. AC_C_BIGENDIAN
  13. # Check for some target-specific stuff
  14. case "$host" in
  15. *-*-hpux*)
  16. CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE_EXTENDED"
  17. ;;
  18. *-*-solaris*)
  19. CPPFLAGS="$CPPFLAGS -I/usr/local/include"
  20. LDFLAGS="$LDFLAGS -L/usr/local/lib -R/usr/local/lib"
  21. need_dash_r=1
  22. ;;
  23. *-*-sunos4*)
  24. CPPFLAGS="$CPPFLAGS -DSUNOS4"
  25. ;;
  26. *-*-aix*)
  27. CPPFLAGS="$CPPFLAGS -I/usr/local/include"
  28. LDFLAGS="$LDFLAGS -L/usr/local/lib"
  29. if (test "$LD" != "gcc" && test -z "$blibpath"); then
  30. blibpath="/usr/lib:/lib:/usr/local/lib"
  31. fi
  32. ;;
  33. *-*-osf*)
  34. CPPFLAGS="$CPPFLAGS -D_POSIX_PII_SOCKET"
  35. ;;
  36. *-*-darwin*)
  37. AC_SUBST(COREFOUNDATION)
  38. COREFOUNDATION="-Wl,-framework,CoreFoundation"
  39. AC_SUBST(IOKIT)
  40. IOKIT="-Wl,-framework,IOKit"
  41. if test "$GCC" = "yes"; then
  42. CFLAGS="$CFLAGS -no-cpp-precomp"
  43. fi
  44. use_libusb=no
  45. AC_MSG_WARN([libusb disabled on Darwin for pcsc-lite])
  46. ;;
  47. esac
  48. # Options
  49. AM_MAINTAINER_MODE
  50. # Checks for programs
  51. AC_PROG_CPP
  52. AC_PROG_INSTALL
  53. AC_PROG_LN_S
  54. AC_PROG_MAKE_SET
  55. AM_PROG_LEX
  56. PKG_PROG_PKG_CONFIG
  57. AM_PROG_CC_C_O
  58. AM_PROG_AR
  59. # Special check for pthread support
  60. AX_PTHREAD([
  61. AC_DEFINE(HAVE_PTHREAD, 1,
  62. [Define if you have POSIX threads libraries and header files.])
  63. ],[
  64. AC_MSG_ERROR([POSIX thread support required])
  65. ])
  66. CC="$PTHREAD_CC"
  67. AC_SUBST(PTHREAD_LIBS)
  68. AC_SUBST(PTHREAD_CFLAGS)
  69. # check for pthread_cancel()
  70. saved_CFLAGS="$CFLAGS"
  71. CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  72. AC_CHECK_FUNCS(pthread_cancel)
  73. CFLAGS="$saved_CFLAGS"
  74. # Add libtool support
  75. # Static lib is disabled by default. Use --enable-static if needed
  76. LT_INIT(disable-static)
  77. LT_INIT
  78. # Automatically update the libtool script if it becomes out-of-date
  79. #AC_SUBST(LIBTOOL_DEPS)
  80. # Checks for header files
  81. AC_HEADER_STDC
  82. AC_HEADER_SYS_WAIT
  83. AC_CHECK_HEADERS([getopt.h sys/filio.h syslog.h dl.h fcntl.h ])
  84. # Checks for typedefs, structures, and compiler characteristics
  85. AC_C_CONST
  86. AC_TYPE_UID_T
  87. AC_TYPE_SIZE_T
  88. AC_HEADER_TIME
  89. # Checks for library functions
  90. AC_FUNC_ERROR_AT_LINE
  91. AC_FUNC_STAT
  92. AC_FUNC_VPRINTF
  93. AC_CHECK_FUNCS(daemon flock getopt_long nanosleep strerror vsnprintf)
  94. # strlcpy, strlcat from OpenBSD
  95. AC_CHECK_FUNCS(strlcpy strlcat)
  96. # C Compiler features
  97. AC_C_INLINE
  98. if test "$GCC" = "yes"; then
  99. CFLAGS="-Wall -fno-common $CFLAGS"
  100. fi
  101. # check if the compiler support -fvisibility=hidden (GCC >= 4)
  102. saved_CFLAGS="$CFLAGS"
  103. CFLAGS="$CFLAGS -fvisibility=hidden"
  104. AC_MSG_CHECKING([for -fvisibility=hidden])
  105. AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
  106. [ AC_MSG_RESULT([yes])
  107. SYMBOL_VISIBILITY="-fvisibility=hidden" ],
  108. AC_MSG_RESULT([no]))
  109. CFLAGS="$saved_CFLAGS"
  110. AC_SUBST(SYMBOL_VISIBILITY)
  111. AC_SEARCH_LIBS([dlopen], [dl dld], [], [
  112. AC_MSG_ERROR([unable to find the dlopen() function])
  113. ])
  114. # Use 'uname' output as an architecture define
  115. PCSC_ARCH=`uname | sed -e s,/,_,`
  116. case "$PCSC_ARCH" in
  117. Darwin)
  118. PCSC_ARCH=MacOS
  119. ;;
  120. SunOS)
  121. PCSC_ARCH=Solaris
  122. ;;
  123. esac
  124. AC_DEFINE_UNQUOTED(PCSC_ARCH, "$PCSC_ARCH", [PC/SC target architecture])
  125. PCSCLITE_FEATURES="${PCSCLITE_FEATURES} $PCSC_ARCH $host"
  126. # See if socket() is found from libsocket
  127. AC_CHECK_LIB(socket, socket, [LIBS="$LIBS -lsocket"])
  128. # check for mq_getattr()
  129. AC_CHECK_LIB(rt, mq_getattr, [LIBS="$LIBS -lrt"])
  130. # --disable-serial
  131. AC_ARG_ENABLE(serial,
  132. AS_HELP_STRING([--disable-serial],[do not use serial reader.conf file]),
  133. [ use_serial="${enableval}" ], [ use_serial="yes" ] )
  134. AM_CONDITIONAL(ENABLE_SERIAL, test "$use_serial" != "no")
  135. if test "$use_serial" != "no"; then
  136. AC_DEFINE(USE_SERIAL, 1, [Use serial conf file mechanism])
  137. PCSCLITE_FEATURES="${PCSCLITE_FEATURES} serial"
  138. fi
  139. # --disable-usb
  140. AC_ARG_ENABLE(usb,
  141. AS_HELP_STRING([--disable-usb],[do not use usb hotplug]),
  142. [ use_usb="${enableval}" ], [ use_usb="yes" ] )
  143. AM_CONDITIONAL(ENABLE_USB, test "$use_usb" != "no")
  144. if test "$use_usb" != "no"; then
  145. AC_DEFINE(USE_USB, 1, [Use USB hotplug mechanism])
  146. PCSCLITE_FEATURES="${PCSCLITE_FEATURES} usb"
  147. fi
  148. # --enable-libudev
  149. AC_ARG_ENABLE(libudev,
  150. AS_HELP_STRING([--disable-libudev],[do not use libudev]),
  151. [ use_libudev="${enableval}" ],
  152. [ if test "$PCSC_ARCH" != "Linux" ; then
  153. use_libudev="no"
  154. else
  155. use_libudev="${use_libudev-yes}"
  156. fi ])
  157. # disable libudev check is USB is not used
  158. if test "$use_usb" == "no"; then
  159. use_libudev="no"
  160. fi
  161. # check if libudev is used
  162. if test "x$use_libudev" != xno ; then
  163. PKG_CHECK_MODULES(LIBUDEV, libudev, [],
  164. [ AC_MSG_ERROR([install libudev-dev or use --disable-libudev]) ])
  165. saved_CPPFLAGS="$CPPFLAGS"
  166. saved_LIBS="$LIBS"
  167. CPPFLAGS="$CPPFLAGS $LIBUDEV_CFLAGS"
  168. LIBS="$LDFLAGS $LIBUDEV_LIBS"
  169. AC_CHECK_HEADERS(libudev.h, [],
  170. [ AC_MSG_ERROR([libudev.h not found, use ./configure LIBUDEV_CFLAGS=...]) ])
  171. LIBS="$LIBS $COREFOUNDATION $IOKIT"
  172. AC_MSG_CHECKING([for udev_monitor_unref])
  173. AC_TRY_LINK_FUNC(udev_monitor_unref, [ AC_MSG_RESULT([yes]) ],
  174. [ AC_MSG_ERROR([udev_monitor_unref not found, use ./configure LIBUDEV_LIBS=...]) ])
  175. # everything needed for libudev support is present
  176. use_libudev=yes
  177. CPPFLAGS="$saved_CPPFLAGS"
  178. LIBS="$saved_LIBS"
  179. fi
  180. AC_SUBST(LIBUDEV_CFLAGS)
  181. AC_SUBST(LIBUDEV_LIBS)
  182. if test x$use_libudev = xyes; then
  183. AC_DEFINE(HAVE_LIBUDEV, 1, [Libudev is available])
  184. PCSCLITE_FEATURES="${PCSCLITE_FEATURES} libudev"
  185. fi
  186. # --enable-libusb
  187. AC_ARG_ENABLE(libusb,
  188. AS_HELP_STRING([--enable-libusb],[use libusb]),
  189. [ use_libusb="${enableval}" ],
  190. [ if test "x$use_libudev" = xyes ; then use_libusb="${use_libusb-no}" ;
  191. else use_libusb="${use_libusb-yes}" ; fi ] )
  192. # disable libusb check is USB is not used
  193. if test "$use_usb" == "no"; then
  194. use_libusb="no"
  195. fi
  196. # check if libusb is used
  197. if test "x$use_libusb" != xno ; then
  198. if test "x$use_libudev" != xno ; then
  199. AC_MSG_ERROR([You can't use libudev _and_ libusb. Select only one.])
  200. fi
  201. PKG_CHECK_MODULES(LIBUSB, libusb-1.0, [],
  202. [
  203. AC_MSG_RESULT([no])
  204. AC_CHECK_PROG([LIBUSBCONFIG], [libusb-config], [yes])
  205. if test "$LIBUSBCONFIG" = "yes" ; then
  206. LIBUSB_CFLAGS="$LIBUSB_CFLAGS `libusb-config --cflags`"
  207. LIBUSB_LIBS="$LIBUSB_LIBS `libusb-config --libs`"
  208. else
  209. AC_MSG_WARN([libusb-config not found.])
  210. fi
  211. ])
  212. saved_CPPFLAGS="$CPPFLAGS"
  213. saved_LIBS="$LIBS"
  214. CPPFLAGS="$CPPFLAGS $LIBUSB_CFLAGS"
  215. LIBS="$LDFLAGS $LIBUSB_LIBS"
  216. AC_CHECK_HEADERS(libusb.h, [],
  217. [ AC_MSG_ERROR([libusb.h not found, use ./configure LIBUSB_CFLAGS=...]) ])
  218. LIBS="$LIBS $COREFOUNDATION $IOKIT"
  219. AC_MSG_CHECKING([for libusb_init])
  220. AC_TRY_LINK_FUNC(libusb_init, [ AC_MSG_RESULT([yes]) ],
  221. [ AC_MSG_ERROR([libusb not found, use ./configure LIBUSB_LIBS=...]) ])
  222. # everything needed for libusb support is present
  223. use_libusb=yes
  224. CPPFLAGS="$saved_CPPFLAGS"
  225. LIBS="$saved_LIBS"
  226. fi
  227. AC_SUBST(LIBUSB_CFLAGS)
  228. AC_SUBST(LIBUSB_LIBS)
  229. if test x$use_libusb = xyes; then
  230. AC_DEFINE(HAVE_LIBUSB, 1, [Libusb is available])
  231. PCSCLITE_FEATURES="${PCSCLITE_FEATURES} libusb"
  232. fi
  233. # --enable-polkit
  234. POLKIT_MINIMUM=0.111
  235. AC_ARG_ENABLE(polkit,
  236. AS_HELP_STRING([--enable-polkit],
  237. [Build with polkit support]),
  238. use_polkit=$enableval, use_polkit=no)
  239. if test "$use_polkit" != "no"; then
  240. PKG_CHECK_MODULES(POLKIT, [polkit-gobject-1 >= $POLKIT_MINIMUM], [use_polkit=yes], [use_polkit=no])
  241. if test "$use_polkit" != "no";then
  242. AC_DEFINE([HAVE_POLKIT], 1, [Build polkit access control support])
  243. polkit_policy_dir=$($PKG_CONFIG polkit-gobject-1 --variable=policydir)
  244. AC_SUBST(POLICY_DIR, [$polkit_policy_dir])
  245. else
  246. use_polkit=no
  247. AC_MSG_ERROR([[
  248. ***
  249. *** polkit >= $POLKIT_MINIMUM was not found. Access control will be disabled.
  250. *** You may get it from http://www.freedesktop.org/software/polkit/
  251. *** ]])
  252. fi
  253. fi
  254. AM_CONDITIONAL(ENABLE_POLKIT, test "$use_polkit" != "no")
  255. # --with-systemdsystemunitdir=DIR
  256. AC_ARG_WITH([systemdsystemunitdir],
  257. AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
  258. [], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
  259. if test "x$with_systemdsystemunitdir" != xno; then
  260. AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
  261. fi
  262. AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
  263. # --enable-embedded
  264. AC_ARG_ENABLE(embedded,
  265. AS_HELP_STRING([--enable-embedded],[limit RAM and CPU ressources by disabling features (log)]),
  266. [ use_embedded="${enableval}" ])
  267. if test x$use_embedded = xyes; then
  268. AC_DEFINE(NO_LOG, 1, [Disable logging support])
  269. PCSCLITE_FEATURES="${PCSCLITE_FEATURES} nolog"
  270. fi
  271. # --enable-usbdropdir=DIR
  272. AC_ARG_ENABLE(usbdropdir,
  273. AS_HELP_STRING([--enable-usbdropdir=DIR],[directory containing USB
  274. drivers (default /usr/local/lib/pcsc/drivers)]),
  275. [usbdropdir="${enableval}"], [usbdropdir=false])
  276. if test x${usbdropdir} = xfalse ; then
  277. if test "x$libdir" != xNONE; then
  278. usbdropdir="$libdir/pcsc/drivers"
  279. else
  280. usbdropdir="$ac_default_libdir/pcsc/drivers"
  281. fi
  282. fi
  283. AS_AC_EXPAND(usbdropdir_exp,$usbdropdir)
  284. usbdropdir=$usbdropdir_exp
  285. AC_DEFINE_UNQUOTED(PCSCLITE_HP_DROPDIR, "$usbdropdir", [directory containing USB drivers])
  286. PCSCLITE_FEATURES="${PCSCLITE_FEATURES} usbdropdir=${usbdropdir}"
  287. # --enable-debugatr
  288. AC_ARG_ENABLE(debugatr,
  289. AS_HELP_STRING([--enable-debugatr],[enable ATR debug messages from pcscd]),
  290. [ case "${enableval}" in
  291. yes) debugatr=true ;;
  292. no) debugatr=false ;;
  293. *) AC_MSG_ERROR([bad value ${enableval} for --enable-debugatr]) ;;
  294. esac], [debugatr=false])
  295. if test x${debugatr} = xtrue ; then
  296. AC_DEFINE(ATR_DEBUG, 1, [display ATR parsing debug messages.])
  297. PCSCLITE_FEATURES="${PCSCLITE_FEATURES} debugatr"
  298. fi
  299. # --enable-ipcdir=DIR
  300. AC_ARG_ENABLE(ipcdir,
  301. AS_HELP_STRING([--enable-ipcdir=DIR],[directory containing IPC files
  302. (default /var/run/pcscd)]),
  303. [ipcdir="${enableval}"], [ipcdir=false])
  304. if test x${ipcdir} = xfalse ; then
  305. ipcdir="/var/run/pcscd"
  306. fi
  307. AC_DEFINE_UNQUOTED(USE_IPCDIR, "$ipcdir", [directory containing IPC files])
  308. PCSCLITE_FEATURES="${PCSCLITE_FEATURES} ipcdir=${ipcdir}"
  309. CPPFLAGS="-I\${top_srcdir}/src $CPPFLAGS"
  310. # --enable-confdir=DIR
  311. AC_ARG_ENABLE(confdir,
  312. AS_HELP_STRING([--enable-confdir=DIR],[directory containing reader configurations (default /etc/reader.conf.d)]),
  313. [confdir="${enableval}"],
  314. [confdir="${sysconfdir}/reader.conf.d"])
  315. # Setup dist stuff
  316. AC_SUBST(usbdropdir)
  317. AC_SUBST(ipcdir)
  318. AC_SUBST(serialconfdir)
  319. AC_SUBST(host_to_ccid_16)
  320. AC_SUBST(host_to_ccid_32)
  321. AS_AC_EXPAND(confdir_exp,$confdir)
  322. AS_AC_EXPAND(sbindir_exp,$sbindir)
  323. AS_AC_EXPAND(localstatedir_exp,$localstatedir)
  324. PCSCLITE_CONFIG_DIR="${confdir_exp}"
  325. AC_SUBST(PCSCLITE_CONFIG_DIR)
  326. PCSCLITE_FEATURES="${PCSCLITE_FEATURES} configdir=${PCSCLITE_CONFIG_DIR}"
  327. AC_DEFINE_UNQUOTED([PCSCLITE_FEATURES], ["${PCSCLITE_FEATURES}"], [Enabled PC/SC lite features])
  328. PCSCD_BINARY="${sbindir_exp}/pcscd"
  329. AC_DEFINE_UNQUOTED([PCSCD_BINARY], ["$PCSCD_BINARY"], [pcscd filename])
  330. cat << EOF
  331. PC/SC lite has been configured with following options:
  332. Version: ${PACKAGE_VERSION}
  333. System binaries: $(eval eval eval echo "${sbindir_exp}")
  334. Configuration dir: ${PCSCLITE_CONFIG_DIR}
  335. Host: ${host}
  336. Compiler: ${CC}
  337. Preprocessor flags: ${CPPFLAGS}
  338. Compiler flags: ${CFLAGS}
  339. Preprocessor flags: ${CPPFLAGS}
  340. Linker flags: ${LDFLAGS}
  341. Libraries: ${LIBS}
  342. PTHREAD_CFLAGS: ${PTHREAD_CFLAGS}
  343. PTHREAD_LIBS: ${PTHREAD_LIBS}
  344. PCSC_ARCH: ${PCSC_ARCH}
  345. pcscd binary ${PCSCD_BINARY}
  346. polkit support: ${use_polkit}
  347. polkit policy dir: ${polkit_policy_dir}
  348. libudev support: ${use_libudev}
  349. libusb support: ${use_libusb}
  350. USB drop directory: ${usbdropdir}
  351. ATR parsing messages: ${debugatr}
  352. ipcdir: ${ipcdir}
  353. use serial: ${use_serial}
  354. use usb: ${use_usb}
  355. systemd unit directory: ${with_systemdsystemunitdir}
  356. serial config dir.: ${confdir_exp}
  357. PCSCLITE_FEATURES: ${PCSCLITE_FEATURES}
  358. EOF
  359. # Write Makefiles
  360. AC_CONFIG_FILES([
  361. Makefile
  362. doc/Makefile
  363. doc/doxygen.conf
  364. doc/pcscd.8
  365. doc/reader.conf.5
  366. doc/example/Makefile
  367. etc/Makefile
  368. etc/pcscd.service
  369. etc/pcscd.socket
  370. src/Makefile
  371. src/libpcsclite.pc
  372. src/pcscd.h
  373. src/PCSC/pcsclite.h
  374. src/spy/Makefile
  375. ])
  376. AC_OUTPUT