~ubuntu-branches/ubuntu/karmic/mjpegtools/karmic

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
dnl Process this file with autoconf to produce a configure script.
AC_INIT(lavtools/lav_io.c)

MJPEG_MAJOR_VERSION=1
MJPEG_MINOR_VERSION=6
MJPEG_MICRO_VERSION=2
MJPEG_VERSION=$MJPEG_MAJOR_VERSION.$MJPEG_MINOR_VERSION.$MJPEG_MICRO_VERSION

AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE(mjpegtools, $MJPEG_VERSION)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
AM_OUTPUT_DEPENDENCY_COMMANDS

# libtool versioning
LT_RELEASE=$MJPEG_MAJOR_VERSION.$MJPEG_MINOR_VERSION
LT_CURRENT=$MJPEG_MICRO_VERSION
LT_REVISION=$MJPEG_MICRO_VERSION
LT_AGE=$MJPEG_MICRO_VERSION
AC_SUBST(LT_RELEASE)
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)

dnl **********************************************************************
dnl Options

AC_ARG_ENABLE(compile-warnings,     
  [  --enable-compile-warnings,        Turn on compiler warnings.])
AC_ARG_ENABLE(warnings_as_errors,   
  [  --enable-warnings_as_errors,      Compiler warnings are errors.])
AC_ARG_ENABLE(xfree-ext, 
  [  --enable-xfree-ext,               use XFree extensions (DGA)])
AC_ARG_ENABLE(cmov-extension, 
  [  --enable-cmov-extension,          use the cmov instruction.])
AC_ARG_ENABLE(simd-accel,
  [  --enable-simd-accel,              use SIMD multimedia instructions (MMX,AltiVec etc) if possible])
AC_ARG_WITH(quicktime,
  [  --with-quicktime,                 quicktime support for record/playback])
AC_ARG_WITH(dv,
  [  --with-dv,                        libDV (digital video) support])
AC_ARG_WITH(dv-yv12,
  [  --with-dv-yv12,                   libDV PAL YV12 read-support])
AC_ARG_ENABLE(zalpha,
  [  --enable-zalpha,                  include MPEG Z/Alpha support in mplex (www.geofront.se/products_software_mza.php)])

AC_GNU_SOURCE

dnl Initialize libtool
AM_PROG_LIBTOOL

dnl Checks for programs.
AC_PROG_AWK
AC_PROG_CC
AM_PROG_CC_STDC
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_LN_S
#AC_PROG_RANLIB
AC_C_BIGENDIAN
AC_C_CONST
AC_C_INLINE
AC_SYS_LARGEFILE

dnl configure AS and ASFLAGS... a pity nasm doesn't take  flags similar to cc
dnl CCAS=nasm
dnl CCASFLAGS=
AM_PROG_AS

AC_CHECK_HEADERS(fenv.h stdint.h inttypes.h sys/types.h getopt.h alloca.h sys/soundcard.h malloc.h)

dnl sizeof PRId64 etc...
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
case 8 in
$ac_cv_sizeof_int)
  PRID64_STRING_FORMAT="d"
  ;;
$ac_cv_sizeof_long)
  PRID64_STRING_FORMAT="ld"
  ;;
$ac_cv_sizeof_long_long)
  PRID64_STRING_FORMAT="lld"
  ;;
*)
  AC_MSG_WARN(No suitable variant for 64bits integers found)
  ;;
esac
AC_DEFINE_UNQUOTED(PRID64_STRING_FORMAT, "$PRID64_STRING_FORMAT",
				   [Format string for 64 bit integers]
				  )
AC_SUBST(PRID64_STRING_FORMAT)

AC_CHECK_FUNC(getopt_long,[AC_DEFINE(HAVE_GETOPT_LONG,1,long getopt support)],
[ # FreeBSD and BSD/OS have a gnugetopt library for this:
  AC_CHECK_LIB([gnugetopt],[getopt_long],
  [AC_DEFINE(HAVE_GETOPT_LONG,1,getopt support) LIBGETOPT_LIB="-lgnugetopt"])])
AC_SUBST(LIBGETOPT_LIB)

AC_CHECK_FUNC(posix_memalign,[AC_DEFINE(HAVE_POSIX_MEMALIGN,1,posix_memalign support)])
AC_CHECK_FUNC(memalign,[AC_DEFINE(HAVE_MEMALIGN,1,memalign support)])
AC_CHECK_FUNC(fmax,[AC_DEFINE(HAVE_FMAX,1,fmax support)])
AC_CHECK_LIB([m],[lround], [AC_DEFINE(HAVE_LROUND,1,lround support)])

AC_TYPE_SIGNAL

OS_ARCH=`uname -s | sed -e 's|/|_|g'`
OS_RELEASE=`uname -r`
OS_CPU=`uname -m`

dnl test for alpha architecture, and Compaq Math Library (cpml) -- much faster
dnl than GNU libm on this arch.
LIBM_LIBS="-lm "
AC_SUBST(LIBM_LIBS)
AC_MSG_CHECKING([for alpha architecture])
if test x$OS_ARCH = xLinux && test x$OS_CPU = xalpha ; then
    AC_MSG_RESULT([yes])
    AC_CHECK_LIB(cpml, asin,
      [ LIBM_LIBS="-lcpml"
        have_cpml=true ],,)
else
    AC_MSG_RESULT([no])
fi

# FreeBSD and OpenBSD have neither -lpthread nor integrated pthreads in libc.
# Instead -pthread is used to the compiler/linker to get pthreads working right.
if test x$OS_ARCH = xFreeBSD -o x$OS_ARCH = xOpenBSD; then
   CFLAGS="$CFLAGS -pthread"
   CXXFLAGS="$CXXFLAGS -pthread"
fi

dnl *********************************************************************
dnl madmac/gernot: This activates architecture specific changes (e g no MMX)
dnl
dnl It defines a tag called "IRIX" to circumvent all the Linux video device code (and its includes)
dnl and defines WORD_BIGENDIAN to flag a big iron system ;-) 

case "$HOSTTYPE" in
  mips*) 
   echo NEW: Activating IRIX architecture flags:IRIX and WORD_BIGENDIAN !
   CFLAGS="$CFLAGS -DIRIX -DWORD_BIGENDIAN"
   ;;
  Darwin)
   echo Adding -no-cpp-precomp to CFLAGS for Darwin to avoid compile errors
   CFLAGS="$CFLAGS -no-cpp-precomp"
   ;;
esac

dnl *********************************************************************
dnl Test whether we're linux or not. If so, define HAVE_V4L and build the
dnl video4linux/hardware dependent tools. Else, undefine HAVE_V4L

os_type=`uname`
have_video4linux=false
if test x$os_type = x"Linux"; then
  AC_CHECK_HEADER(linux/videodev.h,
    have_video4linux=true
    AC_DEFINE(HAVE_V4L,1,
		      [Building for Linux - using the video4linux API]),
    AC_MSG_ERROR([videodev.h not found - please install the linux kernel headers])
    )
else
  AC_MSG_WARN([Did not find linux platform - video4linux functionality will be disabled])
  AC_MSG_WARN([If you are on MacOS X, please note that only the classic libjpeg works !])
fi

dnl *********************************************************************
dnl Check for the various libraries we depend on.
dnl
dnl First lets see if glib is present on this machine

AM_PATH_GLIB(1.2.0)

dnl *********************************************************************
dnl Check for the pthread lib
dnl
AC_SUBST(PTHREAD_LIBS)
have_pthread=false
AC_CHECK_LIB(pthread, pthread_create,
  [ PTHREAD_LIBS="-lpthread" 
    AC_DEFINE(HAVE_LIBPTHREAD,1,
			  [Posix pththreads lib present])
    have_pthread=true ],,)

AC_CHECK_FUNC(pthread_attr_getstacksize,
	          [
				AC_DEFINE(HAVE_PTHREADSTACKSIZE,1,
					      [pthread stack sizes accesible] )
			  ] )


dnl *********************************************************************
dnl Check for the special mmx accelerated jpeg library
dnl At the end of this mess, JPEG_LIBS will contain the libraries and 
dnl flags needed to link with the jpeg library and JPEG_CFLAGS will 
dnl have the needed flags to compile against said library
AC_SUBST(JPEG_LIBS)
AC_SUBST(JPEG_CFLAGS)
have_jpeg=false
if test x$with_jpeg_mmx = xyes ; then
  AC_MSG_ERROR([
*** A directory must be specified for --with-jpeg-mmx option.])
fi
if test x$with_jpeg_mmx = x ; then
  dnl Special case for building .deb's
  if test -d ../jpeg-mmx ; then
    with_jpeg_mmx=`pwd`/../jpeg-mmx
  elif test -d ../jpeg-mmx-0.1.4 ; then
    with_jpeg_mmx=`pwd`/../jpeg-mmx-0.1.4
  else
    with_jpeg_mmx=/usr/local/src/jpeg-mmx
  fi
fi

dnl
dnl Look for the installed/specified copy
dnl

OLD_CFLAGS="$CFLAGS"
OLD_LIBS="$LIBS"
LIBS="$LIBS -L$with_jpeg_mmx"
CFLAGS="$CFLAGS -I$with_jpeg_mmx"
AC_CHECK_LIB(jpeg-mmx, jpeg_start_compress,
   [ JPEG_LIBS="$LIBS -ljpeg-mmx"
     JPEG_CFLAGS="-I$with_jpeg_mmx"
       have_jpeg=true ],,)
  LIBS="$OLD_LIBS"
  CFLAGS="$OLD_CFLAGS"

dnl 
dnl Look for _a_ jpeg lib that will work.
dnl
if test x$have_jpeg = xfalse ; then
  AC_CHECK_HEADER(jpeglib.h,,
    AC_MSG_ERROR([jpeglib.h not found - please install the libjpeg headers]))
  AC_CHECK_LIB(jpeg, jpeg_start_compress,
    [ JPEG_LIBS="-ljpeg"
      JPEG_CFLAGS=""
      have_jpeg=true ],,)
fi

dnl *********************************************************************
dnl Check for the libquicktime library
AC_SUBST(QUICKTIME_LIBS)
AC_SUBST(QUICKTIME_CFLAGS)
if test x$with_quicktime = x -o x$with_quicktime = xyes ; then
   lqt-config --version >/dev/null 2>/dev/null
   if test $? != 0; then
     have_quicktime=false
   else
     QUICKTIME_LIBS=`lqt-config --libs`
     QUICKTIME_CFLAGS=`lqt-config --cflags`
     AC_DEFINE(HAVE_LIBQUICKTIME,1,
			   [libquicktime is present])
     have_quicktime=true
   fi
else
     have_quicktime=false
fi

dnl test for PNG lib, moved out of Quicktime checks because of png2yuv /gz
have_png=false
OLD_LIBS="$LIBS"
LIBS="$LIBS -lz $LIBM_LIBS"
AC_CHECK_LIB(png, png_read_info, [have_png=true])
LIBS="$OLD_LIBS"

dnl some more libs which are probably needed.  Don't add -ldl unconditionally
dnl Some systems lack -ldl and adding it here breaks things.
EXTRA_LIBS="$LIBM_LIBS $GLIB_LIBS"
if test x$have_pthread = xtrue ; then
  EXTRA_LIBS="$EXTRA_LIBS $PTHREAD_LIBS"
fi

AC_CHECK_LIB([dl],[dlopen],
    [AC_DEFINE(HAVE_LIBDL,1,dlopen support) LIBDL_LIB="-ldl"])
AC_SUBST(LIBDL_LIB)

dnl *********************************************************************
dnl Check for libdv
dnl At the end of this DV_LIBS will contain the libraries and 
dnl flags needed for linking and DV_CFLAGS will have the flags for compilation.
AC_SUBST(DV_LIBS)
AC_SUBST(DV_CFLAGS)
if test x$with_dv = xyes ; then
  AC_MSG_ERROR([
*** A directory must be specified for the --with-dv option.])
fi

if test x$with_dv = x ; then
  with_dv=/usr/local
fi

have_dv=false
EXTRA_LIBS=" $LIBM_LIBS $GLIB_LIBS  $PTHREAD_LIBS"
AC_CHECK_LIB(dv, dv_decoder_free,
  [ DV_LIBS="-L${with_dv}/lib -ldv ${EXTRA_LIBS}"
    DV_CFLAGS="-I${with_dv}/include"
    AC_DEFINE(HAVE_LIBDV,1,
			  [libdv is present])
    have_dv=true],, 
    -L${with_dv}/lib -ldv ${EXTRA_LIBS})

dnl *********************************************************************
dnl Check for libDV YV12 read-support
have_dv_yv12=false
if test x$with_dv_yv12 = xyes -a $have_dv = true; then
    AC_DEFINE(LIBDV_PAL_YV12,1,
		      [YV12 support in libdv])
    have_dv_yv12=true
fi

dnl *********************************************************************
dnl  Lets find where xwindows lives on this machine. Punt if not found.
AC_PATH_XTRA

have_x=false
if test x"-DX_DISPLAY_MISSING" = x"$X_CFLAGS"; then
  AC_MSG_WARN(can not find X11)
else
  have_x=true
  AC_DEFINE(HAVE_X, 1, [Whether XFree86 is available])
fi
AM_CONDITIONAL(HAVE_X, test x$have_x = xtrue)

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

dnl ********************************************************************
dnl Check to see if __progname is provided by the system
dnl ********************************************************************
AC_MSG_CHECKING(for __progname)
AC_CACHE_VAL(ac_cv_extern__progname,
AC_TRY_LINK([],
	[extern char *__progname;
	puts(__progname)],
	ac_cv_extern___progname=yes,
	ac_cv_extern___progname=no))
if test x$ac_cv_extern___progname = xyes ; then
	AC_DEFINE(HAVE___PROGNAME,,[Is __progname defined by system?])
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
fi




dnl ********************************************************************
dnl Check for DGA (for v4l-conf)
dnl ********************************************************************
AC_SUBST(V4LCONF_LIBS)
AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension,
	V4LCONF_LIBS="$X_LIBS -lXxf86dga" 
	AC_DEFINE(HAVE_LIBXXF86DGA,1,
			  [libxf86dga is present]),,
	$X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS)
dnl ********************************************************************
dnl Check for Gtk+/glib (for glav)
dnl ********************************************************************
have_gtk=false
ifdef([AM_PATH_GTK],
      [ AM_PATH_GTK(1.2.0, [ have_gtk=true
                           AC_DEFINE(HAVE_GTK,1,
									 [Gtk library present]
							)],,) ])

dnl ********************************************************************
dnl Check for the SDL library (for software playback)
dnl
dnl AM_PATH_SDL defines SDL_CFLAGS and SDL_LIBS for us..
have_sdl=false
if test x$have_jpeg = xtrue ; then
ifdef([AM_PATH_SDL],
	[ AM_PATH_SDL(1.1.3, [ AC_DEFINE(BUILD_MJPEG,1,
									 [Build MJPEG software playback])
                           have_sdl=true
                           AC_DEFINE(HAVE_SDL,1,
                                     [SDL library present]
						  )],,) ])
fi

dnl ********************************************************************
dnl Test for MMX support, if we find an IA32 platform then check to see
dnl if gcc and its tools can generate MMX instructions, also make sure
dnl nasm is present for the files that need that. 
dnl Both are checked for for the maximum flexablity.
dnl
dnl TODO: host = non intel, target = intel <blah> do the checks also?
dnl       remeber we are checking that the toolchain can generate the
dnl       code, not whether the host can execute the code, thats done
dnl       at run time with the exception of the SSE code.
dnl
dnl 
have_asm_mmx=false
have_asm_sse=false
have_asm_nasm=false
have_x86cpu=false
AC_MSG_CHECKING([for Intel Pentium architecture (IA32)])
if test "$host_cpu" = "i386" -o "$host_cpu" = "i486" \
   -o "$host_cpu" = "i586" -o "$host_cpu" = "i686" \
   -o "$host_cpu" = "i786" ; then
  AC_MSG_RESULT(yes)
  have_x86cpu=true
else
  AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING([for PowerPC architecture])
if test "$host_cpu" = "powerpc" ; then
  AC_MSG_RESULT(yes)
  AC_DEFINE(HAVE_PPCCPU,1,
			[Compiling for PowerPC CPU])
  have_ppccpu=true
  have_altivec=false
else
  AC_MSG_RESULT(no)
  have_altivec=false
fi

if test "$enable_simd_accel" != "false" -a "$enable_simd_accel" != "no"
then
  if test x$have_x86cpu = xtrue
  then
   AC_DEFINE(HAVE_X86CPU,1,
			 [Compiling for x86 architecture CPU])
   AC_MSG_CHECKING([for support for gcc-style register parameters on Intel])
   AC_TRY_COMPILE([],
    [extern void x(
     const unsigned char *src1,
     const unsigned char *src2,
     unsigned count,
     unsigned char *dst) __attribute((regparm(3)));],
   [AC_MSG_RESULT(yes)
    AC_MSG_CHECKING([for support of MMX in assembly code])
    cat > conftest.S <<EOF
       .text

       psubusb %mm3, %mm4
EOF
    if $CC -c conftest.S ; then
      AC_MSG_RESULT(yes)
      rm -f conftest.*
      AC_DEFINE(HAVE_ASM_MMX,1,
				[Inline GCC MMX assembler supported in C compiler])
      have_asm_mmx=true
    else
      AC_MSG_RESULT(no)
      echo "configure: failed program was:" >&AC_FD_CC
      cat conftest.S >&AC_FD_CC
      rm -f conftest.*;
    fi
    AC_PATH_PROGS(AS, nasm nasmw)
    if test x$AS = x -o x$AS = x'"$AS"'; then
        echo "*************************************************************************"
        echo "** nasm not found!  X86 optimizations disabled!  (MMX/SSE instructions)**"
        echo "** INSTALL NASM OR PERFORMANCE WILL BE CRAP!                           **"
        echo "*************************************************************************"
        enable_3dnow_accel=no
        enable_cmov_extension=no
        enable_simd_accel=no
        have_asm_mmx=false
        have_asm_sse=false
        have_asm_nasm=false
    else
     AC_DEFINE(HAVE_ASM_NASM,1,[nasm assembler is available])
	 have_asm_nasm=true
     ASFLAGS="-f elf"
     if test x$CYGWIN = xyes; then
       ASFLAGS="-f coff"
     fi
     AC_SUBST(ASFLAGS)
    fi


   ],
   [AC_MSG_RESULT(no)
    AC_MSG_WARN(*** MMX Optimizations disabled....)]);
  fi


  if test x$have_ppccpu = xtrue
  then
    AC_MSG_CHECKING([compiler support for AltiVec])
    cat > conftest.c <<EOF
#ifdef HAVE_ALTIVEC_H
#include <altivec.h>
#endif
int main() {
    union { vector signed int v;
            signed int i;
          } vi;
    vi.v = vec_splat_s32(1);
    return vi.i;
}
EOF
    ALTIVEC_CFLAGS=""
    if $CC -o conftest conftest.c >/dev/null 2>&1; then
      have_altivec=true
    elif $CC -faltivec -o conftest conftest.c >/dev/null 2>&1; then
      # Mac OS X style
      have_altivec=true
      ALTIVEC_CFLAGS="-faltivec"
    elif $CC -fvec -o conftest conftest.c >/dev/null 2>&1; then
      # Motorola style
      have_altivec=true
      ALTIVEC_CFLAGS="-fvec"
    elif $CC -DHAVE_ALTIVEC_H=1 -maltivec -mabi=altivec -o conftest conftest.c >/dev/null 2>&1; then
      # gcc 3.1 style
      have_altivec=true
      ALTIVEC_CFLAGS="-DHAVE_ALTIVEC_H=1 -maltivec -mabi=altivec"
    fi
    rm -f conftest*;
  
    if test x$have_altivec = xtrue
    then
      # add -O3 flag
      ALTIVEC_CFLAGS="-O3 ${ALTIVEC_CFLAGS}"
      AC_MSG_RESULT(yes)
      AC_DEFINE(HAVE_ALTIVEC,1,
				[Inline PPC Altivec primitives available])
      AC_SUBST(ALTIVEC_CFLAGS)
    else
      AC_MSG_RESULT(no)
    fi
  fi
fi


dnl *********************************************************************
dnl For x86 machines only check which code model we should use
dnl and whether the GCC tool chain can generate 3DNow assmebly instructions
dnl 

if test x$have_x86cpu = xtrue ; then
AC_MSG_CHECKING(x86 sub-architecture settings)

  if test "$enable_cmov_extension" != "no" ; then
    arch=`uname -m`
  else
    arch=i586
  fi 
  have_cmov=false
  case $arch in
  i786) ARCHFLAGS="-mcpu=i786 -march=$arch"
  have_cmov=true
  ;;
  i686) ARCHFLAGS="-mcpu=i686 -march=$arch"
  have_cmov=true
  ;;
  i586) ARCHFLAGS="-mcpu=i586 -march=$arch"
  have_cmov=false
  ;;
  *) ARCHFLAGS="-mcpu=i686 -march=$arch"
  have_cmov=true
  ;;
  esac
AC_MSG_RESULT($ARCHFLAGS)

else
  have_cmov=false
fi

dnl *********************************************************************
dnl Check if Z/Alpha has been enabled. 
dnl 

use_zalpha=false
if test "x$enable_zalpha" = "xyes" ; then
  use_zalpha=true
fi

dnl **********************************************************************
dnl All the conditional stuff for the Makefiles
dnl
AM_CONDITIONAL(HAVE_ASM_MMX, test x$have_asm_mmx = xtrue)
AM_CONDITIONAL(HAVE_ASM_NASM, test x$have_asm_nasm = xtrue)
AM_CONDITIONAL(HAVE_X86CPU, test x$have_x86cpu = xtrue)
AM_CONDITIONAL(HAVE_PPCCPU, test x$have_ppccpu = xtrue)
AM_CONDITIONAL(HAVE_ALTIVEC, test x$have_altivec = xtrue)
AM_CONDITIONAL(BUILD_MJPEG, test x$have_sdl = xtrue)
AM_CONDITIONAL(HAVE_GTK, test x$have_gtk = xtrue)
AM_CONDITIONAL(HAVE_SDL, test x$have_sdl = xtrue)
AM_CONDITIONAL(HAVE_V4L, test x$have_video4linux = xtrue)
AM_CONDITIONAL(HAVE_PNG, test x$have_png = xtrue)
have_v4l_or_sdl=false
if test x$have_video4linux = xtrue; then
  have_v4l_or_sdl=true
else
  if test x$have_sdl = xtrue; then
    have_v4l_or_sdl=true
  fi
fi
AM_CONDITIONAL(HAVE_V4L_OR_SDL, test x$have_v4l_or_sdl = xtrue)
AM_CONDITIONAL(HAVE_ZALPHA, test x$use_zalpha = xtrue)

dnl *********************************************************************
dnl Check for what warnings we want gcc to use and adjust the CFLAGS
dnl as needed. This only works for GCC.
dnl We do this last as it can screw up library detection etc...
dnl 

CFLAGS="$ARCHFLAGS $CFLAGS"
CXXFLAGS="$ARCHFLAGS $CXXFLAGS"
if test "x${GCC}" != "xyes" ; then
  enable_compile_warnings=no
fi
AC_MSG_CHECKING(what warning flags to pass to the C compiler)
warnCFLAGS=
warnCXXFLAGS=
if test "x$enable_compile_warnings" != "xno" ; then
 if test "x$GCC" = "xyes" ; then
    case "$CFLAGS" in
     *-Wall*) ;;
     *) warnCFLAGS="-Wall -Wunused" ;;
    esac
  if test "x$enable_compile_warnings" = "xyes" ; then
    warnCFLAGS="$warnCFLAGS -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wcast-align -Wwrite-strings -Wcast-qual"
    warnCXXFLAGS="$warnCXXFLAGS -Wmissing-prototypes  -Wpointer-arith -Wcast-align -Wwrite-strings -Wcast-qual"
  fi
  if test "x$enable_warnings_as_errors" = "xyes" ; then
    warnCFLAGS="$warnCFLAGS -Werror"
    warnCXXFLAGS="$warnCXXFLAGS -Werror"
  fi
 fi
fi
AC_MSG_RESULT($warnCFLAGS)
AC_MSG_RESULT($warnCXXFLAGS)
if test "x$cflags_set" != "xyes" ; then
  CFLAGS="$CFLAGS $warnCFLAGS"
  CXXFLAGS="$CXXFLAGS $warnCXXFLAGS"
  cflags_set=yes
fi

AC_ARG_ENABLE(assert,
 [  --disable-assert        Do not assert parameters to functions in libraries.],
 [ case "$enableval" in yes|no) : ;; *) AC_MSG_ERROR(bad value for --enable-assert)                ;; esac ],
 [ enable_assert=yes ])

if test x"$enable_assert"                 = x"no"; then NDEBUG=1;                fi

AC_DEFINE(MJPEGTOOLS,1,
		  [Building mjpegtools])
case x"$NDEBUG"                in x"1") 
	AC_DEFINE(NDEBUG,1, [Optimised no DEBUG build, assertions disabled])       
	;; 
esac

dnl **********************************************************************
dnl Output a Makefile or two and the lib/header descriptor script
dnl
AC_OUTPUT([
Makefile
debian/Makefile
debian/control
docs/Makefile
lavtools/Makefile
yuvdenoise/Makefile
yuvfilters/Makefile
mpeg2enc/Makefile
aenc/Makefile
mplex/Makefile
scripts/Makefile
utils/Makefile
utils/altivec/Makefile
utils/mmxsse/Makefile
mjpegtools-config
mjpegtools.pc
mjpegtools.spec
])

AC_DEFINE(VERSION, ${VERSION}, 
		  [Version of this build])

dnl ************************************************************************
dnl Summarize the config for the user.
dnl
echo ""
echo " MJPEG tools ${VERSION} build configuration :"
echo ""
if test "$have_x86cpu" = "true" ; then
echo "    - X86 Optimizations:"
echo "      - MMX/3DNow!/SSE enabled      : ${have_asm_mmx}"
echo "      - cmov support enabled        : ${have_cmov}"
  if test "$have_cmov" = "true" ; then
    echo "
****************************************************************************
* NOTE:                                                                    *
*   The resultant binaries will ***NOT*** run on a K6 or Pentium CPU       *
****************************************************************************"
  fi
fi
if test "$have_ppccpu" = "true" ; then
echo "    - PowerPC Optimizations:"
echo "      - AltiVec enabled             : ${have_altivec}"
fi
echo "    - video4linux recording/playback: ${have_video4linux}"
echo "    - software MJPEG playback       : ${have_sdl}"
echo "    - MPEG Z/Alpha                  : ${use_zalpha}"
echo "    - Quicktime playback/recording  : ${have_quicktime}"
echo "    - PNG input support             : ${have_png}"
echo "    - AVI MJPEG playback/recording  : true (always)"
echo "    - libDV (digital video) support : ${have_dv} "
echo "    - libDV PAL YV12 read support   : ${have_dv_yv12} "
echo "    - Gtk+ support for glav         : ${have_gtk}"
echo ""