1dnl Process this file with autoconf to produce a configure script. 2 3dnl ****************************************************************** 4dnl Set up autoconf and automake 5dnl ****************************************************************** 6AC_INIT([sane-backends], 7 m4_esyscmd_s([tools/git-version-gen --prefix '' .tarball-version]), 8 [sane-devel@alioth-lists.debian.net]) 9AC_PREREQ([2.69]) dnl minimum autoconf version required 10AC_CONFIG_MACRO_DIR([m4]) 11AC_CONFIG_HEADERS([include/sane/config.h]) 12 13AM_INIT_AUTOMAKE([1.15 subdir-objects -Wall]) 14AM_SILENT_RULES 15 16dnl ****************************************************************** 17dnl Determine SANE version components and release status 18dnl ****************************************************************** 19AS_IF([test x = "x$AWK"],[AC_PROG_AWK]) 20AS_IF([test x = "x`echo $VERSION | sed 's/[[.0-9]]//g'`"], 21 [is_release=yes], 22 [is_release=no]) 23V_MAJOR=`echo $VERSION | $AWK -F. '{print $1}'` 24V_MINOR=`echo $VERSION | $AWK -F. '{print $2}'` 25V_REV=`echo $VERSION | $AWK -F. '{print $3}' | sed 's/^\([[0-9]]*\).*/\1/'`; 26 27AC_DEFINE_UNQUOTED(SANE_DLL_V_MAJOR, $V_MAJOR, [SANE DLL major number]) 28AC_DEFINE_UNQUOTED(SANE_DLL_V_MINOR, $V_MINOR, [SANE DLL minor number]) 29AC_DEFINE_UNQUOTED(SANE_DLL_V_BUILD, $V_REV, [SANE DLL revision number]) 30AC_SUBST(V_MAJOR) 31AC_SUBST(V_MINOR) 32AC_SUBST(V_REV) 33 34dnl ****************************************************************** 35dnl Set up the compiler and linker 36dnl ****************************************************************** 37AC_PROG_CC 38AC_PROG_CXX 39AM_PROG_CC_C_O 40AM_PATH_PYTHON(2.7) 41sane_save_CC=$CC 42AC_PROG_CC_C99 dnl enables extensions to ISO C99 :-( 43AS_IF([test xno != "x$ac_cv_prog_cc_c99"], 44 [AC_MSG_CHECKING([for $sane_save_CC option for ISO C99 w/o extensions]) 45 AS_CASE([$ac_cv_prog_cc_c99], 46 [-std=gnu99], [sane_prog_cc_c99="-std=c99"], 47 [-qlanglvl=extc99],[sane_prog_cc_c99="-qlanglvl=stdc99"]) 48 AS_IF([test "x$ac_cv_prog_cc_c99" = "x$sane_prog_cc_c99"], 49 [AC_MSG_RESULT([$ac_cv_prog_cc_99])], 50 [AC_MSG_RESULT([$sane_prog_cc_c99]) 51 CC="$sane_save_CC $sane_prog_cc_c99"]) 52 ]) 53AC_PROG_GCC_TRADITIONAL 54AC_USE_SYSTEM_EXTENSIONS dnl call before running the C compiler 55 56AM_PROG_AR 57LT_INIT([disable-static win32-dll]) 58LT_PREREQ([2.4.6]) 59 60dnl ***************************************************************** 61dnl Set up I18N/L10N support 62dnl ***************************************************************** 63AM_GNU_GETTEXT([external]) 64AM_GNU_GETTEXT_VERSION([0.19.8]) 65 66dnl *********************************************************************** 67dnl Checks for programs. 68dnl *********************************************************************** 69AC_PATH_PROG(SANE_CONFIG_PATH, sane-config, no) 70 71dnl Call explicitly before using PKG_* 72PKG_PROG_PKG_CONFIG 73 74AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes) 75 76dnl *********************************************************************** 77dnl set compiler/linker flags 78dnl *********************************************************************** 79SANE_SET_AM_CFLAGS([$is_release]) 80AX_CXX_COMPILE_STDCXX_11([noext], [optional]) 81SANE_SET_AM_LDFLAGS 82 83dnl *********************************************************************** 84dnl Checks for unix variants 85dnl *********************************************************************** 86AC_SEARCH_LIBS([strerror],[cposix]) 87 88AC_NEED_BYTEORDER_H([include/byteorder.h]) 89AX_CREATE_STDINT_H([include/_stdint.h]) 90 91dnl *********************************************************************** 92dnl Checks for libraries 93dnl *********************************************************************** 94AC_ARG_ENABLE(dynamic, 95 AS_HELP_STRING([--disable-dynamic], 96 [Disable dynamic loading of backends]), 97 [enable_dynamic=$enableval], [enable_dynamic=auto]) 98SANE_CHECK_DLL_LIB 99dnl Checks for Backend libraries. 100AC_CHECK_LIB(m, sqrt, MATH_LIB="-lm") 101AC_SUBST(MATH_LIB) 102case ${host_os} in 103 os2*) 104 AC_CHECK_LIB(syslog, syslog, SYSLOG_LIBS="-lsyslog") 105 ;; 106 beos*) 107 AC_CHECK_LIB(be, syslog, SYSLOG_LIBS="-lbe") 108 ;; 109esac 110AC_SUBST(SYSLOG_LIBS) 111 112SANE_CHECK_JPEG 113SANE_CHECK_TIFF 114SANE_CHECK_PNG 115SANE_CHECK_IEEE1284 116SANE_CHECK_PTHREAD 117SANE_CHECK_LOCKING 118SANE_CHECK_GPHOTO2 119 120 121AC_ARG_WITH(v4l, 122 AS_HELP_STRING([--with-v4l], 123 [include the v4l backend @<:@default=yes@:>@]), 124 [# If --with-v4l=no or --without-v4l, disable backend 125 # as "$with_v4l" will be set to "no"]) 126 127if test "$with_v4l" != "no" ; then 128 PKG_CHECK_MODULES(LIBV4L, [libv4l1 >= 0.8.3], have_libv4l1=yes, have_libv4l1=no) 129fi 130 131AC_ARG_WITH(avahi, 132 AS_HELP_STRING([--with-avahi], 133 [enable Avahi support @<:@default=check@:>@]), 134 [], 135 [with_avahi=check]) 136AC_DEFINE(WITH_AVAHI, 137 [0], [Define to 1 if Avahi support is available]) 138AS_IF([test xno != "x$with_avahi"], 139 [PKG_CHECK_MODULES(AVAHI, [avahi-client >= 0.6.24], 140 [AC_DEFINE([WITH_AVAHI], [1]) 141 with_avahi=yes 142 ], 143 [AS_IF([test xcheck != "x$with_avahi"], 144 [AC_MSG_ERROR([Avahi support requested but not found])]) 145 with_avahi=no 146 ]) 147 ]) 148AM_CONDITIONAL([have_libavahi], [test x != "x$AVAHI_LIBS"]) 149 150dnl check sane to make sure we don't have two installations 151AC_CHECK_LIB(sane, sane_init, LIBSANE_EXISTS="yes") 152 153 154dnl ************************************************************** 155dnl Check for libsnmp availability 156dnl ************************************************************** 157 158AC_ARG_WITH(snmp, 159 AS_HELP_STRING([--with-snmp], 160 [enable SNMP support @<:@default=check@:>@]), 161 [], 162 [with_snmp=check]) 163AC_DEFINE(HAVE_LIBSNMP, 164 [0], [Define to 1 if libsnmp is available]) 165AS_IF([test xno != "x$with_snmp"], 166 [PKG_CHECK_MODULES(SNMP, [netsnmp >= 5.6], 167 [AC_DEFINE([HAVE_LIBSNMP], [1]) 168 with_snmp=yes 169 ], 170 [AS_IF([test xcheck != "x$with_snmp"], 171 [AC_MSG_ERROR([libsnmp requested but not found])]) 172 with_snmp=no 173 ]) 174 ]) 175AM_CONDITIONAL([have_snmp], [test x != "x$SNMP_LIBS"]) 176 177dnl *********************************************************************** 178dnl Checks for header files. 179dnl *********************************************************************** 180AC_HEADER_STDC 181AC_CHECK_HEADERS(fcntl.h unistd.h libc.h sys/dsreq.h sys/select.h \ 182 sys/time.h sys/shm.h sys/ipc.h sys/scanio.h os2.h \ 183 sys/socket.h sys/io.h sys/hw.h sys/types.h linux/ppdev.h \ 184 dev/ppbus/ppi.h machine/cpufunc.h sys/sem.h poll.h \ 185 windows.h be/kernel/OS.h limits.h sys/ioctl.h asm/types.h\ 186 netinet/in.h tiffio.h ifaddrs.h pwd.h getopt.h) 187AC_CHECK_HEADERS([asm/io.h],,,[#include <sys/types.h>]) 188 189SANE_CHECK_MISSING_HEADERS 190 191AC_CHECK_HEADERS(winsock2.h, SOCKET_LIB="-lws2_32") 192 193AC_CHECK_HEADER(resmgr.h,[ 194 AC_CHECK_LIB( 195 resmgr, 196 rsm_open_device,[ 197 AC_DEFINE(HAVE_RESMGR,1,[define if you have the resmgr library]) 198 RESMGR_LIBS="-lresmgr" 199 ] 200 ) 201]) 202AC_SUBST(RESMGR_LIBS) 203 204dnl *********************************************************************** 205dnl Checks for types and structures 206dnl *********************************************************************** 207 208AC_TYPE_SIZE_T 209AC_TYPE_PID_T 210AC_TYPE_SSIZE_T 211SANE_CHECK_U_TYPES 212 213# from Python, check for "long long" type 214AC_MSG_CHECKING(for long long support) 215have_long_long=no 216AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[AC_DEFINE(HAVE_LONG_LONG, 1, Define if the long long type is available.) have_long_long=yes],[]) 217AC_MSG_RESULT($have_long_long) 218 219AC_MSG_CHECKING([for socklen_t in <sys/socket.h>]) 220AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 221#include <sys/socket.h> 222]], [[socklen_t len]])],AC_MSG_RESULT(yes), 223[AC_MSG_RESULT(no); AC_DEFINE(socklen_t,int, 224[Define socklen_t as \'int\' if necessary.])]) 225 226AC_MSG_CHECKING([for union semun in <sys/sem.h>]) 227AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 228#include <sys/types.h> 229#include <sys/ipc.h> 230#include <sys/sem.h> 231]], [[union semun test_semun]])],[AC_MSG_RESULT(yes); 232AC_DEFINE(HAVE_UNION_SEMUN,1,[Define if union semun is available.])], 233[AC_MSG_RESULT(no)]) 234 235AC_MSG_CHECKING([for struct flock in fcntl.h]) 236AC_EGREP_HEADER([struct flock], fcntl.h, [AC_MSG_RESULT(yes) ; 237 AC_DEFINE(HAVE_STRUCT_FLOCK, 1, 238 [Define if struct flock is available.])], AC_MSG_RESULT(no)) 239 240AC_MSG_CHECKING([for Linux ioctl defines]) 241AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 242#include <sys/ioctl.h> 243#include <asm/types.h> 244]],[[ 245__u32 houba = _IOR('v',14, unsigned long); 246]])],[AC_MSG_RESULT(yes); 247have_linux_ioctl_defines="yes";],AC_MSG_RESULT(no)) 248 249dnl *********************************************************************** 250dnl Checks for compiler characteristics 251dnl *********************************************************************** 252AC_C_BIGENDIAN 253AC_C_CONST 254AC_C_INLINE 255 256dnl *********************************************************************** 257dnl Checks for library functions 258dnl *********************************************************************** 259 260dnl Functions for which we provide an implementation if missing 261AC_CONFIG_LIBOBJ_DIR([lib]) 262AC_FUNC_ALLOCA 263AC_REPLACE_FUNCS([getenv inet_ntop inet_pton sigprocmask \ 264 sleep snprintf strcasestr strdup strndup strsep syslog usleep \ 265 vsyslog]) 266AS_IF([test x != x$ALLOCA], 267 [LTALLOCA=`echo "$ALLOCA" | sed 's/\.o$//; s/\.obj$//'`.lo]) 268AC_SUBST(LTALLOCA) 269 270dnl Define SOCKET_LIB, NSL_LIB, BIND_LIB, and RESOLV_LIB when required 271dnl for functions we use. 272AC_CHECK_FUNC(gethostbyaddr,, [AC_CHECK_LIB(bind, gethostbyaddr, BIND_LIB="-lbind")]) 273AC_CHECK_FUNC(gethostbyaddr,, [AC_CHECK_LIB(nsl, gethostbyaddr, NSL_LIB="-lnsl")]) 274AC_CHECK_FUNC(socket,, [AC_CHECK_LIB(socket, socket, SOCKET_LIB="-lsocket")]) 275AC_CHECK_FUNC(inet_aton,, [AC_CHECK_LIB(resolv, inet_aton, RESOLV_LIB="-lresolv")]) 276 277dnl Group related network libraries together so they can always be linked 278dnl in. 279SOCKET_LIBS="$SOCKET_LIB $NSL_LIB $BIND_LIB $RESOLV_LIB" 280AC_SUBST(SOCKET_LIBS) 281 282dnl define HAVE_* values for network functions. This may require 283dnl SOCKET_LIBS so set LIBS temporarily. 284save_LIBS="$LIBS" 285LIBS="$LIBS $SOCKET_LIBS" 286AC_CHECK_FUNCS(inet_addr inet_aton inet_ntoa) 287LIBS="$save_LIBS" 288 289if test "$ac_cv_header_be_kernel_OS_h" = "yes" ; then 290 dnl those are known to be broken in BeOS (BONE) 291 ac_cv_func_getaddrinfo=no 292 ac_cv_func_getnameinfo=no 293fi 294 295AC_FUNC_MMAP 296AC_CHECK_FUNCS(atexit ioperm i386_set_ioperm \ 297 mkdir strftime strstr strtod \ 298 cfmakeraw tcsendbreak strcasecmp strncasecmp _portaccess \ 299 getaddrinfo getnameinfo poll setitimer iopl getuid getpass) 300 301dnl sys/io.h might provide ioperm but not inb,outb (like for 302dnl non i386/x32/x86_64 with musl libc) 303if test "${ac_cv_header_sys_io_h}" = "yes"; then 304 AC_MSG_CHECKING([for inb,outb (provided by sys/io.h)]) 305 AC_LINK_IFELSE( 306 [AC_LANG_PROGRAM([[#include <sys/io.h>]], 307 [[inb(0);outb(0,0);]])], 308 [AC_MSG_RESULT([yes]) 309 sane_cv_have_sys_io_h_with_inb_outb="yes"], 310 [AC_MSG_RESULT([no]) 311 sane_cv_have_sys_io_h_with_inb_outb="no" 312 AC_MSG_WARN([sys/io.h does not provide inb,outb (non i386/x32/x86_64 arch?)])]) 313 if test "$sane_cv_have_sys_io_h_with_inb_outb" = "yes"; then 314 AC_DEFINE(SANE_HAVE_SYS_IO_H_WITH_INB_OUTB, 1, [Define to 1 if you have the <sys/io.h> providing inb,outb.]) 315 fi 316else 317 sane_cv_have_sys_io_h_with_inb_outb="no" 318fi 319 320SANE_PROTOTYPES 321 322if test "$ac_cv_header_os2_h" = "yes" ; then 323 AC_DEFINE(strncasecmp, strnicmp, [Define for OS/2 only]) 324 AC_DEFINE(strcasecmp, stricmp, [Define for OS/2 only]) 325fi 326 327if test "$ac_cv_header_getopt_h" = "yes" ; then 328 AC_CHECK_FUNCS(getopt_long) 329fi 330 331# Slightly abuse the AC_LIBOBJ macro to mark files as replacement code 332AS_IF([test x$ac_cv_header_getopt_h != xyes \ 333 && test x$ac_cv_func_getopt_long != xyes], 334 [AC_LIBOBJ(getopt) 335 AC_LIBOBJ(getopt1)]) 336 337dnl *********************************************************************** 338dnl checks for system services 339dnl *********************************************************************** 340if test -c /dev/urandom ; then 341 AC_DEFINE(HAVE_DEV_URANDOM, 1, [Is /dev/urandom available?]) 342fi 343 344AC_ARG_WITH(systemd, 345 AS_HELP_STRING([--with-systemd], [enable systemd support @<:@default=yes@:>@])) 346if test "x$with_systemd" != xno ; then 347 PKG_CHECK_MODULES(SYSTEMD, [libsystemd], have_systemd=yes, have_systemd=no) 348 if test "x$have_systemd" = xno; then 349 PKG_CHECK_MODULES(SYSTEMD, [libsystemd-daemon], have_systemd=yes, have_systemd=no) 350 fi 351 if test "x$have_systemd" = xyes; then 352 AC_DEFINE(HAVE_SYSTEMD, 1, [Is /usr/include/systemd/sd-daemon.h available?]) 353 else 354 if test "x$with_systemd" = xyes; then 355 AC_MSG_ERROR([Systemd support was requested but systemd was not found]) 356 fi 357 fi 358fi 359 360dnl ****************************************************************** 361dnl Check for USB support 362dnl ****************************************************************** 363 364AC_ARG_WITH(usb, 365 AS_HELP_STRING([--with-usb], [enable USB support @<:@default=check@:>@]), 366 [], 367 [with_usb=check]) 368AS_IF([test xno != "x$with_usb"], 369 [have_usb=no 370 AS_CASE(x$host_os, dnl odd-ball operating systems first 371 [xbeos*], 372 [AC_CHECK_HEADER(be/drivers/USB_scanner.h, [have_usb=yes])], 373 [xos2*], 374 [AC_CHECK_HEADER(usbcalls.h, 375 [AC_CHECK_LIB(usbcall, UsbQueryNumberDevices, 376 [USB_LIBS="-lusbcall" 377 have_usb=yes 378 AC_DEFINE(HAVE_USBCALLS, [1], 379 [Define to 1 if you have usbcall.dll.]) 380 ]) 381 ], 382 [], 383 [#include <usb.h> 384 #include <os2.h> 385 ]) 386 ], 387 [dnl default to libusb-1.x, fall back to libusb-0.x if missing 388 PKG_CHECK_MODULES([USB], [libusb-1.0], 389 [AC_DEFINE([HAVE_LIBUSB], [1], 390 [Define to 1 if you have libusb-1.0]) 391 have_usb=yes 392 ], 393 [PKG_CHECK_MODULES([USB], [libusb >= 0.1.8], 394 [AC_DEFINE([HAVE_LIBUSB_LEGACY], [1], 395 [Define to 1 if you have libusb-0.1]) 396 have_usb=yes 397 ], 398 [dnl 10+ years old libusb or Windows version 399 AC_CHECK_HEADER(usb.h, 400 AC_CHECK_LIB(usb, usb_interrupt_read, 401 [USB_LIBS="-lusb" 402 have_usb=yes 403 ])) 404 AC_CHECK_HEADERS(lusb0_usb.h, 405 AC_CHECK_LIB(usb, usb_interrupt_read, 406 [USB_LIBS="-lusb" 407 have_usb=yes 408 ])) 409 ]) 410 ]) 411 ]) 412 ]) 413AS_IF([test xyes = "x$with_usb" && test xyes != "x$have_usb"], 414 [AC_MSG_ERROR([USB support requested but required libraries not found.]) 415 ]) 416AM_CONDITIONAL([have_usblib], [test x != "x$USB_LIBS"]) 417 418dnl ****************************************************************** 419dnl Check for libcurl availability 420dnl ****************************************************************** 421AC_ARG_WITH(libcurl, 422 AS_HELP_STRING([--with-libcurl], 423 [enable functionality that needs libcurl @<:@default=check@:>@]), 424 [], 425 [with_libcurl=check]) 426AC_DEFINE(HAVE_LIBCURL, 427 [0], [Define to 1 if libcurl is available]) 428AS_IF([test xno != "x$with_libcurl"], 429 [PKG_CHECK_MODULES(libcurl, [libcurl], 430 [AC_DEFINE([HAVE_LIBCURL], [1]) 431 with_libcurl=yes 432 ], 433 [AS_IF([test xcheck != "x$with_libcurl"], 434 [AC_MSG_ERROR([libcurl requested but not found])]) 435 with_libcurl=no 436 ]) 437 ]) 438AM_CONDITIONAL([have_libcurl], [test x != "x$libcurl_LIBS"]) 439 440dnl ****************************************************************** 441dnl Check for poppler-glib availability 442dnl ****************************************************************** 443AC_ARG_WITH(poppler-glib, 444 AS_HELP_STRING([--with-poppler-glib], 445 [enable functionality that needs poppler-glib @<:@default=check@:>@]), 446 [], 447 [with_poppler_glib=check]) 448AC_DEFINE(HAVE_POPPLER_GLIB, 449 [0], [Define to 1 if libpoppler-glib is available]) 450AS_IF([test xno != "x$with_poppler_glib"], 451 [PKG_CHECK_MODULES(POPPLER_GLIB, [poppler-glib], 452 [AC_DEFINE([HAVE_POPPLER_GLIB], [1]) 453 with_poppler_glib=yes 454 ], 455 [AS_IF([test xcheck != "x$with_poppler_glib"], 456 [AC_MSG_ERROR([poppler-glib requested but not found])]) 457 with_poppler_glib=no 458 ]) 459 ]) 460AM_CONDITIONAL([have_poppler_glib], [test x != "x$POPPLER_GLIB_LIBS"]) 461 462dnl ****************************************************************** 463dnl Check for USB record/replay support 464dnl ****************************************************************** 465AC_ARG_WITH(usb_record_replay, 466 AS_HELP_STRING([--with-usb-record-replay], 467 [enable USB record and replay to XML files @<:@default=yes@:>@])) 468 469if test "x$with_usb_record_replay" != "xno"; then 470 PKG_CHECK_MODULES([XML], [libxml-2.0], have_libxml=yes, have_libxml=no) 471 if test "x$have_libxml" = xyes; then 472 AC_DEFINE(HAVE_LIBXML2, 1, [Define to 1 if libxml2 is available]) 473 AC_DEFINE(WITH_USB_RECORD_REPLAY, 1, [define if USB record replay is enabled]) 474 else 475 if test "x$with_usb_record_replay" = xyes; then 476 AC_MSG_ERROR([USB record and replay support was requested but libxml-2.0 was not found]) 477 fi 478 fi 479fi 480AM_CONDITIONAL([have_libxml2], [test x != "x$XML_LIBS"]) 481 482dnl ************ 483dnl SCSI Support 484dnl ************ 485 486dnl FIXME: These are a lot of header files to scan. We should 487dnl scan for just one that is unique per platform and then do 488dnl conditional scans for more specific only as needed. 489 490# Unset VERSION during the SCSI header check 491sed "s!^#define VERSION .*!/* & */!" confdefs.h > confdefs.h.tmp 492mv confdefs.h.tmp confdefs.h 493 494AC_CHECK_HEADERS(IOKit/scsi/SCSITaskLib.h IOKit/cdb/IOSCSILib.h \ 495 IOKit/scsi/SCSICommandOperationCodes.h \ 496 IOKit/scsi-commands/SCSICommandOperationCodes.h scsi.h sys/scsi.h \ 497 sys/scsicmd.h sys/scsiio.h bsd/dev/scsireg.h scsi/sg.h \ 498 camlib.h gscdds.h sys/scsi/scsi.h sys/scsi/sgdefs.h \ 499 sys/scsi/targets/scgio.h apollo/scsi.h sys/sdi_comm.h \ 500 sys/passthrudef.h) 501 502# Restore VERSION 503sed "s!/\* \(#define VERSION .*\) \*/!\1!" confdefs.h > confdefs.h.tmp 504mv confdefs.h.tmp confdefs.h 505 506AC_CHECK_HEADERS([io/cam/cam.h],,,[#include <io/common/iotypes.h>]) 507AC_CHECK_HEADERS([ntddscsi.h ddk/ntddscsi.h],,,[#include <windows.h>]) 508 509dnl FreeBSD < 3 510if test "$ac_cv_header_sys_scsiio_h" = "yes" \ 511 && test "$ac_cv_header_scsi_h" = "yes"; then 512 AC_MSG_CHECKING([if 'scsireq_t' needs to be defined as 'struct scsireq']) 513 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 514#include <sys/scsiio.h> 515#include <scsi.h> 516]], [[scsireq_t req]])],, 517 [AC_MSG_RESULT(yes); 518 AC_DEFINE(scsireq_t, struct scsireq_t, 519 [Define scsireq_t as \'struct scsireq\' if necessary.])]) 520fi 521AC_CHECK_LIB(scsi, scsireq_enter, SCSI_LIBS="-lscsi") # FreeBSD needs this 522 523dnl FreeBSD >= 3 524AC_CHECK_LIB(cam, cam_open_device, SCSI_LIBS="-lcam") # FreeBSD 3+ needs this 525 526AC_CHECK_FUNCS(scsireq_enter) 527 528if test "$ac_cv_header_scsi_sg_h" = "yes"; then 529 AC_MSG_CHECKING([for sg_header.target_status in <scsi/sg.h>]) 530 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 531#include <sys/types.h> 532#include <scsi/sg.h> 533]],[[ 534struct sg_header hdr; 535hdr.target_status = 1; 536return 0; 537]])],[AC_MSG_RESULT(yes); 538 AC_DEFINE(HAVE_SG_TARGET_STATUS,1, 539 [Define if sg_header.target_status is available.])], 540 AC_MSG_RESULT(no)) 541fi 542 543if test "$ac_cv_header_IOKit_scsi_SCSITaskLib_h" = "yes"; then 544 AC_MSG_CHECKING([for SCSITaskSGElement in IOKit/scsi/SCSITaskLib.h]) 545 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 546#undef VERSION 547#include <IOKit/scsi/SCSITaskLib.h> 548]],[[ 549SCSITaskSGElement range; 550return 0; 551]])],[AC_MSG_RESULT(yes); 552 AC_DEFINE(HAVE_SCSITASKSGELEMENT, 1, 553 [Define if SCSITaskSGElement is available.])], 554 AC_MSG_RESULT(no)) 555fi 556 557# Multiple platforms can set SCSI_LIBS so do substitution at end. 558AC_SUBST(SCSI_LIBS) 559 560AC_ARG_ENABLE(scsibuffersize, 561 AS_HELP_STRING([--enable-scsibuffersize=N], 562 [specify the default size in bytes of the buffer for SCSI 563 commands @<:@default=131072@:>@]), 564 [set_scsibuffersize="$enableval"], [set_scsibuffersize=131072]) 565AC_DEFINE_UNQUOTED(SCSIBUFFERSIZE, $set_scsibuffersize, 566 [SCSI command buffer size]) 567dnl FIXME: Move this to configuration printout area but probably 568dnl but probably needs to be wrapped by what ever uses it so its 569dnl only printed when used. 570echo "scsi buffersize: $set_scsibuffersize" 571 572AC_ARG_ENABLE(scsi-directio, 573 AS_HELP_STRING([--enable-scsi-directio], 574 [enable SCSI direct IO (Linux only, dangerous, see 575 README.linux)]), 576 [ 577 if eval "test x$enable_scsi_directio = xyes"; then 578 AM_CFLAGS="$AM_CFLAGS -DENABLE_SCSI_DIRECTIO" 579 fi 580 ]) 581 582dnl **** 583dnl IPv6 584dnl **** 585 586dnl check for IPv6 (can be overridden by --enable-ipv6) 587if test "$ac_cv_func_getnameinfo" = "yes" \ 588 && test "$ac_cv_func_getaddrinfo" = "yes" ; then 589 SANE_CHECK_IPV6 590else 591 ipv6="no" 592fi 593 594dnl *********************************************************************** 595dnl initialize libtool 596dnl *********************************************************************** 597AC_ARG_ENABLE(preload, 598 AS_HELP_STRING([--disable-preload], 599 [Disable preloading of backends]), 600 [enable_preload=$enableval], [enable_preload=auto]) 601 602dnl Windows (cygwin/mingw), BeOS, and OS/2 need this. 603case $host_os in 604 cygwin* | mingw* | beos* | os2*) 605 AM_LDFLAGS="$AM_LDFLAGS -no-undefined" 606esac 607 608dnl Check for lock dir 609 610AC_ARG_WITH(lockdir, AS_HELP_STRING([--with-lockdir=DIR], 611 [set SANE lockdir @<:@localstatedir/lock@:>@]), 612 [locksanedir=$withval],[locksanedir=${localstatedir}/lock]) 613AC_SUBST(locksanedir) 614 615configdir="${sysconfdir}/sane.d" 616AC_SUBST(configdir) 617 618dnl *********************************************************************** 619dnl enable/disable backends and features based on previous tests and user's 620dnl choice 621dnl *********************************************************************** 622 623AM_CPPFLAGS="${AM_CPPFLAGS} -DPATH_SANE_CONFIG_DIR=\$(configdir) \ 624 -DPATH_SANE_DATA_DIR=\$(datadir) \ 625 -DPATH_SANE_LOCK_DIR=\$(locksanedir) \ 626 -DV_MAJOR=${V_MAJOR} -DV_MINOR=${V_MINOR}" 627 628if test "${ac_cv_header_sys_socket_h}" = "no"; then 629 echo "*** disabling saned (sys/socket.h not found)" 630 SANED= 631else 632 SANED=saned 633fi 634AM_CONDITIONAL(COMPILE_SANED, test x$SANED = xsaned) 635 636dnl These are the backends that are build in any case: 637 638AC_ARG_ENABLE(local-backends, 639 AS_HELP_STRING([--disable-local-backends], 640 [turn off compilation of all backends but net])) 641 642ALL_BACKENDS="abaton agfafocus apple artec artec_eplus48u as6e \ 643 avision bh canon canon630u canon_dr canon_lide70 canon_pp cardscan \ 644 coolscan coolscan2 coolscan3 dc25 dc210 dc240 \ 645 dell1600n_net dmc epjitsu epson epson2 epsonds escl fujitsu \ 646 genesys gphoto2 gt68xx hp hp3500 hp3900 hp4200 hp5400 \ 647 hp5590 hpsj5s hpljm1005 hs2p ibm kodak kodakaio kvs1025 kvs20xx \ 648 kvs40xx leo lexmark ma1509 magicolor \ 649 matsushita microtek microtek2 mustek mustek_pp \ 650 mustek_usb mustek_usb2 nec net niash pie pieusb pint \ 651 pixma plustek plustek_pp qcam ricoh ricoh2 rts8891 s9036 \ 652 sceptre sharp sm3600 sm3840 snapscan sp15c st400 \ 653 stv680 tamarack teco1 teco2 teco3 test u12 umax \ 654 umax_pp umax1220u v4l xerox_mfp p5" 655 656# If user specifies backends manually then cause configure 657# to fail if its detected it can't be compiled. If we 658# are in automatic mode then remove backend from list instead. 659user_selected_backends="yes" 660 661AC_ARG_VAR(BACKENDS, [list of backends to compile]) 662if eval "test x$enable_local_backends = xno"; then 663 BACKENDS="net" 664else 665 if test "${BACKENDS}" != "" ; then 666 AC_MSG_NOTICE([Manually selected backends: ${BACKENDS}]) 667 else 668 BACKENDS="$ALL_BACKENDS" 669 user_selected_backends="no" 670 fi 671fi 672 673if test "${sane_cv_use_libjpeg}" = "yes"; then 674 SANEI_SANEI_JPEG_LO="../sanei/sanei_jpeg.lo" 675 saved_LIBS="${LIBS}" 676 LIBS="${JPEG_LIBS}" 677 AC_CHECK_FUNCS(jpeg_crop_scanline jpeg_skip_scanlines) 678 LIBS="${saved_LIBS}" 679fi 680AM_CONDITIONAL(HAVE_JPEG, test x$sane_cv_use_libjpeg = xyes) 681AC_SUBST(SANEI_SANEI_JPEG_LO) 682 683SANE_CHECK_BACKENDS 684 685AC_ARG_ENABLE(pnm-backend, 686 AS_HELP_STRING([--enable-pnm-backend], 687 [enable the pnm backend for testing frontends (possible security risk, see PROBLEMS file)]), 688 [FILTERED_BACKENDS="${FILTERED_BACKENDS} pnm"], 689 [echo "*** pnm backend not manually selected - disabling"]) 690 691BACKENDS="$FILTERED_BACKENDS" 692BACKEND_LIBS_ENABLED="" 693BACKEND_CONFS_ENABLED="" 694BACKEND_MANS_ENABLED="" 695for backend in ${BACKENDS} ; do 696 BACKEND_LIBS_ENABLED="${BACKEND_LIBS_ENABLED} libsane-${backend}.la" 697 BACKEND_CONFS_ENABLED="${BACKEND_CONFS_ENABLED} ${backend}.conf" 698 BACKEND_MANS_ENABLED="${BACKEND_MANS_ENABLED} sane-${backend}.5" 699 if test x$backend = xgenesys; then 700 with_genesys_tests=yes 701 fi 702 if test x$backend = xumax_pp; then 703 install_umax_pp_tools=yes 704 fi 705done 706AC_SUBST(BACKEND_LIBS_ENABLED) 707AM_CONDITIONAL(WITH_GENESYS_TESTS, test xyes = x$with_genesys_tests) 708AM_CONDITIONAL(INSTALL_UMAX_PP_TOOLS, test xyes = x$install_umax_pp_tools) 709 710AC_ARG_VAR(PRELOADABLE_BACKENDS, [list of backends to preload into single DLL]) 711if test "${enable_preload}" = "auto"; then 712 if test "${enable_shared}" = "no" || test "${enable_dynamic}" != "yes"; then 713 enable_preload=yes 714 fi 715fi 716if test "${enable_preload}" = "yes"; then 717 echo "preloading backends into DLL" 718 719 # If user specifies backends manually then cause configure 720 # to fail if its detected it can't be compiled. If we 721 # are in automatic mode then remove backend from list instead. 722 user_selected_backends="yes" 723 724 if eval "test x$enable_local_backends = xno"; then 725 PRELOADABLE_BACKENDS="net" 726 else 727 if test "${PRELOADABLE_BACKENDS}" != "" ; then 728 AC_MSG_NOTICE([Manually selected preloadable backends: ${PRELOADABLE_BACKENDS}]) 729 else 730 PRELOADABLE_BACKENDS="$BACKENDS" 731 user_selected_backends="no" 732 fi 733 fi 734 735 saved_BACKENDS="$BACKENDS" 736 BACKENDS="${PRELOADABLE_BACKENDS}" 737 738 SANE_CHECK_BACKENDS 739 740 PRELOADABLE_BACKENDS="$FILTERED_BACKENDS" 741 BACKENDS="$saved_BACKENDS" 742else 743 PRELOADABLE_BACKENDS="" 744fi 745PRELOADABLE_BACKENDS_ENABLED="" 746# Do not initialize BACKEND_CONFS_ENABLED so that its a combination 747# of all backends. 748for backend in ${PRELOADABLE_BACKENDS} ; do 749 BACKEND_CONFS_ENABLED="${BACKEND_CONFS_ENABLED} ${backend}.conf" 750 BACKEND_MANS_ENABLED="${BACKEND_MANS_ENABLED} sane-${backend}.5" 751 # Special hacks. Normally, we create a convenience library that 752 # matches the backend's name but in some cases that will conflict 753 # with an external library name that also matches backend name. 754 # Work around that here by renaming internal library. 755 if test "${backend}" = "gphoto2"; then 756 backend=gphoto2_i 757 fi 758 PRELOADABLE_BACKENDS_ENABLED="${PRELOADABLE_BACKENDS_ENABLED} lib${backend}.la" 759done 760AM_CONDITIONAL([preloadable_backends_enabled], 761 [test x != "x$PRELOADABLE_BACKENDS_ENABLED"]) 762 763AC_SUBST(PRELOADABLE_BACKENDS) 764AC_SUBST(PRELOADABLE_BACKENDS_ENABLED) 765AC_SUBST(BACKEND_CONFS_ENABLED) 766AC_SUBST(BACKEND_MANS_ENABLED) 767 768dnl in BeOS, backends are not installed in lib/sane, but add-ons/sane/ 769dnl we account for both installing in /boot/beos and ~/config 770case $host_os in 771 beos*) 772 libdir='${exec_prefix}/add-ons' 773 ;; 774esac 775 776AC_ARG_ENABLE(parport-directio, 777 AS_HELP_STRING([--enable-parport-directio], 778 [enable direct hardware access to the parallel port, so 779 frontends will require special permission level]), 780 [ 781 if eval "test x$enable_parport_directio = xyes"; then 782 AM_CFLAGS="$AM_CFLAGS -DENABLE_PARPORT_DIRECTIO" 783 fi 784 ]) 785 786dnl *********************************************************************** 787dnl Write output files 788dnl *********************************************************************** 789 790AC_SUBST(AM_CPPFLAGS) 791AC_SUBST(AM_CFLAGS) 792AC_SUBST(AM_CXXFLAGS) 793AC_SUBST(AM_LDFLAGS) 794 795AC_CONFIG_FILES([Makefile lib/Makefile sanei/Makefile frontend/Makefile \ 796 japi/Makefile backend/Makefile include/Makefile doc/Makefile \ 797 po/Makefile.in testsuite/Makefile \ 798 testsuite/backend/Makefile \ 799 testsuite/backend/genesys/Makefile \ 800 testsuite/sanei/Makefile testsuite/tools/Makefile \ 801 tools/Makefile doc/doxygen-sanei.conf doc/doxygen-genesys.conf]) 802AC_CONFIG_FILES([tools/sane-config], [chmod a+x tools/sane-config]) 803AC_CONFIG_FILES([tools/sane-backends.pc]) 804AC_OUTPUT 805 806dnl *********************************************************************** 807dnl print configuration information 808dnl *********************************************************************** 809 810echo "-> Variables used for compilation/linking:" 811echo AM_CPPFLAGS=\"${AM_CPPFLAGS}\" 812echo AM_CFLAGS=\"${AM_CFLAGS}\" 813echo AM_CXXFLAGS=\"${AM_CXXFLAGS}\" 814echo AM_LDFLAGS=\"${AM_LDFLAGS}\" 815echo LIBS=\"${LIBS}\" 816echo "-> Installation directories:" 817echo "Configuration: `eval eval echo ${sysconfdir}`" 818echo "Libraries: `eval eval echo ${libdir}`" 819echo "Binaries: `eval eval echo ${bindir}` and `eval eval echo ${sbindir}`" 820echo "Manpages: `eval eval echo ${mandir}`" 821echo "Documentation: `eval eval echo ${docdir}`" 822if eval "test x$INSTALL_LOCKPATH = xinstall-lockpath" ; then 823 echo "Lockfiles: `eval eval echo ${locksanedir}`" 824else 825 echo "Lockfiles: Feature is disabled!" 826fi 827echo "-> Network parameters:" 828if test "${SANED}" = "saned" ; then 829 echo "Build saned: yes" 830else 831 echo "Build saned: no" 832fi 833echo "IPv6 support: `eval eval echo ${ipv6}`" 834echo "Avahi support: `eval eval echo ${with_avahi}`" 835echo "cURL support: `eval eval echo ${with_libcurl}`" 836echo "POPPLER_GLIB support: `eval eval echo ${with_poppler_glib}`" 837echo "SNMP support: `eval eval echo ${with_snmp}`" 838echo "-> The following backends will be built:" 839for backend in ${BACKENDS} ; do 840 echo $ECHO_N "${backend} " 841done 842echo 843echo 844echo "-> The following preload backends will be built:" 845for backend in ${PRELOADABLE_BACKENDS} ; do 846 echo $ECHO_N "${backend} " 847done 848echo 849 850if test "$SANE_CONFIG_PATH" != "no" ; then 851 SANE_INSTALLED_VERSION=`$SANE_CONFIG_PATH --version` 852 SANE_INSTALLED_PREFIX=`$SANE_CONFIG_PATH --prefix` 853 if test "$SANE_INSTALLED_PREFIX" != "$prefix" ; then 854 echo "*** WARNING: SANE is already installed (version $SANE_INSTALLED_VERSION). The old" 855 echo "*** installation is at $SANE_INSTALLED_PREFIX while SANE will now be installed" 856 echo "*** at $prefix. It is recommended to uninstall the old SANE version" 857 echo "*** before installing the new one to avoid problems." 858 fi 859else 860 if test "$LIBSANE_EXISTS" = "yes" ; then 861 echo "*** Warning: An old version of SANE was detected but the sane-config program" 862 echo "*** couldn't be found. If you encounter any problems with SANE remove the old" 863 echo "*** SANE files and reinstall this version." 864 fi 865fi 866if eval "test x${sysconfdir} = x/usr/etc" ; then 867 echo "*** WARNING: Configuration files are stored in /usr/etc. If this is not" 868 echo "*** intended, use --sysconfdir to set another path (e.g. "/etc")." 869fi 870if test "$SELECTED_BACKENDS" != "" ; then 871 echo "*** Warning: Local backends have been disabled. This means that scanners" 872 echo "*** connected to your local computer won't be supported. Only a network" 873 echo "*** connection to a remote host is possible." 874fi 875if test "$with_usb" != "no" && test "$have_usb" != "yes" ; then 876 echo "*** Warning: sane-backends will be built without USB support. There may" 877 echo "*** be valid reasons to do so, e.g. if you don't use USB scanners or on" 878 echo "*** platforms without USB support but generally this means that you" 879 echo "*** can't use USB devices with SANE. The most probable cause is that" 880 if test "${ac_cv_header_usb_h}" != "yes"; then 881 echo "*** the libusb header file usb.h is not installed. If you use Linux" 882 echo "*** you may need a package called 'libusb-dev', 'libusb-devel' or similar." 883 else 884 echo "*** libusb is not installed at all or is too old. See README." 885 fi 886fi 887 888echo "****************************************************************" 889echo "* Please be sure to read file PROBLEMS in this directory *" 890echo "* BEFORE running any of the SANE applications. Some devices *" 891echo "* may be damaged by improper operation, so please do heed this *" 892echo "* advice. *" 893echo "****************************************************************" 894