1dnl
2dnl Contains the following macros
3dnl   SANE_SET_AM_CFLAGS(is_release)
4dnl   SANE_CHECK_MISSING_HEADERS
5dnl   SANE_SET_AM_LDFLAGS
6dnl   SANE_CHECK_DLL_LIB
7dnl   SANE_EXTRACT_LDFLAGS(LIBS, LDFLAGS)
8dnl   SANE_CHECK_JPEG
9dnl   SANE_CHECK_IEEE1284
10dnl   SANE_CHECK_PTHREAD
11dnl   SANE_CHECK_LOCKING
12dnl   JAPHAR_GREP_AM_CFLAGS(flag, cmd_if_missing, cmd_if_present)
13dnl   SANE_CHECK_U_TYPES
14dnl   SANE_CHECK_GPHOTO2
15dnl   SANE_CHECK_IPV6
16dnl   SANE_CHECK_BACKENDS
17dnl   SANE_PROTOTYPES
18dnl   AC_PROG_LIBTOOL
19dnl
20
21# SANE_SET_AM_CFLAGS(is_release)
22# Set default AM_CFLAGS if gcc is used.  Enable/disable additional
23# compilation warnings.  The extra warnings are enabled by default
24# during the development cycle but disabled for official releases.
25# The argument is_release is either yes or no.
26AC_DEFUN([SANE_SET_AM_CFLAGS],
27[
28if test "${ac_cv_c_compiler_gnu}" = "yes"; then
29  DEFAULT_WARNINGS="\
30      -Wall"
31  EXTRA_WARNINGS="\
32      -Wextra \
33      -pedantic"
34
35  for flag in $DEFAULT_WARNINGS; do
36    JAPHAR_GREP_AM_CFLAGS($flag, [ AM_CFLAGS="$AM_CFLAGS $flag" ])
37    JAPHAR_GREP_AM_CXXFLAGS($flag, [ AM_CXXFLAGS="$AM_CXXFLAGS $flag" ])
38  done
39
40  AC_ARG_ENABLE(warnings,
41    AS_HELP_STRING([--enable-warnings],
42                   [turn on tons of compiler warnings (GCC only)]),
43    [
44      if eval "test x$enable_warnings = xyes"; then
45        for flag in $EXTRA_WARNINGS; do
46          JAPHAR_GREP_AM_CFLAGS($flag, [ AM_CFLAGS="$AM_CFLAGS $flag" ])
47          JAPHAR_GREP_AM_CXXFLAGS($flag, [ AM_CXXFLAGS="$AM_CXXFLAGS $flag" ])
48        done
49      fi
50    ],
51    [if test x$1 = xno; then
52       # Warnings enabled by default (development)
53       for flag in $EXTRA_WARNINGS; do
54         JAPHAR_GREP_AM_CFLAGS($flag, [ AM_CFLAGS="$AM_CFLAGS $flag" ])
55         JAPHAR_GREP_AM_CXXFLAGS($flag, [ AM_CXXFLAGS="$AM_CXXFLAGS $flag" ])
56       done
57    fi])
58fi # ac_cv_c_compiler_gnu
59])
60
61dnl SANE_CHECK_MISSING_HEADERS
62dnl Do some sanity checks. It doesn't make sense to proceed if those headers
63dnl aren't present.
64AC_DEFUN([SANE_CHECK_MISSING_HEADERS],
65[
66  MISSING_HEADERS=
67  if test "${ac_cv_header_fcntl_h}" != "yes" ; then
68    MISSING_HEADERS="${MISSING_HEADERS}\"fcntl.h\" "
69  fi
70  if test "${ac_cv_header_sys_time_h}" != "yes" ; then
71    MISSING_HEADERS="${MISSING_HEADERS}\"sys/time.h\" "
72  fi
73  if test "${ac_cv_header_unistd_h}" != "yes" ; then
74    MISSING_HEADERS="${MISSING_HEADERS}\"unistd.h\" "
75  fi
76  if test "${MISSING_HEADERS}" != "" ; then
77    echo "*** The following essential header files couldn't be found:"
78    echo "*** ${MISSING_HEADERS}"
79    echo "*** Maybe the compiler isn't ANSI C compliant or not properly installed?"
80    echo "*** For details on what went wrong see config.log."
81    AC_MSG_ERROR([Exiting now.])
82  fi
83])
84
85# SANE_SET_AM_LDFLAGS
86# Add special AM_LDFLAGS
87AC_DEFUN([SANE_SET_AM_LDFLAGS],
88[
89  # Define stricter linking policy on GNU systems.  This is not
90  # added to global LDFLAGS because we may want to create convenience
91  # libraries that don't require such strick linking.
92  if test "$GCC" = yes; then
93    case ${host_os} in
94    linux* | solaris*)
95      STRICT_LDFLAGS="-Wl,-z,defs"
96      ;;
97    esac
98  fi
99  AC_SUBST(STRICT_LDFLAGS)
100  case "${host_os}" in
101    aix*) #enable .so libraries, disable archives
102      AM_LDFLAGS="$AM_LDFLAGS -Wl,-brtl"
103      ;;
104    darwin*) #include frameworks
105      LIBS="$LIBS -framework CoreFoundation -framework IOKit"
106      ;;
107  esac
108])
109
110# SANE_CHECK_DLL_LIB
111# Find dll library
112AC_DEFUN([SANE_CHECK_DLL_LIB],
113[
114  dnl Checks for dll libraries: dl
115  DL_LIBS=""
116  if test "${enable_dynamic}" = "auto"; then
117      # default to disabled unless library found.
118      enable_dynamic=no
119      # dlopen
120      AC_CHECK_HEADERS(dlfcn.h,
121      [AC_CHECK_LIB(dl, dlopen, DL_LIBS=-ldl)
122       saved_LIBS="${LIBS}"
123       LIBS="${LIBS} ${DL_LIBS}"
124       AC_CHECK_FUNCS(dlopen, enable_dynamic=yes,)
125       LIBS="${saved_LIBS}"
126      ],)
127      # HP/UX DLL handling
128      AC_CHECK_HEADERS(dl.h,
129      [AC_CHECK_LIB(dld,shl_load, DL_LIBS=-ldld)
130       saved_LIBS="${LIBS}"
131       LIBS="${LIBS} ${DL_LIBS}"
132       AC_CHECK_FUNCS(shl_load, enable_dynamic=yes,)
133       LIBS="${saved_LIBS}"
134      ],)
135      if test -z "$DL_LIBS" ; then
136      # old Mac OS X/Darwin (without dlopen)
137      AC_CHECK_HEADERS(mach-o/dyld.h,
138      [AC_CHECK_FUNCS(NSLinkModule, enable_dynamic=yes,)
139      ],)
140      fi
141  fi
142  AC_SUBST(DL_LIBS)
143
144  DYNAMIC_FLAG=
145  if test "${enable_dynamic}" = yes ; then
146    DYNAMIC_FLAG=-module
147  fi
148  AC_SUBST(DYNAMIC_FLAG)
149])
150
151#
152# Separate LIBS from LDFLAGS to link correctly on HP/UX (and other
153# platforms who care about the order of params to ld.  It removes all
154# non '-l..'-params from passed in $1(LIBS), and appends them to $2(LDFLAGS).
155#
156# Use like this: SANE_EXTRACT_LDFLAGS(PKGNAME_LIBS, PKGNAME_LDFLAGS)
157 AC_DEFUN([SANE_EXTRACT_LDFLAGS],
158[
159    tmp_LIBS=""
160    for param in ${$1}; do
161        case "${param}" in
162	-l*)
163         tmp_LIBS="${tmp_LIBS} ${param}"
164	 ;;
165	 *)
166         $2="${$2} ${param}"
167	 ;;
168	 esac
169     done
170     $1="${tmp_LIBS}"
171     unset tmp_LIBS
172     unset param
173])
174
175#
176#
177# Checks for ieee1284 library, needed for canon_pp backend.
178AC_DEFUN([SANE_CHECK_IEEE1284],
179[
180  AC_CHECK_HEADER(ieee1284.h, [
181    AC_CACHE_CHECK([for libieee1284 >= 0.1.5], sane_cv_use_libieee1284, [
182      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <ieee1284.h>]], [[
183	struct parport p; char *buf;
184	ieee1284_nibble_read(&p, 0, buf, 1);
185	]])],
186        [sane_cv_use_libieee1284="yes"; IEEE1284_LIBS="-lieee1284"
187      ],[sane_cv_use_libieee1284="no"])
188    ],)
189  ],)
190  if test "$sane_cv_use_libieee1284" = "yes" ; then
191    AC_DEFINE(HAVE_LIBIEEE1284,1,[Define to 1 if you have the `ieee1284' library (-lcam).])
192  fi
193  AC_SUBST(IEEE1284_LIBS)
194])
195
196#
197# Checks for pthread support
198AC_DEFUN([SANE_CHECK_PTHREAD],
199[
200
201  case "${host_os}" in
202  linux* | darwin* | mingw*) # enabled by default on Linux, MacOS X and MINGW
203    use_pthread=yes
204    ;;
205  *)
206    use_pthread=no
207  esac
208  have_pthread=no
209
210  #
211  # now that we have the systems preferences, we check
212  # the user
213
214  AC_ARG_ENABLE([pthread],
215    AS_HELP_STRING([--enable-pthread],
216                   [use pthread instead of fork (default=yes for Linux/MacOS X/MINGW, no for everything else)]),
217    [
218      if test $enableval = yes ; then
219        use_pthread=yes
220      else
221        use_pthread=no
222      fi
223    ])
224
225  if test $use_pthread = yes ; then
226  AC_CHECK_HEADERS(pthread.h,
227    [
228       AC_CHECK_LIB(pthread, pthread_create, PTHREAD_LIBS="-lpthread")
229       have_pthread=yes
230       save_LIBS="$LIBS"
231       LIBS="$LIBS $PTHREAD_LIBS"
232       AC_CHECK_FUNCS([pthread_create pthread_kill pthread_join pthread_detach pthread_cancel pthread_testcancel],
233	,[ have_pthread=no; use_pthread=no ])
234       LIBS="$save_LIBS"
235    ],[ have_pthread=no; use_pthread=no ])
236  fi
237
238  # Based on a similar test for pthread_key_t from the Python project.
239  # See https://bugs.python.org/review/25658/patch/19209/75870
240  AC_MSG_CHECKING(whether pthread_t is integer)
241  AC_COMPILE_IFELSE(
242    [AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t k; k * 1;]])],
243    [ac_pthread_t_is_integer=yes],
244    [ac_pthread_t_is_integer=no]
245  )
246  AC_MSG_RESULT($ac_pthread_t_is_integer)
247  if test "$ac_pthread_t_is_integer" = yes ; then
248    AC_DEFINE(PTHREAD_T_IS_INTEGER, 1,
249              [Define if pthread_t is integer.])
250  else
251    # Until the sanei_thread implementation is fixed.
252    use_pthread=no
253  fi
254
255  if test "$have_pthread" = "yes" ; then
256    AM_CPPFLAGS="${AM_CPPFLAGS} -D_REENTRANT"
257  fi
258  AC_SUBST(PTHREAD_LIBS)
259
260  if test $use_pthread = yes ; then
261    AC_DEFINE_UNQUOTED(USE_PTHREAD, "$use_pthread",
262                   [Define if pthreads should be used instead of forked processes.])
263    SANEI_THREAD_LIBS=$PTHREAD_LIBS
264  else
265    SANEI_THREAD_LIBS=""
266  fi
267  AC_SUBST(SANEI_THREAD_LIBS)
268  AC_MSG_CHECKING([whether to enable pthread support])
269  AC_MSG_RESULT([$have_pthread])
270  AC_MSG_CHECKING([whether to use pthread instead of fork])
271  AC_MSG_RESULT([$use_pthread])
272])
273
274#
275# Checks for jpeg library >= v6B (61), needed for DC210,  DC240,
276# GPHOTO2 and dell1600n_net backends.
277AC_DEFUN([SANE_CHECK_JPEG],
278[
279  AC_CHECK_LIB(jpeg,jpeg_start_decompress,
280  [
281    AC_CHECK_HEADER(jconfig.h,
282    [
283      AC_MSG_CHECKING([for jpeglib - version >= 61 (6a)])
284      AC_EGREP_CPP(sane_correct_jpeg_lib_version_found,
285      [
286        #include <jpeglib.h>
287        #if JPEG_LIB_VERSION >= 61
288          sane_correct_jpeg_lib_version_found
289        #endif
290      ], [sane_cv_use_libjpeg="yes"; JPEG_LIBS="-ljpeg";
291      AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
292    ],)
293  ],)
294  if test "$sane_cv_use_libjpeg" = "yes" ; then
295    AC_DEFINE(HAVE_LIBJPEG,1,[Define to 1 if you have the libjpeg library.])
296  fi
297  AC_SUBST(JPEG_LIBS)
298])
299
300# Checks for tiff library dell1600n_net backend.
301AC_DEFUN([SANE_CHECK_TIFF],
302[
303  AC_CHECK_LIB(tiff,TIFFFdOpen,
304  [
305    AC_CHECK_HEADER(tiffio.h,
306    [sane_cv_use_libtiff="yes"; TIFF_LIBS="-ltiff"],)
307  ],)
308  AC_SUBST(TIFF_LIBS)
309])
310
311AC_DEFUN([SANE_CHECK_PNG],
312[
313  AC_CHECK_LIB(png,png_init_io,
314  [
315    AC_CHECK_HEADER(png.h,
316    [sane_cv_use_libpng="yes"; PNG_LIBS="-lpng"],)
317  ],)
318  if test "$sane_cv_use_libpng" = "yes" ; then
319    AC_DEFINE(HAVE_LIBPNG,1,[Define to 1 if you have the libpng library.])
320  fi
321  AC_SUBST(PNG_LIBS)
322])
323
324#
325# Checks for device locking support
326AC_DEFUN([SANE_CHECK_LOCKING],
327[
328  use_locking=yes
329  case "${host_os}" in
330    os2* )
331      use_locking=no
332      ;;
333  esac
334
335  #
336  # we check the user
337  AC_ARG_ENABLE( [locking],
338    AS_HELP_STRING([--enable-locking],
339                   [activate device locking (default=yes, but only used by some backends)]),
340    [
341      if test $enableval = yes ; then
342        use_locking=yes
343      else
344        use_locking=no
345      fi
346    ])
347  if test $use_locking = yes ; then
348    INSTALL_LOCKPATH=install-lockpath
349    AC_DEFINE([ENABLE_LOCKING], 1,
350              [Define to 1 if device locking should be enabled.])
351  else
352    INSTALL_LOCKPATH=
353  fi
354  AC_MSG_CHECKING([whether to enable device locking])
355  AC_MSG_RESULT([$use_locking])
356  AC_SUBST(INSTALL_LOCKPATH)
357])
358
359dnl
360dnl JAPHAR_GREP_AM_CFLAGS(flag, cmd_if_missing, cmd_if_present)
361dnl
362dnl From Japhar.  Report changes to japhar@hungry.com
363dnl
364AC_DEFUN([JAPHAR_GREP_AM_CFLAGS],
365[case "$AM_CFLAGS" in
366"$1" | "$1 "* | *" $1" | *" $1 "* )
367  ifelse($#, 3, [$3], [:])
368  ;;
369*)
370  $2
371  ;;
372esac
373])
374
375dnl
376dnl JAPHAR_GREP_AM_CXXFLAGS(flag, cmd_if_missing, cmd_if_present)
377dnl
378AC_DEFUN([JAPHAR_GREP_AM_CXXFLAGS],
379[case "$AM_CXXFLAGS" in
380"$1" | "$1 "* | *" $1" | *" $1 "* )
381  ifelse($#, 3, [$3], [:])
382  ;;
383*)
384  $2
385  ;;
386esac
387])
388
389dnl
390dnl   SANE_CHECK_U_TYPES
391dnl
392AC_DEFUN([SANE_CHECK_U_TYPES],
393[
394dnl Use new style of check types that doesn't take default to use.
395dnl The old style would add an #undef of the type check on platforms
396dnl that defined that type... That is not portable to platform that
397dnl define it as a #define.
398AC_CHECK_TYPES([u_char, u_short, u_int, u_long],,,)
399])
400
401#
402# Checks for gphoto2 libs, needed by gphoto2 backend
403AC_DEFUN([SANE_CHECK_GPHOTO2],
404[
405  AC_ARG_WITH(gphoto2,
406	      AS_HELP_STRING([--with-gphoto2],
407			     [include the gphoto2 backend @<:@default=yes@:>@]),
408	      [# If --with-gphoto2=no or --without-gphoto2, disable backend
409               # as "$with_gphoto2" will be set to "no"])
410
411  # If --with-gphoto2=yes (or not supplied), first check if
412  # pkg-config exists, then use it to check if libgphoto2 is
413  # present.  If all that works, then see if we can actually link
414  # a program.   And, if that works, then add the -l flags to
415  # GPHOTO2_LIBS and any other flags to GPHOTO2_LDFLAGS to pass to
416  # sane-config.
417  if test "$with_gphoto2" != "no" ; then
418    AC_CHECK_TOOL(HAVE_GPHOTO2, pkg-config, false)
419
420    if test ${HAVE_GPHOTO2} != "false" ; then
421      if pkg-config --exists libgphoto2 ; then
422        with_gphoto2="`pkg-config --modversion libgphoto2`"
423	GPHOTO2_CPPFLAGS="`pkg-config --cflags libgphoto2`"
424        GPHOTO2_LIBS="`pkg-config --libs libgphoto2`"
425
426        saved_CPPFLAGS="${CPPFLAGS}"
427        CPPFLAGS="${GPHOTO2_CPPFLAGS}"
428	saved_LIBS="${LIBS}"
429	LIBS="${LIBS} ${GPHOTO2_LIBS}"
430 	# Make sure we an really use the library
431        AC_CHECK_FUNCS(gp_camera_init, HAVE_GPHOTO2=true, HAVE_GPHOTO2=false)
432	if test "${HAVE_GPHOTO2}" = "true"; then
433	  AC_CHECK_FUNCS(gp_port_info_get_path)
434	fi
435	CPPFLAGS="${saved_CPPFLAGS}"
436        LIBS="${saved_LIBS}"
437      else
438        HAVE_GPHOTO2=false
439      fi
440      if test "${HAVE_GPHOTO2}" = "false"; then
441        GPHOTO2_CPPFLAGS=""
442        GPHOTO2_LIBS=""
443      else
444        SANE_EXTRACT_LDFLAGS(GPHOTO2_LIBS, GPHOTO2_LDFLAGS)
445        if pkg-config --atleast-version=2.5.0 libgphoto2; then
446          AC_DEFINE([GPLOGFUNC_NO_VARGS], [1],
447                    [Define if GPLogFunc does not take a va_list.])
448        fi
449      fi
450    fi
451  fi
452  AC_SUBST(GPHOTO2_CPPFLAGS)
453  AC_SUBST(GPHOTO2_LIBS)
454  AC_SUBST(GPHOTO2_LDFLAGS)
455])
456
457#
458# Check for AF_INET6, determines whether or not to enable IPv6 support
459# Check for ss_family member in struct sockaddr_storage
460AC_DEFUN([SANE_CHECK_IPV6],
461[
462  AC_MSG_CHECKING([whether to enable IPv6])
463  AC_ARG_ENABLE(ipv6,
464    AS_HELP_STRING([--disable-ipv6],[disable IPv6 support]),
465      [  if test "$enableval" = "no" ; then
466         AC_MSG_RESULT([no, manually disabled])
467         ipv6=no
468         fi
469      ])
470
471  if test "$ipv6" != "no" ; then
472    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
473	#define INET6
474	#include <sys/types.h>
475	#include <sys/socket.h> ]], [[
476	 /* AF_INET6 available check */
477 	if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
478   	  exit(1);
479 	else
480   	  exit(0);
481      ]])],[
482        AC_MSG_RESULT(yes)
483        AC_DEFINE([ENABLE_IPV6], 1, [Define to 1 if the system supports IPv6])
484        ipv6=yes
485      ],[
486        AC_MSG_RESULT([no (couldn't compile test program)])
487        ipv6=no
488      ])
489  fi
490
491  if test "$ipv6" != "no" ; then
492    AC_MSG_CHECKING([whether struct sockaddr_storage has an ss_family member])
493    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
494	#define INET6
495	#include <sys/types.h>
496	#include <sys/socket.h> ]], [[
497	/* test if the ss_family member exists in struct sockaddr_storage */
498	struct sockaddr_storage ss;
499	ss.ss_family = AF_INET;
500	exit (0);
501    ]])], [
502	AC_MSG_RESULT(yes)
503	AC_DEFINE([HAS_SS_FAMILY], 1, [Define to 1 if struct sockaddr_storage has an ss_family member])
504    ], [
505		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
506		#define INET6
507		#include <sys/types.h>
508		#include <sys/socket.h> ]], [[
509		/* test if the __ss_family member exists in struct sockaddr_storage */
510		struct sockaddr_storage ss;
511		ss.__ss_family = AF_INET;
512		exit (0);
513	  ]])], [
514		AC_MSG_RESULT([no, but __ss_family exists])
515		AC_DEFINE([HAS___SS_FAMILY], 1, [Define to 1 if struct sockaddr_storage has __ss_family instead of ss_family])
516	  ], [
517		AC_MSG_RESULT([no])
518		ipv6=no
519    	  ])
520    ])
521  fi
522])
523
524#
525# Verifies that values in $BACKENDS and updates FILTERED_BACKEND
526# with either backends that can be compiled or fails the script.
527AC_DEFUN([SANE_CHECK_BACKENDS],
528[
529if test "${user_selected_backends}" = "yes"; then
530  DISABLE_MSG="aborting"
531else
532  DISABLE_MSG="disabling"
533fi
534
535FILTERED_BACKENDS=""
536for be in ${BACKENDS}; do
537  backend_supported="yes"
538  case $be in
539    plustek_pp)
540    case "$host_os" in
541      gnu*)
542      echo "*** $be backend not supported on GNU/Hurd - $DISABLE_MSG"
543      backend_supported="no"
544      ;;
545    esac
546    ;;
547
548    dc210|dc240|pixma)
549    if test "${sane_cv_use_libjpeg}" != "yes"; then
550      echo "*** $be backend requires JPEG library - $DISABLE_MSG"
551      backend_supported="no"
552    fi
553    ;;
554
555    canon_pp|hpsj5s)
556    if test "${sane_cv_use_libieee1284}" != "yes"; then
557      echo "*** $be backend requires libieee1284 library - $DISABLE_MSG"
558      backend_supported="no"
559    fi
560    ;;
561
562    genesys)
563    if test "${HAVE_CXX11}" != "1"; then
564      echo "*** $be backend requires C++11 support - $DISABLE_MSG"
565      backend_supported="no"
566    fi
567    ;;
568
569    mustek_pp)
570    if test "${sane_cv_use_libieee1284}" != "yes" && test "${enable_parport_directio}" != "yes"; then
571      echo "*** $be backend requires libieee1284 or parport-directio libraries - $DISABLE_MSG"
572      backend_supported="no"
573    fi
574    ;;
575
576    dell1600n_net)
577    if test "${sane_cv_use_libjpeg}" != "yes" || test "${sane_cv_use_libtiff}" != "yes"; then
578      echo "*** $be backend requires JPEG and TIFF library - $DISABLE_MSG"
579      backend_supported="no"
580    fi
581    ;;
582
583    epsonds)
584    if test "${sane_cv_use_libjpeg}" != "yes"; then
585      echo "*** $be backend requires JPEG library - $DISABLE_MSG"
586      backend_supported="no"
587    fi
588    ;;
589
590    escl)
591    if test "x${with_avahi}" != "xyes"; then
592      echo "*** $be backend requires AVAHI library - $DISABLE_MSG"
593      backend_supported="no"
594    fi
595    if test "x${with_libcurl}" != "xyes"; then
596      echo "*** $be backend requires cURL library - $DISABLE_MSG"
597      backend_supported="no"
598    fi
599    if test "x${have_libxml}" != "xyes"; then
600      echo "*** $be backend requires XML library - $DISABLE_MSG"
601      backend_supported="no"
602    fi
603    # FIXME: Remove when PNG and/or PDF support have been added.
604    if test "x${sane_cv_use_libjpeg}" != "xyes"; then
605      echo "*** $be backend currently requires JPEG library - $DISABLE_MSG"
606      backend_supported="no"
607    else
608      if test "x${ac_cv_func_jpeg_crop_scanline}"  != "xyes" \
609      || test "x${ac_cv_func_jpeg_skip_scanlines}" != "xyes"; then
610        echo "*** $be backend requires a newer JPEG library - $DISABLE_MSG"
611        backend_supported="no"
612      fi
613    fi
614
615    ;;
616
617    gphoto2)
618    if test "${HAVE_GPHOTO2}" != "true" \
619      || test "${sane_cv_use_libjpeg}" != "yes"; then
620      echo "*** $be backend requires gphoto2 and JPEG libraries - $DISABLE_MSG"
621      backend_supported="no"
622    fi
623    ;;
624
625    pint)
626    if test "${ac_cv_header_sys_scanio_h}" = "no"; then
627      echo "*** $be backend requires sys/scanio.h - $DISABLE_MSG"
628      backend_supported="no"
629    fi
630    ;;
631
632    qcam)
633    if ( test "${ac_cv_func_ioperm}" = "no" || test "${sane_cv_have_sys_io_h_with_inb_outb}" = "no" )\
634      && test "${ac_cv_func__portaccess}" = "no"; then
635      echo "*** $be backend requires (ioperm, inb and outb) or portaccess functions - $DISABLE_MSG"
636      backend_supported="no"
637    fi
638    ;;
639
640    v4l)
641    if test "${have_linux_ioctl_defines}" != "yes" \
642      || test "${have_libv4l1}" != "yes"; then
643      echo "*** $be backend requires v4l libraries - $DISABLE_MSG"
644      backend_supported="no"
645    fi
646    ;;
647
648    net)
649    if test "${ac_cv_header_sys_socket_h}" = "no"; then
650      echo "*** $be backend requires sys/socket.h - $DISABLE_MSG"
651      backend_supported="no"
652    fi
653    ;;
654
655    mustek_usb2|kvs40xx)
656    if test "${have_pthread}" != "yes"; then
657      echo "*** $be backend requires pthread library - $DISABLE_MSG"
658      backend_supported="no"
659    fi
660    ;;
661  esac
662  if test "${backend_supported}" = "no"; then
663    if test "${user_selected_backends}" = "yes"; then
664      exit 1
665    fi
666  else
667    FILTERED_BACKENDS="${FILTERED_BACKENDS} $be"
668  fi
669done
670])
671
672#
673# Generate prototypes for functions not available on the system
674AC_DEFUN([SANE_PROTOTYPES],
675[
676AH_BOTTOM([
677
678#if defined(__MINGW32__)
679#define _BSDTYPES_DEFINED
680#endif
681
682#ifndef HAVE_U_CHAR
683#define u_char unsigned char
684#endif
685#ifndef HAVE_U_SHORT
686#define u_short unsigned short
687#endif
688#ifndef HAVE_U_INT
689#define u_int unsigned int
690#endif
691#ifndef HAVE_U_LONG
692#define u_long unsigned long
693#endif
694
695/* Prototype for getenv */
696#ifndef HAVE_GETENV
697#define getenv sanei_getenv
698char * getenv(const char *name);
699#endif
700
701/* Prototype for inet_ntop */
702#ifndef HAVE_INET_NTOP
703#define inet_ntop sanei_inet_ntop
704#include <sys/types.h>
705const char * inet_ntop (int af, const void *src, char *dst, size_t cnt);
706#endif
707
708/* Prototype for inet_pton */
709#ifndef HAVE_INET_PTON
710#define inet_pton sanei_inet_pton
711int inet_pton (int af, const char *src, void *dst);
712#endif
713
714/* Prototype for sigprocmask */
715#ifndef HAVE_SIGPROCMASK
716#define sigprocmask sanei_sigprocmask
717int sigprocmask (int how, int *new, int *old);
718#endif
719
720/* Prototype for snprintf */
721#ifndef HAVE_SNPRINTF
722#define snprintf sanei_snprintf
723#include <sys/types.h>
724int snprintf (char *str,size_t count,const char *fmt,...);
725#endif
726
727/* Prototype for strcasestr */
728#ifndef HAVE_STRCASESTR
729#define strcasestr sanei_strcasestr
730char * strcasestr (const char *phaystack, const char *pneedle);
731#endif
732
733/* Prototype for strdup */
734#ifndef HAVE_STRDUP
735#define strdup sanei_strdup
736char *strdup (const char * s);
737#endif
738
739/* Prototype for strndup */
740#ifndef HAVE_STRNDUP
741#define strndup sanei_strndup
742#include <sys/types.h>
743char *strndup(const char * s, size_t n);
744#endif
745
746/* Prototype for strsep */
747#ifndef HAVE_STRSEP
748#define strsep sanei_strsep
749char *strsep(char **stringp, const char *delim);
750#endif
751
752/* Prototype for usleep */
753#ifndef HAVE_USLEEP
754#define usleep sanei_usleep
755unsigned int usleep (unsigned int useconds);
756#endif
757
758/* Prototype for vsyslog */
759#ifndef HAVE_VSYSLOG
760#include <stdarg.h>
761void vsyslog(int priority, const char *format, va_list args);
762#endif
763])
764])
765
766m4_include([m4/byteorder.m4])
767