summaryrefslogtreecommitdiffstats
path: root/debian/transcode/transcode-1.1.7/acinclude.m4
blob: d89f9f6342bad1c4b0f715d6919ed8daec968261 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
dnl TC_CHECK_STD_HEADERS
dnl Ensure that standard headers are available, and abort if not.
dnl
AC_DEFUN([TC_CHECK_STD_HEADERS],
    [AC_CACHE_CHECK(for standard header files, ac_cv_header_std,
        [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
]])],
            [ac_cv_header_std=yes],
            [ac_cv_header_std=no])])
if test x"$ac_cv_header_std" != x"yes"; then
    AC_MSG_ERROR([cannot compile with one or more of:
    errno.h fcntl.h limits.h stdarg.h stddef.h stdint.h stdio.h
    stdlib.h string.h time.h sys/stat.h sys/time.h sys/types.h
See \`config.log' for more details.])
fi
dnl Stop autoconf from running its own standard header check.
AC_PROVIDE([AC_HEADER_STDC])dnl
dnl Define HAVE_* macros in case anybody wants them anyway.
AC_DEFINE([STDC_HEADERS], 1,
          [Define to 1 if you have the ANSI C header files.])
AC_DEFINE([HAVE_ERRNO_H], 1,
          [Define to 1 if you have the <errno.h> include file.])
AC_DEFINE([HAVE_FCNTL_H], 1,
          [Define to 1 if you have the <fcntl.h> include file.])
AC_DEFINE([HAVE_LIMITS_H], 1,
          [Define to 1 if you have the <limits.h> include file.])
AC_DEFINE([HAVE_STDARG_H], 1,
          [Define to 1 if you have the <stdarg.h> include file.])
AC_DEFINE([HAVE_STDDEF_H], 1,
          [Define to 1 if you have the <stddef.h> include file.])
AC_DEFINE([HAVE_STDINT_H], 1,
          [Define to 1 if you have the <stdint.h> include file.])
AC_DEFINE([HAVE_STDIO_H], 1,
          [Define to 1 if you have the <stdio.h> include file.])
AC_DEFINE([HAVE_STDLIB_H], 1,
          [Define to 1 if you have the <stdlib.h> include file.])
AC_DEFINE([HAVE_STRING_H], 1,
          [Define to 1 if you have the <string.h> include file.])
AC_DEFINE([HAVE_TIME_H], 1,
          [Define to 1 if you have the <time.h> include file.])
AC_DEFINE([HAVE_SYS_STAT_H], 1,
          [Define to 1 if you have the <sys/stat.h> include file.])
AC_DEFINE([HAVE_SYS_TIME_H], 1,
          [Define to 1 if you have the <sys/time.h> include file.])
AC_DEFINE([HAVE_SYS_TYPES_H], 1,
          [Define to 1 if you have the <sys/types.h> include file.])
])

dnl Argh, we have to redefine this to stop headers.m4 from doing extra checks
AC_DEFUN([_AC_INCLUDES_DEFAULT_REQUIREMENTS],
[m4_divert_text([DEFAULTS],
[# Factoring default headers for most tests.
dnl If ever you change this variable, please keep autoconf.texi in sync.
ac_includes_default="\
#include <stdio.h>
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#if STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#else
# if HAVE_STDLIB_H
#  include <stdlib.h>
# endif
#endif
#if HAVE_STRING_H
# if !STDC_HEADERS && HAVE_MEMORY_H
#  include <memory.h>
# endif
# include <string.h>
#endif
#if HAVE_STRINGS_H
# include <strings.h>
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
#else
# if HAVE_STDINT_H
#  include <stdint.h>
# endif
#endif
#if HAVE_UNISTD_H
# include <unistd.h>
#endif"
])])

dnl -----------------------------------------------------------------------

dnl TC_C_GCC_ATTRIBUTES
dnl See if __attribute__((format(...))) and __attribute__((unused)) are
dnl available.
dnl
AC_DEFUN([TC_C_GCC_ATTRIBUTES],
    [AC_CACHE_CHECK([__attribute__((...)) support],
        [ac_cv_c_gcc_attributes],
        [AC_TRY_COMPILE([],
            [extern int foo(char *,...) __attribute__((format(printf,1,2)));
             __attribute__((unused)) static int bar;],
            [ac_cv_c_gcc_attributes=yes],
            [ac_cv_c_gcc_attributes=no])])
    if test x"$ac_cv_c_gcc_attributes" = x"yes"; then
        AC_DEFINE([HAVE_GCC_ATTRIBUTES], 1,
               [Compiler understands __attribute__((...))])
    fi])

dnl -----------------------------------------------------------------------

dnl TC_C_ATTRIBUTE_ALIGNED
dnl Define ATTRIBUTE_ALIGNED_MAX to the maximum alignment if this is supported.
dnl
AC_DEFUN([TC_C_ATTRIBUTE_ALIGNED],
    [AC_CACHE_CHECK([__attribute__((aligned())) support],
	[ac_cv_c_attribute_aligned],
	[ac_cv_c_attribute_aligned=0
	for ac_cv_c_attr_align_try in 2 4 8 16 32 64; do
	    AC_TRY_COMPILE([],
		[static char c __attribute__((aligned($ac_cv_c_attr_align_try))) = 0; return c;],
		[ac_cv_c_attribute_aligned=$ac_cv_c_attr_align_try])
	done])
    if test x"$ac_cv_c_attribute_aligned" != x"0"; then
	AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
	    [$ac_cv_c_attribute_aligned],[maximum supported data alignment])
    fi])

dnl -----------------------------------------------------------------------

dnl TC_TRY_CFLAGS (CFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS])
dnl Check if $CC supports a given set of CFLAGS.

AC_DEFUN([TC_TRY_CFLAGS],
    [AC_MSG_CHECKING([if $CC supports $1 flags])
    SAVE_CFLAGS="$CFLAGS"
    CFLAGS="$1"
    AC_TRY_COMPILE([],[],[ac_cv_try_cflags_ok=yes],[ac_cv_try_cflags_ok=no])
    CFLAGS="$SAVE_CFLAGS"
    AC_MSG_RESULT([$ac_cv_try_cflags_ok])
    if test x"$ac_cv_try_cflags_ok" = x"yes"; then
	ifelse([$2],[],[:],[$2])
    else
	ifelse([$3],[],[:],[$3])
    fi])

dnl -----------------------------------------------------------------------

dnl TC_CHECK_V4L([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl Test for video4linux headers, and define HAVE_STRUCT_V4L2_BUFFER
dnl
AC_DEFUN([TC_CHECK_V4L],
[
AC_MSG_CHECKING([whether v4l support is requested])
AC_ARG_ENABLE(v4l,
  AC_HELP_STRING([--enable-v4l],
    [enable v4l/v4l2 support (no)]),
  [case "${enableval}" in
    yes) ;;
    no)  ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-v4l) ;;
  esac],
  [enable_v4l=no])
AC_MSG_RESULT($enable_v4l)

have_v4l=no
have_v4l2=no
if test x"$enable_v4l" = x"yes" ; then
  AC_CHECK_HEADERS([linux/videodev.h], [v4l=yes], [v4l=no])
  AC_CHECK_HEADERS([linux/videodev2.h], [v4l2=yes], [v4l2=no],
    [#include <linux/types.h>])

  if test x"$v4l2" = x"yes" ; then
    AC_MSG_CHECKING([for struct v4l2_buffer in videodev2.h])
    dnl (includes, function-body, [action-if-found], [action-if-not-found])
    AC_TRY_COMPILE([
#include <linux/types.h>
#include <linux/videodev2.h>
],   [
struct v4l2_buffer buf;
buf.memory = V4L2_MEMORY_MMAP
],    [AC_DEFINE([HAVE_STRUCT_V4L2_BUFFER], 1,
        [define if your videodev2 header has struct v4l2_buffer])
        AC_MSG_RESULT([yes])],
      [AC_MSG_RESULT([no])])
  fi

  if test x"$v4l" = x"yes" -o x"$v4l2" = x"yes" ; then
    if test x"$v4l" = x"yes" ; then
      have_v4l=yes
    fi
    if test x"$v4l2" = x"yes" ; then
      have_v4l2=yes
    fi
    dnl yes, this is pure cargo cult.
    ifelse([$1], , :, [$1])
  else
    AC_MSG_ERROR([v4l is requested, but cannot find headers])
  fi
fi
])

dnl -----------------------------------------------------------------------

dnl TC_CHECK_BKTR([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl Test for bktr headers
dnl
AC_DEFUN([TC_CHECK_BKTR],
[
AC_MSG_CHECKING([whether bktr support is requested])
AC_ARG_ENABLE(bktr,
  AC_HELP_STRING([--enable-bktr],
    [enable bktr support (no)]),
  [case "${enableval}" in
    yes) ;;
    no)  ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-bktr) ;;
  esac],
  [enable_bktr=no])
AC_MSG_RESULT($enable_bktr)

have_bktr="no"
if test x"$enable_bktr" = x"yes" ; then
  AC_CHECK_HEADERS([dev/ic/bt8xx.h], [have_bktr="yes"])
  if test x"$have_bktr" = x"no" ; then
    AC_CHECK_HEADERS([dev/bktr/ioctl_bt848.h], [have_bktr="yes"])
  fi
  if test x"$have_bktr" = x"no" ; then
    AC_CHECK_HEADERS([machine/ioctl_bt848.h], [have_bktr="yes"])
  fi

  if test x"$have_bktr" = x"yes" ; then
    have_bktr="yes"
    ifelse([$1], , :, [$1])
  else
    AC_MSG_ERROR([bktr is requested, but cannot find headers])
  fi
fi
])

dnl -----------------------------------------------------------------------

dnl TC_CHECK_SUNAU([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl Test for sunau headers
dnl
AC_DEFUN([TC_CHECK_SUNAU],
[
AC_MSG_CHECKING([whether sunau support is requested])
AC_ARG_ENABLE(sunau,
  AC_HELP_STRING([--enable-sunau],
    [enable sunau support (no)]),
  [case "${enableval}" in
    yes) ;;
    no)  ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-sunau) ;;
  esac],
  [enable_sunau=no])
AC_MSG_RESULT($enable_sunau)

have_sunau="no"
if test x"$enable_sunau" = x"yes" ; then
  AC_CHECK_HEADERS([sys/audioio.h], [have_sunau="yes"])

  if test x"$have_sunau" = x"yes" ; then
    have_sunau="yes"
    ifelse([$1], , :, [$1])
  else
    AC_MSG_ERROR([sunau is requested, but cannot find headers])
  fi
fi
])

dnl -----------------------------------------------------------------------

dnl TC_CHECK_OSS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl Test for OSS headers
dnl
AC_DEFUN([TC_CHECK_OSS],
[
AC_MSG_CHECKING([whether OSS support is requested])
AC_ARG_ENABLE(oss,
  AC_HELP_STRING([--enable-oss],
    [enable OSS audio support (no)]),
  [case "${enableval}" in
    yes) ;;
    no)  ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-oss) ;;
  esac],
  [enable_oss=no])
AC_MSG_RESULT($enable_oss)

have_oss="no"
if test x"$enable_oss" = x"yes" ; then
  AC_CHECK_HEADERS([sys/soundcard.h], [have_oss="yes"])
  if test x"$have_oss" = x"no" ; then
    AC_CHECK_HEADERS([soundcard.h], [have_oss="yes"])
  fi

  if test x"$have_oss" = x"yes" ; then
    have_oss="yes"
    ifelse([$1], , :, [$1])
  else
    AC_MSG_ERROR([OSS is requested, but cannot find headers])
  fi
fi
])

dnl -----------------------------------------------------------------------

dnl TC_CHECK_ALSA([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl Test for ALSA headers
dnl
AC_DEFUN([TC_CHECK_ALSA],
[
AC_MSG_CHECKING([whether ALSA support is requested])
AC_ARG_ENABLE(alsa,
  AC_HELP_STRING([--enable-alsa],
    [enable ALSA audio support (no)]),
  [case "${enableval}" in
    yes) ;;
    no)  ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-alsa) ;;
  esac],
  [enable_alsa=no])
AC_MSG_RESULT($enable_alsa)

have_alsa="no"
if test x"$enable_alsa" = x"yes" ; then
  AC_CHECK_HEADERS([alsa/asoundlib.h], [have_alsa="yes"])

  if test x"$have_alsa" = x"yes" ; then
    have_alsa="yes"
    ifelse([$1], , :, [$1])
  else
    AC_MSG_ERROR([ALSA is requested, but cannot find headers])
  fi
fi
])

dnl -----------------------------------------------------------------------

dnl TC_PATH_IBP([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl Test for ibp libraries, and define IBP_LIBS
dnl
AC_DEFUN([TC_PATH_IBP],
[
AC_MSG_CHECKING([whether ibp and lors support is requested])
AC_ARG_ENABLE(ibp,
  AC_HELP_STRING([--enable-ibp],
    [enable ibp support (no)]),
  [case "${enableval}" in
    yes) ;;
    no)  ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-ibp) ;;
  esac],
  enable_ibp=no)
AC_MSG_RESULT($enable_ibp)

have_ibp=no
if test x"$enable_ibp" = x"yes" ; then
  AC_MSG_CHECKING(for ibp and lors)
  if test x"$have_libxml2" = x"yes" ; then
    OLD_LIBS="$LIBS"
    AC_ARG_WITH(libfdr,
      AC_HELP_STRING([--with-libfdr=DIR],
        [base directory for libfdr]),
      [CPPFLAGS="-I$with_libfdr/include $CPPFLAGS"
        LIBFDR=yes
        IBP_LIBS1="-L$with_libfdr/lib -lfdr $LIBS"],
      [AC_CHECK_LIB(fdr, jval_v,
        [IBP_LIBS1="-lfdr"],
        [AC_MSG_ERROR(unable to locate libfdr)])])

    AC_ARG_WITH(libibp,
      AC_HELP_STRING([--with-libibp=DIR],
        [base directory for libibp]),
      [CPPFLAGS="-I$with_libibp/include $CPPFLAGS"
        LIBIBP=yes
        IBP_LIBS1="-L$with_libibp/lib -libp $PTHREAD_LIBS $IBP_LIBS1"],
      [LIBS="$PTHREAD_LIBS $IBP_LIBS1"
        AC_CHECK_LIB(ibp, IBP_allocate,
          [IBP_LIBS1="-libp $PTHREAD_LIBS $IBP_LIBS1"],
          [AC_MSG_ERROR(unable to locate libibp)])])

    AC_ARG_WITH(libexnode,
      AC_HELP_STRING([--with-libexnode=DIR],
        [base directory for libexnode]),
      [CPPFLAGS="-I$with_libexnode/include/libexnode $CPPFLAGS"
        LIBEXNODE=yes
        IBP_LIBS1="-L$with_libexnode/lib -lexnode $IBP_LIBS1"],
      [LIBS="$IBP_LIBS1"
        AC_CHECK_LIB(exnode, exnodeCreateExnode,
          [IBP_LIBS1="-lexnode $IBP_LIBS1"],
          [AC_MSG_ERROR(unable to locate libexnode)],
          [$IBP_LIBS1])])

    AC_ARG_WITH(liblbone,
      AC_HELP_STRING([--with-liblbone=DIR],
        [base directory for liblbone]),
      [CPPFLAGS="-I$with_liblbone/include $CPPFLAGS"
        LIBLBONE=yes
        IBP_LIBS1="-L$with_liblbone/lib -llbone $IBP_LIBS1"],
      [LIBS="$IBP_LIBS1"
        AC_CHECK_LIB(lbone,lbone_checkDepots,
          [IBP_LIBS1="-llbone $IBP_LIBS1"],
          [AC_MSG_ERROR(unable to locate liblbone)])])

    AC_ARG_WITH(libend2end,
      AC_HELP_STRING([--with-libend2end=DIR],
        [base directory for libend2end]),
      [CPPFLAGS="-I$with_libend2end/include $CPPFLAGS"
        LIBE2E=yes
        IBP_LIBS1="-L$with_libend2end/lib -lend2end -lmd5 -ldes -laes $IBP_LIBS1"],
      [LIBS="-lmd5 -ldes -laes $IBP_LIBS1 -lz"
        AC_CHECK_LIB(end2end, ConditionMapping,
          [IBP_LIBS1="-lend2end -lmd5 -ldes -laes $IBP_LIBS1"],
          [AC_MSG_ERROR(unable to locate libend2end)])])

    AC_ARG_WITH(liblors,
      AC_HELP_STRING([--with-liblors=DIR],
        [base directory for liblors]),
      [CPPFLAGS="-I$with_liblors/include $CPPFLAGS"
        LIBLORS=yes
        IBP_LIBS1="-L$with_liblors/lib -llors $IBP_LIBS1"],
      [LIBS="$IBP_LIBS1 $LIBXML2_LIBS -lz"
        AC_CHECK_LIB(lors,lorsExnodeCreate,
          [IBP_LIBS1="-llors $IBP_LIBS1"],
          [AC_MSG_ERROR(unable to locate liblors)])])

    LIBS="$OLD_LIBS"
    IBP_LIBS="$IBP_LIBS1"
    have_ibp=yes
  fi
  AC_MSG_RESULT($have_ibp)
  if test x"$have_ibp" = x"yes" ; then
    ifelse([$1], , :, [$1])
  else
    ifelse([$2], , :, [$2])
  fi
else
  IBP_LIBS=""
  ifelse([$2], , :, [$2])
fi
AC_SUBST([IBP_LIBS])
])

dnl -----------------------------------------------------------------------
dnl -----------------------------------------------------------------------

dnl TC_PKG_CHECK(name, req-enable, var-name, conf-script, header, lib,
dnl     symbol, pkgconfig-name, url)
dnl Test for pkg-name, and define var-name_CFLAGS and var-name_LIBS
dnl   and HAVE_var-name if found
dnl
dnl 1 name          name of package; required (used in messages, option names)
dnl 2 req-enable    enable by default, 'required', 'optional', 'yes' or 'no'; required
dnl 3 var-name      name stub for variables, preferably uppercase; required
dnl 4 conf-script   name of "-config" script or 'no'
dnl 5 header        header file to check or 'none'
dnl 6 lib           library to check or 'none'
dnl 7 symbol        symbol from the library to check or ''
dnl 8 pkg           package (pkg-config name if applicable)
dnl 9 url           homepage for the package

AC_DEFUN([TC_PKG_CHECK],
[
if test x"$2" = x"required" -o x"$2" = x"optional" ; then
  enable_$1="yes"
else
  AC_MSG_CHECKING([whether $1 support is requested])
  AC_ARG_ENABLE($1,
    AC_HELP_STRING([--enable-$1],
      [build with $1 support ($2)]),
    [case "${enableval}" in
      yes) ;;
      no)  ;;
      *) AC_MSG_ERROR(bad value ${enableval} for --enable-$1) ;;
    esac],
    enable_$1="$2")
  AC_MSG_RESULT($enable_$1)
fi

AC_ARG_WITH($1-prefix,
  AC_HELP_STRING([--with-$1-prefix=PFX],
    [prefix where $1 is installed (/usr)]),
  w_$1_p="$withval", w_$1_p="")

AC_ARG_WITH($1-includes,
  AC_HELP_STRING([--with-$1-includes=DIR],
    [directory where $1 headers ($5) are installed (/usr/include)]),
  w_$1_i="$withval", w_$1_i="")

AC_ARG_WITH($1-libs,
  AC_HELP_STRING([--with-$1-libs=DIR],
    [directory where $1 libraries (lib$6.so) are installed (/usr/lib)]),
  w_$1_l="$withval", w_$1_l="")

have_$1="no"
this_pkg_err="no"

if test x"$enable_$1" = x"yes" ; then

  dnl pkg-config

  pkg_config_$1="no"
  AC_MSG_CHECKING([for pkgconfig support for $1])
  if test x"$PKG_CONFIG" != x"no" ; then
    if $PKG_CONFIG $8 --exists ; then
      pkg_config_$1="yes"
    fi
  fi
  AC_MSG_RESULT($pkg_config_$1)

  dnl *-config

  if test x"$4" != x"no" ; then
    if test x"$w_$1_p" != x"" ; then
      if test -x $w_$1_p/bin/$4 ; then
        $1_config="$w_$1_p/bin/$4"
      fi
    fi
    AC_PATH_PROG($1_config, $4, no)
  else
    $1_config="no"
  fi

  # get and test the _CFLAGS

  AC_MSG_CHECKING([how to determine $3_CFLAGS])
  if test x"$w_$1_i" != x"" ; then
    $1_ii="-I$w_$1_i"
    AC_MSG_RESULT(user)
  else
    if test x"$pkg_config_$1" != x"no" ; then
      $1_ii="`$PKG_CONFIG $8 --cflags`"
      AC_MSG_RESULT(pkg-config)
    else
      if test x"$$1_config" != x"no" ; then
        $1_ii="`$$1_config --cflags`"
        AC_MSG_RESULT($$1_config)
      else
        if test x"$w_$1_p" != x"" ; then
          $1_ii="-I$w_$1_p/include"
          AC_MSG_RESULT(prefix)
        else
          $1_ii="-I/usr/include"
          AC_MSG_RESULT(default)
        fi
      fi
    fi
  fi
  ipaths="" ; xi=""
  for i in $$1_ii ; do
    case $i in
      -I*) ipaths="$ipaths $i" ;;
        *) xi="$xi $i" ;;
    esac
  done
  $1_ii="$ipaths"
  $1_ii="`echo $$1_ii | sed -e 's/  */ /g'`"
  $3_EXTRA_CFLAGS="$$3_EXTRA_CFLAGS $xi"
  $3_EXTRA_CFLAGS="`echo $$3_EXTRA_CFLAGS | sed -e 's/  */ /g'`"

  if test x"$5" != x"none" ; then
    save_CPPFLAGS="$CPPFLAGS"
    CPPFLAGS="$CPPFLAGS $$1_ii"
    AC_CHECK_HEADER([$5],
      [$3_CFLAGS="$$1_ii"],
      [TC_PKG_ERROR($1, $5, $2, $8, $9, [cannot compile $5])])
    CPPFLAGS="$save_CPPFLAGS"
  elif test x"$pkg_config_$1" != x"no" ; then
     $3_CFLAGS="`$PKG_CONFIG $8 --cflags`"
  fi

  # get and test the _LIBS

  AC_MSG_CHECKING([how to determine $3_LIBS])
  if test x"$w_$1_l" != x"" ; then
    $1_ll="-L$w_$1_l"
    AC_MSG_RESULT(user)
  else
    if test x"$pkg_config_$1" != x"no" ; then
      $1_ll="`$PKG_CONFIG $8 --libs`"
      AC_MSG_RESULT(pkg-config)
    else
      if test x"$$1_config" != x"no" ; then
        $1_ll="`$$1_config --libs`"
        AC_MSG_RESULT($$1_config)
      else
        if test x"$w_$1_p" != x"" ; then
          $1_ll="-L$w_$1_p${deflib}"
          AC_MSG_RESULT(prefix)
        else
          $1_ll="-L/usr${deflib}"
          AC_MSG_RESULT(default)
        fi
      fi
    fi
  fi
  lpaths="" ; xlibs="" ; xlf=""
  for l in $$1_ll ; do
    case $l in
      -L*) lpaths="$lpaths $l" ;;
      -l*) test x"$l" != x"-l$6" && xlibs="$xlibs $l" ;;
        *) xlf="$xlf $l" ;;
    esac
  done
  $1_ll="$lpaths"
  $1_ll="`echo $$1_ll | sed -e 's/  */ /g'`"
  xl=""
  for i in $xlibs $xlf ; do
    echo " $$3_EXTRA_LIBS " | grep -vq " $i " && xl="$xl $i"
  done
  $3_EXTRA_LIBS="$$3_EXTRA_LIBS $xl"
  $3_EXTRA_LIBS="`echo $$3_EXTRA_LIBS | sed -e 's/  */ /g'`"

  if test x"$6" != x"none" ; then
    save_LDFLAGS="$LDFLAGS"
    LDFLAGS="$LDFLAGS $$1_ll"
    AC_CHECK_LIB([$6], [$7],
      [$3_LIBS="$$1_ll -l$6 $$3_EXTRA_LIBS"],
      [TC_PKG_ERROR($1, lib$6, $2, $8, $9, [cannot link against lib$6])],
      [$$3_EXTRA_LIBS])
    LDFLAGS="$save_LDFLAGS"
  elif test x"$pkg_config_$1" != x"no" ; then
     $3_LIBS="`$PKG_CONFIG $8 --libs`"
  fi

  if test x"$this_pkg_err" = x"no" ; then
    have_$1="yes"
  fi

else
  $3_CFLAGS=""
  $3_LIBS=""
fi
])

dnl -----------------------------------------------------------------------
dnl -----------------------------------------------------------------------

dnl TC_PKG_CONFIG_CHECK(name, req-enable, var-name, pkgconfig-name, url)
dnl Test for pkg-name, and define var-name_CFLAGS and var-name_LIBS
dnl   and HAVE_var-name if found; like TC_PKG_CHECK, but using pkg-config
dnl
dnl 1 name          name of package; required (used in messages, option names)
dnl 2 req-enable    enable by default, 'required', 'optional', 'yes' or 'no'; required
dnl 3 var-name      name stub for variables, preferably uppercase; required
dnl 4 pkg           pkg-config name
dnl 5 url           homepage for the package

AC_DEFUN([TC_PKG_CONFIG_CHECK],
[
if test x"$2" = x"required" -o x"$2" = x"optional" ; then
  enable_$1="yes"
else
  AC_MSG_CHECKING([whether $1 support is requested])
  AC_ARG_ENABLE($1,
    AC_HELP_STRING([--enable-$1],
      [build with $1 support ($2)]),
    [case "${enableval}" in
      yes) ;;
      no)  ;;
      *) AC_MSG_ERROR(bad value ${enableval} for --enable-$1) ;;
    esac],
    enable_$1="$2")
  AC_MSG_RESULT($enable_$1)
fi

have_$1="no"
this_pkg_err="no"

if test x"$enable_$1" = x"yes" ; then
   PKG_CHECK_MODULES($3, $4,
       [have_$1="yes"],
       [TC_PKG_ERROR($1, $4, $3, $4, $5)])
else
  $3_CFLAGS=""
  $3_LIBS=""
fi
])



dnl -----------------------------------------------------------------------
dnl -----------------------------------------------------------------------

dnl TC_PKG_ERROR(name, object, req-enable, pkg, url, [error message])
dnl
AC_DEFUN([TC_PKG_ERROR],
[
this_pkg_err="yes"
if test x"$3" != x"optional" ; then
  tc_pkg_err="yes"

  prob=""
  if test x"$3" = x"required" ; then
    prob="requirement failed"
  else
    prob="option '--enable-$1' failed"
  fi
  msg="ERROR: $prob: $6
$2 can be found in the following packages:
  $4  $5

"
  tc_pkg_err_text="$tc_pkg_err_text$msg"
fi
])

dnl -----------------------------------------------------------------------

dnl TC_PKG_INIT
dnl
AC_DEFUN([TC_PKG_INIT],
[
tc_pkg_err="no"
])

dnl -----------------------------------------------------------------------

dnl TC_PKG_HAVE(pkg, PKG)
dnl
AC_DEFUN([TC_PKG_HAVE],
[
if test x"$have_$1" = x"yes" ; then
  AC_DEFINE([HAVE_$2], 1, [have $1 support])
fi
AM_CONDITIONAL(HAVE_$2, test x"$have_$1" = x"yes")
AC_SUBST($2_CFLAGS)
AC_SUBST($2_LIBS)

msg=`printf "%-30s %s" "$1" "$have_$1"`
tc_pkg_rpt_text="$tc_pkg_rpt_text$msg
"
])

dnl -----------------------------------------------------------------------

dnl TC_PKG_REPORT()
dnl
AC_DEFUN([TC_PKG_REPORT],
[
echo "$tc_pkg_rpt_text"
echo ""

if test x"$tc_pkg_err" = x"yes" ; then
  echo "$tc_pkg_err_text"
  echo ""
  echo "Please see the INSTALL file in the top directory of the"
  echo "transcode sources for more information about building"
  echo "transcode with this configure script."
  echo ""
  exit 1
fi
])