• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    case "$host_os" in
252      darwin*)
253        # Always use pthreads on macOS
254        use_pthread=yes
255        ;;
256      *)
257        # Until the sanei_thread implementation is fixed.
258        use_pthread=no
259        ;;
260    esac
261  fi
262
263  if test "$have_pthread" = "yes" ; then
264    AM_CPPFLAGS="${AM_CPPFLAGS} -D_REENTRANT"
265  fi
266  AC_SUBST(PTHREAD_LIBS)
267
268  if test $use_pthread = yes ; then
269    AC_DEFINE_UNQUOTED(USE_PTHREAD, "$use_pthread",
270                   [Define if pthreads should be used instead of forked processes.])
271    SANEI_THREAD_LIBS=$PTHREAD_LIBS
272  else
273    SANEI_THREAD_LIBS=""
274  fi
275  AC_SUBST(SANEI_THREAD_LIBS)
276  AC_MSG_CHECKING([whether to enable pthread support])
277  AC_MSG_RESULT([$have_pthread])
278  AC_MSG_CHECKING([whether to use pthread instead of fork])
279  AC_MSG_RESULT([$use_pthread])
280])
281
282#
283# Checks for jpeg library >= v6B (61), needed for DC210,  DC240,
284# GPHOTO2 and dell1600n_net backends.
285AC_DEFUN([SANE_CHECK_JPEG],
286[
287  AC_CHECK_LIB(jpeg,jpeg_start_decompress,
288  [
289    AC_CHECK_HEADER(jconfig.h,
290    [
291      AC_MSG_CHECKING([for jpeglib - version >= 61 (6a)])
292      AC_EGREP_CPP(sane_correct_jpeg_lib_version_found,
293      [
294        #include <jpeglib.h>
295        #if JPEG_LIB_VERSION >= 61
296          sane_correct_jpeg_lib_version_found
297        #endif
298      ], [sane_cv_use_libjpeg="yes"; JPEG_LIBS="-ljpeg";
299      AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
300    ],)
301  ],)
302  if test "$sane_cv_use_libjpeg" = "yes" ; then
303    AC_DEFINE(HAVE_LIBJPEG,1,[Define to 1 if you have the libjpeg library.])
304  fi
305  AC_SUBST(JPEG_LIBS)
306])
307
308# Checks for tiff library dell1600n_net backend.
309AC_DEFUN([SANE_CHECK_TIFF],
310[
311  AC_CHECK_LIB(tiff,TIFFFdOpen,
312  [
313    AC_CHECK_HEADER(tiffio.h,
314    [sane_cv_use_libtiff="yes"; TIFF_LIBS="-ltiff"],)
315  ],)
316  AC_SUBST(TIFF_LIBS)
317])
318
319AC_DEFUN([SANE_CHECK_PNG],
320[
321  AC_CHECK_LIB(png,png_init_io,
322  [
323    AC_CHECK_HEADER(png.h,
324    [sane_cv_use_libpng="yes"; PNG_LIBS="-lpng"],)
325  ],)
326  if test "$sane_cv_use_libpng" = "yes" ; then
327    AC_DEFINE(HAVE_LIBPNG,1,[Define to 1 if you have the libpng library.])
328  fi
329  AC_SUBST(PNG_LIBS)
330])
331
332#
333# Checks for device locking support
334AC_DEFUN([SANE_CHECK_LOCKING],
335[
336  use_locking=yes
337  case "${host_os}" in
338    os2* )
339      use_locking=no
340      ;;
341  esac
342
343  #
344  # we check the user
345  AC_ARG_ENABLE( [locking],
346    AS_HELP_STRING([--enable-locking],
347                   [activate device locking (default=yes, but only used by some backends)]),
348    [
349      if test $enableval = yes ; then
350        use_locking=yes
351      else
352        use_locking=no
353      fi
354    ])
355  if test $use_locking = yes ; then
356    INSTALL_LOCKPATH=install-lockpath
357    AC_DEFINE([ENABLE_LOCKING], 1,
358              [Define to 1 if device locking should be enabled.])
359  else
360    INSTALL_LOCKPATH=
361  fi
362  AC_MSG_CHECKING([whether to enable device locking])
363  AC_MSG_RESULT([$use_locking])
364  AC_SUBST(INSTALL_LOCKPATH)
365])
366
367dnl
368dnl JAPHAR_GREP_AM_CFLAGS(flag, cmd_if_missing, cmd_if_present)
369dnl
370dnl From Japhar.  Report changes to japhar@hungry.com
371dnl
372AC_DEFUN([JAPHAR_GREP_AM_CFLAGS],
373[case "$AM_CFLAGS" in
374"$1" | "$1 "* | *" $1" | *" $1 "* )
375  ifelse($#, 3, [$3], [:])
376  ;;
377*)
378  $2
379  ;;
380esac
381])
382
383dnl
384dnl JAPHAR_GREP_AM_CXXFLAGS(flag, cmd_if_missing, cmd_if_present)
385dnl
386AC_DEFUN([JAPHAR_GREP_AM_CXXFLAGS],
387[case "$AM_CXXFLAGS" in
388"$1" | "$1 "* | *" $1" | *" $1 "* )
389  ifelse($#, 3, [$3], [:])
390  ;;
391*)
392  $2
393  ;;
394esac
395])
396
397dnl
398dnl   SANE_CHECK_U_TYPES
399dnl
400AC_DEFUN([SANE_CHECK_U_TYPES],
401[
402dnl Use new style of check types that doesn't take default to use.
403dnl The old style would add an #undef of the type check on platforms
404dnl that defined that type... That is not portable to platform that
405dnl define it as a #define.
406AC_CHECK_TYPES([u_char, u_short, u_int, u_long],,,)
407])
408
409#
410# Checks for gphoto2 libs, needed by gphoto2 backend
411AC_DEFUN([SANE_CHECK_GPHOTO2],
412[
413  AC_ARG_WITH(gphoto2,
414	      AS_HELP_STRING([--with-gphoto2],
415			     [include the gphoto2 backend @<:@default=yes@:>@]),
416	      [# If --with-gphoto2=no or --without-gphoto2, disable backend
417               # as "$with_gphoto2" will be set to "no"])
418
419  # If --with-gphoto2=yes (or not supplied), first check if
420  # pkg-config exists, then use it to check if libgphoto2 is
421  # present.  If all that works, then see if we can actually link
422  # a program.   And, if that works, then add the -l flags to
423  # GPHOTO2_LIBS and any other flags to GPHOTO2_LDFLAGS to pass to
424  # sane-config.
425  if test "$with_gphoto2" != "no" ; then
426    AC_CHECK_TOOL(HAVE_GPHOTO2, pkg-config, false)
427
428    if test ${HAVE_GPHOTO2} != "false" ; then
429      if pkg-config --exists libgphoto2 ; then
430        with_gphoto2="`pkg-config --modversion libgphoto2`"
431	GPHOTO2_CPPFLAGS="`pkg-config --cflags libgphoto2`"
432        GPHOTO2_LIBS="`pkg-config --libs libgphoto2`"
433
434        saved_CPPFLAGS="${CPPFLAGS}"
435        CPPFLAGS="${GPHOTO2_CPPFLAGS}"
436	saved_LIBS="${LIBS}"
437	LIBS="${LIBS} ${GPHOTO2_LIBS}"
438 	# Make sure we an really use the library
439        AC_CHECK_FUNCS(gp_camera_init, HAVE_GPHOTO2=true, HAVE_GPHOTO2=false)
440	if test "${HAVE_GPHOTO2}" = "true"; then
441	  AC_CHECK_FUNCS(gp_port_info_get_path)
442	fi
443	CPPFLAGS="${saved_CPPFLAGS}"
444        LIBS="${saved_LIBS}"
445      else
446        HAVE_GPHOTO2=false
447      fi
448      if test "${HAVE_GPHOTO2}" = "false"; then
449        GPHOTO2_CPPFLAGS=""
450        GPHOTO2_LIBS=""
451      else
452        SANE_EXTRACT_LDFLAGS(GPHOTO2_LIBS, GPHOTO2_LDFLAGS)
453        if pkg-config --atleast-version=2.5.0 libgphoto2; then
454          AC_DEFINE([GPLOGFUNC_NO_VARGS], [1],
455                    [Define if GPLogFunc does not take a va_list.])
456        fi
457      fi
458    fi
459  fi
460  AC_SUBST(GPHOTO2_CPPFLAGS)
461  AC_SUBST(GPHOTO2_LIBS)
462  AC_SUBST(GPHOTO2_LDFLAGS)
463])
464
465#
466# Check for AF_INET6, determines whether or not to enable IPv6 support
467# Check for ss_family member in struct sockaddr_storage
468AC_DEFUN([SANE_CHECK_IPV6],
469[
470  AC_MSG_CHECKING([whether to enable IPv6])
471  AC_ARG_ENABLE(ipv6,
472    AS_HELP_STRING([--disable-ipv6],[disable IPv6 support]),
473      [  if test "$enableval" = "no" ; then
474         AC_MSG_RESULT([no, manually disabled])
475         ipv6=no
476         fi
477      ])
478
479  if test "$ipv6" != "no" ; then
480    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
481	#define INET6
482	#include <stdlib.h>
483	#include <sys/types.h>
484	#include <sys/socket.h> ]], [[
485	 /* AF_INET6 available check */
486 	if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
487   	  exit(1);
488 	else
489   	  exit(0);
490      ]])],[
491        AC_MSG_RESULT(yes)
492        AC_DEFINE([ENABLE_IPV6], 1, [Define to 1 if the system supports IPv6])
493        ipv6=yes
494      ],[
495        AC_MSG_RESULT([no (couldn't compile test program)])
496        ipv6=no
497      ])
498  fi
499
500  if test "$ipv6" != "no" ; then
501    AC_MSG_CHECKING([whether struct sockaddr_storage has an ss_family member])
502    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
503	#define INET6
504	#include <stdlib.h>
505	#include <sys/types.h>
506	#include <sys/socket.h> ]], [[
507	/* test if the ss_family member exists in struct sockaddr_storage */
508	struct sockaddr_storage ss;
509	ss.ss_family = AF_INET;
510	exit (0);
511    ]])], [
512	AC_MSG_RESULT(yes)
513	AC_DEFINE([HAS_SS_FAMILY], 1, [Define to 1 if struct sockaddr_storage has an ss_family member])
514    ], [
515		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
516		#define INET6
517		#include <stdlib.h>
518		#include <sys/types.h>
519		#include <sys/socket.h> ]], [[
520		/* test if the __ss_family member exists in struct sockaddr_storage */
521		struct sockaddr_storage ss;
522		ss.__ss_family = AF_INET;
523		exit (0);
524	  ]])], [
525		AC_MSG_RESULT([no, but __ss_family exists])
526		AC_DEFINE([HAS___SS_FAMILY], 1, [Define to 1 if struct sockaddr_storage has __ss_family instead of ss_family])
527	  ], [
528		AC_MSG_RESULT([no])
529		ipv6=no
530    	  ])
531    ])
532  fi
533])
534
535#
536# Verifies that values in $BACKENDS and updates FILTERED_BACKEND
537# with either backends that can be compiled or fails the script.
538AC_DEFUN([SANE_CHECK_BACKENDS],
539[
540if test "${user_selected_backends}" = "yes"; then
541  DISABLE_MSG="aborting"
542else
543  DISABLE_MSG="disabling"
544fi
545
546FILTERED_BACKENDS=""
547for be in ${BACKENDS}; do
548  backend_supported="yes"
549  case $be in
550    plustek_pp)
551    case "$host_os" in
552      gnu*)
553      echo "*** $be backend not supported on GNU/Hurd - $DISABLE_MSG"
554      backend_supported="no"
555      ;;
556    esac
557    ;;
558
559    dc210|dc240|pixma)
560    if test "${sane_cv_use_libjpeg}" != "yes"; then
561      echo "*** $be backend requires JPEG library - $DISABLE_MSG"
562      backend_supported="no"
563    fi
564    ;;
565
566    canon_pp|hpsj5s)
567    if test "${sane_cv_use_libieee1284}" != "yes"; then
568      echo "*** $be backend requires libieee1284 library - $DISABLE_MSG"
569      backend_supported="no"
570    fi
571    ;;
572
573    genesys)
574    if test "${HAVE_CXX11}" != "1"; then
575      echo "*** $be backend requires C++11 support - $DISABLE_MSG"
576      backend_supported="no"
577    fi
578    ;;
579
580    mustek_pp)
581    if test "${sane_cv_use_libieee1284}" != "yes" && test "${enable_parport_directio}" != "yes"; then
582      echo "*** $be backend requires libieee1284 or parport-directio libraries - $DISABLE_MSG"
583      backend_supported="no"
584    fi
585    ;;
586
587    dell1600n_net)
588    if test "${sane_cv_use_libjpeg}" != "yes" || test "${sane_cv_use_libtiff}" != "yes"; then
589      echo "*** $be backend requires JPEG and TIFF library - $DISABLE_MSG"
590      backend_supported="no"
591    fi
592    ;;
593
594    epsonds)
595    if test "${sane_cv_use_libjpeg}" != "yes"; then
596      echo "*** $be backend requires JPEG library - $DISABLE_MSG"
597      backend_supported="no"
598    fi
599    ;;
600
601    escl)
602    if test "x${with_avahi}" != "xyes"; then
603      echo "*** $be backend requires AVAHI library - $DISABLE_MSG"
604      backend_supported="no"
605    fi
606    if test "x${with_libcurl}" != "xyes"; then
607      echo "*** $be backend requires cURL library - $DISABLE_MSG"
608      backend_supported="no"
609    fi
610    if test "x${have_libxml}" != "xyes"; then
611      echo "*** $be backend requires XML library - $DISABLE_MSG"
612      backend_supported="no"
613    fi
614    # FIXME: Remove when PNG and/or PDF support have been added.
615    if test "x${sane_cv_use_libjpeg}" != "xyes"; then
616      echo "*** $be backend currently requires JPEG library - $DISABLE_MSG"
617      backend_supported="no"
618    else
619      if test "x${ac_cv_func_jpeg_crop_scanline}"  != "xyes" \
620      || test "x${ac_cv_func_jpeg_skip_scanlines}" != "xyes"; then
621        echo "*** $be backend requires a newer JPEG library - $DISABLE_MSG"
622        backend_supported="no"
623      fi
624    fi
625
626    ;;
627
628    gphoto2)
629    if test "${HAVE_GPHOTO2}" != "true" \
630      || test "${sane_cv_use_libjpeg}" != "yes"; then
631      echo "*** $be backend requires gphoto2 and JPEG libraries - $DISABLE_MSG"
632      backend_supported="no"
633    fi
634    ;;
635
636    pint)
637    if test "${ac_cv_header_sys_scanio_h}" = "no"; then
638      echo "*** $be backend requires sys/scanio.h - $DISABLE_MSG"
639      backend_supported="no"
640    fi
641    ;;
642
643    qcam)
644    if ( test "${ac_cv_func_ioperm}" = "no" || test "${sane_cv_have_sys_io_h_with_inb_outb}" = "no" )\
645      && test "${ac_cv_func__portaccess}" = "no"; then
646      echo "*** $be backend requires (ioperm, inb and outb) or portaccess functions - $DISABLE_MSG"
647      backend_supported="no"
648    fi
649    ;;
650
651    v4l)
652    if test "${have_linux_ioctl_defines}" != "yes" \
653      || test "${have_libv4l1}" != "yes"; then
654      echo "*** $be backend requires v4l libraries - $DISABLE_MSG"
655      backend_supported="no"
656    fi
657    ;;
658
659    net)
660    if test "${ac_cv_header_sys_socket_h}" = "no"; then
661      echo "*** $be backend requires sys/socket.h - $DISABLE_MSG"
662      backend_supported="no"
663    fi
664    ;;
665
666    mustek_usb2|kvs40xx)
667    if test "${have_pthread}" != "yes"; then
668      echo "*** $be backend requires pthread library - $DISABLE_MSG"
669      backend_supported="no"
670    fi
671    ;;
672  esac
673  if test "${backend_supported}" = "no"; then
674    if test "${user_selected_backends}" = "yes"; then
675      exit 1
676    fi
677  else
678    FILTERED_BACKENDS="${FILTERED_BACKENDS} $be"
679  fi
680done
681])
682
683#
684# Generate prototypes for functions not available on the system
685AC_DEFUN([SANE_PROTOTYPES],
686[
687AH_BOTTOM([
688
689#if defined(__MINGW32__)
690#define _BSDTYPES_DEFINED
691#endif
692
693#ifndef HAVE_U_CHAR
694#define u_char unsigned char
695#endif
696#ifndef HAVE_U_SHORT
697#define u_short unsigned short
698#endif
699#ifndef HAVE_U_INT
700#define u_int unsigned int
701#endif
702#ifndef HAVE_U_LONG
703#define u_long unsigned long
704#endif
705
706/* Prototype for getenv */
707#ifndef HAVE_GETENV
708#define getenv sanei_getenv
709char * getenv(const char *name);
710#endif
711
712/* Prototype for inet_ntop */
713#ifndef HAVE_INET_NTOP
714#define inet_ntop sanei_inet_ntop
715#include <sys/types.h>
716const char * inet_ntop (int af, const void *src, char *dst, size_t cnt);
717#endif
718
719/* Prototype for inet_pton */
720#ifndef HAVE_INET_PTON
721#define inet_pton sanei_inet_pton
722int inet_pton (int af, const char *src, void *dst);
723#endif
724
725/* Prototype for sigprocmask */
726#ifndef HAVE_SIGPROCMASK
727#define sigprocmask sanei_sigprocmask
728int sigprocmask (int how, int *new, int *old);
729#endif
730
731/* Prototype for snprintf */
732#ifndef HAVE_SNPRINTF
733#define snprintf sanei_snprintf
734#include <sys/types.h>
735int snprintf (char *str,size_t count,const char *fmt,...);
736#endif
737
738/* Prototype for strcasestr */
739#ifndef HAVE_STRCASESTR
740#define strcasestr sanei_strcasestr
741char * strcasestr (const char *phaystack, const char *pneedle);
742#endif
743
744/* Prototype for strdup */
745#ifndef HAVE_STRDUP
746#define strdup sanei_strdup
747char *strdup (const char * s);
748#endif
749
750/* Prototype for strndup */
751#ifndef HAVE_STRNDUP
752#define strndup sanei_strndup
753#include <sys/types.h>
754char *strndup(const char * s, size_t n);
755#endif
756
757/* Prototype for strsep */
758#ifndef HAVE_STRSEP
759#define strsep sanei_strsep
760char *strsep(char **stringp, const char *delim);
761#endif
762
763/* Prototype for usleep */
764#ifndef HAVE_USLEEP
765#define usleep sanei_usleep
766unsigned int usleep (unsigned int useconds);
767#endif
768
769/* Prototype for vsyslog */
770#ifndef HAVE_VSYSLOG
771#include <stdarg.h>
772void vsyslog(int priority, const char *format, va_list args);
773#endif
774])
775])
776
777m4_include([m4/byteorder.m4])
778