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