summaryrefslogtreecommitdiffstats
path: root/debian/transcode/transcode-1.1.7/configure.in
blob: 03178c3275c89f908fb98e90c95c2e5c5b9be11a (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
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
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
# Process this file with autoconf to produce a configure script.

AC_INIT(transcode,1.1.7)
AC_CONFIG_AUX_DIR(autotools)
AC_CONFIG_SRCDIR(src/transcode.c)

dnl Detect the canonical host and target build environment
AC_CANONICAL_SYSTEM

AM_INIT_AUTOMAKE(transcode,1.1.7)
AM_CONFIG_HEADER(config.h)

AM_MAINTAINER_MODE

dnl Checks for programs.
AC_LANG([C])
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AM_PROG_AS
AM_CONDITIONAL(HAVE_GCC, test x"$GCC" = x"yes")

dnl Check for gcc2, which doesn't seem to handle asm templates
dnl And check for gcc4, which also has problems with filter_tomsmocomp
dnl
gcc2=no
gcc4=no
if test x"$GCC" = x"yes" ; then
  gcc_ver="`LANG=C $CC -dumpversion`"
  if test x"$gcc_ver" != x"" ; then
    if echo $gcc_ver | grep -q ^2 ; then
      gcc2=yes
    fi
    if echo $gcc_ver | grep -q ^4 ; then
      gcc4=yes
    fi
  fi
fi
AM_CONDITIONAL(HAVE_GCC2, test x"$gcc2" = x"yes")
AM_CONDITIONAL(HAVE_GCC4, test x"$gcc4" = x"yes")

dnl we got $AWK already, but not its full path
AC_PATH_PROG(PATH_TO_AWK, $AWK)

dnl Check the OS.  This has to be done here, after checks for proograms and
dnl before checks for libraries.

deflib="/lib"
is_linux=no
is_bsd=no
is_osx=no
case "${target_os}" in
  *linux*)
    is_linux=yes
    AC_DEFINE([OS_LINUX], 1, [Define if your system is Linux])
    ;;
  freebsd*|openbsd*|netbsd*|bsdi*|darwin*|rhapsody*)
    is_bsd=yes
    AC_DEFINE([OS_BSD], 1, [Define if your system is modern BSD])
  
  # darwin is a subcase of BSD
  case "${target_os}" in
    darwin*)
      is_osx=yes
      CFLAGS="${CFLAGS} -no-cpp-precomp -D_INTL_REDIRECT_MACROS"
      #LDFLAGS="${LDFLAGS} -all_load"

      AC_DEFINE([OS_DARWIN], 1, [Define if this is a Darwin / MacOS X system.])
      AC_DEFINE([BROKEN_PTHREADS], 1, [Define if you have weird pthreads.])

      # Include Fink in compile and link if present
      if test -d /sw; then
        CPPFLAGS="${CPPFLAGS} -I/sw/include"
        LDFLAGS="${LDFLAGS} -L/sw/lib"
      fi
      ;;
  esac
    ;;
esac
AM_CONDITIONAL([OS_LINUX], test x"$is_linux" = x"yes")
AM_CONDITIONAL([OS_BSD], test x"$is_bsd" = x"yes")
AM_CONDITIONAL([OS_DARWIN], test x"$is_osx" = x"yes")


dnl Checks for libraries.
AC_CHECK_LIB(dl, dlopen)
AC_CHECK_FUNCS([dlopen])
if test x"$is_osx" = x"true" ; then
  AC_CHECK_FUNCS(dlsym_prepend_underscore,
    [CFLAGS="${CFLAGS} -Ddlsym=dlsym_prepend_underscore"],
    AC_MSG_WARN([Function 'dlsym_prepend_underscore' not found.])
    AC_MSG_WARN([Using function 'dlsym' directly instead.])
    AC_MSG_WARN([This can be a problem if the installed dlsym])
    AC_MSG_WARN([does not automatically prepend an underscore])
    AC_MSG_WARN([to symbols.]))
fi

USE_DLDARWIN=no
if test x"$ac_cv_lib_dl_dlopen" = x"no" ; then
  case x${target_os} in
    xdarwin*)
      USE_DLDARWIN=yes
      DLDARWIN_CFLAGS="-I\$(top_srcdir)/libdldarwin/"
      DLDARWIN_LIBS="\$(top_builddir)/libdldarwin/libdldarwin.a"
      ;;
  esac
fi
AC_SUBST(USE_DLDARWIN)
AC_SUBST(DLDARWIN_CFLAGS)
AC_SUBST(DLDARWIN_LIBS)
AM_CONDITIONAL(USE_DLDARWIN, test x"$USE_DLDARWIN" = x"yes")

dnl libtool setup
AC_PROVIDE([AC_PROG_CXX])  dnl we don't want it!
AC_PROVIDE([AC_PROG_F77])  dnl likewise
AC_DISABLE_STATIC
AC_LIBTOOL_DLOPEN
AC_PROG_LIBTOOL


dnl Checks for header files.
TC_CHECK_STD_HEADERS
AC_CHECK_HEADERS([endian.h malloc.h sys/mman.h sys/select.h])

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_C_BIGENDIAN([words_bigendian=true
  AC_DEFINE([WORDS_BIGENDIAN], 1, [Define if your CPU is big-endian.])],
  words_bigendian=false)
AM_CONDITIONAL(WORDS_BIGENDIAN, test x"$words_bigendian" = x"true")
TC_C_GCC_ATTRIBUTES
TC_C_ATTRIBUTE_ALIGNED

dnl Checks for library functions.
AC_FUNC_MALLOC
AC_TYPE_SIGNAL
AC_CHECK_FUNCS([getopt_long_only getpagesize gettimeofday mmap strlcat strlcpy strtof vsscanf])
AM_CONDITIONAL(HAVE_GETOPT_LONG_ONLY, test x"$ac_cv_func_getopt_long_only" = x"yes")
AM_CONDITIONAL(HAVE_MMAP, test x"$ac_cv_func_mmap" = x"yes")
AM_CONDITIONAL(HAVE_GETTIMEOFDAY, test x"$ac_cv_func_gettimeofday" = x"yes")

dnl Special check for sysconf() to ensure _SC_PAGESIZE is also available.
AC_CACHE_CHECK([for sysconf(_SC_PAGESIZE)], ac_cv_sysconf_with_sc_pagesize,
               [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]],[[sysconf(_SC_PAGESIZE);]])],
                                  [ac_cv_sysconf_with_sc_pagesize=yes],
                                  [ac_cv_sysconf_with_sc_pagesize=no])])
if test x"$ac_cv_sysconf_with_sc_pagesize" = x"yes"; then
    AC_DEFINE([HAVE_SYSCONF_WITH_SC_PAGESIZE], 1,
              [Define to 1 if you have sysconf(_SC_PAGESIZE).])
fi

dnl Large file support.
AC_SYS_LARGEFILE
AC_FUNC_FSEEKO

dnl Thread support (pthreads).
case "$host" in
  *-*-freebsd*)
    pthread_cflags="-pthread -D_REENTRANT -D_THREAD_SAFE"
    pthread_libs="-pthread"
    ;;
  *-*-openbsd*)
    pthread_cflags="-D_REENTRANT"
    pthread_libs="-pthread"
    ;;
  *-*-bsdi*)
    pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
    pthread_libs=""
    ;;
  *)
    pthread_cflags="-D_REENTRANT"
    pthread_libs="-lpthread"
    ;;
esac
# let user override
if test -n "$PTHREAD_LIBS" ; then
  pthread_libs="$PTHREAD_LIBS"
fi
if test -n "$PTHREAD_CFLAGS" ; then
  pthread_cflags="$PTHREAD_CFLAGS"
fi
save_LIBS="$LIBS"
LIBS="$LIBS $pthread_libs"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $pthread_cflags"
AC_MSG_CHECKING(for pthreads in $pthread_libs)
AC_TRY_LINK([
#include <pthread.h>
],[
   pthread_attr_t type;
   pthread_attr_init(&type);
],
  [use_pthreads="yes"],
  [use_pthreads="no"]
);
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
AC_MSG_RESULT($use_pthreads)
if test x"$use_pthreads" = x"yes" ; then
  PTHREAD_LIBS="$pthread_libs"
  PTHREAD_CFLAGS="$pthread_cflags"
else
  PTHREAD_LIBS=""
  PTHREAD_CFLAGS=""
fi
AC_SUBST(PTHREAD_LIBS)
AC_SUBST(PTHREAD_CFLAGS)


dnl
dnl Architecture specific instructions
dnl

AC_MSG_CHECKING([for build architecture])
have_x86cpu=false
have_x86_64cpu=false
have_ppccpu=false
case x"$host_cpu" in
  xi?86*|xk6*)
    have_x86cpu=true
    AC_MSG_RESULT([Intel Pentium architecture (IA32)])
    AC_DEFINE([ARCH_X86], 1, [Define if your machine is x86 based])
    ;;
  xx86_64*|xamd64*)
    have_x86_64cpu=true
    AC_MSG_RESULT([AMD64 architecture (AMD64)])
    AC_DEFINE([ARCH_X86_64], 1, [Define if your machine is AMD64 based])
    ;;
  xpowerpc*)
    have_ppccpu=true
    AC_MSG_RESULT([Mac PPC architecture (PPC)])
    AC_DEFINE([ARCH_PPC], 1, [Define if your machine is PPC based])
    ;;
  *)
    ;;
esac
AM_CONDITIONAL(ARCH_X86, test x"$have_x86cpu" = x"true")
AM_CONDITIONAL(ARCH_X86_64, test x"$have_x86_64cpu" = x"true")
AM_CONDITIONAL(ARCH_PPC, test x"$have_ppccpu" = x"true")


dnl x86 & x86_64 architectures

dnl MMX support
dnl
explicit_mmx=no
AC_ARG_ENABLE(mmx,
  AC_HELP_STRING([--enable-mmx],
    [enable MMX code portions (yes)]),
  [case "${enableval}" in
    yes) use_mmx=yes ;;
    no)  use_mmx=no ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-mmx) ;;
  esac
  explicit_mmx=yes],
  [if test x"$have_x86cpu" = x"true" -o x"$have_x86_64cpu" = x"true" ; then
    use_mmx=yes
  else
    use_mmx=no
  fi])

have_asm_mmx="no"
if test x"$use_mmx" = x"yes" ; then
  AC_MSG_CHECKING([if \$CC groks MMX inline assembly])
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [void *p;asm volatile("packuswb %%mm1,%%mm2"::"r"(p));])],
    [have_asm_mmx="yes"])
  if test x"$have_asm_mmx" = x"yes" ; then
    AC_DEFINE([HAVE_ASM_MMX], 1,
      [Define if your compiler understands MMX assembly instructions])
  fi
  AC_MSG_RESULT($have_asm_mmx)
  if test x"$have_asm_mmx" = x"no" -a x"$explicit_mmx" = x"yes" ; then
    AC_MSG_WARN(*** Ignoring --enable-mmx due to no compiler support ***)
  fi
fi
AM_CONDITIONAL(HAVE_ASM_MMX, test x"$have_asm_mmx" = x"yes")
if test x"$have_asm_mmx" = x"no" ; then
  AC_MSG_WARN(*** All MMX dependent parts will be disabled ***)
fi

dnl 3DNow support
dnl
explicit_3dnow=no
AC_ARG_ENABLE(3dnow,
  AC_HELP_STRING([--enable-3dnow],
    [enable 3DNow code portions (yes)]),
  [case "${enableval}" in
    yes) if test x"$have_asm_mmx" = x"no"; then
             AC_MSG_ERROR(--enable-3dnow requires --enable-mmx)
         else
             use_3dnow=yes
         fi ;;
    no)  use_3dnow=no ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-3dnow) ;;
  esac
  explicit_3dnow=yes],
  [if test x"$have_asm_mmx" = x"yes" -a \( x"$have_x86cpu" = x"true" -o x"$have_x86_64cpu" = x"true" \) ; then
    use_3dnow=yes
  else
    use_3dnow=no
  fi])
have_asm_3dnow="no"
if test x"$use_3dnow" = x"yes" ; then
  AC_MSG_CHECKING([if \$CC groks 3DNow inline assembly])
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [void *p;asm volatile("pfmul %%mm3,%%mm4"::"r"(p));])],
    [have_asm_3dnow="yes"])
  if test x"$have_asm_3dnow" = x"yes" ; then
    AC_DEFINE([HAVE_ASM_3DNOW], 1,
      [Define if your compiler understands 3DNow assembly instructions])
  fi
  AC_MSG_RESULT($have_asm_3dnow)
  if test x"$have_asm_3dnow" = x"no" -a x"$explicit_3dnow" = x"yes" ; then
    AC_MSG_WARN(*** Ignoring --enable-3dnow due to no compiler support ***)
  fi
fi
AM_CONDITIONAL(HAVE_ASM_3DNOW, test x"$have_asm_3dnow" = x"yes")
if test x"$have_asm_3dnow" = x"no" ; then
  AC_MSG_WARN(*** All 3DNow dependent parts will be disabled ***)
fi


dnl SSE support
dnl
explicit_sse=no
AC_ARG_ENABLE(sse,
  AC_HELP_STRING([--enable-sse],
    [enable SSE code portions (yes)]),
  [case "${enableval}" in
    yes) if test x"$have_asm_mmx" = x"no"; then
             AC_MSG_ERROR(--enable-sse requires --enable-mmx)
         else
             use_sse=yes
         fi ;;
    no)  use_sse=no ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-sse) ;;
  esac
  explicit_sse=yes],
  [if test x"$have_asm_mmx" = x"yes" -a \( x"$have_x86cpu" = x"true" -o x"$have_x86_64cpu" = x"true" \) ; then
    use_sse=yes
  else
    use_sse=no
  fi])
have_asm_sse="no"
if test x"$use_sse" = x"yes" ; then
  AC_MSG_CHECKING([if \$CC groks SSE inline assembly])
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [void *p; asm volatile("movntps  %%xmm0, 0"::"r"(p));])],
    [have_asm_sse=yes])
  if test x"$have_asm_sse" = x"yes" ; then
    AC_DEFINE([HAVE_ASM_SSE], 1,
      [Define if your compiler understands SSE assembly instructions])
  fi
  AC_MSG_RESULT($have_asm_sse)
  if test x"$have_asm_sse" = x"no" -a x"$explicit_sse" = x"yes" ; then
    AC_MSG_WARN(*** Ignoring --enable-sse due to no compiler support ***)
  fi
fi
AM_CONDITIONAL(HAVE_ASM_SSE, test x"$have_asm_sse" = x"yes")
if test x"$have_asm_sse" = x"no" ; then
  AC_MSG_WARN(*** All SSE dependent parts will be disabled ***)
fi


dnl SSE2 support
dnl
explicit_sse2=no
AC_ARG_ENABLE(sse2,
  AC_HELP_STRING([--enable-sse2],
    [enable SSE2 code portions (yes)]),
  [case "${enableval}" in
    yes) if test x"$have_asm_sse" = x"no"; then
             AC_MSG_ERROR(--enable-sse2 requires --enable-sse)
         else
             use_sse2=yes
         fi ;;
    no)  use_sse2=no ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-sse2) ;;
  esac
  explicit_sse2=yes],
  [if test x"$have_asm_sse" = x"yes" -a \( x"$have_x86cpu" = x"true" -o x"$have_x86_64cpu" = x"true" \) ; then
    use_sse2=yes
  else
    use_sse2=no
  fi])
have_asm_sse2="no"
if test x"$use_sse2" = x"yes" ; then
  AC_MSG_CHECKING([if \$CC can handle SSE2 inline asm])
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [void *p; asm volatile("movdqa  %%xmm2, %%xmm3"::"r"(p));])],
    [have_asm_sse2=yes])
  if test x"$have_asm_sse2" = x"yes" ; then
    AC_DEFINE([HAVE_ASM_SSE2], 1,
      [Define if your compiler understands SSE2 assembly instructions])
  fi
  AC_MSG_RESULT($have_asm_sse2)
  if test x"$have_asm_sse2" = x"no" -a x"$explicit_sse2" = x"yes" ; then
    AC_MSG_WARN(*** Ignoring --enable-sse2 due to no compiler support ***)
  fi
fi
AM_CONDITIONAL(HAVE_ASM_SSE2, test x"$have_asm_sse2" = x"yes")
if test x"$have_asm_sse2" = x"no" ; then
  AC_MSG_RESULT(*** All SSE2 dependent parts will be disabled ***)
fi



dnl ppc architectures


dnl
dnl Altivec support
dnl
AC_ARG_ENABLE(altivec,
  AC_HELP_STRING([--enable-altivec],
    [enable Altivec code portions (yes)]),
  [case "${enableval}" in
    yes) use_altivec=yes ;;
    no)  use_altivec=no ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-altivec) ;;
  esac],
  [if test x"$have_ppccpu" = x"true" ; then
    use_altivec=yes
  else
    use_altivec=no
  fi])
dnl if test x"$use_altivec" = x"no" ; then
dnl	AC_MSG_WARN(*** All Altivec dependent parts will be disabled ***)
dnl fi


AC_MSG_CHECKING([if \$CC groks AltiVec inline assembly])
have_asm_altivec=no
if test x"$use_altivec" = x"yes" ; then
  AC_COMPILE_IFELSE([AC_LANG_SOURCE([], [asm volatile("vperm 0,1,2,3");])],
    [have_asm_altivec=yes],
    [save_CFLAGS="$CFLAGS"
      CFLAGS="$CFLAGS -Wa,-m7400"
      AC_COMPILE_IFELSE([AC_LANG_SOURCE([], [asm volatile("vperm 0,1,2,3");])],
        [have_asm_altivec=yes])
      CFLAGS="$save_CFLAGS"])
fi
AC_MSG_RESULT($have_asm_altivec)
if test x"$have_asm_altivec" = x"yes" ; then
  AC_DEFINE([HAVE_ASM_ALTIVEC], 1,
    [Define if your compiler understands AltiVec inline assembly])
fi

AC_MSG_CHECKING([if \$CC groks AltiVec C extensions])
have_c_altivec=no
if test x"$use_altivec" = x"yes" ; then
  # Darwin test
  save_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS -faltivec"
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [vec_mtvscr((vector unsigned int)(0));])],
    [have_c_altivec=yes
      ALTIVEC_CFLAGS="-faltivec"],
    [# Linux/PPC test
      CFLAGS="${save_CFLAGS} -fvec"
      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [vec_mtvscr((vector unsigned int)(0));])],
        [have_c_altivec=yes
          ALTIVEC_CFLAGS="-fvec"])
    ])
  CFLAGS="$save_CFLAGS"
fi
AC_MSG_RESULT($have_c_altivec)
AM_CONDITIONAL(CAN_COMPILE_C_ALTIVEC, test x"$have_c_altivec" = x"yes")
if test x"$have_c_altivec" = x"yes" ; then
  AC_DEFINE([CAN_COMPILE_C_ALTIVEC], 1,
    [Define if your compiler groks C AltiVec extensions.])
  AC_SUBST(ALTIVEC_CFLAGS)
fi

AC_MSG_CHECKING([if linker needs -framework vecLib])
if test x"$use_altivec" = x"yes" ; then
  save_LDFLAGS="$LDFLAGS"
  LDFLAGS="$LDFLAGS -framework vecLib"
  ld_altivec=no
  AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [ld_altivec=yes])
  LDFLAGS="$save_LDFLAGS"
fi
AC_MSG_RESULT($ld_altivec)
if test x"$ld_altivec" = x"yes" ; then
  LDFLAGS="$LDFLAGS -framework vecLib"
fi


dnl ---------------------------------------------------------------------
dnl
dnl pkgconfig
dnl
PKG_PROG_PKG_CONFIG([0.20])
if test -z "$PKG_CONFIG" ; then
  AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
fi


dnl ---------------------------------------------------------------------
dnl X11 checks

AC_PATH_XTRA
if test x"${no_x}" = x"yes" ; then
  AC_MSG_WARN(can not find X11)
  USE_X11=no
else
  AC_DEFINE([HAVE_X11], 1, [Have X11 support])
  USE_X11=yes
fi

AC_SUBST(X_CFLAGS)
AC_SUBST(X_PRE_LIBS)
AC_SUBST(X_EXTRA_LIBS)
AC_SUBST(X_LIBS)
AC_SUBST(x_includes)
AC_SUBST(x_libraries)

dnl fi

AM_CONDITIONAL(HAVE_X11, test x"${USE_X11}" = x"yes")

if test x"${USE_X11}" = x"yes" ; then
  AC_CHECK_LIB(Xv, XvQueryExtension,
    [have_xv=yes
      AC_DEFINE([HAVE_LIBXV], 1,
        [Have libxv support])],
    [have_xv=no],
    [$X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS])

  AC_CHECK_LIB(X11, XShmQueryExtension,
    [have_xshm=yes
      AC_DEFINE([HAVE_X11_SHM], 1,
        [Have Xshm support])],
    [have_xshm=no],
    [$X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS])

  AC_CHECK_HEADERS([X11/Xaw/Simple.h],
    [have_xaw_simple=yes
      AC_DEFINE([HAVE_XAW_SIMPLE], 1,
        [Have the Xaw Simple.h file support])],
    [have_xaw_simple=no])

  AC_CHECK_LIB(Xpm, XpmFreeAttributes,
    [have_xpm=yes
      AC_DEFINE([HAVE_LIBXPM], 1,
        [Have libXpm support])],
    [have_xpm=no],
    [$X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS])
else
  have_xv="no"
  have_xshm="no"
  have_xaw_simple="no"
  have_xpm="no"
fi

AM_CONDITIONAL(HAVE_LIBXV, test x"$have_xv" = x"yes")
AM_CONDITIONAL(HAVE_X11_SHM, test x"$have_xshm" = x"yes")
AM_CONDITIONAL(HAVE_XAW_SIMPLE, test x"$have_xaw_simple" = x"yes" )
AM_CONDITIONAL(HAVE_LIBXPM, test x"$have_xpm" = x"yes")

dnl end X11 checks
dnl ---------------------------------------------------------------------

AC_CHECK_LIB(z, gzopen,
  [],
  [AC_MSG_ERROR([transcode depends on libz, but cannot links against libz])],
  [])

AC_CHECK_LIB(m, sin,
  [],
  [AC_MSG_ERROR([transcode depends on libm (>= 2.0), but cannot link against libm])],
  [-lc])

TC_PKG_INIT

have_libavcodec=no
have_libavformat=no
AC_MSG_CHECKING([for ffmpeg support])
AC_ARG_ENABLE(ffmpeg,
  AC_HELP_STRING([--enable-ffmpeg],
    [enable support for FFmpeg libraries - RECOMMENDED (yes)]),
  [case "${enableval}" in
    yes) ;;
    no)  ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-ffmpeg) ;;
  esac],
  [enable_ffmpeg=yes])
if test x"$enable_ffmpeg" = x"no" ; then
  AC_MSG_RESULT(disabled)
else
  AC_MSG_RESULT(requested, checking for libraries)

  dnl
  dnl libavcodec
  dnl
  TC_PKG_CONFIG_CHECK(libavcodec, "$enable_ffmpeg", LIBAVCODEC, libavcodec, [http://www.ffmpeg.org/])
  
  dnl
  dnl libavformat
  dnl
  TC_PKG_CONFIG_CHECK(libavformat, "$enable_ffmpeg", LIBAVFORMAT, libavformat, [http://www.ffmpeg.org/])

  AC_DEFINE([HAVE_FFMPEG], 1, [Have FFmpeg libraries support])
fi

TC_PKG_HAVE(libavcodec, LIBAVCODEC)
TC_PKG_HAVE(libavformat, LIBAVFORMAT)

AM_CONDITIONAL(HAVE_FFMPEG, test x"$enable_ffmpeg" = x"yes")



dnl
dnl setup layout define once
dnl

dnl
dnl libv4l toolkit
dnl
TC_PKG_CONFIG_CHECK(libv4l2, no, LIBV4L2, libv4l2,
                    [http://hansdegoede.livejournal.com/3636.html])
TC_PKG_CONFIG_CHECK(libv4lconvert, no, LIBV4LCONVERT,
                    libv4lconvert,
                    [http://hansdegoede.livejournal.com/3636.html])
TC_PKG_HAVE(libv4l2, LIBV4L2)
TC_PKG_HAVE(libv4lconvert, LIBV4LCONVERT)

dnl
dnl libmpeg2
dnl
TC_PKG_CONFIG_CHECK(libmpeg2, no, LIBMPEG2, libmpeg2,
                    [http://libmpeg2.sf.net/])
TC_PKG_CONFIG_CHECK(libmpeg2convert, no, LIBMPEG2CONVERT,
                    libmpeg2convert, [http://libmpeg2.sf.net/])
TC_PKG_HAVE(libmpeg2, LIBMPEG2)
TC_PKG_HAVE(libmpeg2convert, LIBMPEG2CONVERT)

dnl
dnl build options
dnl

dnl
dnl support for new/experimental features (1.1.0: NMS)
dnl
AC_MSG_CHECKING([enable new or experimental components])
AC_ARG_ENABLE(experimental,
  AC_HELP_STRING([--enable-experimental],
    [enable new, experimental or even incomplete transcode components (no)]),
  [case "${enableval}" in
    yes) ;;
    no)  ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-experimental) ;;
  esac],
  [enable_experimental=no])
AC_MSG_RESULT($enable_experimental)
if test x"$enable_experimental" = x"yes" ; then
  AC_DEFINE([ENABLE_EXPERIMENTAL], 1, [Enable experimental components])
fi
AM_CONDITIONAL(ENABLE_EXPERIMENTAL, test x"$enable_experimental" = x"yes")

dnl
dnl support for deprecated features (1.1.0: tcrequant)
dnl
AC_MSG_CHECKING([enable deprecated components])
AC_ARG_ENABLE(deprecated,
  AC_HELP_STRING([--enable-deprecated],
    [enable deprecated or even broken transcode components (no)]),
  [case "${enableval}" in
    yes) ;;
    no)  ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-deprecated) ;;
  esac],
  [enable_deprecated=no])
AC_MSG_RESULT($enable_deprecated)
if test x"$enable_deprecated" = x"yes" ; then
  AC_DEFINE([ENABLE_DEPRECATED], 1, [Enable deprecated components])
fi
AM_CONDITIONAL(ENABLE_DEPRECATED, test x"$enable_deprecated" = x"yes")

dnl
dnl static import frame buffer
dnl
AC_MSG_CHECKING([for internal static framebuffer support])
AC_ARG_ENABLE(statbuffer,
  AC_HELP_STRING([--enable-statbuffer],
    [enable internal static framebuffer support; recommended (yes)]),
  [case "${enableval}" in
    yes) ;;
    no)  ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-statbuffer) ;;
  esac],
  [enable_statbuffer=yes])
AC_MSG_RESULT($enable_statbuffer)
if test x"$enable_statbuffer" = x"yes" ; then
  AC_DEFINE([STATBUFFER], 1, [Use the static buffers])
fi


dnl
dnl hardware/OS dependent modules
dnl

dnl
dnl v4l
dnl
TC_CHECK_V4L(AC_DEFINE([HAVE_V4L], 1, [Have video4linux(2)]))
AM_CONDITIONAL(HAVE_V4L, test x"$have_v4l" = x"yes")
AM_CONDITIONAL(HAVE_V4L2, test x"$have_v4l2" = x"yes")

dnl
dnl bktr
dnl
TC_CHECK_BKTR(AC_DEFINE([HAVE_BKTR], 1, [Have bktr(4)]))
AM_CONDITIONAL(HAVE_BKTR, test x"$have_bktr" = x"yes")

dnl
dnl sunau
dnl
TC_CHECK_SUNAU(AC_DEFINE([HAVE_SUNAU], 1, [Have Sun style audio(4)]))
AM_CONDITIONAL(HAVE_SUNAU, test x"$have_sunau" = x"yes")

dnl
dnl OSS
dnl
TC_CHECK_OSS(AC_DEFINE([HAVE_OSS], 1, [Have OSS audio]))
AM_CONDITIONAL(HAVE_OSS, test x"$have_oss" = x"yes")

dnl
dnl ALSA
dnl
TC_CHECK_ALSA(AC_DEFINE([HAVE_ALSA], 1, [Have ALSA audio]))
AM_CONDITIONAL(HAVE_ALSA, test x"$have_alsa" = x"yes")

dnl
dnl optional 3rd party package support
dnl

dnl
dnl Divx4linux
dnl
AC_CHECK_HEADERS([encore2.h])

dnl
dnl libpostproc
dnl
TC_PKG_CONFIG_CHECK(libpostproc, no, LIBPOSTPROC, libpostproc, [http://ffmpeg.mplayerhq.hu/])
TC_PKG_HAVE(libpostproc, LIBPOSTPROC)

dnl
dnl freetype2
dnl
TC_PKG_CONFIG_CHECK(freetype2, no, FREETYPE2, freetype2, [http://www.freetype.org/])
TC_PKG_HAVE(freetype2, FREETYPE2)

dnl
dnl lame
dnl
TC_PKG_CHECK(lame, yes, LAME, no, none, mp3lame, lame_init, lame,
 [http://www.mp3dev.org/])
if test x"$have_lame" = x"yes" ; then
  lame_inc="no"
  save_CPPFLAGS="$CPPFLAGS"
  CPPFLAGS="$CPPFLAGS $lame_ii"
  AC_CHECK_HEADER([lame/lame.h],
    [AC_DEFINE([HAVE_LAME_INC], [1],
      [Have Lame includes in separate path]) lame_inc=yes])
  if test x"$lame_inc" = x"no" ; then
    AC_CHECK_HEADER([lame.h], lame_inc="yes")
  fi
  if test x"$lame_inc" = x"no" ; then
    have_lame="no"
    TC_PKG_ERROR(lame, lame.h, yes, lame, [http://www.mp3dev.org/],
      [cannot compile lame.h])
  else
    LAME_CFLAGS="$lame_ii"
  fi
  CPPFLAGS="$save_CPPFLAGS"

  AC_MSG_CHECKING([lame version])
  ac_save_CFLAGS="$CFLAGS"
  ac_save_LIBS="$LIBS"
  CFLAGS="$CFLAGS $LAME_CFLAGS"
  LIBS="$LIBS $LAME_LIBS"
  AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>

#ifdef HAVE_LAME_INC
#include <lame/lame.h>
#else
#include <lame.h>
#endif

int main () {
  lame_version_t lv;
  get_lame_version_numerical(&lv);
  if(lv.alpha || lv.beta) lv.minor--;
  printf("%d%d\n", lv.major, lv.minor);
  return 0;
}
]])],
    [lame_version="`./conftest$ac_exeext`"],
    [AC_MSG_RESULT([failed])
     TC_PKG_ERROR(lame, lame.h, yes, lame, [http://www.mp3dev.org/],
      [cannot compile and run a test program])],,
    [AC_MSG_RESULT([cross compiling; assumed OK...])])
  CFLAGS="$ac_save_CFLAGS"
  LIBS="$ac_save_LIBS"

  if test 393 -ge "$lame_version" ; then
    have_lame="no"
    TC_PKG_ERROR(lame, lame.h, yes, lame, [http://www.mp3dev.org/],
      [lame version < 3.93])
  fi
fi
TC_PKG_HAVE(lame, LAME)

dnl
dnl xvid
dnl
TC_PKG_CHECK(xvid, no, xvid, no, xvid.h, xvidcore, xvid_global, xvid,
 [http://www.xvid.org/])
if test x"$have_xvid" = x"yes" ; then
  AC_MSG_CHECKING([xvid version >= 1.0])
  AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>
#include <xvid.h>

int main() {
	printf("%s\n", (XVID_API >= XVID_MAKE_API(4, 0)) ?"yes" :"no");
	return 0;
}
]])],
    [xvid_version_ok="`./conftest$ac_exeext`"],
    [AC_MSG_RESULT([failed])
     TC_PKG_ERROR(xvid, xvid.h, yes, xvid, [http://www.xvid.org/],
      [cannot compile and run a test program])],,
    [AC_MSG_RESULT([cross compiling; assumed OK...])])
  if test x"$xvid_version_ok" = x"yes"; then
    XVID_LIBS="-lxvidcore"
  else
    have_xvid="no"
    TC_PKG_ERROR(xvid, xvid.h, yes, xvid, [http://www.xvid.org/],
      [XviD version < 1.0])
  fi
fi
TC_PKG_HAVE(xvid, XVID)

dnl
dnl x264
dnl
TC_PKG_CONFIG_CHECK(x264, no, X264, x264, [http://developers.videolan.org/x264.html])
if test x"$have_x264" = x"yes" ; then
  AC_MSG_CHECKING([x264 version])
  AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>
#include <stdint.h>  /* required by x264.h */
#include <x264.h>

int main() {
	printf("%d\n", X264_BUILD);
	return 0;
}
]])],
    [x264_version="`./conftest$ac_exeext`"],
    [AC_MSG_RESULT([failed])
     TC_PKG_ERROR(x264, x264.h, yes, x264,
                  [http://developers.videolan.org/x264.html],
                  [cannot compile and run a test program])],
    [AC_MSG_RESULT([cross compiling; assumed OK...])
     x264_version=54])
  if test 54 -gt "$x264_version"; then
    have_x264="no"
    TC_PKG_ERROR(x264, x264.h, yes, x264,
                 [http://developers.videolan.org/x264.html],
                 [x264 version too old (must be at least 54)])
  fi
fi
TC_PKG_HAVE(x264, X264)

dnl
dnl ogg
dnl
TC_PKG_CONFIG_CHECK(ogg, no, OGG, ogg, [http://www.xiph.org/ogg/])
TC_PKG_HAVE(ogg, OGG)

dnl
dnl vorbis
dnl
TC_PKG_CONFIG_CHECK(vorbis, no, VORBIS, vorbis, [http://www.xiph.org/ogg/vorbis/])
TC_PKG_HAVE(vorbis, VORBIS)

dnl
dnl theora
dnl
TC_PKG_CONFIG_CHECK(theora, no, THEORA, theora, [http://www.theora.org/])
TC_PKG_HAVE(theora, THEORA)

dnl
dnl libdvdread
dnl
LIBDVDREAD_EXTRA_LIBS="$LIBDVDREAD_EXTRA_LIBS -lm"
TC_PKG_CHECK(libdvdread, yes, LIBDVDREAD, no, none, dvdread, DVDOpen,
 libdvdread, [http://www.dtek.chalmers.se/groups/dvd/downloads.shtml])
if test x"$have_libdvdread" = x"yes" ; then
  libdvdread_inc="no"
  save_CPPFLAGS="$CPPFLAGS"
  CPPFLAGS="$CPPFLAGS $libdvdread_ii"
  AC_CHECK_HEADER([dvdread/dvd_reader.h],
    [AC_DEFINE([HAVE_LIBDVDREAD_INC], [1],
      [have libdvdread includes in separate path])
    libdvdread_inc="yes"])
  if test x"$libdvdread_inc" = x"no" ; then
    AC_CHECK_HEADER([dvd_reader.h],
      [libdvdread_inc="yes"])
  fi
  CPPFLAGS="$save_CPPFLAGS"
  if test x"$libdvdread_inc" = x"no" ; then
    have_libdvdread="no"
    TC_PKG_ERROR(libdvdread, dvd_reader.h, yes, libdvdread,
      [http://www.dtek.chalmers.se/groups/dvd/downloads.shtml],
      [cannot compile dvd_reader.h])
  else
    LIBDVDREAD_CFLAGS="$libdvdread_ii"
  fi
fi
TC_PKG_HAVE(libdvdread, LIBDVDREAD)

dnl
dnl PVM3
dnl
PVM3_EXTRA_LIBS="$PVM3_EXTRA_LIBS -lgpvm3"
TC_PKG_CHECK(pvm3, no, PVM3, no, pvm3.h, pvm3, pvm_initsend,
  pvm3, [])
if test x"$have_pvm3" = x"yes" ; then
  save_CPPFLAGS="$CPPFLAGS"
  CPPFLAGS="$CPPFLAGS $PVM3_CFLAGS"
  AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>
#include <pvm3.h>
int main ()
{
  if ((PVM_MAJOR_VERSION == 3) && (PVM_MINOR_VERSION < 4))
  {
	printf("You need to upgrade pvm3 to version > 3.4\n");
	return(1);
  }
  if (PVM_MAJOR_VERSION < 3)
  {
	printf("You need to upgrade pvm3 to version > 3.4\n");
	return(1);
  }
  return 0;
}
]])],
  [have_pvm3="yes"],
  [have_pvm3="no"],
  [AC_MSG_RESULT([cross compiling; assumed OK...])
   have_pvm3="yes"])
  CPPFLAGS="$save_CPPFLAGS"
  # also include the in-tree pvm3 headers
  PVM3_CFLAGS="$PVM3_CFLAGS -I\$(top_srcdir)/pvm3"
  PVM3_PVMGS="$w_pvm3_l/pvmgs"
fi
AC_SUBST(PVM3_PVMGS)
TC_PKG_HAVE(pvm3, PVM3)

dnl
dnl libdv
dnl
TC_PKG_CONFIG_CHECK(libdv, no, LIBDV, libdv, [http://libdv.sourceforge.net/])
TC_PKG_HAVE(libdv, LIBDV)

dnl
dnl libquicktime
dnl
TC_PKG_CONFIG_CHECK(libquicktime, no, LIBQUICKTIME, libquicktime,
 [http://libquicktime.sourceforge.net/])
if test x"$have_libquicktime" = x"yes" ; then
  AC_CHECK_LIB(quicktime, lqt_encode_video,
    [AC_DEFINE([LIBQUICKTIME_000904], [1], [Have libquicktime 1.0.0 or newer])],
    [],
    [$LIBQUICKTIME_LIBS $LIBQUICKTIME_EXTRA_LIBS])
fi
TC_PKG_HAVE(libquicktime, LIBQUICKTIME)

dnl
dnl LZO
dnl
TC_PKG_CHECK(lzo, no, LZO, no, [lzo/lzo1x.h], lzo2, lzo_version, lzo,
 [http://www.oberhumer.com/opensource/lzo/])
TC_PKG_HAVE(lzo, LZO)

dnl
dnl A52
dnl
A52_EXTRA_LIBS="$A52_EXTRA_LIBS -lm"
TC_PKG_CHECK(a52, no, A52, no, [a52dec/a52.h], a52, a52_init, liba52,
 [http://liba52.sourceforge.net/])
TC_PKG_HAVE(a52, A52)
if test x"$have_a52" = x"yes" ; then
  enable_a52_default_decoder="yes"
else
  enable_a52_default_decoder="no"
fi

dnl
dnl FAAC
dnl
TC_PKG_CHECK(faac, no, FAAC, no, [faac.h], faac, faacEncGetVersion, no,
  [http://www.audiocoding.com/])
TC_PKG_HAVE(faac, FAAC)

dnl
dnl libxml2
dnl
TC_PKG_CONFIG_CHECK(libxml2, no, LIBXML2, libxml-2.0, [http://xmlsoft.org])
TC_PKG_HAVE(libxml2, LIBXML2)

dnl
dnl ibp, lors and libxio -- must be after libxml2
dnl
TC_PATH_IBP(AC_DEFINE([HAVE_IBP], 1, [ibp and lors support]))
AM_CONDITIONAL(HAVE_IBP, test x"$have_ibp" = x"yes")

XIO_CFLAGS="-I\$(top_srcdir)/libtc"
if test x"$have_ibp" = x"yes" ; then
  XIO_LIBS="\$(top_builddir)/libtc/libtc.la $IBP_LIBS $LIBXML2_LIBS"
else
  XIO_LIBS=""
fi
AC_SUBST(XIO_CFLAGS)
AC_SUBST(XIO_LIBS)

dnl
dnl mjpegtools (actually only YUV4MPEG)
dnl
TC_PKG_CONFIG_CHECK(mjpegtools, no, MJPEGTOOLS, mjpegtools,
 [http://mjpeg.sourceforge.net/])
if test x"$have_mjpegtools" = x"yes" ; then
  # check if mjpegtools version >= Mar 31 2004
  save_CFLAGS="$CFLAGS"
  save_LIBS="$LIBS"
  CFLAGS="$CFLAGS $MJPEGTOOLS_CFLAGS"
  LIBS="$LIBS $MJPEGTOOLS_LIBS"
  AC_LINK_IFELSE([AC_LANG_PROGRAM([
#if defined(HAVE_MJPEGTOOLS_INC)
#include "yuv4mpeg.h"
#include "mpegconsts.h"
#else
#include "mjpegtools/yuv4mpeg.h"
#include "mjpegtools/mpegconsts.h"
#endif
],
    [y4m_write_frame_header(1, NULL, NULL)])],
    [AC_DEFINE([USE_NEW_MJPEGTOOLS_CODE], [1],
      [using mjpegtools post Mar 31 2004])])
  CFLAGS="$save_CFLAGS"
  LIBS="$save_LIBS"
fi
TC_PKG_HAVE(mjpegtools, MJPEGTOOLS)

dnl
dnl SDL
dnl
TC_PKG_CONFIG_CHECK(sdl, no, SDL, sdl, [http://www.libsdl.org/])
if test x"$have_sdl" = x"yes" ; then
  sdl_major_version=1
  sdl_minor_version=2
  sdl_micro_version=5
  save_CPPFLAGS="$CPPFLAGS"
  CPPFLAGS="$CPPFLAGS $SDL_CFLAGS"
  AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL.h"
int main (int argc, char *argv[])
{
   if ( (SDL_MAJOR_VERSION > $sdl_major_version) ||
        ((SDL_MAJOR_VERSION == $sdl_major_version) &&
		(SDL_MINOR_VERSION > $sdl_minor_version)) ||
        ((SDL_MAJOR_VERSION == $sdl_major_version) &&
		(SDL_MINOR_VERSION == $sdl_minor_version) &&
		(SDL_PATCHLEVEL >= $sdl_micro_version)) )
    {
      return 0;
    }
  else
    {
      fprintf(stderr, "SDL version %d.%d.%d is too old!\n",
			SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
      return 1;
    }
}
]])],
  [have_sdl="yes"],
  [have_sdl="no"],
  [AC_MSG_RESULT([cross compiling; assumed OK...])
   have_sdl="yes"])
  CPPFLAGS="$save_CPPFLAGS"
fi
TC_PKG_HAVE(sdl, SDL)

dnl
dnl ImageMagick
dnl
IMAGEMAGICK_EXTRA_LIBS="$IMAGEMAGICK_EXTRA_LIBS $($PKG_CONFIG --libs ImageMagick)"
TC_PKG_CHECK(imagemagick, no, IMAGEMAGICK, no, [magick/api.h],
 none, InitializeMagick, Wand, [http://www.imagemagick.org/])
TC_PKG_HAVE(imagemagick, IMAGEMAGICK)
if test x"$have_imagemagick" = x"yes" ; then
  SAVE_CPPFLAGS="$CPPFLAGS"
  CPPFLAGS="$IMAGEMAGICK_CFLAGS $CPPFLAGS"
  AC_CHECK_HEADER([wand/magick-wand.h],
    [AC_DEFINE([HAVE_BROKEN_WAND], [1], ["have old wand header"])])
  CPPFLAGS="$SAVE_CPPFLAGS"
fi

dnl
dnl libjpegmmx or libjpeg
dnl
TC_PKG_CHECK(libjpegmmx, no, LIBJPEGMMX, no, jpeglib.h, jpeg-mmx,
  jpeg_CreateCompress, jpeg-mmx, [http://sourceforge.net/projects/mjpeg/])
if test x"$have_libjpegmmx" = x"no" ; then
  TC_PKG_CHECK(libjpeg, yes, LIBJPEG, no, jpeglib.h, jpeg,
    jpeg_CreateCompress, jpeg, [ftp://ftp.uu.net/graphics/jpeg/])
else
  have_libjpeg="yes"
  LIBJPEG_CFLAGS="$LIBJPEGMMX_CFLAGS"
  LIBJPEG_LIBS="$LIBJPEGMMX_LIBS"
fi
TC_PKG_HAVE(libjpeg, LIBJPEG)


dnl
dnl bsdav
dnl
TC_PKG_CHECK(bsdav, no, BSDAV, no, bsdav.h, bsdav,
  bsdav_read_stream_header, bsdav, [http://www.jakemsr.com/bsdav/])
TC_PKG_HAVE(bsdav, BSDAV)


dnl
dnl iconv
dnl
TC_PKG_CHECK(iconv, yes, ICONV, no, iconv.h, none, none, libiconv,
 [http://www.gnu.org/software/libiconv/])
if test x"$have_iconv" = x"yes" ; then
  save_LDFLAGS="$LDFLAGS"
  LDFLAGS="$LDFLAGS $iconv_ll"
  AC_CHECK_LIB(iconv, iconv_open,
    [],
    [have_iconv="no"],
    [$ICONV_EXTRA_LIBS])
  LDFLAGS="$save_LDFLAGS"
  if test x"$have_iconv" = x"no" ; then
    save_LDFLAGS="$LDFLAGS"
    LDFLAGS="$LDFLAGS $iconv_ll"
    AC_CHECK_LIB(iconv, libiconv_open,
      [have_iconv="yes"],
      [have_iconv="no"],
      [$ICONV_EXTRA_LIBS])
    LDFLAGS="$save_LDFLAGS"
  fi
  # see if iconv_open is in (g)libc
  have_libc_iconv="no"
  if test x"$have_iconv" = x"no" ; then
    save_LDFLAGS="$LDFLAGS"
    LDFLAGS="$LDFLAGS $iconv_ll"
    AC_CHECK_LIB(c, iconv_open,
      [have_iconv="yes" have_libc_iconv="yes"],
      [have_iconv="no"],
      [$ICONV_EXTRA_LIBS])
    LDFLAGS="$save_LDFLAGS"
  fi
  if test x"$have_iconv" = x"yes" ; then
    if test x"$have_libc_iconv" != x"yes" ; then
      ICONV_LIBS="$iconv_ll -liconv $ICONV_EXTRA_LIBS"
    fi
  else
    TC_PKG_ERROR(iconv, [iconv_open()], yes, libiconv,
      [http://www.gnu.org/software/libiconv/],
      [cannot find either iconv_open() or libiconv_open()])
  fi
fi
TC_PKG_HAVE(iconv, ICONV)


dnl
dnl Other modules
dnl

dnl
dnl import_pv3
dnl
AC_MSG_CHECKING([for PV3 support])
AC_ARG_ENABLE(pv3,
  AC_HELP_STRING([--enable-pv3],
    [enable PV3 support (no)]),
  [case "${enableval}" in
    yes) if test true != "$have_x86cpu" -o yes != "$is_linux" -o yes != "$ac_cv_func_mmap"; then
           AC_MSG_ERROR(PV3 not supported on this platform)
         fi
         ;;
    no)  ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-pv3) ;;
  esac],
  [enable_pv3=no])
AC_MSG_RESULT($enable_pv3)
AM_CONDITIONAL(ENABLE_PV3, test "yes" = "$enable_pv3")

dnl
dnl import_nuv
dnl
AC_MSG_CHECKING([for NuppelVideo support])
AC_ARG_ENABLE(nuv,
  AC_HELP_STRING([--enable-nuv],
    [enable NuppelVideo support (no)]),
  [case "${enableval}" in
    yes) if test yes != "$have_lzo"; then
           AC_MSG_ERROR([liblzo2 is required for NuppelVideo support, try --enable-lzo])
         fi
    	 if test true == "$have_x86_64cpu"; then
           AC_MSG_WARN([NuppelVideo support on x86_64 platform is ***EXPERIMENTAL***])
         elif test true != "$have_x86cpu"; then
           AC_MSG_ERROR([NuppelVideo is supported only on x86 and x86_64 platforms yet])
         fi
         ;;
    no)  ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-nuv) ;;
  esac],
  [enable_nuv=no])
AC_MSG_RESULT($enable_nuv)
AM_CONDITIONAL(ENABLE_NUV, test "yes" = "$enable_nuv")


dnl
dnl The following come with transcode
dnl

dnl
dnl libtc
dnl
LIBTC_LIBS="\$(top_builddir)/libtc/libtc.la"
AC_SUBST(LIBTC_LIBS)

dnl
dnl libtcaudio
dnl
LIBTCAUDIO_LIBS="\$(top_builddir)/libtcaudio/libtcaudio.la"
AC_SUBST(LIBTCAUDIO_LIBS)

dnl
dnl libtcvideo
dnl
LIBTCVIDEO_LIBS="\$(top_builddir)/libtcvideo/libtcvideo.la"
AC_SUBST(LIBTCVIDEO_LIBS)

dnl
dnl avilib
dnl
AVILIB_LIBS="\$(top_builddir)/avilib/libavi.la"
AC_SUBST(AVILIB_LIBS)

dnl
dnl wavlib
dnl
WAVLIB_LIBS="\$(top_builddir)/avilib/libwav.la"
AC_SUBST(WAVLIB_LIBS)


dnl
dnl aclib
dnl
AC_ARG_ENABLE([x86-textrels],
    AC_HELP_STRING([--enable-x86-textrels], [enable x86-32 optimizations which use text relocations (yes)]),
    [if test "no" = "$enableval"; then
         AC_DEFINE([ACLIB_DISABLE_X86_TEXTRELS], [1], [Disable x86-32 optimizations in aclib that require text relocations])
     fi])
ACLIB_LIBS="\$(top_builddir)/aclib/libac.la"
AC_SUBST(ACLIB_LIBS)



dnl
dnl warning flags; always add -Wall -Wstrict-prototypes -Wmissing-prototypes
dnl note that autoconf uses an unprototyped main(), so we disable prototype
dnl warnings when checking whether -Werror works
dnl
AC_ARG_ENABLE([warnings-as-errors],
    AC_HELP_STRING([--enable-warnings-as-errors], [treat warnings as errors]))
dnl GCC 4.2.x spits out bogus warnings when un-consting arguments in a
dnl function call (GCC bug 29478), so don't use -Werror there
if test x"$GCC" = x"yes" && test -n "`$CC -v 2>&1 | tail -1 | grep '4\.2\.'`"; then
    AC_MSG_WARN([GCC 4.2.x produces spurious warnings, -Werror disabled])
elif test x"$GCC" = x"yes" ; then
    OPT_CFLAGS="-Wall -Wstrict-prototypes -Wmissing-prototypes"
    TMP_CFLAGS=""
    TC_TRY_CFLAGS([$OPT_CFLAGS $CFLAGS],[TMP_CFLAGS="$OPT_CFLAGS "])
    dnl Don't assign this yet, as -Wall would counteract the -Wno-XXX options
    if test x"$enable_warnings_as_errors" = x"yes" ; then
        dnl compiler warnings treated as errors
        dnl we don't care about pointer sign warnings, and empty format
        dnl strings are occasionally useful, so disable those warnings
        OPT_CFLAGS="-Werror -Wno-pointer-sign -Wno-format-zero-length $CFLAGS"
        TC_TRY_CFLAGS([$OPT_CFLAGS -Wno-strict-prototypes -Wno-missing-prototypes],[CFLAGS=$OPT_CFLAGS])
    fi
    CFLAGS="$TMP_CFLAGS$CFLAGS"
fi
AC_SUBST(CFLAGS)

dnl import/export module path
dnl
MOD_PATH="\${libdir}/transcode"
AC_ARG_WITH(mod-path,
  AC_HELP_STRING([--with-mod-path],
    [where export/import modules are installed (${libdir}/transcode)]),
  MOD_PATH=$withval)
AC_SUBST(MOD_PATH)

dnl export profiles data path
dnl
PROF_PATH="\${datadir}/transcode/profiles"
AC_ARG_WITH(prof-path,
  AC_HELP_STRING([--with-prof-path],
    [where export profiles data are installed (${datadir}/transcode/profiles)]),
  PROF_PATH=$withval)
AC_SUBST(PROF_PATH)


X_CFLAGS=`echo $X_CFLAGS | sed -e 's/  */ /g'`
X_PRE_LIBS=`echo $X_PRE_LIBS | sed -e 's/  */ /g'`
X_LIBS=`echo $X_LIBS | sed -e 's/  */ /g'`
X_EXTRA_LIBS=`echo $X_EXTRA_LIBS | sed -e 's/  */ /g'`

CC=`echo $CC | sed -e 's/  */ /g'`
CFLAGS=`echo $CFLAGS | sed -e 's/  */ /g'`
CPPFLAGS=`echo $CPPFLAGS | sed -e 's/  */ /g'`
CXXFLAGS=`echo $CXXFLAGS | sed -e 's/  */ /g'`
LDFLAGS=`echo $LDFLAGS | sed -e 's/  */ /g'`

AC_SUBST(CFLAGS)
AC_SUBST(CC)
AC_SUBST(LDFLAGS)
AC_SUBST(SIMD_FLAGS)

AC_CONFIG_FILES([
	Makefile
	aclib/Makefile
	avilib/Makefile
	docs/Makefile
	docs/html/Makefile
	docs/man/Makefile
	docs/pvm3/Makefile
	docs/tech/Makefile
	docs/tech/html/Makefile
	encode/Makefile
	export/Makefile
	filter/Makefile
	filter/divxkey/Makefile
	filter/extsub/Makefile
	filter/preview/Makefile
	filter/subtitler/Makefile
	filter/tomsmocomp/Makefile
	filter/yuvdenoise/Makefile
	filter/stabilize/Makefile
	import/Makefile
	import/framegen/Makefile
	import/nuv/Makefile
	import/v4l/Makefile
	multiplex/Makefile
	libdldarwin/Makefile
	libtc/Makefile
	libtcaudio/Makefile
	libtcvideo/Makefile
	pvm3/Makefile
	src/Makefile
	testsuite/Makefile
	tools/Makefile
	transcode.spec
	filter/parse_csv.awk
	filter/filter_list.awk
])
AC_OUTPUT


AC_MSG_RESULT([
----------------------------------------
Summary for transcode $VERSION:
----------------------------------------

core options
----------------------------------------
enable experimental code       $enable_experimental
enable deprecated code         $enable_deprecated
static AV-frame buffering      $enable_statbuffer
A52 default decoder            $enable_a52_default_decoder
FFmpeg support                 $enable_ffmpeg

hardware support
----------------------------------------
v4l (legacy)                   $have_v4l
v4l2                           $have_v4l2
ALSA                           $have_alsa
OSS                            $have_oss
bktr                           $have_bktr
sunau                          $have_sunau

optional module support
----------------------------------------
PV3                            $enable_pv3
NuppelVideo                    $enable_nuv

optional package support
----------------------------------------
IBP (libxio)                   $have_ibp
X11                            $USE_X11
    Xv      extension          $have_xv
    Xshm    extension          $have_xshm
    Xaw     library            $have_xaw_simple
    Xpm     library            $have_xpm
])

TC_PKG_REPORT

if test x"yes" = x"$have_pvm3"; then
    AC_MSG_WARN([PVM3 support is yet untested, unsupported and may be BROKEN!.])
    AC_MSG_WARN([Please be careful and be prepared for bugs or nasty behaviours.])
    AC_MSG_WARN([Report problems on transcode-devel mailing list.])
    # ugly -- has anyone a better idea?
    echo
    echo
fi