File: configure.in

package info (click to toggle)
zapping 0.10~cvs6-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 9,856 kB
  • ctags: 11,841
  • sloc: ansic: 111,154; asm: 11,770; sh: 9,812; xml: 2,742; makefile: 1,283; perl: 488
file content (979 lines) | stat: -rw-r--r-- 31,793 bytes parent folder | download | duplicates (6)
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
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
dnl Process this file with autoconf to produce a configure script.

AC_INIT(zapping, 0.10cvs6,
  [http://sourceforge.net/tracker/?atid=102599&group_id=2599&func=browse])
AC_CONFIG_SRCDIR(configure.in)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)

AM_MAINTAINER_MODE
AM_CONFIG_HEADER(config.h)

AC_GNU_SOURCE
AC_PROG_CC
AC_ISC_POSIX
AM_PROG_CC_STDC
AC_HEADER_STDC
AM_PROG_AS

AC_DISABLE_STATIC
AM_PROG_LIBTOOL

AC_PROG_INTLTOOL(0.22)

dnl Check for BSD/GNU extensions.
dnl If not present we use replacements.
AC_CHECK_FUNCS([strlcpy strndup asprintf getopt_long program_invocation_name])
SAVE_LIBS=$LIBS
LIBS="$LIBS -lm"
AC_LINK_IFELSE(
  AC_LANG_PROGRAM([#include <math.h>], [return lrint(1.5);]),
  AC_DEFINE(HAVE_LRINT, 1, [Define if the lrint() function is available]))
LIBS="$SAVE_LIBS"

test -e site_def.h || cat <<EOF >site_def.h
/* These defines enable various tests and other hacks
   we do not want in released packages. */

#ifndef SITE_DEF_H
#define SITE_DEF_H
/* #define AUDIO_MIXER_LOG_FP stderr */
/* #define CACHE_CONSISTENCY 1 */
/* #define CACHE_DEBUG 1 */
/* #define CACHE_STATUS 1 */
/* #define DI_GREEDYHM_V_ASSERT 1 */
/* #define DI_MAIN_HEIGHT_DIV 1 */
/* #define DLIST_CONSISTENCY 1 */
/* #define KEYBOARD_KEY_LOG 1 */
/* #define OSD_TEST 1 */
/* #define OSS_LOG_FP stderr */
/* #define OVERLAY_CHROMA_TEST 1 */
/* #define OVERLAY_COLORMAP_FAILURE_TEST 1 */
/* #define OVERLAY_DUMP_CLIPS 1 */
/* #define OVERLAY_EVENT_LOG_FP stderr */
/* #define OVERLAY_LOG_FP stderr */
/* #define REMOTE_COMMAND_LOG 1 */
/* #define TVENG1_RIVATV_TEST 1 */
/* #define TVENG1_XV_TEST 1 */
/* #define TVENG25_BAYER_TEST 1 */
/* #define TVENG25_NOVERLAY_TEST 1 */
/* #define TVENG25_NV12_TEST 1 */
/* #define TVENG25_XV_TEST 1 */
/* #define TVENGEMU_ENABLE 1 */
/* #define TVENG_FORCE_FORMAT 20 */
/* #define TVENG_MIXER_VOLUME_DEBUG 1 */
/* #define TV_SCREEN_DGA_DEBUG 1 */
/* #define X11STUFF_SCREENSAVER_DEBUG 1 */
/* #define X11STUFF_VIDMODE_DEBUG 1 */
/* #define X11STUFF_WM_HINTS_DEBUG 1 */
/* #define XAWTV_CONFIG_TEST 1 */
/* #define ZAPPING_CRASH_TEST 1 */
/* #define ZMISC_TOOLTIP_WARNING 1 */
/* #define ZVBI_CAPTION_DEBUG 1 */
/* #define ZVBI_CAPTURE_THREAD_DEBUG 1 */
/* #define ZVIDEO_EXPOSE_TEST 1 */
#endif
EOF

dnl These are the plugins we can build, depending on the libs we find.
dnl Screenshot can compile unconditional.
PLUGINS_TO_BUILD="screenshot"
dnl "template lirc"

dnl ===========================================================================
dnl Compile checks
dnl ===========================================================================

dnl GCC_VERSION(min_version, max_version, action_if_true, action_if_false)
AC_DEFUN([GCC_VERSION], [
  AC_EGREP_CPP([6177459036], [
    #ifdef __GNUC__
    #  define GCC_VERSION \
         (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
    #  if $1 <= GCC_VERSION && GCC_VERSION < $2
         6177459036
    #  endif
    #endif
    ], [$3], [$4])
  ])

dnl ---------------------------------------------------------------------------
dnl Endianess
dnl ---------------------------------------------------------------------------

AC_DEFINE(Z_LITTLE_ENDIAN, 1234, [naidne elttiL])
AC_DEFINE(Z_BIG_ENDIAN, 4321, [Big endian])
AC_C_BIGENDIAN(
  AC_DEFINE(Z_BYTE_ORDER, 4321, [Byte order]),
  AC_DEFINE(Z_BYTE_ORDER, 1234, [Byte order]))

dnl ---------------------------------------------------------------------------
dnl SIMD support
dnl ---------------------------------------------------------------------------

SIMD_SUPPORT=""

case "$host" in
i?86-* | k?-*) dnl i386, i486, i586, i686, k6, k7, k8
  AC_DEFINE(HAVE_X86, 1, [Define if target is x86 (not x86_64)])
  HAVE_X86=yes ;;
*)
  HAVE_X86=no ;;
esac

dnl Some old code will not run on x86_64.
AM_CONDITIONAL(HAVE_X86, test "x$HAVE_X86" = "xyes")

AC_DEFUN([CHECK_SIMD], [
  AC_MSG_CHECKING(if $CC supports $1)
  SAVE_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS $2"
  CAN_COMPILE_$1="yes"
  AC_COMPILE_IFELSE(
    AC_LANG_PROGRAM([#include <$3>], [$4]),, CAN_COMPILE_$1="no")
  if test x$CAN_COMPILE_$1 = xyes; then
    dnl Older versions of GCC and other compilers have not been tested.
    GCC_VERSION(0, 30200, CAN_COMPILE_$1="disabled")
  fi
  if test x$CAN_COMPILE_$1 = xyes; then
    dnl GCC 3.2.3:
    dnl DI_TomsMoComp.c: In function `Search_Effort_1':
    dnl DI_TomsMoComp.c:876: Internal compiler error
    dnl   in find_reloads_toplev, at reload.c:4438
    GCC_VERSION(30200, 30300, CAN_COMPILE_$1="broken")
  fi
  if test x$CAN_COMPILE_$1 = xyes; then
    if test $HAVE_X86 = no -o x$1 = xSSE2 -o x$1 = xSSE3; then
      dnl GCC 3.3.5:
      dnl DI_GreedyHF.c: In function `DI_GreedyHF_SSE2':
      dnl DI_GreedyHF.c:172: internal compiler error:
      dnl   in push_reload, at reload.c:1315
      dnl GCC 3.4.1 (x86_64), GCC 4.0.0 (i686):
      dnl DI_GreedyHM.c:1281: internal compiler error:
      dnl   in extract_insn, at recog.c:2083
      dnl GCC 3.4.2 (x86_64):
      dnl rgb2rgb.c: In function `_tv_sbggr_to_rgb_MMX':
      dnl rgb2rgb.c:809: internal compiler error:
      dnl   in trunc_int_for_mode, at explow.c:54
      GCC_VERSION(30300, 40001, CAN_COMPILE_$1="broken")
    fi
  fi
  if test x$CAN_COMPILE_$1 = xyes; then
    SIMD_SUPPORT="${SIMD_SUPPORT}$1 "
    AC_DEFINE(CAN_COMPILE_$1, 1, [Define if $CC supports $1 extensions])
  fi
  AM_CONDITIONAL(CAN_COMPILE_$1, test "x$CAN_COMPILE_$1" = "xyes")
  CFLAGS="$SAVE_CFLAGS"]
  AC_MSG_RESULT($CAN_COMPILE_$1))

dnl x86 and x86_64
CHECK_SIMD(MMX, [-mmmx], [mmintrin.h], [_mm_setzero_si64 ()])
CHECK_SIMD(3DNOW, [-m3dnow], [mm3dnow.h], [_m_femms ()])
CHECK_SIMD(SSE, [-msse], [xmmintrin.h], [_mm_setzero_ps ()])
CHECK_SIMD(SSE2, [-msse2], [emmintrin.h], [_mm_setzero_pd ()])
CHECK_SIMD(SSE3, [-msse3], [pmmintrin.h], [_mm_lddqu_si128 (0x1000)])

dnl powerpc
CHECK_SIMD(ALTIVEC, [-maltivec -mabi=altivec], [altivec.h], [vec_dssall ()])

dnl See if we can increase inlining limits for SIMD code (GCC 3.4+).
AC_MSG_CHECKING([if $CC supports --param inline-unit-growth])
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS --param inline-unit-growth=3000"
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([], [return 0;]),
		  [HAVE_GCC_LIMITS=yes], [HAVE_GCC_LIMITS=no])
AC_MSG_RESULT($HAVE_GCC_LIMITS)
AM_CONDITIONAL(HAVE_GCC_LIMITS, test "x$HAVE_GCC_LIMITS" = "xyes")
CFLAGS="$SAVE_CFLAGS"

dnl ---------------------------------------------------------------------------
dnl GCC builtins
dnl ---------------------------------------------------------------------------

AC_MSG_CHECKING(if $CC has __builtin_popcount)
HAVE_BUILTIN_POPCOUNT="yes"
AC_LINK_IFELSE(AC_LANG_PROGRAM(, [__builtin_popcount(123)]),
  AC_DEFINE(HAVE_BUILTIN_POPCOUNT, 1, [Define if CC has __builtin_popcount]),
  HAVE_BUILTIN_POPCOUNT="no")
AC_MSG_RESULT($HAVE_BUILTIN_POPCOUNT)

dnl ---------------------------------------------------------------------------
dnl How to link pthreads functions
dnl ---------------------------------------------------------------------------

AC_CHECK_LIB(pthread, pthread_create,,[
  AC_TRY_LINK(, pthread_create();,,[
    LDFLAGS="$LDFLAGS -pthread"
    AC_TRY_LINK(, pthread_create();,,[
      AC_MSG_FAILURE([
*** Unable to link pthread functions. Please report this bug.
      ])
    ])
  ])
])

dnl ---------------------------------------------------------------------------
dnl Flavours of varargs macros
dnl ---------------------------------------------------------------------------

# Stolen from glib package.

HAVE_ISO_C_VARIADIC_MACROS="no"
AC_MSG_CHECKING(for ISO C99 variadic macros)
AC_TRY_COMPILE([], [
  int a (int p1, int p2, int p3);
  #define call_a(...) a(1,__VA_ARGS__)
  call_a(2,3);
  ], HAVE_ISO_C_VARIADIC="yes"
  AC_DEFINE(HAVE_ISO_C_VARIADIC_MACROS, 1,
    [Define if $CC supports __VA_ARGS__]))
AC_MSG_RESULT($HAVE_ISO_C_VARIADIC_MACROS)

HAVE_GNU_C_VARIADIC_MACROS="no"
AC_MSG_CHECKING(for GNU C variadic macros)
AC_TRY_COMPILE([], [
  int a (int p1, int p2, int p3);
  #define call_a(params...) a(1,params)
  call_a(2,3);
  ], HAVE_GNU_C_VARIADIC_MACROS="yes"
  AC_DEFINE(HAVE_GNU_C_VARIADIC_MACROS, 1,
    [Define if $CC supports GNU C variadic macros]))
AC_MSG_RESULT($HAVE_GNU_C_VARIADIC_MACROS)

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

dnl Obsolete.
AC_SUBST(PG_CFLAGS)

dnl ===========================================================================
dnl Video (TV) device checks
dnl ===========================================================================

VIDEO_SUPPORT=""
NEED_ZSFB=""

dnl ---------------------------------------------------------------------------
dnl Video For Linux [Two]
dnl ---------------------------------------------------------------------------

AC_MSG_CHECKING(whether to build the Video4Linux driver interfaces)
AC_ARG_ENABLE(v4l,
  AC_HELP_STRING([--enable-v4l],
    [Include V4L and V4L2 driver interfaces (auto)]),
  enable_v4l="$enableval", enable_v4l="auto")

test "x$enable_v4l" = "xauto" &&
  test "x`uname -s`" = "xLinux" &&
    enable_v4l=yes

test "x$enable_v4l" != "xyes" && enable_v4l=no

AC_MSG_RESULT($enable_v4l)

if test "x$enable_v4l" = "xyes"; then
  AC_DEFINE(ENABLE_V4L, 1, [Define to build with V4L support])
  VIDEO_SUPPORT="${VIDEO_SUPPORT}V4L V4L2 "
  NEED_ZSFB=yes
  PLUGINS_TO_BUILD="$PLUGINS_TO_BUILD deinterlace"
fi

AM_CONDITIONAL(BUILD_DEINTERLACE_PLUGIN, test "x$enable_v4l" = "xyes")

dnl ---------------------------------------------------------------------------
dnl BSD Brooktree / Meteor
dnl ---------------------------------------------------------------------------

AC_MSG_CHECKING(whether to build the Bktr/Meteor driver interfaces)
AC_ARG_ENABLE(bktr,
  AC_HELP_STRING([--enable-bktr],
    [Include Bktr/Meteor driver interfaces (auto)]),
  enable_bktr="$enableval", enable_bktr="auto")

test "x$enable_bktr" = "xauto" &&
  case "`uname -s`" in
  OpenBSD | FreeBSD | NetBSD | BSDi)
    enable_bktr=yes
    ;;
  *)
    ;;
  esac

test "x$enable_bktr" != "xyes" && enable_bktr=no

AC_MSG_RESULT($enable_bktr)

if test "x$enable_bktr" = "xyes"; then
  AC_DEFINE(ENABLE_BKTR, 1, [Define to build with Bktr/Meteor support])
  VIDEO_SUPPORT="${VIDEO_SUPPORT}BKTR "
fi

dnl ---------------------------------------------------------------------------
dnl consolehelper, PAM authentication for zapping_setup_fb
dnl ---------------------------------------------------------------------------

if test "x$NEED_ZSFB" != "x"; then
  HAVE_PAM="no - using setuid"
  AC_MSG_CHECKING(whether to enable PAM support)
  AC_ARG_ENABLE(pam,
    AC_HELP_STRING([--enable-pam], [Enable PAM support]),
    enable_pam="$enableval", enable_pam="yes")
  AC_MSG_RESULT($enable_pam)
  if test "x$enable_pam" = "xyes"; then
    AC_PATH_PROG(CONSOLEHELPER_LOCATION, consolehelper, "")
    if test "x$CONSOLEHELPER_LOCATION" = "x"; then
      AC_MSG_RESULT([consolehelper not found, using setuid binary])
    fi
    HAVE_PAM="yes"
  fi
  AC_SUBST(CONSOLEHELPER_LOCATION)
else
  HAVE_PAM="not needed"
fi

AM_CONDITIONAL(NEED_ZSFB, test "x$NEED_ZSFB" != "x")
AM_CONDITIONAL(SUID_ZSFB, test "x$CONSOLEHELPER_LOCATION" = "x")

ZSFB_OWNER="root"
AC_SUBST(ZSFB_OWNER)

ZSFB_GROUP="root"
AC_SUBST(ZSFB_GROUP)

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

test "x$VIDEO_SUPPORT" = "x" && VIDEO_SUPPORT="none"

dnl ===========================================================================
dnl Audio device checks
dnl ===========================================================================

AUDIO_SUPPORT=""

dnl ---------------------------------------------------------------------------
dnl Open Sound System
dnl ---------------------------------------------------------------------------

HAVE_OSS="no"

AC_REQUIRE_CPP
AC_CHECK_HEADERS(sys/soundcard.h, HAVE_OSS=yes,)
AC_CHECK_HEADERS(machine/soundcard.h, HAVE_OSS=yes)

AC_MSG_CHECKING(for OSS)
AC_MSG_RESULT($HAVE_OSS)

if test "x$HAVE_OSS" = "xyes"; then
  AC_DEFINE(HAVE_OSS, 1, [Define to compile with OSS support])
  AUDIO_SUPPORT="${AUDIO_SUPPORT}OSS "
fi

dnl ---------------------------------------------------------------------------
dnl ESD (Gnome sound server) - FIXME
dnl ---------------------------------------------------------------------------

HAVE_ESD="yes"
ESD_LIBS=""

AC_CHECK_LIB(esd, esd_record_stream_fallback, ESD_LIBS="-lesd", HAVE_ESD="no")
if test "x$HAVE_ESD" = "xyes"; then
  AC_DEFINE(HAVE_ESD, 1, [Define if ESD lib is present])
  AUDIO_SUPPORT="${AUDIO_SUPPORT}ESD "
fi

AC_SUBST(ESD_LIBS)

dnl ---------------------------------------------------------------------------
dnl ARTS (KDE sound server).
dnl ---------------------------------------------------------------------------

HAVE_ARTS="no"
AC_MSG_CHECKING(for ARTS)

ARTS_VERSION=`artsc-config --version`
if test $? -eq 0; then
  ARTS_CFLAGS=`artsc-config --cflags`
  ARTS_LIBS=`artsc-config --libs`
  SAVE_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS $ARTS_CFLAGS $ARTS_LIBS"
  AC_TRY_LINK([#include <artsc.h>],, HAVE_ARTS="yes")
  CFLAGS="$SAVE_CFLAGS"
fi

if test "x$HAVE_ARTS" = "xno"; then
  AC_MSG_RESULT([no])
else
  AC_MSG_RESULT($ARTS_VERSION)
  AC_SUBST(ARTS_CFLAGS)
  AC_SUBST(ARTS_LIBS)
  AC_DEFINE(HAVE_ARTS, 1, [Define if ARTS sound server is present])
  AUDIO_SUPPORT="${AUDIO_SUPPORT}ARTS "
fi

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

test "x$AUDIO_SUPPORT" = "x" && AUDIO_SUPPORT="none"

dnl ===========================================================================
dnl X11 checks
dnl ===========================================================================

AC_PATH_XTRA
if test "x$X_CFLAGS" = "x-DX_DISPLAY_MISSING"; then
  AC_MSG_FAILURE([
*** Cannot find X11.
  ])
fi

AC_SUBST(X_CFLAGS)
AC_SUBST(X_PRE_LIBS)
AC_SUBST(X_EXTRA_LIBS)
AC_SUBST(X_LIBS)

dnl Macros and other pieces stolen from JWZ's xscreensaver package.

dnl header.h, action-if-found, action-if-not, #include <other>
AC_DEFUN([CHECK_X_HEADER], [
  SAVE_CPPFLAGS="$CPPFLAGS"
  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
  AC_CHECK_HEADER([$1],[$2],[$3],[$4])
  CPPFLAGS="$SAVE_CPPFLAGS"])

dnl -lib, function, action-if-found, action-if-not, -Lother
AC_DEFUN([CHECK_X_LIB], [
  SAVE_CPPFLAGS="$CPPFLAGS"
  SAVE_LDFLAGS="$LDFLAGS"
  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
  AC_CHECK_LIB([$1],[$2],[$3],[$4],[$5])
  CPPFLAGS="$SAVE_CPPFLAGS"
  LDFLAGS="$SAVE_LDFLAGS"])

dnl header.h, rary, function, action-if-found, action-if-not,
dnl #include <other>, -Lother
AC_DEFUN([CHECK_X_BOTH], [
  SAVE_CPPFLAGS="$CPPFLAGS"
  SAVE_LDFLAGS="$LDFLAGS"
  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
  AC_CHECK_HEADER([$1],[
    AC_CHECK_LIB([$2],[$3],[$4],[$5],[$7])],
    [$5],[$6])
  CPPFLAGS="$SAVE_CPPFLAGS"
  LDFLAGS="$SAVE_LDFLAGS"])

dnl ---------------------------------------------------------------------------
dnl DPMS extension (to disable screensaver)
dnl ---------------------------------------------------------------------------

HAVE_DPMS=no

AC_ARG_WITH(dpms-ext,
  AC_HELP_STRING([--with-dpms-ext],
    [Include support for the DPMS extension (yes).]),
  [with_dpms="$withval"], [with_dpms=yes])

if test "x$with_dpms" = "xyes"; then
  CHECK_X_HEADER(X11/extensions/dpms.h, [HAVE_DPMS=yes],,
    [#include <X11/Xlib.h>])
  if test "x$HAVE_DPMS" = "xyes"; then
    # first look in -lXext (this is where it is in XFree86 4.0)
    CHECK_X_LIB(Xext, DPMSInfo, [X_XDPMS_LIBS="-lXext"], [HAVE_DPMS=no],)
    # if that failed, look in -lXdpms (this is where it was in XFree86 3.x)
    if test "x$HAVE_DPMS" = "xno"; then
      CHECK_X_LIB(Xdpms, DPMSInfo, [HAVE_DPMS=yes; X_DPMS_LIBS="-lXdpms"],
        [true], [-lXext])
    fi
  fi
  if test "x$HAVE_DPMS" = "xyes"; then
    AC_DEFINE(HAVE_DPMS_EXTENSION, 1, [Define if present])
    AC_SUBST(X_DPMS_LIBS)
  fi
fi

dnl ---------------------------------------------------------------------------
dnl DGA extension (DMA overlay without Xv)
dnl ---------------------------------------------------------------------------

HAVE_DGA=no

AC_ARG_WITH(xf86dga-ext,
  AC_HELP_STRING([--with-xf86dga-ext],
    [Include support for the DGA extension (yes).]),
  [with_dga="$withval"], [with_dga=yes])

if test "x$with_dga" = "xyes"; then
  CHECK_X_BOTH([X11/extensions/xf86dga.h], [Xxf86dga],
    [XF86DGAQueryExtension],
    [HAVE_DGA=yes
     AC_DEFINE(HAVE_DGA_EXTENSION, 1, [Define if present])
     X_XF86DGA_LIBS="-lXxf86dga"
     AC_SUBST(X_XF86DGA_LIBS)],,
    [#include <X11/Xlib.h>], [-lXext])
fi

dnl ---------------------------------------------------------------------------
dnl VidMode extension (XF86Config Modelines for fullscreen)
dnl ---------------------------------------------------------------------------

HAVE_VIDMODE=no

AC_ARG_WITH(xf86vmode-ext,
  AC_HELP_STRING([--with-xf86vmode-ext],
    [Include support for the VidMode extension (yes).]),
  [with_vidmode="$withval"], [with_vidmode=yes])

if test "x$with_vidmode" = "xyes"; then
  CHECK_X_BOTH([X11/extensions/xf86vmode.h], [Xxf86vm],
    [XF86VidModeGetViewPort],
    [HAVE_VIDMODE=yes
     AC_DEFINE(HAVE_VIDMODE_EXTENSION, 1, [Define if present])
     X_XF86VMODE_LIBS="-lXxf86vm"
     AC_SUBST(X_XF86VMODE_LIBS)],,
    [#include <X11/Xlib.h>], [-lXext])
fi

dnl ---------------------------------------------------------------------------
dnl XVideo extension (video windows and hardware scaler)
dnl ---------------------------------------------------------------------------

HAVE_XV=no

AC_ARG_WITH(xv-ext,
  AC_HELP_STRING([--with-xv-ext],
    [Include support for the XVideo extension (yes).]),
  [with_xv="$withval"], [with_xv=yes])

if test "x$with_xv" = "xyes"; then
  CHECK_X_BOTH([X11/extensions/Xv.h], [Xv],
    [XvShmPutImage],
    [HAVE_XV=yes
     AC_DEFINE(HAVE_XV_EXTENSION, 1, [Define if present])
     X_XV_LIBS="-lXv"
     AC_SUBST(X_XV_LIBS)
     VIDEO_SUPPORT="${VIDEO_SUPPORT}XVideo "],,
    [#include <X11/Xlib.h>], [-lXext])
fi

dnl ---------------------------------------------------------------------------
dnl Xinerama extension
dnl ---------------------------------------------------------------------------

HAVE_XINERAMA=no

AC_ARG_WITH(xinerama-ext,
  AC_HELP_STRING([--with-xinerama-ext],
    [Include support for the Xinerama extension (yes).]),
  [with_xinerama="$withval"], [with_xinerama=yes])

if test "x$with_xinerama" = "xyes"; then
  # XFree86 implementation
  CHECK_X_BOTH([X11/extensions/Xinerama.h], [Xinerama],
    [XineramaQueryExtension],
    [HAVE_XINERAMA="XFree86"
     AC_DEFINE(HAVE_XFREE86_XINERAMA_EXTENSION, 1, [Define if present])
     X_XINERAMA_LIBS="-lXinerama"],,
    [#include <X11/Xlib.h>], [-lXext])

  if test "x$HAVE_XINERAMA" = "xno"; then
    # Solaris implementation
    CHECK_X_BOTH([X11/extensions/xinerama.h], [Xext],
      [XineramaGetInfo],
      [HAVE_XINERAMA="Solaris"
       AC_DEFINE(HAVE_SOLARIS_XINERAMA_EXTENSION, 1, [Define if present])
       X_XINERAMA_LIBS=""],,
      [#include <X11/Xlib.h>], [-lXext])
  fi

  if test "x$HAVE_XINERAMA" != "xno"; then
    AC_DEFINE(HAVE_XINERAMA_EXTENSION, 1, [Define if present])
    AC_SUBST(X_XINERAMA_LIBS)
  fi
fi

dnl ---------------------------------------------------------------------------
dnl Xmu (zapping_remote)
dnl ---------------------------------------------------------------------------

HAVE_XMU=no

AC_ARG_WITH(zapping-remote,
  AC_HELP_STRING([--with-zapping-remote],
    [Build the zapping_remote tool (yes).]),
  [with_zapping_remote="$withval"], [with_zapping_remote=yes])

if test "x$with_zapping_remote" = "xyes"; then
  CHECK_X_BOTH([X11/Xmu/WinUtil.h], [Xmu], [XmuClientWindow],
    [HAVE_XMU="yes"
     X_XMU_LIBS="-lXmu"
     AC_SUBST(X_XMU_LIBS)],
    [AC_MSG_FAILURE([
*** To build zapping_remote (a command line tool to send a Zapping
*** process Python commands), we need libXmu which should be part of
*** the X11 (Xorg or XFree86) devel package. To compile Zapping
*** without zapping_remote run ./configure --without-zapping-remote
     ])],
    [#include <X11/Xlib.h>], [-lXext])
fi

AM_CONDITIONAL(HAVE_XMU, test "x$HAVE_XMU" = "xyes")

dnl ===========================================================================
dnl Libraries
dnl ===========================================================================

dnl ---------------------------------------------------------------------------
dnl Gnome libs
dnl ---------------------------------------------------------------------------

GNOME_COMPILE_WARNINGS
AM_GCONF_SOURCE_2

PKG_CHECK_MODULES(PACKAGE, [
  gtk+-2.0 >= 2.4
  libgnomeui-2.0
  libglade-2.0
  gconf-2.0])
AC_SUBST(PACKAGE_CFLAGS)
AC_SUBST(PACKAGE_LIBS)

AC_PATH_PROG(GDK_PIXBUF_CSOURCE, gdk-pixbuf-csource)
test -z "$GDK_PIXBUF_CSOURCE" && AC_MSG_FAILURE([
*** To create icons we need the gdk-pixbuf-csource tool
*** which is part of GTK+ 2.0's gdk-pixbuf package.
])

AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
test -z "$GLIB_GENMARSHAL" && AC_MSG_FAILURE([
*** To compile Zapping we need the glib-genmarshal tool
*** which is part of GTK+ 2.0's glib package.
])

dnl ---------------------------------------------------------------------------
dnl VBI capture and decoding library
dnl ---------------------------------------------------------------------------

HAVE_ZVBI="no"
REQUIRED_ZVBI_VERSION=0.2.11

AC_ARG_WITH([zvbi], 
  AS_HELP_STRING([--with-zvbi], [Use libzvbi (yes).]),
  [with_zvbi="$withval"], [with_zvbi=yes])

if test "x$with_zvbi" = "xyes"; then
  PKG_CHECK_MODULES(ZVBI, [zvbi-0.2 >= $REQUIRED_ZVBI_VERSION],
    [AC_DEFINE(HAVE_LIBZVBI, 1, [Define if ZVBI lib is present])
     HAVE_ZVBI="yes"
     AC_SUBST(ZVBI_CFLAGS)
     AC_SUBST(ZVBI_LIBS)],
    [echo -n "*** Could not find libzvbi >= $REQUIRED_ZVBI_VERSION. "
     echo "The library is required" 
     echo "*** for Teletext, caption/subtitles and OSD. If you are sure"
     echo "*** libzvbi $REQUIRED_ZVBI_VERSION or later is installed, try"
     echo "*** ./configure PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ..."
     echo "*** The latest version of libzvbi is available from"
     echo "*** http://zapping.sourceforge.net. To compile Zapping without"
     echo "*** libzvbi run ./configure --without-zvbi"
     exit 1])
fi

AM_CONDITIONAL(HAVE_LIBZVBI, test "x$HAVE_ZVBI" = "xyes")

test "x$HAVE_ZVBI" = "xyes" && \
  PLUGINS_TO_BUILD="$PLUGINS_TO_BUILD teletext subtitle"

dnl ---------------------------------------------------------------------------
dnl Check for Gnome unicode library or libc 2.1.
dnl (Teletext URE search wchar_t ctype.h functions)
dnl ---------------------------------------------------------------------------

AC_MSG_CHECKING(whether we are using the GNU C Library 2.1 or newer)

AC_EGREP_CPP([GNU 98765876],[
#include <features.h>
#ifdef __GNU_LIBRARY__
 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
  GNU 98765876
 #endif
#endif
],[
  AC_MSG_RESULT([yes])
  AC_DEFINE(HAVE_GLIBC21, 1, [Define if you have GNU C Lib 2.1+])
],[
  AC_MSG_RESULT([no])
  AC_MSG_CHECKING(for unicode library)
  UNICODE_VERSION=`unicode-config --version`
  if test $? -eq 0; then
    AC_DEFINE(HAVE_LIBUNICODE, 1, [Define if you have libunicode])
    AC_MSG_RESULT($UNICODE_VERSION)
    UNICODE_CFLAGS=`unicode-config --cflags`
    UNICODE_LIBS=`unicode-config --libs`
    AC_SUBST(UNICODE_CFLAGS)
    AC_SUBST(UNICODE_LIBS)
  else
    AC_MSG_RESULT([not present - Teletext search disabled])
  fi
])

dnl ---------------------------------------------------------------------------
dnl JPEG library (screenshots)
dnl ---------------------------------------------------------------------------

HAVE_JPEG="yes"
JPEG_LIB=""

AC_CHECK_LIB(jpeg, jpeg_destroy_compress, JPEG_LIB="-ljpeg", HAVE_JPEG="no")
dnl The screenshot plugin requires libjpeg
if test "x$HAVE_JPEG" = "xyes"; then
  AC_DEFINE(HAVE_LIBJPEG, 1, [Define if JPEG lib is present])
fi

AC_SUBST(JPEG_LIB)

dnl ---------------------------------------------------------------------------
dnl PNG library (Teletext PNG export)
dnl ---------------------------------------------------------------------------

HAVE_PNG="yes"
PNG_LIBS=""

AC_CHECK_LIB(png, png_destroy_write_struct,
	 PNG_LIBS="-lpng -lz -lm", HAVE_PNG="no", -lz -lm)
if test "x$HAVE_PNG" = "xyes"; then
  AC_DEFINE(HAVE_LIBPNG, 1, [Define if PNG lib is present])
fi

AC_SUBST(PNG_LIBS)

dnl ---------------------------------------------------------------------------
dnl RTE library (mpeg plugin, real time a/v encoding)
dnl ---------------------------------------------------------------------------

SAVE_LIBS=$LIBS
HAVE_RTE="yes"
AC_CHECK_LIB(rte, rte_parameters_set,, [HAVE_RTE="no"])
AC_EGREP_HEADER(rte_parameters_set, librte.h,, [HAVE_RTE="no"])
if test "x$HAVE_RTE" != "xno"; then
  PLUGINS_TO_BUILD="$PLUGINS_TO_BUILD record"
  AC_DEFINE(HAVE_LIBRTE, 1, [Define if RTE lib 0.5 is present])
  RTE_LIBS="-lrte"
fi
AC_SUBST(RTE_LIBS)
LIBS="$SAVE_LIBS"

dnl ---------------------------------------------------------------------------
dnl lirc_client library (remote controls)
dnl ---------------------------------------------------------------------------

if test "x$enable_bktr" = "xyes"; then
dnl Need replacement
  HAVE_LIRC="not available"
else
  HAVE_LIRC="yes"
  AC_REQUIRE_CPP
  AC_CHECK_LIB(lirc_client, lirc_init,
    AC_EGREP_HEADER(lirc_init, lirc/lirc_client.h, true, HAVE_LIRC=no),
      HAVE_LIRC=no,)
  if test "x$HAVE_LIRC" = "xyes"; then
    PLUGINS_TO_BUILD="$PLUGINS_TO_BUILD alirc"
    AC_DEFINE(HAVE_LIRC, 1, [Define if LIRC client lib is present])
    LIRC_LIB="-llirc_client"
  fi
  AC_SUBST(LIRC_LIB)
fi

dnl ---------------------------------------------------------------------------
dnl Python support (our script language)
dnl ---------------------------------------------------------------------------

AC_PYTHON_CHECK

dnl ----------------------------------------------------------------------
dnl Check for libxml2 (src/zconf)
dnl ----------------------------------------------------------------------

AC_MSG_CHECKING([for libxml2])
HAVE_LIBXML="no"

LIBXML_VERSION=`xml2-config --version`
if test $? -eq 0; then
  LIBXML_CFLAGS=`xml2-config --cflags`
  LIBXML_LIBS=`xml2-config --libs`
  XML_LIB="xml2"
  SAVE_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS $LIBXML_CFLAGS $LIBXML_LIBS"
  AC_TRY_LINK([#include <libxml/parser.h>],, HAVE_LIBXML="yes")
  CFLAGS="$SAVE_CFLAGS"
fi

AC_MSG_RESULT($LIBXML_VERSION)

if test "x$HAVE_LIBXML" = "xno"; then
  AC_MSG_FAILURE([
*** This version of Zapping requires libxml2.
  ])
fi

AC_SUBST(LIBXML_CFLAGS)
AC_SUBST(LIBXML_LIBS)

dnl ---------------------------------------------------------------------------
dnl Native language support
dnl ---------------------------------------------------------------------------

GETTEXT_PACKAGE=AC_PACKAGE_NAME
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Package name])

ALL_LINGUAS="cs de es fr it ja nl"
dnl da, pl, sv need update

AM_GLIB_GNU_GETTEXT

dnl ---------------------------------------------------------------------------
dnl Documentation
dnl ---------------------------------------------------------------------------

SCROLLKEEPER_BUILD_REQUIRED=0.3.5
AC_SUBST(SCROLLKEEPER_BUILD_REQUIRED)

AC_PATH_PROG(SCROLLKEEPER_CONFIG, [scrollkeeper-config], [no])
if test "x$SCROLLKEEPER_CONFIG" = "xno"; then
  AC_MSG_FAILURE([
*** Couldn't find scrollkeeper-config. Scrollkeeper is required to
*** install the Zapping documentation. Download the appropriate
*** package for your distribution or get the source tarball from
*** http://scrollkeeper.sourceforge.net
  ])
fi

dnl For build test scripts.
AC_ARG_ENABLE(rebuild-man,
  AC_HELP_STRING([--enable-rebuild-man], [Rebuild manual pages (auto).]),,
  [enableval=auto])

BUILD_MAN=no
if test "x$enableval" != "xno"; then
  AC_PATH_PROG([XSLTPROC], [xsltproc])
  if test ! -z "$XSLTPROC"; then
    dnl Check for DocBook DTD and stylesheets in the local catalog.
    JH_CHECK_XML_CATALOG([-//OASIS//DTD DocBook XML V4.1.2//EN],
      [DocBook XML DTD V4.1.2], [BUILD_MAN=yes])
    JH_CHECK_XML_CATALOG([http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl],
      [DocBook XSL Stylesheets],, [BUILD_MAN=no])
  fi
  if test "x$enableval" = "xyes" -a "x$BUILD_MAN" = "xno"; then
    AC_MSG_FAILURE([
*** Cannot rebuild the Zapping manual pages because DocBook
*** files are missing.
    ]);
  fi
fi

AM_CONDITIONAL(BUILD_MAN, test "x$BUILD_MAN" = "xyes")

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

dnl Compilation flags

dnl Warnings are not enabled by default, they must be added to CFLAGS
dnl at configure or autogen.sh time by the maintainer.
dnl WARN_CFLAGS="-W -Wall -Wunused -Wmissing-prototypes \
dnl   -Wmissing-declarations -Wdeclaration-after-statement -Wundef \
dnl   -Wendif-labels -Wshadow -Wfloat-equal -Wpointer-arith -Wwrite-strings \
dnl   -Wbad-function-cast -Wcast-qual -Wcast-align \
dnl   -Winline -Wconversion" # -Wpadded

dnl XXX maintainer only, see list
dnl DEPR_CFLAGS="\
dnl  -DG_DISABLE_DEPRECATED \
dnl  -DGTK_DISABLE_DEPRECATED \
dnl  -DGDK_DISABLE_DEPRECATED \
dnl  -DGDK_PIXBUF_DISABLE_DEPRECATED \
dnl  -DGNOME_DISABLE_DEPRECATED \
dnl "

dnl Note $prefix and derived variables must not be expanded in
dnl configure but only in Makefiles. They are, in fact, undefined
dnl at this point. Defaults:
dnl prefix=/usr/local      eprefix=/usr/local
dnl datadir=$prefix/share  sbindir=$eprefix/sbin
DIR_CFLAGS="\
  -DPACKAGE_DATA_DIR=\\\"\${datadir}\\\" \
  -DPACKAGE_LOCALE_DIR=\\\"\${datadir}/locale\\\" \
  -DPACKAGE_PIXMAPS_DIR=\\\"\${datadir}/pixmaps/\${PACKAGE}\\\"\
  -DPACKAGE_LIB_DIR=\\\"\${prefix}/lib/\${PACKAGE}\\\" \
  -DPACKAGE_ZSFB_DIR=\\\"\${sbindir}\\\" \
"

DEFAULT_CFLAGS="-D_GNU_SOURCE $X_CFLAGS $DIR_CFLAGS"
AC_SUBST(DEFAULT_CFLAGS)

PACKAGE_PIXMAPS_DIR="\${prefix}/\${DATADIRNAME}/pixmaps/\${PACKAGE}"
AC_SUBST(PACKAGE_PIXMAPS_DIR)

PACKAGE_LIB_DIR="\${prefix}/lib/\${PACKAGE}"
AC_SUBST(PACKAGE_LIB_DIR)

PLUGIN_DEFAULT_DIR="\${PACKAGE_LIB_DIR}/plugins"
AC_SUBST(PLUGIN_DEFAULT_DIR)

PLUGIN_DEFAULT_FLAGS="$DEFAULT_CFLAGS $ZVBI_CFLAGS"
AC_SUBST(PLUGIN_DEFAULT_FLAGS)

COMMON_INCLUDES="$PY_CFLAGS $PACKAGE_CFLAGS $UNICODE_CFLAGS $ARTS_CFLAGS"
AC_SUBST(COMMON_INCLUDES)

PACKAGE_VERSION_ID=`echo $VERSION | sed s/[[^a-z0-9]]/_/g`
AC_SUBST(PACKAGE_VERSION_ID)

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

AC_OUTPUT([
Makefile
zapping.desktop.in
zapping.spec
common/Makefile
libtv/Makefile
libvbi/Makefile
src/Makefile
po/Makefile.in
glade/Makefile
pixmaps/Makefile
zapping_setup_fb/Makefile
plugins/Makefile
plugins/alirc/Makefile
plugins/deinterlace/Makefile
plugins/deinterlace/DI_GreedyH/Makefile
plugins/deinterlace/DI_Misc/Makefile
plugins/deinterlace/test/Makefile
plugins/mpeg/Makefile
plugins/screenshot/Makefile
plugins/subtitle/Makefile
plugins/teletext/Makefile
help/Makefile
help/man/Makefile
help/C/Makefile
test/Makefile
])

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

echo "
        Optional packages
        -------------------------------------------------------------
        Video devices                       $VIDEO_SUPPORT
        Audio devices                       $AUDIO_SUPPORT
        PAM                                 $HAVE_PAM
        DPMS                                $HAVE_DPMS
        DGA                                 $HAVE_DGA
        VidMode                             $HAVE_VIDMODE
        XVideo                              $HAVE_XV
        Xinerama                            $HAVE_XINERAMA
        SIMD                                $SIMD_SUPPORT
        libzvbi                             $HAVE_ZVBI
        libpng                              $HAVE_PNG
        librte                              $HAVE_RTE
        liblirc_client                      $HAVE_LIRC
        libjpeg                             $HAVE_JPEG

        Plugins: $PLUGINS_TO_BUILD
"