libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcvd-members] libcvd Makefile.in configure configure.in cvd/c...


From: Edward Rosten
Subject: [libcvd-members] libcvd Makefile.in configure configure.in cvd/c...
Date: Thu, 28 Feb 2008 00:27:25 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    libcvd
Changes by:     Edward Rosten <edrosten>        08/02/28 00:27:24

Modified files:
        .              : Makefile.in configure configure.in 
        cvd            : convolution.h diskbuffer2.h image_convert.h 
                         image_io.h utility.h videosource.h vision.h 
        cvd/Linux      : dvbuffer.h 
        cvd_src        : bayer.cxx convolution.cc image_io.cc 
                         nonmax_suppression.cxx yuv420.cpp yuv422.cpp 
        cvd_src/i686   : halfsample.s rgb_to_gray.s yuv420p_to_rgb.s 
                         yuv422_to_grey.s yuv422_to_rgb.s 
        make           : march_flags 
Added files:
        cvd_src        : half_sample.cc utility_helpers.h yuv422.h 
        cvd_src/i686   : convert_rgb_to_y.cc convolve_gaussian.cc 
                         gradient.cc median_3x3.cc testconf 
                         utility_byte_differences.cc 
                         utility_double_int.cc utility_float.cc 
                         yuv422_wrapper.cc 
        cvd_src/noarch : convert_rgb_to_y.cc convolve_gaussian.cc 
                         gradient.cc median_3x3.cc 
                         utility_byte_differences.cc 
                         utility_double_int.cc utility_float.cc 
                         yuv422_wrapper.cc 
        make           : compile_deps.awk 
Removed files:
        cvd_src        : image_convert.cc utility.cc vision.cc 
        make           : prog_dependencies.awk 

Log message:
        Retooled the build system:
        
        All dependencies are handled in the configure script. Now, each 
optional feature
        should be (ideally) in spearate sorce files or controlled by a single 
define--no
        logic shold be used in #ifdef blocks.
        
        See the new autoconf script for a description of the DSL used for 
dependencies.
        
        Also see the atoconf script for new, shorder ways of doing configration.
        
        Moves a bit of code around to make the build work
        
        Removed most #ifdef blocks
        
        Fixed some of the warnings which have now surfaced since -Wall -Wextra 
works.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/Makefile.in?cvsroot=libcvd&r1=1.68&r2=1.69
http://cvs.savannah.gnu.org/viewcvs/libcvd/configure?cvsroot=libcvd&r1=1.102&r2=1.103
http://cvs.savannah.gnu.org/viewcvs/libcvd/configure.in?cvsroot=libcvd&r1=1.103&r2=1.104
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/convolution.h?cvsroot=libcvd&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/diskbuffer2.h?cvsroot=libcvd&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/image_convert.h?cvsroot=libcvd&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/image_io.h?cvsroot=libcvd&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/utility.h?cvsroot=libcvd&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/videosource.h?cvsroot=libcvd&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/vision.h?cvsroot=libcvd&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/Linux/dvbuffer.h?cvsroot=libcvd&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/bayer.cxx?cvsroot=libcvd&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/convolution.cc?cvsroot=libcvd&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/image_io.cc?cvsroot=libcvd&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/nonmax_suppression.cxx?cvsroot=libcvd&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/yuv420.cpp?cvsroot=libcvd&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/yuv422.cpp?cvsroot=libcvd&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/half_sample.cc?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/utility_helpers.h?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/yuv422.h?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/image_convert.cc?cvsroot=libcvd&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/utility.cc?cvsroot=libcvd&r1=1.8&r2=0
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/vision.cc?cvsroot=libcvd&r1=1.8&r2=0
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/i686/halfsample.s?cvsroot=libcvd&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/i686/rgb_to_gray.s?cvsroot=libcvd&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/i686/yuv420p_to_rgb.s?cvsroot=libcvd&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/i686/yuv422_to_grey.s?cvsroot=libcvd&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/i686/yuv422_to_rgb.s?cvsroot=libcvd&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/i686/convert_rgb_to_y.cc?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/i686/convolve_gaussian.cc?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/i686/gradient.cc?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/i686/median_3x3.cc?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/i686/testconf?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/i686/utility_byte_differences.cc?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/i686/utility_double_int.cc?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/i686/utility_float.cc?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/i686/yuv422_wrapper.cc?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/noarch/convert_rgb_to_y.cc?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/noarch/convolve_gaussian.cc?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/noarch/gradient.cc?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/noarch/median_3x3.cc?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/noarch/utility_byte_differences.cc?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/noarch/utility_double_int.cc?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/noarch/utility_float.cc?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/noarch/yuv422_wrapper.cc?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/make/march_flags?cvsroot=libcvd&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/libcvd/make/compile_deps.awk?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/make/prog_dependencies.awk?cvsroot=libcvd&r1=1.6&r2=0

Patches:
Index: Makefile.in
===================================================================
RCS file: /cvsroot/libcvd/libcvd/Makefile.in,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -b -r1.68 -r1.69
--- Makefile.in 25 Feb 2008 23:46:24 -0000      1.68
+++ Makefile.in 28 Feb 2008 00:27:21 -0000      1.69
@@ -88,11 +88,9 @@
                        cvd_src/deinterlacebuffer.o                     \
                        cvd_src/exceptions.o                            \
                        cvd_src/image_io.o                              \
-                       cvd_src/image_convert.o                         \
                        cvd_src/bayer.o                                 \
                        cvd_src/colourspace_convert.o                   \
-                       cvd_src/vision.o                                \
-                       cvd_src/utility.o                               \
+                       cvd_src/half_sample.o                           \
                        cvd_src/draw.o                                  \
                        cvd_src/yuv422.o                                \
                        cvd_src/yuv420.o                                \
@@ -104,190 +102,12 @@
                        cvd_src/nonmax_suppression.o                    \
                        cvd_src/timeddiskbuffer.o                       \
                        cvd_src/videosource.o                           \
-
-                       #cvd_src/fast/address@hidden@address@hidden@.o   \
-                       #cvd_src/fast/address@hidden@address@hidden@.o   \
-                       #cvd_src/fast/address@hidden@address@hidden@.o  \
-
-
-################################################################################
-#
-# Allow disabling of FAST detectors
-#
-ifeq (@have_FAST_7@,yes)
-       CVD_OBJS+=cvd_src/fast/fast_7_detect.o                    \
-                         cvd_src/fast/fast_7_score.o                     
-endif
-
-ifeq (@have_FAST_8@,yes)
-       CVD_OBJS+=cvd_src/fast/fast_8_detect.o                    \
-                         cvd_src/fast/fast_8_score.o                     
-endif
-
-ifeq (@have_FAST_9@,yes)
-       CVD_OBJS+=cvd_src/fast/fast_9_detect.o                    \
-                         cvd_src/fast/fast_9_score.o                     
-endif
-
-ifeq (@have_FAST_10@,yes)
-       CVD_OBJS+=cvd_src/fast/fast_10_detect.o                    \
-                         cvd_src/fast/fast_10_score.o                     
-endif
-
-ifeq (@have_FAST_11@,yes)
-       CVD_OBJS+=cvd_src/fast/fast_11_detect.o                    \
-                         cvd_src/fast/fast_11_score.o                     
-endif
-
-ifeq (@have_FAST_12@,yes)
-       CVD_OBJS+=cvd_src/fast/fast_12_detect.o                    \
-                         cvd_src/fast/fast_12_score.o                     
-endif
-
-################################################################################
-#
-# Stuff requiring TooN
-
-ifeq (@have_toon@,yes)
-       CVD_OBJS+=cvd_src/brezenham.o                                           
\
-                         cvd_src/tensor_voting.o                               
        
-endif
-
-ifeq (@have_lapack@,yes)
-       CVD_OBJS+=
-endif
-
+                       @dep_objects@
 
 
################################################################################
 #
-# Libraries
-
-ifeq (@have_glob@,yes)
-       CVD_OBJS+=cvd_src/globlist.o
-endif
-
-ifeq (@have_tiff@,yes)
-       CVD_OBJS+=pnm_src/tiff.o
-endif
-
-ifeq (@have_jpeg@,yes)
-       CVD_OBJS+=pnm_src/jpeg.o
-endif
-
-
-ifeq (@have_png@,yes)
-       CVD_OBJS+=pnm_src/png.o
-endif
-
-ifeq (@have_ffmpeg@,yes)
-       CVD_OBJS+=cvd_src/videofilebuffer.o
-endif
-
-ifeq (@have_pthread@,yes)
-       CVD_OBJS+=cvd_src/thread.o cvd_src/synchronized.o cvd_src/eventobject.o
-endif
-
-ifeq (@have_videodisplay@,yes)
-       CVD_OBJS+=cvd_src/videodisplay.o
-       CVD_OBJS+=cvd_src/glwindow.o
-endif
-
-################################################################################
+# Shared objects
 #
-# Linux
-
-ifeq (@have_dvbuffer@,yes)
-       CVD_OBJS+=cvd_src/Linux/dvbuffer.o
-endif
-
-ifeq (@have_v4l2buffer@,yes)
-       CVD_OBJS+=cvd_src/Linux/v4l2buffer.o \
-               cvd_src/Linux/v4lbuffer.o \
-               cvd_src/Linux/v4lcontrol.o
-endif
-
-ifeq (@have_v4l1buffer@,yes)
-       CVD_OBJS+=cvd_src/Linux/v4l1buffer.o
-endif
-
-################################################################################
-#
-# IRIX
-ifeq (@have_o2buffer@,yes)
-       CVD_OBJS+=cvd_src/IRIX/O2buffer.o cvd_src/IRIX/sgi-video.o
-endif
-
-################################################################################
-#
-# OSX
-ifeq (@have_qtbuffer@,yes)
-    CVD_OBJS+=cvd_src/OSX/qtbuffer.o
-endif
-
-################################################################################
-#
-#Architecture objects
-ifeq (@host_cpu@@have_sse2@,i686yes)
-       CVD_OBJS+= 
-endif
-
-ifeq (@host_cpu@@have_sse@,i686yes)
-       CVD_OBJS+=  cvd_src/i686/convolve_float.o \
-                   cvd_src/i686/convolve_float4.o \
-                   cvd_src/i686/float_difference.o \
-                   cvd_src/i686/float_assign_mul.o \
-                   cvd_src/i686/float_add_mul_add.o \
-                   cvd_src/i686/float_add_mul_add_unaligned.o \
-                   cvd_src/i686/float_innerproduct.o 
-endif
-
-ifeq (@host_cpu@@have_mmxext@,i686yes)
-       CVD_OBJS+=cvd_src/i686/yuv411_to_stuff_MMX.o  \
-                       cvd_src/i686/halfsample.o \
-                       cvd_src/i686/byte_to_short_difference.o \
-                       cvd_src/i686/short_difference.o \
-                       cvd_src/i686/int_difference.o \
-                       cvd_src/i686/yuv422_to_rgb.o \
-                       cvd_src/i686/yuv422_to_grey.o \
-                       cvd_src/i686/yuv420p_to_rgb.o \
-                       cvd_src/i686/rgb_to_gray.o 
-
-else
-       CVD_OBJS+=cvd_src/yuv411_to_stuff.o
-endif
-
-
-ifeq (@have_faster9@@have_sse2@@have_FAST_9@,yesyesyes)
-       CVD_OBJS+=cvd_src/faster_corner_9.o
-else
-ifeq (@have_FAST_9@,yes)
-       CVD_OBJS+=cvd_src/slower_corner_9.o
-endif
-endif
-       
-
-ifeq (@have_faster10@@have_sse2@@have_FAST_10@,yesyesyes)
-       CVD_OBJS+=cvd_src/faster_corner_10.o
-else
-ifeq (@have_FAST_10@,yes)
-       CVD_OBJS+=cvd_src/slower_corner_10.o
-endif
-endif
-
-ifeq (@have_faster12@@have_sse2@@have_FAST_12@,yesyesyes)
-       CVD_OBJS+=cvd_src/faster_corner_12.o
-else
-ifeq (@have_FAST_12@,yes)
-       CVD_OBJS+=cvd_src/slower_corner_12.o
-endif
-endif
-
-
-
-################################################################################
-#
-#
-
 
 ifeq (@osx_hacks@,yes)
        soname=libcvd.dylib
@@ -380,7 +200,7 @@
 
 install-progs:progs
        mkdir -p $(bindir)
-       [ "$(PROGS)" == "" ] || cp $(PROGS) $(bindir)
+       [ "$(PROGS)" = "" ] || cp $(PROGS) $(bindir)
 
 install-headers:
        mkdir -p $(includedir)
@@ -412,7 +232,7 @@
        rm -rf html man
 
 distclean: clean
-       /bin/rm -f Makefile config.h config.status config.cache config.log 
cvd/config.h .deps
+       /bin/rm -f Makefile config.h config.status config.cache config.log 
cvd/config.h .deps config.dep_tmp
 
 depend:
        rm -f .sourcefiles
@@ -428,16 +248,16 @@
 .PRECIOUS: %.o
 
 %.o : %.cc
-       $(CXX) -I. $(OFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
+       $(CXX) $(OFLAGS) -I. $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
 
 %.o: %.cpp
-       $(CXX) -I. $(OFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
+       $(CXX) $(OFLAGS) -I. $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
 
 %.o: %.cxx
-       $(CXX) -I. $(OFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
+       $(CXX) $(OFLAGS) -I. $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
 
 %.o: %.C
-       $(CXX) -I. $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
+       $(CXX) $(OFLAGS) -I. $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
 
 %.o: %.s
        as -g -o $@ $<

Index: configure
===================================================================
RCS file: /cvsroot/libcvd/libcvd/configure,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -b -r1.102 -r1.103
--- configure   25 Feb 2008 23:41:26 -0000      1.102
+++ configure   28 Feb 2008 00:27:21 -0000      1.103
@@ -652,19 +652,23 @@
 host_alias
 target_alias
 AWK
-CC
-CFLAGS
+CXX
+CXXFLAGS
 LDFLAGS
 CPPFLAGS
-ac_ct_CC
+ac_ct_CXX
 EXEEXT
 OBJEXT
-CXX
-CXXFLAGS
-ac_ct_CXX
+INSTALL_PROGRAM
+INSTALL_SCRIPT
+INSTALL_DATA
+LN_S
+RANLIB
 CXXCPP
 GREP
 EGREP
+major
+minor
 build
 build_cpu
 build_vendor
@@ -673,66 +677,54 @@
 host_cpu
 host_vendor
 host_os
+have_x86
 have_mmx
 have_mmxext
 have_sse
 have_sse2
-have_64bit
-OFLAGS
-INSTALL_PROGRAM
-INSTALL_SCRIPT
-INSTALL_DATA
-LN_S
-RANLIB
-osx_hacks
-have_toon
-have_lapack
-have_acml
-major
-minor
+have_sse3
+have_32bit
 have_dvbuffer
 have_v4l1buffer
 have_v4l2buffer
 have_o2buffer
+osx_hacks
 have_qtbuffer
-have_pthread
 XMKMF
 have_videodisplay
+have_toon
+have_lapack
+have_pthread
+have_png
 have_jpeg
 have_tiff
-have_png
 have_ffmpeg
 have_glob
 have_memalign
-have_faster9
-have_faster10
-have_faster12
-have_FAST_7
-have_fast_7
-have_FAST_8
-have_FAST_9
-have_FAST_10
-have_FAST_11
-have_FAST_12
-docs
-cpu
+have_fast7
+have_fast8
+have_fast9
+have_fast10
+have_fast11
+have_fast12
+have_ssefast9
+have_ssefast10
+have_ssefast12
+dep_objects
 progs
 testprogs
+OFLAGS
 LIBOBJS
-LTLIBOBJS
-debug_options
-debug_all_options'
+LTLIBOBJS'
 ac_subst_files=''
       ac_precious_vars='build_alias
 host_alias
 target_alias
-CC
-CFLAGS
+CXX
+CXXFLAGS
 LDFLAGS
 LIBS
 CPPFLAGS
-CXX
-CXXFLAGS
 CCC
 CXXCPP
 XMKMF'
@@ -1314,59 +1306,63 @@
 Optional Features:
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
-  --disable-ssefast9      Disable the probably OK SSE FAST-9 detector
-  --disable-ssefast10     Disable the probably OK SSE FAST-10 detector
-  --disable-ssefast12     Disable the probably OK SSE FAST-12 detector
-  --enable-missingfast=7,8,...  compile without certain FAST detectors.
+  --disable-ssefast9      Disable the probably OK SSE FAST-9 detector 
(debgging only)
+  --disable-ssefast10     Disable the probably OK SSE FAST-10 detector 
(debgging only)
+  --disable-ssefast12     Disable the probably OK SSE FAST-12 detector 
(debgging only)
+  --disable-fast7               compile without the FAST-7 detector (use on 
low memory systems).
+  --disable-fast8               compile without the FAST-8 detector (use on 
low memory systems).
+  --disable-fast9               compile without the FAST-9 detector (use on 
low memory systems).
+  --disable-fast10              compile without the FAST-10 detector (use on 
low memory systems).
+  --disable-fast11              compile without the FAST-11 detector (use on 
low memory systems).
+  --disable-fast12              compile without the FAST-12 detector (use on 
low memory systems).
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-  --without-debug         compile without debug support
   --with-debug=flags      compile with debug support
-  --with-profile=flags    compile with profile support
-  --with-cpu=type         Specify pocessor type:
+  --without-optimize      compile without optimizations
+  --with-optimize=flags   compile with optimization flags
+  --with-cpu=type         Specify pocessor type for optimization selection:
                             X86:
                               p3 p4 p4_64 xeon pM core2 core2_64 opteron
                               opteron_64 athlon athlon64 athlon64_64
                             SPARC:
                               sparc
                           Autodetection works on Linux only.
-  --without-simd          disable SIMD code
+  --without-simd          disable SIMD code. Use --without- or --with-
+                             to force presence/absence and disable 
autodetection.
     --with-mmx            force presence or absence of MMX  (x86 only)
     --with-mmxext         force presence or absence of MMXEXT (x86 only)
     --with-sse            force presence or absence of SSE  (x86 only)
     --with-sse2           force presence or absence of SSE2  (x86 only)
-  --without-optimize      compile without optimizations
-  --with-optimize=flags   compile with optimization flags
-  --with-TooN=directory   Specify location for TooN
-  --without-lapack        Disable BLAS and LAPACK.
-  --with-acml[=directory] Use BLAS and LAPACK routines from the ACML library 
[located in the specified directory]
-  --without-firewire     compile without firewire (dvbuffer) support
-  --without-v4l1         compile without v4l1 support
-  --without-v4l2         compile without v4l2 support
-  --without-o2buffer     compile without sgi video
-  --without-quicktime    compile without quicktime buffer support
-  --without-threads       compile without PThread support
-  --with-x                use the X Window System
+  --without-dvbuffer      compile without dvbuffer (DC camera) support (Linux 
only)
+  --without-v4l1buffer   compile without v4l1bffer (Video4Linux) support 
(Linux only)
+  --without-v4l2buffer   compile without v4l2buffer (Video4Linux2) support 
(Linux only)
+  --without-o2buffer     compile without sgi video (IRIX only)
+  --without-qtbuffer     compile without quicktime buffer support (MacOSX only)
+  --without-vidoedisplay  compile without videodisplay support
+  --without-pthread       compile without PThread support
   --without-jpeg          compile without JPEG support
   --with-jpegbuffer=N     Set JPEG read buffer size. N>1 will not be able to 
read multiple JPEGS from a stream.
   --without-tiff          compile without TIFF support
   --with-tiff=forceold    Debug/wierd build environment only. Force use of 
older library facilities.
   --without-png           compile without PNG support
   --without-ffmpeg       compile without FFMPEG support
-  --without-glob          Compile without diskbuffer glob matching
+  --withot-toon          Compile without TooN support
+  --without-lapack        Disable BLAS and LAPACK.
+  --with-acml[=directory] Use BLAS and LAPACK routines from the ACML library 
[located in the specified directory]
+  --with-x                use the X Window System
+  --without-glob          Compile without diskbuffer glob matching (for 
debugging only)
+  --without-memalign      Compile without posix_memalign (for debugging only)
 
 Some influential environment variables:
-  CC          C compiler command
-  CFLAGS      C compiler flags
+  CXX         C++ compiler command
+  CXXFLAGS    C++ compiler flags
   LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
               nonstandard directory <lib dir>
   LIBS        libraries to pass to the linker, e.g. -l<library>
   CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
               you have headers in a nonstandard directory <include dir>
-  CXX         C++ compiler command
-  CXXFLAGS    C++ compiler flags
   CXXCPP      C++ preprocessor
   XMKMF       Path to xmkmf, Makefile generator for X Window System
 
@@ -1803,11 +1799,6 @@
 
 
 
-
-
-
-orig_CXXFLAGS="$CXXFLAGS"
-
 #Use builtin autoconf checks for all the programs we need.
 for ac_prog in gawk mawk nawk awk
 do
@@ -1851,217 +1842,27 @@
   test -n "$AWK" && break
 done
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext 
$LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program 
name with args.
-set dummy ${ac_tool_prefix}gcc; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x 
"$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_CC="${ac_tool_prefix}gcc"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6; }
-else
-  { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_CC"; then
-  ac_ct_CC=$CC
-  # Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$ac_ct_CC"; then
-  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x 
"$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_CC="gcc"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
-  { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6; }
-else
-  { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
-  if test "x$ac_ct_CC" = x; then
-    CC=""
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS 
conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+  if test -n "$CCC"; then
+    CXX=$CCC
   else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect 
cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to address@hidden" >&5
-echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to address@hidden" >&2;}
-ac_tool_warned=yes ;;
-esac
-    CC=$ac_ct_CC
-  fi
-else
-  CC="$ac_cv_prog_CC"
-fi
-
-if test -z "$CC"; then
-          if test -n "$ac_tool_prefix"; then
-    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program 
name with args.
-set dummy ${ac_tool_prefix}cc; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x 
"$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_CC="${ac_tool_prefix}cc"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6; }
-else
-  { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
-
-  fi
-fi
-if test -z "$CC"; then
-  # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-  ac_prog_rejected=no
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x 
"$as_dir/$ac_word$ac_exec_ext"; }; then
-    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
-       ac_prog_rejected=yes
-       continue
-     fi
-    ac_cv_prog_CC="cc"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-IFS=$as_save_IFS
-
-if test $ac_prog_rejected = yes; then
-  # We found a bogon in the path, so make sure we never use it.
-  set dummy $ac_cv_prog_CC
-  shift
-  if test $# != 0; then
-    # We chose a different compiler from the bogus one.
-    # However, it has the same basename, so the bogon will be chosen
-    # first if we set CC to just the basename; use the full file name.
-    shift
-    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
-  fi
-fi
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6; }
-else
-  { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
-
-fi
-if test -z "$CC"; then
   if test -n "$ac_tool_prefix"; then
-  for ac_prog in cl.exe
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a 
program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
 { echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then
+if test "${ac_cv_prog_CXX+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
+  if test -n "$CXX"; then
+  ac_cv_prog_CXX="$CXX" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -2070,7 +1871,7 @@
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x 
"$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -2080,32 +1881,32 @@
 
 fi
 fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6; }
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+  { echo "$as_me:$LINENO: result: $CXX" >&5
+echo "${ECHO_T}$CXX" >&6; }
 else
   { echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6; }
 fi
 
 
-    test -n "$CC" && break
+    test -n "$CXX" && break
   done
 fi
-if test -z "$CC"; then
-  ac_ct_CC=$CC
-  for ac_prog in cl.exe
+if test -z "$CXX"; then
+  ac_ct_CXX=$CXX
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
 do
   # Extract the first word of "$ac_prog", so it can be a program name with 
args.
 set dummy $ac_prog; ac_word=$2
 { echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -n "$ac_ct_CC"; then
-  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+  if test -n "$ac_ct_CXX"; then
+  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -2114,7 +1915,7 @@
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x 
"$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_CC="$ac_prog"
+    ac_cv_prog_ac_ct_CXX="$ac_prog"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -2124,21 +1925,21 @@
 
 fi
 fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
-  { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6; }
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
+echo "${ECHO_T}$ac_ct_CXX" >&6; }
 else
   { echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6; }
 fi
 
 
-  test -n "$ac_ct_CC" && break
+  test -n "$ac_ct_CXX" && break
 done
 
-  if test "x$ac_ct_CC" = x; then
-    CC=""
+  if test "x$ac_ct_CXX" = x; then
+    CXX="g++"
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
@@ -2150,21 +1951,14 @@
 configuration is useful to you, please write to address@hidden" >&2;}
 ac_tool_warned=yes ;;
 esac
-    CC=$ac_ct_CC
+    CXX=$ac_ct_CXX
   fi
 fi
 
+  fi
 fi
-
-
-test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler 
found in \$PATH
-See \`config.log' for more details." >&5
-echo "$as_me: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-
 # Provide some information about the compiler.
-echo "$as_me:$LINENO: checking for C compiler version" >&5
+echo "$as_me:$LINENO: checking for C++ compiler version" >&5
 ac_compiler=`set X $ac_compile; echo $2`
 { (ac_try="$ac_compiler --version >&5"
 case "(($ac_try" in
@@ -2217,8 +2011,8 @@
 # Try to create an executable without -o first, disregard a.out.
 # It will help us diagnose broken compilers, and finding out an intuition
 # of exeext.
-{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
-echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" 
>&6; }
+{ echo "$as_me:$LINENO: checking for C++ compiler default output file name" >&5
+echo $ECHO_N "checking for C++ compiler default output file name... $ECHO_C" 
>&6; }
 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
 #
 # List of possible output files, starting from the most likely.
@@ -2291,9 +2085,9 @@
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
+{ { echo "$as_me:$LINENO: error: C++ compiler cannot create executables
 See \`config.log' for more details." >&5
-echo "$as_me: error: C compiler cannot create executables
+echo "$as_me: error: C++ compiler cannot create executables
 See \`config.log' for more details." >&2;}
    { (exit 77); exit 77; }; }
 fi
@@ -2302,8 +2096,8 @@
 
 # Check that the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
-{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5
-echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: checking whether the C++ compiler works" >&5
+echo $ECHO_N "checking whether the C++ compiler works... $ECHO_C" >&6; }
 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0
 # If not cross compiling, check that we can run a simple program.
 if test "$cross_compiling" != yes; then
@@ -2322,10 +2116,10 @@
     if test "$cross_compiling" = maybe; then
        cross_compiling=yes
     else
-       { { echo "$as_me:$LINENO: error: cannot run C compiled programs.
+       { { echo "$as_me:$LINENO: error: cannot run C++ compiled programs.
 If you meant to cross compile, use \`--host'.
 See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run C compiled programs.
+echo "$as_me: error: cannot run C++ compiled programs.
 If you meant to cross compile, use \`--host'.
 See \`config.log' for more details." >&2;}
    { (exit 1); exit 1; }; }
@@ -2440,9 +2234,9 @@
 echo "${ECHO_T}$ac_cv_objext" >&6; }
 OBJEXT=$ac_cv_objext
 ac_objext=$OBJEXT
-{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" 
>&6; }
-if test "${ac_cv_c_compiler_gnu+set}" = set; then
+{ echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" 
>&6; }
+if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
@@ -2477,7 +2271,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && {
-        test -z "$ac_c_werror_flag" ||
+        test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
   ac_compiler_gnu=yes
@@ -2489,23 +2283,23 @@
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_c_compiler_gnu=$ac_compiler_gnu
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
 
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; }
-GCC=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CFLAGS=${CFLAGS+set}
-ac_save_CFLAGS=$CFLAGS
-{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
-echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; }
-if test "${ac_cv_prog_cc_g+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_save_c_werror_flag=$ac_c_werror_flag
-   ac_c_werror_flag=yes
-   ac_cv_prog_cc_g=no
-   CFLAGS="-g"
+{ echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; }
+GXX=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
+echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; }
+if test "${ac_cv_prog_cxx_g+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+   ac_cxx_werror_flag=yes
+   ac_cv_prog_cxx_g=no
+   CXXFLAGS="-g"
    cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -2535,15 +2329,15 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && {
-        test -z "$ac_c_werror_flag" ||
+        test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  ac_cv_prog_cc_g=yes
+  ac_cv_prog_cxx_g=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       CFLAGS=""
+       CXXFLAGS=""
       cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -2573,7 +2367,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && {
-        test -z "$ac_c_werror_flag" ||
+        test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
   :
@@ -2581,8 +2375,8 @@
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_c_werror_flag=$ac_save_c_werror_flag
-        CFLAGS="-g"
+       ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+        CXXFLAGS="-g"
         cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -2612,10 +2406,10 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && {
-        test -z "$ac_c_werror_flag" ||
+        test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  ac_cv_prog_cc_g=yes
+  ac_cv_prog_cxx_g=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
@@ -2630,167 +2424,163 @@
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-   ac_c_werror_flag=$ac_save_c_werror_flag
+   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; }
-if test "$ac_test_CFLAGS" = set; then
-  CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
-  if test "$GCC" = yes; then
-    CFLAGS="-g -O2"
+{ echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
+    CXXFLAGS="-g -O2"
   else
-    CFLAGS="-g"
+    CXXFLAGS="-g"
   fi
 else
-  if test "$GCC" = yes; then
-    CFLAGS="-O2"
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
   else
-    CFLAGS=
+    CXXFLAGS=
   fi
 fi
-{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
-echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; }
-if test "${ac_cv_prog_cc_c89+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_cv_prog_cc_c89=no
-ac_save_CC=$CC
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
-     char **p;
-     int i;
-{
-  return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
-  char *s;
-  va_list v;
-  va_start (v,p);
-  s = g (p, va_arg (v,int));
-  va_end (v);
-  return s;
-}
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext 
$LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ac_aux_dir=
+for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+  if test -f "$ac_dir/install-sh"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install-sh -c"
+    break
+  elif test -f "$ac_dir/install.sh"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install.sh -c"
+    break
+  elif test -f "$ac_dir/shtool"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/shtool install -c"
+    break
+  fi
+done
+if test -z "$ac_aux_dir"; then
+  { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in 
\"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5
+echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" 
\"$srcdir/..\" \"$srcdir/../..\"" >&2;}
+   { (exit 1); exit 1; }; }
+fi
 
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
-   function prototypes and stuff, but not '\xHH' hex character constants.
-   These don't provoke an error unfortunately, instead are silently treated
-   as 'x'.  The following induces an error, until -std is added to get
-   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
-   array size at least.  It's necessary to write '\x00'==0 to get something
-   that's true only with -std.  */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
 
-/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
-   inside strings and character constants.  */
-#define FOO(x) 'x'
-int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
 
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, 
int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
-  ;
-  return 0;
-}
-_ACEOF
-for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
-       -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; }
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
 do
-  CC="$ac_save_CC $ac_arg"
-  rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in
+  ./ | .// | /cC/* | \
+  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+  ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
+  /usr/ucb/* ) ;;
+  *)
+    # OSF1 and SCO ODT 3.0 have their own names for install.
+    # Don't use installbsd from OSF since it installs stuff as root
+    # by default.
+    for ac_prog in ginstall scoinst install; do
+      for ac_exec_ext in '' $ac_executable_extensions; do
+       if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x 
"$as_dir/$ac_prog$ac_exec_ext"; }; then
+         if test $ac_prog = install &&
+           grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # AIX install.  It has an incompatible calling convention.
+           :
+         elif test $ac_prog = install &&
+           grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # program-specific install script used by HP pwplus--don't use.
+           :
+         else
+           ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+           break 3
+         fi
+       fi
+      done
+    done
+    ;;
 esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_c_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_prog_cc_c89=$ac_arg
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+done
+IFS=$as_save_IFS
 
 
 fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL=$ac_cv_path_install
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    INSTALL=$ac_install_sh
+  fi
+fi
+{ echo "$as_me:$LINENO: result: $INSTALL" >&5
+echo "${ECHO_T}$INSTALL" >&6; }
 
-rm -f core conftest.err conftest.$ac_objext
-  test "x$ac_cv_prog_cc_c89" != "xno" && break
-done
-rm -f conftest.$ac_ext
-CC=$ac_save_CC
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
 
-fi
-# AC_CACHE_VAL
-case "x$ac_cv_prog_cc_c89" in
-  x)
-    { echo "$as_me:$LINENO: result: none needed" >&5
-echo "${ECHO_T}none needed" >&6; } ;;
-  xno)
-    { echo "$as_me:$LINENO: result: unsupported" >&5
-echo "${ECHO_T}unsupported" >&6; } ;;
-  *)
-    CC="$CC $ac_cv_prog_cc_c89"
-    { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;;
-esac
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
 
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext 
$LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ echo "$as_me:$LINENO: checking whether ln -s works" >&5
+echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+  { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no, using $LN_S" >&5
+echo "${ECHO_T}no, using $LN_S" >&6; }
+fi
 
-ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS 
conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-if test -z "$CXX"; then
-  if test -n "$CCC"; then
-    CXX=$CCC
-  else
-    if test -n "$ac_tool_prefix"; then
-  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a 
program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a 
program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
 { echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_CXX+set}" = set; then
+if test "${ac_cv_prog_RANLIB+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -n "$CXX"; then
-  ac_cv_prog_CXX="$CXX" # Let the user override the test.
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -2799,7 +2589,7 @@
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x 
"$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -2809,32 +2599,28 @@
 
 fi
 fi
-CXX=$ac_cv_prog_CXX
-if test -n "$CXX"; then
-  { echo "$as_me:$LINENO: result: $CXX" >&5
-echo "${ECHO_T}$CXX" >&6; }
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  { echo "$as_me:$LINENO: result: $RANLIB" >&5
+echo "${ECHO_T}$RANLIB" >&6; }
 else
   { echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6; }
 fi
 
 
-    test -n "$CXX" && break
-  done
 fi
-if test -z "$CXX"; then
-  ac_ct_CXX=$CXX
-  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with 
args.
-set dummy $ac_prog; ac_word=$2
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
 { echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -n "$ac_ct_CXX"; then
-  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -2843,7 +2629,7 @@
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x 
"$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_CXX="$ac_prog"
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -2853,21 +2639,17 @@
 
 fi
 fi
-ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
-if test -n "$ac_ct_CXX"; then
-  { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
-echo "${ECHO_T}$ac_ct_CXX" >&6; }
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
+echo "${ECHO_T}$ac_ct_RANLIB" >&6; }
 else
   { echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6; }
 fi
 
-
-  test -n "$ac_ct_CXX" && break
-done
-
-  if test "x$ac_ct_CXX" = x; then
-    CXX="g++"
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB=":"
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
@@ -2879,264 +2661,243 @@
 configuration is useful to you, please write to address@hidden" >&2;}
 ac_tool_warned=yes ;;
 esac
-    CXX=$ac_ct_CXX
+    RANLIB=$ac_ct_RANLIB
   fi
+else
+  RANLIB="$ac_cv_prog_RANLIB"
 fi
 
-  fi
-fi
-# Provide some information about the compiler.
-echo "$as_me:$LINENO: checking for C++ compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (ac_try="$ac_compiler --version >&5"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compiler --version >&5") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-{ (ac_try="$ac_compiler -v >&5"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compiler -v >&5") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-{ (ac_try="$ac_compiler -V >&5"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compiler -V >&5") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
+#Switch testing language to C++
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS 
conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
-{ echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" 
>&6; }
-if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
+#Start the compiler
+ac_config_headers="$ac_config_headers "
+
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS 
conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+{ echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5
+echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6; }
+if test -z "$CXXCPP"; then
+  if test "${ac_cv_prog_CXXCPP+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
+      # Double quotes because CXXCPP needs to be expanded
+    for CXXCPP in "$CXX -E" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_cxx_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-
-int
-main ()
-{
-#ifndef __GNUC__
-       choke me
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
 #endif
-
-  ;
-  return 0;
-}
+                    Syntax error
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+if { (ac_try="$ac_cpp conftest.$ac_ext"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
         test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_compiler_gnu=yes
+       }; then
+  :
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_compiler_gnu=no
+  # Broken: fails on valid input.
+continue
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+rm -f conftest.err conftest.$ac_ext
 
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; }
-GXX=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CXXFLAGS=${CXXFLAGS+set}
-ac_save_CXXFLAGS=$CXXFLAGS
-{ echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
-echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; }
-if test "${ac_cv_prog_cxx_g+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
-   ac_cxx_werror_flag=yes
-   ac_cv_prog_cxx_g=no
-   CXXFLAGS="-g"
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
    cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
+#include <ac_nonexistent.h>
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+if { (ac_try="$ac_cpp conftest.$ac_ext"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
         test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_prog_cxx_g=yes
+       }; then
+  # Broken: success on invalid input.
+continue
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       CXXFLAGS=""
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  break
+fi
+
+    done
+    ac_cv_prog_CXXCPP=$CXXCPP
+
+fi
+  CXXCPP=$ac_cv_prog_CXXCPP
+else
+  ac_cv_prog_CXXCPP=$CXXCPP
+fi
+{ echo "$as_me:$LINENO: result: $CXXCPP" >&5
+echo "${ECHO_T}$CXXCPP" >&6; }
+ac_preproc_ok=false
+for ac_cxx_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
       cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+if { (ac_try="$ac_cpp conftest.$ac_ext"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
         test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
+       }; then
   :
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cxx_werror_flag=$ac_save_cxx_werror_flag
-        CXXFLAGS="-g"
+  # Broken: fails on valid input.
+continue
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
         cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
+#include <ac_nonexistent.h>
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+if { (ac_try="$ac_cpp conftest.$ac_ext"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
         test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_prog_cxx_g=yes
+       }; then
+  # Broken: success on invalid input.
+continue
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-
+  # Passes both tests.
+ac_preproc_ok=:
+break
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
+rm -f conftest.err conftest.$ac_ext
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  :
+else
+  { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity 
check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6; }
-if test "$ac_test_CXXFLAGS" = set; then
-  CXXFLAGS=$ac_save_CXXFLAGS
-elif test $ac_cv_prog_cxx_g = yes; then
-  if test "$GXX" = yes; then
-    CXXFLAGS="-g -O2"
-  else
-    CXXFLAGS="-g"
-  fi
-else
-  if test "$GXX" = yes; then
-    CXXFLAGS="-O2"
-  else
-    CXXFLAGS=
-  fi
-fi
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext 
$LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-#Switch testing language to C++
 ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -3144,215 +2905,194 @@
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
 
-###################################################
-#
-# Check for g++ version >= 3
-
-if test x$GXX = xyes
-then
-       good_gcc=0
-
-       { echo "$as_me:$LINENO: checking g++ version" >&5
-echo $ECHO_N "checking g++ version... $ECHO_C" >&6; }
-
-       gxx_major_version=`$CXX -v 2>&1 | $AWK -F '[ .]' '/version/{print $3}'`
-
-
-
-       if test "$gxx_major_version" -lt 3
-       then
-               { echo "$as_me:$LINENO: result: $gxx_major_version (failed)" >&5
-echo "${ECHO_T}$gxx_major_version (failed)" >&6; }
-               { echo "$as_me:$LINENO: checking for other possibilities for 
g++ version >= 3" >&5
-echo $ECHO_N "checking for other possibilities for g++ version >= 3... 
$ECHO_C" >&6; }
-               { echo "$as_me:$LINENO: result: " >&5
-echo "${ECHO_T}" >&6; }
-               #Check for some other possible G++s
-               #Uncache che checks
-               unset CXX
-               unset ac_ct_CXX
-               unset ac_cv_prog_ac_ct_CXX
-               unset ac_cv_prog_cxx_g
-               unset GXX
-               unset ac_cv_cxx_compiler_gnu
-
-               #echo is a dummy target, which will always succeed.
-               #If the c++ compiler is set to echo, then we know that
-               #none of the proper ones worked.
-               ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS 
conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-if test -z "$CXX"; then
-  if test -n "$CCC"; then
-    CXX=$CCC
-  else
-    if test -n "$ac_tool_prefix"; then
-  for ac_prog in g++-4 g++-3 echo
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a 
program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_CXX+set}" = set; then
+{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
+echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" 
>&6; }
+if test "${ac_cv_path_GREP+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -n "$CXX"; then
-  ac_cv_prog_CXX="$CXX" # Let the user override the test.
+  # Extract the first word of "grep ggrep" to use in msg output
+if test -z "$GREP"; then
+set dummy grep ggrep; ac_prog_name=$2
+if test "${ac_cv_path_GREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
+  ac_path_GREP_found=false
+# Loop through the user's path and test for each of PROGNAME-LIST
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
+  for ac_prog in grep ggrep; do
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x 
"$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
+    ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+    { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+    # Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" 
>"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    ac_count=`expr $ac_count + 1`
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
   fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+
+    $ac_path_GREP_found && break 3
+  done
 done
+
 done
 IFS=$as_save_IFS
 
+
 fi
+
+GREP="$ac_cv_path_GREP"
+if test -z "$GREP"; then
+  { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found 
in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+echo "$as_me: error: no acceptable $ac_prog_name could be found in 
$PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+   { (exit 1); exit 1; }; }
 fi
-CXX=$ac_cv_prog_CXX
-if test -n "$CXX"; then
-  { echo "$as_me:$LINENO: result: $CXX" >&5
-echo "${ECHO_T}$CXX" >&6; }
+
 else
-  { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
+  ac_cv_path_GREP=$GREP
 fi
 
 
-    test -n "$CXX" && break
-  done
 fi
-if test -z "$CXX"; then
-  ac_ct_CXX=$CXX
-  for ac_prog in g++-4 g++-3 echo
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with 
args.
-set dummy $ac_prog; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
+{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
+echo "${ECHO_T}$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6; }
+if test "${ac_cv_path_EGREP+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -n "$ac_ct_CXX"; then
-  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     # Extract the first word of "egrep" to use in msg output
+if test -z "$EGREP"; then
+set dummy egrep; ac_prog_name=$2
+if test "${ac_cv_path_EGREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
+  ac_path_EGREP_found=false
+# Loop through the user's path and test for each of PROGNAME-LIST
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
+  for ac_prog in egrep; do
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x 
"$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_CXX="$ac_prog"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
+    ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+    { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+    # Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || 
break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    ac_count=`expr $ac_count + 1`
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
   fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+
+    $ac_path_EGREP_found && break 3
+  done
 done
+
 done
 IFS=$as_save_IFS
 
+
 fi
+
+EGREP="$ac_cv_path_EGREP"
+if test -z "$EGREP"; then
+  { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found 
in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+echo "$as_me: error: no acceptable $ac_prog_name could be found in 
$PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+   { (exit 1); exit 1; }; }
 fi
-ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
-if test -n "$ac_ct_CXX"; then
-  { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
-echo "${ECHO_T}$ac_ct_CXX" >&6; }
+
 else
-  { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
+  ac_cv_path_EGREP=$EGREP
 fi
 
 
-  test -n "$ac_ct_CXX" && break
-done
-
-  if test "x$ac_ct_CXX" = x; then
-    CXX="g++"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect 
cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to address@hidden" >&5
-echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to address@hidden" >&2;}
-ac_tool_warned=yes ;;
-esac
-    CXX=$ac_ct_CXX
   fi
 fi
+{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
+echo "${ECHO_T}$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
 
-  fi
-fi
-# Provide some information about the compiler.
-echo "$as_me:$LINENO: checking for C++ compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (ac_try="$ac_compiler --version >&5"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compiler --version >&5") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-{ (ac_try="$ac_compiler -v >&5"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compiler -v >&5") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-{ (ac_try="$ac_compiler -V >&5"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compiler -V >&5") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-
-{ echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" 
>&6; }
-if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-#ifndef __GNUC__
-       choke me
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+
+{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
@@ -3368,786 +3108,458 @@
         test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  ac_compiler_gnu=yes
+  ac_cv_header_stdc=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_compiler_gnu=no
+       ac_cv_header_stdc=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
 
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; }
-GXX=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CXXFLAGS=${CXXFLAGS+set}
-ac_save_CXXFLAGS=$CXXFLAGS
-{ echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
-echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; }
-if test "${ac_cv_prog_cxx_g+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
-   ac_cxx_werror_flag=yes
-   ac_cv_prog_cxx_g=no
-   CXXFLAGS="-g"
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
    cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
+#include <string.h>
 
-int
-main ()
-{
-
-  ;
-  return 0;
-}
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_prog_cxx_g=yes
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then
+  :
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
 
-       CXXFLAGS=""
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
       cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
+#include <stdlib.h>
 
-int
-main ()
-{
-
-  ;
-  return 0;
-}
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then
   :
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
 
-       ac_cxx_werror_flag=$ac_save_cxx_werror_flag
-        CXXFLAGS="-g"
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then
+  :
+else
         cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                  (('a' <= (c) && (c) <= 'i') \
+                    || ('j' <= (c) && (c) <= 'r') \
+                    || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
 
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
 int
 main ()
 {
-
-  ;
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+       || toupper (i) != TOUPPER (i))
+      return 2;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_link") 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_prog_cxx_g=yes
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
 else
-  echo "$as_me: failed program was:" >&5
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-
+( exit $ac_status )
+ac_cv_header_stdc=no
 fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext conftest.$ac_ext
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6; }
-if test "$ac_test_CXXFLAGS" = set; then
-  CXXFLAGS=$ac_save_CXXFLAGS
-elif test $ac_cv_prog_cxx_g = yes; then
-  if test "$GXX" = yes; then
-    CXXFLAGS="-g -O2"
-  else
-    CXXFLAGS="-g"
-  fi
-else
-  if test "$GXX" = yes; then
-    CXXFLAGS="-O2"
-  else
-    CXXFLAGS=
-  fi
 fi
-ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS 
conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
 
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
 
-               if test $ac_cv_prog_ac_ct_CXX = echo
-               then
-                       { { echo "$as_me:$LINENO: error: g++ version >= 3.0 is 
required." >&5
-echo "$as_me: error: g++ version >= 3.0 is required." >&2;}
-   { (exit 1); exit 1; }; }
-               fi
-       else
-               { echo "$as_me:$LINENO: result: $gxx_major_version (ok)" >&5
-echo "${ECHO_T}$gxx_major_version (ok)" >&6; }
-       fi
 fi
 
 
+cvd_major=`echo $PACKAGE_VERSION | $AWK -F'\\\\.' '{print $1}'`
+cvd_minor=`echo $PACKAGE_VERSION | $AWK -F'\\\\.' '{print $2}'`
 
+cat >>confdefs.h <<_ACEOF
+#define CVD_MAJOR_VERSION $cvd_major
+_ACEOF
 
-# Check whether --with-debug was given.
-if test "${with_debug+set}" = set; then
-  withval=$with_debug; debug=no
-fi
+major=$cvd_major
 
+cat >>confdefs.h <<_ACEOF
+#define CVD_MINOR_VERSION $cvd_minor
+_ACEOF
 
-# Check whether --with-debug was given.
-if test "${with_debug+set}" = set; then
-  withval=$with_debug; debug="$withval"
-fi
+minor=$cvd_minor
 
 
-# Check whether --with-profile was given.
-if test "${with_profile+set}" = set; then
-  withval=$with_profile; profile="$withval"
-else
-  profile=no
-fi
 
 
-###################################################
+################################################################################
 #
-# Deal with profiling and debugging
+#Lists of  optional components
 #
+
+all_options="videodisplay jpeg tiff png ffmpeg toon lapack pthread glob 
memalign"
+dodginess_options=
+options=
+simd_all_options=
+simd_options=
+os_all_options=
+
+################################################################################
+#
+# Useful macros
 #
-if test "$debug" != no || test "$profile" != no
-then
-       if test "$debug" == ""
-       then
-               if test "$ac_cv_cxx_compiler_gnu" = yes
-               then
-                       CXXFLAGS="$orig_CXXFLAGS -g -ggdb"
-               fi
-       else
-               CXXFLAGS="$orig_CXXFLAGS $debug"
-       fi
-elif test "$debug" = no
-then
-       #Remove debugging
-       CXXFLAGS="$orig_CXXFLAGS"
-fi
 
-if test "$profile" != no
-then
-       if test "$profile" = yes
-       then
-               if test "$ac_cv_cxx_compiler_gnu" = yes
-               then
-                       CXXFLAGS="$CXXFLAGS -p -pg"
-                       CFLAGS="$CFLAGS -p -pg"
-               else
-                       { echo "$as_me:$LINENO: WARNING: I don't know how to 
switch on profiling for this compiler" >&5
-echo "$as_me: WARNING: I don't know how to switch on profiling for this 
compiler" >&2;}
-               fi
-       else
-               CXXFLAGS="$CXXFLAGS $profile"
-               CFLAGS="$CFLAGS $profile"
-       fi
-fi
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 
################################################################################
 #
-# Make position independent code
+# Compiler flags and optimization
+#
 #
 
-if test x$GXX = xyes
-then
-       CXXFLAGS="$CXXFLAGS -fPIC"
-fi
+       if test "" == ""
+       then
+               { echo "$as_me:$LINENO: checking if compiler flag -Wall works" 
>&5
+echo $ECHO_N "checking if compiler flag -Wall works... $ECHO_C" >&6; }
+       else
+               { echo "$as_me:$LINENO: checking " >&5
+echo $ECHO_N "checking ... $ECHO_C" >&6; }
+       fi
+       save_CXXFLAGS="$CXXFLAGS"
+       CXXFLAGS="$CXXFLAGS -Wall"
 
-#Start the compiler
 
-ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS 
conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-{ echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5
-echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6; }
-if test -z "$CXXCPP"; then
-  if test "${ac_cv_prog_CXXCPP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+       if test "$cross_compiling" = yes; then
+  { { echo "$as_me:$LINENO: error: cannot run test program while cross 
compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
 else
-      # Double quotes because CXXCPP needs to be expanded
-    for CXXCPP in "$CXX -E" "/lib/cpp"
-    do
-      ac_preproc_ok=false
-for ac_cxx_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
   cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-                    Syntax error
+int main(){}
 _ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  (eval "$ac_link") 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       }; then
-  :
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  # Broken: fails on valid input.
-continue
-fi
-
-rm -f conftest.err conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  (eval "$ac_try") 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       }; then
-  # Broken: success on invalid input.
-continue
+  (exit $ac_status); }; }; then
+  cvd_conf_test=1
 else
-  echo "$as_me: failed program was:" >&5
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-  # Passes both tests.
-ac_preproc_ok=:
-break
+( exit $ac_status )
+cvd_conf_test=0
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext conftest.$ac_ext
 fi
 
-rm -f conftest.err conftest.$ac_ext
 
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
-  break
-fi
 
-    done
-    ac_cv_prog_CXXCPP=$CXXCPP
 
-fi
-  CXXCPP=$ac_cv_prog_CXXCPP
+       if test $cvd_conf_test = 1
+       then
+               { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+               ts_success=yes
+       else
+               { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+               CXXFLAGS="$save_CXXFLAGS"
+               ts_success=no
+       fi
+
+
+       if test "" == ""
+       then
+               { echo "$as_me:$LINENO: checking if compiler flag -Wextra 
works" >&5
+echo $ECHO_N "checking if compiler flag -Wextra works... $ECHO_C" >&6; }
+       else
+               { echo "$as_me:$LINENO: checking " >&5
+echo $ECHO_N "checking ... $ECHO_C" >&6; }
+       fi
+       save_CXXFLAGS="$CXXFLAGS"
+       CXXFLAGS="$CXXFLAGS -Wextra"
+
+
+       if test "$cross_compiling" = yes; then
+  { { echo "$as_me:$LINENO: error: cannot run test program while cross 
compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
 else
-  ac_cv_prog_CXXCPP=$CXXCPP
-fi
-{ echo "$as_me:$LINENO: result: $CXXCPP" >&5
-echo "${ECHO_T}$CXXCPP" >&6; }
-ac_preproc_ok=false
-for ac_cxx_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
   cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-                    Syntax error
+int main(){}
 _ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  (eval "$ac_link") 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       }; then
-  :
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  # Broken: fails on valid input.
-continue
-fi
-
-rm -f conftest.err conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  (eval "$ac_try") 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       }; then
-  # Broken: success on invalid input.
-continue
+  (exit $ac_status); }; }; then
+  cvd_conf_test=1
 else
-  echo "$as_me: failed program was:" >&5
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
-  :
-else
-  { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity 
check
-See \`config.log' for more details." >&5
-echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS 
conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-
-{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
-echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" 
>&6; }
-if test "${ac_cv_path_GREP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  # Extract the first word of "grep ggrep" to use in msg output
-if test -z "$GREP"; then
-set dummy grep ggrep; ac_prog_name=$2
-if test "${ac_cv_path_GREP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_path_GREP_found=false
-# Loop through the user's path and test for each of PROGNAME-LIST
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_prog in grep ggrep; do
-  for ac_exec_ext in '' $ac_executable_extensions; do
-    ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-    { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
-    # Check for GNU ac_path_GREP and select it if it is found.
-  # Check for GNU $ac_path_GREP
-case `"$ac_path_GREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
-*)
-  ac_count=0
-  echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    echo 'GREP' >> "conftest.nl"
-    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" 
>"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    ac_count=`expr $ac_count + 1`
-    if test $ac_count -gt ${ac_path_GREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_GREP="$ac_path_GREP"
-      ac_path_GREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-
-    $ac_path_GREP_found && break 3
-  done
-done
-
-done
-IFS=$as_save_IFS
-
-
-fi
-
-GREP="$ac_cv_path_GREP"
-if test -z "$GREP"; then
-  { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found 
in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
-echo "$as_me: error: no acceptable $ac_prog_name could be found in 
$PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
-   { (exit 1); exit 1; }; }
+( exit $ac_status )
+cvd_conf_test=0
 fi
-
-else
-  ac_cv_path_GREP=$GREP
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext conftest.$ac_ext
 fi
 
 
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
-echo "${ECHO_T}$ac_cv_path_GREP" >&6; }
- GREP="$ac_cv_path_GREP"
 
 
-{ echo "$as_me:$LINENO: checking for egrep" >&5
-echo $ECHO_N "checking for egrep... $ECHO_C" >&6; }
-if test "${ac_cv_path_EGREP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
-   then ac_cv_path_EGREP="$GREP -E"
+       if test $cvd_conf_test = 1
+       then
+               { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+               ts_success=yes
    else
-     # Extract the first word of "egrep" to use in msg output
-if test -z "$EGREP"; then
-set dummy egrep; ac_prog_name=$2
-if test "${ac_cv_path_EGREP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_path_EGREP_found=false
-# Loop through the user's path and test for each of PROGNAME-LIST
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_prog in egrep; do
-  for ac_exec_ext in '' $ac_executable_extensions; do
-    ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-    { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
-    # Check for GNU ac_path_EGREP and select it if it is found.
-  # Check for GNU $ac_path_EGREP
-case `"$ac_path_EGREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
-*)
-  ac_count=0
-  echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    echo 'EGREP' >> "conftest.nl"
-    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || 
break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    ac_count=`expr $ac_count + 1`
-    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_EGREP="$ac_path_EGREP"
-      ac_path_EGREP_max=$ac_count
+               { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+               CXXFLAGS="$save_CXXFLAGS"
+               ts_success=no
     fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-
-    $ac_path_EGREP_found && break 3
-  done
-done
 
-done
-IFS=$as_save_IFS
 
 
-fi
+########################################
+#
+# Remove -O2 from CXXFLAGS
+#
+CXXFLAGS="$(echo "$CXXFLAGS" | sed -e's/-O2//')"
 
-EGREP="$ac_cv_path_EGREP"
-if test -z "$EGREP"; then
-  { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found 
in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
-echo "$as_me: error: no acceptable $ac_prog_name could be found in 
$PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
-   { (exit 1); exit 1; }; }
-fi
+########################################
+#
+# Extra debugging
+#
 
+# Check whether --with-debug was given.
+if test "${with_debug+set}" = set; then
+  withval=$with_debug; debug="$withval"
 else
-  ac_cv_path_EGREP=$EGREP
+  debug=yes
 fi
 
+if test "$debug" = yes
+then
 
+       if test "" == ""
+       then
+               { echo "$as_me:$LINENO: checking if compiler flag -ggdb works" 
>&5
+echo $ECHO_N "checking if compiler flag -ggdb works... $ECHO_C" >&6; }
+       else
+               { echo "$as_me:$LINENO: checking " >&5
+echo $ECHO_N "checking ... $ECHO_C" >&6; }
    fi
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
-echo "${ECHO_T}$ac_cv_path_EGREP" >&6; }
- EGREP="$ac_cv_path_EGREP"
+       save_CXXFLAGS="$CXXFLAGS"
+       CXXFLAGS="$CXXFLAGS -ggdb"
 
 
-{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; }
-if test "${ac_cv_header_stdc+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+       if test "$cross_compiling" = yes; then
+  { { echo "$as_me:$LINENO: error: cannot run test program while cross 
compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
 else
   cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
+int main(){}
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_link") 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_header_stdc=yes
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cvd_conf_test=1
 else
-  echo "$as_me: failed program was:" >&5
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cv_header_stdc=no
+( exit $ac_status )
+cvd_conf_test=0
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext conftest.$ac_ext
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
-if test $ac_cv_header_stdc = yes; then
-  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <string.h>
 
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "memchr" >/dev/null 2>&1; then
-  :
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
 
+       if test $cvd_conf_test = 1
+       then
+               { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+               ts_success=yes
+       else
+               { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+               CXXFLAGS="$save_CXXFLAGS"
+               ts_success=no
+       fi
+
+elif test "$debug" != no
+then
+       CXXFLAGS="$CXXFLAGS $debug"
 fi
 
-if test $ac_cv_header_stdc = yes; then
-  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdlib.h>
+########################################
+#
+# Position independent code
+#
 
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "free" >/dev/null 2>&1; then
-  :
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
 
-fi
+       if test "" == ""
+       then
+               { echo "$as_me:$LINENO: checking if compiler flag -fPIC works" 
>&5
+echo $ECHO_N "checking if compiler flag -fPIC works... $ECHO_C" >&6; }
+       else
+               { echo "$as_me:$LINENO: checking " >&5
+echo $ECHO_N "checking ... $ECHO_C" >&6; }
+       fi
+       save_CXXFLAGS="$CXXFLAGS"
+       CXXFLAGS="$CXXFLAGS -fPIC"
+
 
-if test $ac_cv_header_stdc = yes; then
-  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
   if test "$cross_compiling" = yes; then
-  :
+  { { echo "$as_me:$LINENO: error: cannot run test program while cross 
compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
 else
   cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <ctype.h>
-#include <stdlib.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
-                  (('a' <= (c) && (c) <= 'i') \
-                    || ('j' <= (c) && (c) <= 'r') \
-                    || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
-  int i;
-  for (i = 0; i < 256; i++)
-    if (XOR (islower (i), ISLOWER (i))
-       || toupper (i) != TOUPPER (i))
-      return 2;
-  return 0;
-}
+int main(){}
 _ACEOF
 rm -f conftest$ac_exeext
 if { (ac_try="$ac_link"
@@ -4169,124 +3581,401 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  :
+  cvd_conf_test=1
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-ac_cv_header_stdc=no
+cvd_conf_test=0
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext conftest.$ac_ext
 fi
 
 
+
+
+       if test $cvd_conf_test = 1
+       then
+               { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+               ts_success=yes
+       else
+               { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+               CXXFLAGS="$save_CXXFLAGS"
+               ts_success=no
+       fi
+
+if test $ts_success == no
+then
+       { echo "$as_me:$LINENO: WARNING: I don't know how to compile position 
independent code." >&5
+echo "$as_me: WARNING: I don't know how to compile position independent code." 
>&2;}
 fi
+
+
+#Host detection
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+  { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" 
>&5
+echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;}
+   { (exit 1); exit 1; }; }
+
+{ echo "$as_me:$LINENO: checking build system type" >&5
+echo $ECHO_N "checking build system type... $ECHO_C" >&6; }
+if test "${ac_cv_build+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+  { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify 
one" >&5
+echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+   { (exit 1); exit 1; }; }
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+  { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub 
$ac_build_alias failed" >&5
+echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" 
>&2;}
+   { (exit 1); exit 1; }; }
+
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6; }
-if test $ac_cv_header_stdc = yes; then
+{ echo "$as_me:$LINENO: result: $ac_cv_build" >&5
+echo "${ECHO_T}$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5
+echo "$as_me: error: invalid value of canonical build" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
 
-cat >>confdefs.h <<\_ACEOF
-#define STDC_HEADERS 1
-_ACEOF
+
+{ echo "$as_me:$LINENO: checking host system type" >&5
+echo $ECHO_N "checking host system type... $ECHO_C" >&6; }
+if test "${ac_cv_host+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "x$host_alias" = x; then
+  ac_cv_host=$ac_cv_build
+else
+  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+    { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias 
failed" >&5
+echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;}
+   { (exit 1); exit 1; }; }
+fi
 
 fi
+{ echo "$as_me:$LINENO: result: $ac_cv_host" >&5
+echo "${ECHO_T}$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5
+echo "$as_me: error: invalid value of canonical host" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
 
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
 
 
+########################################
+#
+# CPU type detection and optimization
+#
+noopt_CXXFLAGS="$CXXFLAGS"
+CXXFLAGS=
+
+
+# Check whether --with-optimize was given.
+if test "${with_optimize+set}" = set; then
+  withval=$with_optimize; optimize=no
+fi
+
 
+# Check whether --with-optimize was given.
+if test "${with_optimize+set}" = set; then
+  withval=$with_optimize; optimize="$withval"
+else
+  optimize=-O3
+fi
 
 
+if test "$optimize" != no
+then
+       { echo "$as_me:$LINENO: checking for best optimize flags" >&5
+echo $ECHO_N "checking for best optimize flags... $ECHO_C" >&6; }
+       { echo "$as_me:$LINENO: result: " >&5
+echo "${ECHO_T}" >&6; }
 
 
+       if test "" == ""
+       then
+               { echo "$as_me:$LINENO: checking if compiler flag -O3 works" >&5
+echo $ECHO_N "checking if compiler flag -O3 works... $ECHO_C" >&6; }
+       else
+               { echo "$as_me:$LINENO: checking " >&5
+echo $ECHO_N "checking ... $ECHO_C" >&6; }
+       fi
+       save_CXXFLAGS="$CXXFLAGS"
+       CXXFLAGS="$CXXFLAGS -O3"
 
 
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
-                 inttypes.h stdint.h unistd.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+       if test "$cross_compiling" = yes; then
+  { { echo "$as_me:$LINENO: error: cannot run test program while cross 
compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
 else
   cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-
-#include <$ac_header>
+int main(){}
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_link") 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  eval "$as_ac_Header=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       eval "$as_ac_Header=no"
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cvd_conf_test=1
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+cvd_conf_test=0
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext conftest.$ac_ext
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+
+       if test $cvd_conf_test = 1
+       then
+               { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+               ts_success=yes
+       else
+               { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+               CXXFLAGS="$save_CXXFLAGS"
+               ts_success=no
+       fi
+
+       if test $ts_success == no
+       then
+               { echo "$as_me:$LINENO: WARNING: I do not know how to switch on 
optimizing for this compiler" >&5
+echo "$as_me: WARNING: I do not know how to switch on optimizing for this 
compiler" >&2;}
+       fi
+
+       { echo "$as_me:$LINENO: checking CPU type" >&5
+echo $ECHO_N "checking CPU type... $ECHO_C" >&6; }
+
+# Check whether --with-cpu was given.
+if test "${with_cpu+set}" = set; then
+  withval=$with_cpu;
 fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+
+
+       if test "$with_cpu" == ""
+       then
+               case "$host" in
+                       *86*linux*)
+                               cpu="`awk '
+               /Pentium III/                                           {print 
"p3";exit}
+               /Intel\(R\) Pentium\(R\) 4/                     {print 
"p4";exit}
+               /Intel\(R\) Pentium\(R\) D/                     {print 
"p4";exit}
+               /Intel\(R\) Pentium\(R\) M/                     {print 
"pM";exit}
+               /Intel\(R\) Core\(TM\)2/                        {print 
"core2";exit}
+               /Intel\(R\) Xeon\(TM\)/                         {print 
"xeon";exit}
+               /Intel\(R\) XEON\(TM\)/                         {print 
"xeon";exit}
+               /AMD Athlon\(tm\) 64 Processor/         {print "athlon64";exit}
+               /AMD Athlon\(tm\)/                                      {print 
"athlon";exit}
+               /AMD Opteron\(tm\)/                                     {print 
"opteron";exit}' /proc/cpuinfo`"
+                       ;;
+                       sparc*)
+                               cpu=sparc
+                               ;;
+               esac
+
+               cpu="${cpu:-unknown}"
+       else
+               cpu="$with_cpu"
+       fi
+
+       { echo "$as_me:$LINENO: result: $cpu" >&5
+echo "${ECHO_T}$cpu" >&6; }
+
+
+       #Find possible lest of compiler flags
+       #FIXME, only GCC is currently supported
+       cpuoptlist="`$AWK '/^'$cpu'/{$1=""; print}' make/march_flags`"
+
+       for mwhat in -march= -mcpu=
+       do
+               for i in $cpuoptlist
+               do
+
+       if test "" == ""
+       then
+               { echo "$as_me:$LINENO: checking if compiler flag $mwhat$i 
works" >&5
+echo $ECHO_N "checking if compiler flag $mwhat$i works... $ECHO_C" >&6; }
+       else
+               { echo "$as_me:$LINENO: checking " >&5
+echo $ECHO_N "checking ... $ECHO_C" >&6; }
+       fi
+       save_CXXFLAGS="$CXXFLAGS"
+       CXXFLAGS="$CXXFLAGS $mwhat$i"
+
+
+       if test "$cross_compiling" = yes; then
+  { { echo "$as_me:$LINENO: error: cannot run test program while cross 
compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+else
+  cat >conftest.$ac_ext <<_ACEOF
+int main(){}
 _ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cvd_conf_test=1
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
+( exit $ac_status )
+cvd_conf_test=0
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext conftest.$ac_ext
 fi
 
-done
 
 
 
-for ac_header in stdio.h
+       if test $cvd_conf_test = 1
+       then
+               { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+               ts_success=yes
+       else
+               { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+               CXXFLAGS="$save_CXXFLAGS"
+               ts_success=no
+       fi
+
+                       if test $ts_success == yes
+                       then
+                               break 2
+                       fi
+               done
+       done
+
+       if test $ts_success == no
+       then
+               { echo "$as_me:$LINENO: WARNING: I do not know what the best 
flags are for this processor ($cpu)." >&5
+echo "$as_me: WARNING: I do not know what the best flags are for this 
processor ($cpu)." >&2;}
+       fi
+fi
+OFLAGS="$CXXFLAGS"
+CXXFLAGS="$noopt_CXXFLAGS"
+
+################################################################################
+#
+# Processor/Platform specific parts
+#
+
+echo
+echo ------------------------------------
+echo Checking processor specific features
+echo ------------------------------------
+echo
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+                 inttypes.h stdint.h unistd.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
 else
-  # Is the header compilable?
-{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 $ac_includes_default
+
 #include <$ac_header>
 _ACEOF
 rm -f conftest.$ac_objext
@@ -4306,317 +3995,147 @@
         test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  ac_header_compiler=yes
+  eval "$as_ac_Header=yes"
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_header_compiler=no
+       eval "$as_ac_Header=no"
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
 
-# Is the header present?
-{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+fi
+
+done
+
+
+{ echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5
+echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6; }
+if test "${ac_cv_c_bigendian+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  # See if sys/param.h defines the BYTE_ORDER macro.
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <$ac_header>
+#include <sys/types.h>
+#include <sys/param.h>
+
+int
+main ()
+{
+#if  ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \
+       && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN)
+ bogus endian macros
+#endif
+
+  ;
+  return 0;
+}
 _ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+  (exit $ac_status); } && {
+        test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
-       }; then
-  ac_header_preproc=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+       } && test -s conftest.$ac_objext; then
+  # It does; now see whether it defined to BIG_ENDIAN or not.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <sys/param.h>
 
-  ac_header_preproc=no
-fi
+int
+main ()
+{
+#if BYTE_ORDER != BIG_ENDIAN
+ not big endian
+#endif
 
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in
-  yes:no: )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, 
rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the 
preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the 
compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
-    ac_header_preproc=yes
-    ;;
-  no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be 
compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing 
prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header:     check for missing prerequisite 
headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf 
documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But 
Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be 
Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the 
preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" 
>&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler 
will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take 
precedence" >&2;}
-
-    ;;
-esac
-{ echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  eval "$as_ac_Header=\$ac_header_preproc"
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+  ;
+  return 0;
+}
 _ACEOF
-
-fi
-
-done
-
-
-##################################################
-#
-# Cpu type detection and optimization
-#
-
-#Host detection
-ac_aux_dir=
-for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
-  if test -f "$ac_dir/install-sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install-sh -c"
-    break
-  elif test -f "$ac_dir/install.sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install.sh -c"
-    break
-  elif test -f "$ac_dir/shtool"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/shtool install -c"
-    break
-  fi
-done
-if test -z "$ac_aux_dir"; then
-  { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in 
\"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5
-echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" 
\"$srcdir/..\" \"$srcdir/../..\"" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-# These three variables are undocumented and unsupported,
-# and are intended to be withdrawn in a future Autoconf release.
-# They can cause serious problems if a builder's source tree is in a directory
-# whose full name contains unusual characters.
-ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
-ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
-ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
-
-
-# Make sure we can run config.sub.
-$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
-  { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" 
>&5
-echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;}
-   { (exit 1); exit 1; }; }
-
-{ echo "$as_me:$LINENO: checking build system type" >&5
-echo $ECHO_N "checking build system type... $ECHO_C" >&6; }
-if test "${ac_cv_build+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_build_alias=$build_alias
-test "x$ac_build_alias" = x &&
-  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
-test "x$ac_build_alias" = x &&
-  { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify 
one" >&5
-echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
-   { (exit 1); exit 1; }; }
-ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
-  { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub 
$ac_build_alias failed" >&5
-echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" 
>&2;}
-   { (exit 1); exit 1; }; }
-
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_build" >&5
-echo "${ECHO_T}$ac_cv_build" >&6; }
-case $ac_cv_build in
-*-*-*) ;;
-*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5
-echo "$as_me: error: invalid value of canonical build" >&2;}
-   { (exit 1); exit 1; }; };;
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
 esac
-build=$ac_cv_build
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_build
-shift
-build_cpu=$1
-build_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-build_os=$*
-IFS=$ac_save_IFS
-case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
-
-
-{ echo "$as_me:$LINENO: checking host system type" >&5
-echo $ECHO_N "checking host system type... $ECHO_C" >&6; }
-if test "${ac_cv_host+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test "x$host_alias" = x; then
-  ac_cv_host=$ac_cv_build
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_c_bigendian=yes
 else
-  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
-    { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias 
failed" >&5
-echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_host" >&5
-echo "${ECHO_T}$ac_cv_host" >&6; }
-case $ac_cv_host in
-*-*-*) ;;
-*) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5
-echo "$as_me: error: invalid value of canonical host" >&2;}
-   { (exit 1); exit 1; }; };;
-esac
-host=$ac_cv_host
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_host
-shift
-host_cpu=$1
-host_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-host_os=$*
-IFS=$ac_save_IFS
-case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
-
-
-
-
-#Custom host CPU detection
-{ echo "$as_me:$LINENO: checking CPU type" >&5
-echo $ECHO_N "checking CPU type... $ECHO_C" >&6; }
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-# Check whether --with-cpu was given.
-if test "${with_cpu+set}" = set; then
-  withval=$with_cpu;
+       ac_cv_c_bigendian=no
 fi
 
-if test "$with_cpu" == ""
-then
-       case "$host" in
-               *86*linux*)
-                       cpu="`awk '
-       /Pentium III/                                           {print 
"p3";exit}
-       /Intel\(R\) Pentium\(R\) 4/                     {print "p4";exit}
-       /Intel\(R\) Pentium\(R\) D/                     {print "p4";exit}
-       /Intel\(R\) Pentium\(R\) M/                     {print "pM";exit}
-       /Intel\(R\) Core\(TM\)2/                        {print "core2";exit}
-       /Intel\(R\) Xeon\(TM\)/                         {print "xeon";exit}
-       /Intel\(R\) XEON\(TM\)/                         {print "xeon";exit}
-       /AMD Athlon\(tm\) 64 Processor/         {print "athlon64";exit}
-       /AMD Athlon\(tm\)/                                      {print 
"athlon";exit}
-       /AMD Opteron\(tm\)/                                     {print 
"opteron";exit}' /proc/cpuinfo`"
-               ;;
-               sparc*)
-                       cpu=sparc
-                       ;;
-       esac
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 else
-       cpu="$with_cpu"
-fi
-
-{ echo "$as_me:$LINENO: result: $cpu" >&5
-echo "${ECHO_T}$cpu" >&6; }
-
-
-# Check whether --with-simd was given.
-if test "${with_simd+set}" = set; then
-  withval=$with_simd;
-fi
-
-
-if test "$with_simd" != "no"
-then
-       case "$host" in
-               *86*linux*)
-                       simd_possible_options="sse2 sse mmxext mmx"
-                       simd_options=
-
-                       for dummyvar in 1
-                       do
-
-                               save_CPPFLAGS="$CPPFLAGS"
-
-
-# Check whether --with-mmx was given.
-if test "${with_mmx+set}" = set; then
-  withval=$with_mmx;
-fi
-
-                               if test "$with_mmx" != yes && test "$with_mmx" 
!= no
-                               then
-                                       save_CXXFLAGS="$CXXFLAGS"
-                                       CXXFLAGS="$CXXFLAGS -mmmx"
-                                       CPPFLAGS="$CPPFLAGS -mmmx"
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-for ac_header in mmintrin.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  { echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-else
-  # Is the header compilable?
-{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
+       # It does not; compile a test program.
+if test "$cross_compiling" = yes; then
+  # try to guess the endianness by grepping values into an object file
+  ac_cv_c_bigendian=unknown
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-$ac_includes_default
-#include <$ac_header>
+short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
+short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
+void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; }
+short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
+short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
+void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; }
+int
+main ()
+{
+ _ascii (); _ebcdic ();
+  ;
+  return 0;
+}
 _ACEOF
 rm -f conftest.$ac_objext
 if { (ac_try="$ac_compile"
@@ -4635,105 +4154,180 @@
         test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  ac_header_compiler=yes
+  if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then
+  ac_cv_c_bigendian=yes
+fi
+if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
+  if test "$ac_cv_c_bigendian" = unknown; then
+    ac_cv_c_bigendian=no
+  else
+    # finding both strings is unlikely to happen, but who knows?
+    ac_cv_c_bigendian=unknown
+  fi
+fi
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_header_compiler=no
+
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
+else
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <$ac_header>
+$ac_includes_default
+int
+main ()
+{
+
+  /* Are we little or big endian?  From Harbison&Steele.  */
+  union
+  {
+    long int l;
+    char c[sizeof (long int)];
+  } u;
+  u.l = 1;
+  return u.c[sizeof (long int) - 1] == 1;
+
+  ;
+  return 0;
+}
 _ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  (eval "$ac_link") 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       }; then
-  ac_header_preproc=yes
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_c_bigendian=no
 else
-  echo "$as_me: failed program was:" >&5
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-  ac_header_preproc=no
+( exit $ac_status )
+ac_cv_c_bigendian=yes
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext conftest.$ac_ext
 fi
 
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
 
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in
-  yes:no: )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, 
rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the 
preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the 
compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
-    ac_header_preproc=yes
-    ;;
-  no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be 
compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing 
prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header:     check for missing prerequisite 
headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf 
documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But 
Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be 
Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the 
preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" 
>&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler 
will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take 
precedence" >&2;}
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5
+echo "${ECHO_T}$ac_cv_c_bigendian" >&6; }
+case $ac_cv_c_bigendian in
+  yes)
 
+cat >>confdefs.h <<\_ACEOF
+#define WORDS_BIGENDIAN 1
+_ACEOF
+ ;;
+  no)
     ;;
+  *)
+    { { echo "$as_me:$LINENO: error: unknown endianness
+presetting ac_cv_c_bigendian=no (or yes) will help" >&5
+echo "$as_me: error: unknown endianness
+presetting ac_cv_c_bigendian=no (or yes) will help" >&2;}
+   { (exit 1); exit 1; }; } ;;
 esac
-{ echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+
+
+if test x$ac_cv_c_bigendian = xno
+then
+       cat >>confdefs.h <<\_ACEOF
+#define CVD_ARCH_LITTLE_ENDIAN 1
+_ACEOF
+
 else
-  eval "$as_ac_Header=\$ac_header_preproc"
+       cat >>confdefs.h <<\_ACEOF
+#define CVD_ARCH_BIG_ENDIAN 1
+_ACEOF
+
+fi
+
+
+
+
+# Check whether --with-simd was given.
+if test "${with_simd+set}" = set; then
+  withval=$with_simd;
+fi
+
+
+# Check whether --with-mmx was given.
+if test "${with_mmx+set}" = set; then
+  withval=$with_mmx;
 fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
 
+
+# Check whether --with-mmxext was given.
+if test "${with_mmxext+set}" = set; then
+  withval=$with_mmxext;
+fi
+
+
+# Check whether --with-sse was given.
+if test "${with_sse+set}" = set; then
+  withval=$with_sse;
 fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
 
+
+# Check whether --with-sse2 was given.
+if test "${with_sse2+set}" = set; then
+  withval=$with_sse2;
 fi
 
-done
 
+case "$host" in
+       *86*)
+               have_x86=yes
+
+               simd_all_options="mmx mmxext sse sse2 sse3"
+
+
+       if test "$with_simd" != no
+       then
+               if test "$with_MMX" == "yes"
+               then
+                       have_MMX=yes
+               elif test "$with_MMX" != "no"
+               then
+
+       if test "for MMX support" == ""
+       then
+               { echo "$as_me:$LINENO: checking if compiler flag -mmmx works" 
>&5
+echo $ECHO_N "checking if compiler flag -mmmx works... $ECHO_C" >&6; }
+       else
                                        { echo "$as_me:$LINENO: checking for 
MMX support" >&5
 echo $ECHO_N "checking for MMX support... $ECHO_C" >&6; }
+       fi
+       save_CXXFLAGS="$CXXFLAGS"
+       CXXFLAGS="$CXXFLAGS -mmmx"
+
+
                                        if test "$cross_compiling" = yes; then
   { { echo "$as_me:$LINENO: error: cannot run test program while cross 
compiling
 See \`config.log' for more details." >&5
@@ -4772,196 +4366,270 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  mmx=yes
+  cvd_conf_test=1
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-mmx=no
+cvd_conf_test=0
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext conftest.$ac_ext
 fi
 
 
-                                       { echo "$as_me:$LINENO: result: $mmx" 
>&5
-echo "${ECHO_T}$mmx" >&6; }
+
+
+       if test $cvd_conf_test = 1
+       then
+               { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+               ts_success=yes
                                else
-                                       mmx="$with_mmx"
+               { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+               CXXFLAGS="$save_CXXFLAGS"
+               ts_success=no
+       fi
+
+                       have_MMX="$ts_success"
                                fi
 
-                               if test $mmx = no
+               if test "$have_MMX" == yes
                                then
-                                       CXXFLAGS="$save_CXXFLAGS"
-                                       break
-                               else
                                        cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_MMINTRIN 1
+#define CVD_HAVE_MMX 1
 _ACEOF
 
                                        have_mmx=yes
 
                                        simd_options="$simd_options mmx"
                                fi
+       fi
 
 
+       if test "$with_simd" != no
+       then
+               if test "$with_MMXEXT" == "yes"
+               then
+                       have_MMXEXT=yes
+               elif test "$with_MMXEXT" != "no"
+               then
 
-                               #MMXEXT is pretty muxh the intersection of SSE 
nad 3Dnow!
-                               #and includes pshufw, movnta and prefetchnta
+       if test "for MMXEXT support" == ""
+       then
+               { echo "$as_me:$LINENO: checking if compiler flag -msse works" 
>&5
+echo $ECHO_N "checking if compiler flag -msse works... $ECHO_C" >&6; }
+       else
+               { echo "$as_me:$LINENO: checking for MMXEXT support" >&5
+echo $ECHO_N "checking for MMXEXT support... $ECHO_C" >&6; }
+       fi
                                save_CXXFLAGS="$CXXFLAGS"
                                CXXFLAGS="$CXXFLAGS -msse"
-                               CPPFLAGS="$CPPFLAGS -msse"
-
-# Check whether --with-mmxext was given.
-if test "${with_mmxext+set}" = set; then
-  withval=$with_mmxext;
-fi
 
-                               if test "$with_mmxext" != yes && test 
"$with_mmxext" != no
-                               then
 
-for ac_header in xmmintrin.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  { echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
+       if test "$cross_compiling" = yes; then
+  { { echo "$as_me:$LINENO: error: cannot run test program while cross 
compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
 else
-  # Is the header compilable?
-{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-#include <$ac_header>
+  cat >conftest.$ac_ext <<_ACEOF
+
+                       #include <xmmintrin.h>
+                       int main()
+                       {
+                               __m64 a;
+                               a = _mm_setzero_si64();
+                               a = _mm_shuffle_pi16(a, 0);
+                       return 0;}
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_link") 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_header_compiler=yes
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cvd_conf_test=1
 else
-  echo "$as_me: failed program was:" >&5
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_header_compiler=no
+( exit $ac_status )
+cvd_conf_test=0
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext conftest.$ac_ext
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
 
-# Is the header present?
-{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
+
+
+       if test $cvd_conf_test = 1
+       then
+               { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+               ts_success=yes
+       else
+               { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+               CXXFLAGS="$save_CXXFLAGS"
+               ts_success=no
+       fi
+
+                       have_MMXEXT="$ts_success"
+               fi
+
+               if test "$have_MMXEXT" == yes
+               then
+                       cat >>confdefs.h <<\_ACEOF
+#define CVD_HAVE_MMXEXT 1
 _ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <$ac_header>
+
+                       have_mmxext=yes
+
+                       simd_options="$simd_options mmxext"
+               fi
+       fi
+
+
+       if test "$with_simd" != no
+       then
+               if test "$with_SSE" == "yes"
+               then
+                       have_SSE=yes
+               elif test "$with_SSE" != "no"
+               then
+
+       if test "for SSE support" == ""
+       then
+               { echo "$as_me:$LINENO: checking if compiler flag -msse works" 
>&5
+echo $ECHO_N "checking if compiler flag -msse works... $ECHO_C" >&6; }
+       else
+               { echo "$as_me:$LINENO: checking for SSE support" >&5
+echo $ECHO_N "checking for SSE support... $ECHO_C" >&6; }
+       fi
+       save_CXXFLAGS="$CXXFLAGS"
+       CXXFLAGS="$CXXFLAGS -msse"
+
+
+       if test "$cross_compiling" = yes; then
+  { { echo "$as_me:$LINENO: error: cannot run test program while cross 
compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+else
+  cat >conftest.$ac_ext <<_ACEOF
+
+                       #include <xmmintrin.h>
+                       int main()
+                       {
+                               __m128 a;
+                               a = _mm_setzero_ps();
+                               a = _mm_add_ps(a, a);
+                               return 0;
+                       }
 _ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  (eval "$ac_link") 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       }; then
-  ac_header_preproc=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in
-  yes:no: )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, 
rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the 
preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the 
compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
-    ac_header_preproc=yes
-    ;;
-  no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be 
compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing 
prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header:     check for missing prerequisite 
headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf 
documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But 
Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be 
Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the 
preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" 
>&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler 
will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take 
precedence" >&2;}
-
-    ;;
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
 esac
-{ echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cvd_conf_test=1
 else
-  eval "$as_ac_Header=\$ac_header_preproc"
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
+( exit $ac_status )
+cvd_conf_test=0
 fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+
+
+       if test $cvd_conf_test = 1
+       then
+               { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+               ts_success=yes
+       else
+               { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+               CXXFLAGS="$save_CXXFLAGS"
+               ts_success=no
+       fi
+
+                       have_SSE="$ts_success"
+               fi
+
+               if test "$have_SSE" == yes
+               then
+                       cat >>confdefs.h <<\_ACEOF
+#define CVD_HAVE_SSE 1
 _ACEOF
 
-fi
+                       have_sse=yes
+
+                       simd_options="$simd_options sse"
+               fi
+       fi
+
+
+       if test "$with_simd" != no
+       then
+               if test "$with_SSE2" == "yes"
+               then
+                       have_SSE2=yes
+               elif test "$with_SSE2" != "no"
+               then
+
+       if test "for SSE2 support" == ""
+       then
+               { echo "$as_me:$LINENO: checking if compiler flag -msse2 works" 
>&5
+echo $ECHO_N "checking if compiler flag -msse2 works... $ECHO_C" >&6; }
+       else
+               { echo "$as_me:$LINENO: checking for SSE2 support" >&5
+echo $ECHO_N "checking for SSE2 support... $ECHO_C" >&6; }
+       fi
+       save_CXXFLAGS="$CXXFLAGS"
+       CXXFLAGS="$CXXFLAGS -msse2"
 
-done
 
-                                       { echo "$as_me:$LINENO: checking for 
MMXEXT support" >&5
-echo $ECHO_N "checking for MMXEXT support... $ECHO_C" >&6; }
                                        if test "$cross_compiling" = yes; then
   { { echo "$as_me:$LINENO: error: cannot run test program while cross 
compiling
 See \`config.log' for more details." >&5
@@ -4971,12 +4639,12 @@
 else
   cat >conftest.$ac_ext <<_ACEOF
 
-                                               #include <xmmintrin.h>
+                       #include <emmintrin.h>
                                                int main()
                                                {
-                                                       __m64 a;
-                                                       a = _mm_setzero_si64();
-                                                       a = _mm_shuffle_pi16(a, 
0);
+                               __m128d a;
+                               a = _mm_setzero_pd();
+                               a = _mm_add_pd(a, a);
                                                        return 0;
                                                }
 _ACEOF
@@ -5000,53 +4668,69 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  mmxext=yes
+  cvd_conf_test=1
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-mmxext=no
+cvd_conf_test=0
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext conftest.$ac_ext
 fi
 
 
-                                       { echo "$as_me:$LINENO: result: 
$mmxext" >&5
-echo "${ECHO_T}$mmxext" >&6; }
-                               else
-                                       mmxext="$with_mmxext"
-                               fi
 
-                               if test $mmxext = no
+
+       if test $cvd_conf_test = 1
                                then
-                                       CXXFLAGS="$save_CXXFLAGS"
-                                       break
+               { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+               ts_success=yes
                                else
-                                       cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_XMMINTRIN 1
-_ACEOF
+               { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+               CXXFLAGS="$save_CXXFLAGS"
+               ts_success=no
+       fi
+
+                       have_SSE2="$ts_success"
+               fi
 
+               if test "$have_SSE2" == yes
+               then
                                        cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_MMXEXT 1
+#define CVD_HAVE_SSE2 1
 _ACEOF
 
-                                       have_mmxext=yes
+                       have_sse2=yes
 
-                                       simd_options="$simd_options mmxext"
+                       simd_options="$simd_options sse2"
+               fi
                                fi
 
 
-# Check whether --with-sse was given.
-if test "${with_sse+set}" = set; then
-  withval=$with_sse;
-fi
+       if test "$with_simd" != no
+       then
+               if test "$with_SSE3" == "yes"
+               then
+                       have_SSE3=yes
+               elif test "$with_SSE3" != "no"
+               then
 
-                               if test "$with_sse" != yes && test "$with_sse" 
!= no
+       if test "for SSE3 support" == ""
                                then
-                                       { echo "$as_me:$LINENO: checking for 
SSE support" >&5
-echo $ECHO_N "checking for SSE support... $ECHO_C" >&6; }
+               { echo "$as_me:$LINENO: checking if compiler flag -msse3 works" 
>&5
+echo $ECHO_N "checking if compiler flag -msse3 works... $ECHO_C" >&6; }
+       else
+               { echo "$as_me:$LINENO: checking for SSE3 support" >&5
+echo $ECHO_N "checking for SSE3 support... $ECHO_C" >&6; }
+       fi
+       save_CXXFLAGS="$CXXFLAGS"
+       CXXFLAGS="$CXXFLAGS -msse3"
+
+
                                        if test "$cross_compiling" = yes; then
   { { echo "$as_me:$LINENO: error: cannot run test program while cross 
compiling
 See \`config.log' for more details." >&5
@@ -5056,13 +4740,13 @@
 else
   cat >conftest.$ac_ext <<_ACEOF
 
-                                               #include <xmmintrin.h>
+                       #include <pmmintrin.h>
                                                int main()
-                                               {
-                                                       __m128 a;
-                                                       a = _mm_setzero_ps();
-                                                       a = _mm_add_ps(a, a);
-                                                       return 0;
+                       { fuk;
+                               __m128d a;
+                               a = _mm_setzero_pd();
+                               a = _mm_hadd_ps(a, a);
+                               return 1;
                                                }
 _ACEOF
 rm -f conftest$ac_exeext
@@ -5085,78 +4769,223 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  sse=yes
+  cvd_conf_test=1
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-sse=no
+cvd_conf_test=0
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext conftest.$ac_ext
 fi
 
 
-                                       { echo "$as_me:$LINENO: result: $sse" 
>&5
-echo "${ECHO_T}$sse" >&6; }
-                               else
-                                       sse="$with_sse"
-                               fi
 
-                               if test $sse = no
+
+       if test $cvd_conf_test = 1
                                then
-                                       break
+               { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+               ts_success=yes
                                else
-                                       have_sse=yes
+               { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+               CXXFLAGS="$save_CXXFLAGS"
+               ts_success=no
+       fi
+
+                       have_SSE3="$ts_success"
+               fi
 
+               if test "$have_SSE3" == yes
+               then
                                        cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_SSE 1
+#define CVD_HAVE_SSE3 1
 _ACEOF
 
-                                       simd_options="$simd_options sse"
-                               fi
+                       have_sse3=yes
 
+                       simd_options="$simd_options sse3"
+               fi
+       fi
+               ;;
+esac
 
+{ echo "$as_me:$LINENO: checking for void*" >&5
+echo $ECHO_N "checking for void*... $ECHO_C" >&6; }
+if test "${ac_cv_type_voidp+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+typedef void* ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+  return 0;
+if (sizeof (ac__type_new_))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_type_voidp=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
+       ac_cv_type_voidp=no
+fi
 
-                               save_CXXFLAGS="$CXXFLAGS"
-                               CXXFLAGS="$CXXFLAGS -msse2"
-                               CPPFLAGS="$CPPFLAGS -msse2"
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_type_voidp" >&5
+echo "${ECHO_T}$ac_cv_type_voidp" >&6; }
 
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ echo "$as_me:$LINENO: checking size of void*" >&5
+echo $ECHO_N "checking size of void*... $ECHO_C" >&6; }
+if test "${ac_cv_sizeof_voidp+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$cross_compiling" = yes; then
+  # Depending upon the size, compute the lo and hi bounds.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+   typedef void* ac__type_sizeof_;
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 
0)];
+test_array [0] = 0
 
-# Check whether --with-sse2 was given.
-if test "${with_sse2+set}" = set; then
-  withval=$with_sse2;
-fi
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_lo=0 ac_mid=0
+  while :; do
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+   typedef void* ac__type_sizeof_;
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= 
$ac_mid)];
+test_array [0] = 0
 
-                               if test "$with_sse2" != yes && test 
"$with_sse2" != no
-                               then
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_hi=$ac_mid; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-for ac_header in emmintrin.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  { echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+       ac_lo=`expr $ac_mid + 1`
+                       if test $ac_lo -le $ac_mid; then
+                         ac_lo= ac_hi=
+                         break
+                       fi
+                       ac_mid=`expr 2 '*' $ac_mid + 1`
 fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
 else
-  # Is the header compilable?
-{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 $ac_includes_default
-#include <$ac_header>
+   typedef void* ac__type_sizeof_;
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 
0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
 _ACEOF
 rm -f conftest.$ac_objext
 if { (ac_try="$ac_compile"
@@ -5175,534 +5004,314 @@
         test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  ac_header_compiler=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
+  ac_hi=-1 ac_mid=-1
+  while :; do
+    cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <$ac_header>
+$ac_includes_default
+   typedef void* ac__type_sizeof_;
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 
$ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
 _ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+  (exit $ac_status); } && {
+        test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
-       }; then
-  ac_header_preproc=yes
+       } && test -s conftest.$ac_objext; then
+  ac_lo=$ac_mid; break
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-  ac_header_preproc=no
+       ac_hi=`expr '(' $ac_mid ')' - 1`
+                       if test $ac_mid -le $ac_hi; then
+                         ac_lo= ac_hi=
+                         break
+                       fi
+                       ac_mid=`expr 2 '*' $ac_mid`
 fi
 
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in
-  yes:no: )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, 
rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the 
preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the 
compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
-    ac_header_preproc=yes
-    ;;
-  no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be 
compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing 
prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header:     check for missing prerequisite 
headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf 
documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But 
Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be 
Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the 
preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" 
>&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler 
will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take 
precedence" >&2;}
-
-    ;;
-esac
-{ echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
 else
-  eval "$as_ac_Header=\$ac_header_preproc"
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
+       ac_lo= ac_hi=
 fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
 
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 
-done
-
-                                       { echo "$as_me:$LINENO: checking for 
SSE2 support" >&5
-echo $ECHO_N "checking for SSE2 support... $ECHO_C" >&6; }
-                                       if test "$cross_compiling" = yes; then
-  { { echo "$as_me:$LINENO: error: cannot run test program while cross 
compiling
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-else
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+  ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
   cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+   typedef void* ac__type_sizeof_;
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= 
$ac_mid)];
+test_array [0] = 0
 
-                                               #include <emmintrin.h>
-                                               int main()
-                                               {
-                                                       __m128d a;
-                                                       a = _mm_setzero_pd();
-                                                       a = _mm_add_pd(a, a);
+  ;
                                                        return 0;
-                                               }
+}
 _ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_try") 2>&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  sse2=yes
+  (exit $ac_status); } && {
+        test -z "$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_hi=$ac_mid
 else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
+  echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-( exit $ac_status )
-sse2=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext conftest.$ac_ext
+       ac_lo=`expr '(' $ac_mid ')' + 1`
 fi
 
-
-                                       { echo "$as_me:$LINENO: result: $sse2" 
>&5
-echo "${ECHO_T}$sse2" >&6; }
-                               else
-                                       sse2="$with_sse2"
-                               fi
-
-                               if test $sse2 = no
-                               then
-                                       CXXFLAGS="$save_CXXFLAGS"
-                                       break
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in
+?*) ac_cv_sizeof_voidp=$ac_lo;;
+'') if test "$ac_cv_type_voidp" = yes; then
+     { { echo "$as_me:$LINENO: error: cannot compute sizeof (void*)
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (void*)
+See \`config.log' for more details." >&2;}
+   { (exit 77); exit 77; }; }
                                else
-                                       have_sse2=yes
-
-                                       cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_SSE2 1
-_ACEOF
-
-                                       cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_EMMINTRIN 1
-_ACEOF
-
-                                       simd_options="$simd_options sse2"
-                               fi
-                       done
-
-                       CPPFLAGS="$save_CPPFLAGS"
-
-
-                       #Also check whether we have a 64-bit processor
-                       #(since some Pentium 4s have EM64T, and some don't)
-                       #At least AMD name their processors with x86_64 
something different!
-                       { echo "$as_me:$LINENO: checking for 64-bit extensions" 
>&5
-echo $ECHO_N "checking for 64-bit extensions... $ECHO_C" >&6; }
-                       if grep -q lm /proc/cpuinfo
-                       then
-                               { echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
-                               have_64bit=yes
-
-                               cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_64BIT 1
+     ac_cv_sizeof_voidp=0
+   fi ;;
+esac
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
 _ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+   typedef void* ac__type_sizeof_;
+static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); }
+static unsigned long int ulongval () { return (long int) (sizeof 
(ac__type_sizeof_)); }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
 
-                               # Append _64 onto the CPU name so that we can 
look up the right flags
-                               # if it is a pentuim 4
-                               cpu=$cpu"_64"
-                       else
-                               { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-                               bit64=""
-                       fi
-
-               ;;
-       esac
-fi
-
-if test "$cpu" == ""
-then
-       cpu=Unknown
-fi
-
-
-
-# Check whether --with-optimize was given.
-if test "${with_optimize+set}" = set; then
-  withval=$with_optimize; optimize=no
-fi
-
-
-# Check whether --with-optimize was given.
-if test "${with_optimize+set}" = set; then
-  withval=$with_optimize; optimize="$withval"
-fi
-
-
-if test "$optimize" != no
-then
-       if test "$optimize" != ""
-       then
-               OFLAGS="$optimize"
-       elif test "$ac_cv_cxx_compiler_gnu" = yes
-       then
-               { echo "$as_me:$LINENO: checking for best optimize flags" >&5
-echo $ECHO_N "checking for best optimize flags... $ECHO_C" >&6; }
-               { echo "$as_me:$LINENO: result: " >&5
-echo "${ECHO_T}" >&6; }
-
-               #Find possible lest of compiler flags
-               #FIXME, only GCC is currently supported
-               cpuoptlist="`$AWK '/^'$cpu'/{$1=""; print}' make/march_flags`"
-
-               #Test list in order to find the best compiler option
-               save_CXXFLAGS="$CXXFLAGS"
-               for mwhat in -march= -mcpu=
-               do
-                       for i in $cpuoptlist
-                       do
-                               i="$mwhat$i"
-                               { echo "$as_me:$LINENO: checking $CXX supports 
$i" >&5
-echo $ECHO_N "checking $CXX supports $i... $ECHO_C" >&6; }
+  FILE *f = fopen ("conftest.val", "w");
+  if (! f)
+    return 1;
+  if (((long int) (sizeof (ac__type_sizeof_))) < 0)
+    {
+      long int i = longval ();
+      if (i != ((long int) (sizeof (ac__type_sizeof_))))
+       return 1;
+      fprintf (f, "%ld\n", i);
+    }
+  else
+    {
+      unsigned long int i = ulongval ();
+      if (i != ((long int) (sizeof (ac__type_sizeof_))))
+       return 1;
+      fprintf (f, "%lu\n", i);
+    }
+  return ferror (f) || fclose (f) != 0;
 
-                               CXXFLAGS="$save_CXXFLAGS $i"
-                               cat >conftest.$ac_ext <<_ACEOF
-int main(){}
+  ;
+  return 0;
+}
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_link") 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  a=1
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_sizeof_voidp=`cat conftest.val`
 else
-  echo "$as_me: failed program was:" >&5
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       a=0
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-                               if test $a = 1
-                               then
-                                       { echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
-                                       cpuopt=$i
-                                       break 2
-                               else
-                                       { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-                               fi
-                       done
-               done
-               CXXFLAGS="$save_CXXFLAGS"
-
-
-               opt="-O3 $cpuopt"
-               if test "$cpuopt" = ""
-               then
-                       { echo "$as_me:$LINENO: WARNING: I do not know what the 
best flags are for this processor ($cpu)." >&5
-echo "$as_me: WARNING: I do not know what the best flags are for this 
processor ($cpu)." >&2;}
-               fi
-               OFLAGS="$opt"
+( exit $ac_status )
+if test "$ac_cv_type_voidp" = yes; then
+     { { echo "$as_me:$LINENO: error: cannot compute sizeof (void*)
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (void*)
+See \`config.log' for more details." >&2;}
+   { (exit 77); exit 77; }; }
        else
-               { echo "$as_me:$LINENO: WARNING: I do not know how to switch on 
optimizing for this compiler" >&5
-echo "$as_me: WARNING: I do not know how to switch on optimizing for this 
compiler" >&2;}
+     ac_cv_sizeof_voidp=0
        fi
 fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.val
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_voidp" >&5
+echo "${ECHO_T}$ac_cv_sizeof_voidp" >&6; }
 
-OFLAGS=$OFLAGS
 
 
-# Find a good install program.  We prefer a C program (faster),
-# so one script is as good as another.  But avoid the broken or
-# incompatible versions:
-# SysV /etc/install, /usr/sbin/install
-# SunOS /usr/etc/install
-# IRIX /sbin/install
-# AIX /bin/install
-# AmigaOS /C/install, which installs bootblocks on floppy discs
-# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
-# AFS /usr/afsws/bin/install, which mishandles nonexistent args
-# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
-# OS/2's system install, which has a completely different semantic
-# ./install, which can be erroneously created by make from ./install.sh.
-{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
-echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; }
-if test -z "$INSTALL"; then
-if test "${ac_cv_path_install+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  # Account for people who put trailing slashes in PATH elements.
-case $as_dir/ in
-  ./ | .// | /cC/* | \
-  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
-  ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
-  /usr/ucb/* ) ;;
-  *)
-    # OSF1 and SCO ODT 3.0 have their own names for install.
-    # Don't use installbsd from OSF since it installs stuff as root
-    # by default.
-    for ac_prog in ginstall scoinst install; do
-      for ac_exec_ext in '' $ac_executable_extensions; do
-       if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x 
"$as_dir/$ac_prog$ac_exec_ext"; }; then
-         if test $ac_prog = install &&
-           grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
-           # AIX install.  It has an incompatible calling convention.
-           :
-         elif test $ac_prog = install &&
-           grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
-           # program-specific install script used by HP pwplus--don't use.
-           :
-         else
-           ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
-           break 3
-         fi
-       fi
-      done
-    done
-    ;;
-esac
-done
-IFS=$as_save_IFS
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_VOIDP $ac_cv_sizeof_voidp
+_ACEOF
 
 
-fi
-  if test "${ac_cv_path_install+set}" = set; then
-    INSTALL=$ac_cv_path_install
-  else
-    # As a last resort, use the slow shell script.  Don't cache a
-    # value for INSTALL within a source directory, because that will
-    # break other packages using the cache if that directory is
-    # removed, or if the value is a relative name.
-    INSTALL=$ac_install_sh
-  fi
-fi
-{ echo "$as_me:$LINENO: result: $INSTALL" >&5
-echo "${ECHO_T}$INSTALL" >&6; }
+if test "$ac_cv_sizeof_voidp" == 4
+then
+       have_32bit=yes
 
-# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
-# It thinks the first close brace ends the variable substitution.
-test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+fi
 
-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+################################################################################
+#
+# Operating system specific parts
+#
 
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+########################################
+#
+# An OSX specific hack to get at stuff in /sw automatically
+#
 
-{ echo "$as_me:$LINENO: checking whether ln -s works" >&5
-echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6; }
-LN_S=$as_ln_s
-if test "$LN_S" = "ln -s"; then
-  { echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
-else
-  { echo "$as_me:$LINENO: result: no, using $LN_S" >&5
-echo "${ECHO_T}no, using $LN_S" >&6; }
-fi
+echo
+echo -----------------------------------------------
+echo Checking for operating system specific features
+echo -----------------------------------------------
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a 
program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_RANLIB+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$RANLIB"; then
-  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x 
"$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-IFS=$as_save_IFS
 
-fi
-fi
-RANLIB=$ac_cv_prog_RANLIB
-if test -n "$RANLIB"; then
-  { echo "$as_me:$LINENO: result: $RANLIB" >&5
-echo "${ECHO_T}$RANLIB" >&6; }
-else
-  { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
+# Check whether --with-dvbuffer was given.
+if test "${with_dvbuffer+set}" = set; then
+  withval=$with_dvbuffer;
 fi
 
 
-fi
-if test -z "$ac_cv_prog_RANLIB"; then
-  ac_ct_RANLIB=$RANLIB
-  # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$ac_ct_RANLIB"; then
-  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x 
"$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_RANLIB="ranlib"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
-if test -n "$ac_ct_RANLIB"; then
-  { echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
-echo "${ECHO_T}$ac_ct_RANLIB" >&6; }
-else
-  { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
+# Check whether --with-v4l1buffer was given.
+if test "${with_v4l1buffer+set}" = set; then
+  withval=$with_v4l1buffer;
 fi
 
-  if test "x$ac_ct_RANLIB" = x; then
-    RANLIB=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect 
cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to address@hidden" >&5
-echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to address@hidden" >&2;}
-ac_tool_warned=yes ;;
-esac
-    RANLIB=$ac_ct_RANLIB
-  fi
-else
-  RANLIB="$ac_cv_prog_RANLIB"
+
+# Check whether --with-v4l2 was given.
+if test "${with_v4l2+set}" = set; then
+  withval=$with_v4l2;
 fi
 
 
+# Check whether --with-o2buffer was given.
+if test "${with_o2buffer+set}" = set; then
+  withval=$with_o2buffer;
+fi
 
 
-ac_config_headers="$ac_config_headers "
+# Check whether --with-qtbuffer was given.
+if test "${with_qtbuffer+set}" = set; then
+  withval=$with_qtbuffer;
+fi
 
-{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; }
-if test "${ac_cv_header_stdc+set}" = set; then
+
+case "$host" in
+       *linux*)
+               os_all_options="dvbuffer v4l2buffer v4l1buffer"
+
+
+       if test "$with_dvbuffer" != no && test "$have_dvbuffer" != yes
+       then
+               if test "$with_dvbuffer" == ""
+               then
+                       with_dvbuffer=yes
+               fi
+
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
+
+
+
+for ac_header in libraw1394/raw1394.h libdc1394/dc1394_control.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
 else
-  cat >conftest.$ac_ext <<_ACEOF
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
+$ac_includes_default
+#include <$ac_header>
 _ACEOF
 rm -f conftest.$ac_objext
 if { (ac_try="$ac_compile"
@@ -5721,238 +5330,300 @@
         test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  ac_cv_header_stdc=yes
+  ac_header_compiler=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cv_header_stdc=no
+       ac_header_compiler=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
 
-if test $ac_cv_header_stdc = yes; then
-  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  cat >conftest.$ac_ext <<_ACEOF
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <string.h>
-
+#include <$ac_header>
 _ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "memchr" >/dev/null 2>&1; then
-  :
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
 else
-  ac_cv_header_stdc=no
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
 fi
-rm -f conftest*
 
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, 
rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the 
preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the 
compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be 
compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing 
prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite 
headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf 
documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But 
Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be 
Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the 
preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" 
>&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler 
will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take 
precedence" >&2;}
+
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
 fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
 
-if test $ac_cv_header_stdc = yes; then
-  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdlib.h>
 
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "free" >/dev/null 2>&1; then
-  :
 else
-  ac_cv_header_stdc=no
+  a=1
 fi
-rm -f conftest*
 
-fi
+done
 
-if test $ac_cv_header_stdc = yes; then
-  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-  if test "$cross_compiling" = yes; then
-  :
+
+{ echo "$as_me:$LINENO: checking for main in -lraw1394" >&5
+echo $ECHO_N "checking for main in -lraw1394... $ECHO_C" >&6; }
+if test "${ac_cv_lib_raw1394_main+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lraw1394  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <ctype.h>
-#include <stdlib.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
-                  (('a' <= (c) && (c) <= 'i') \
-                    || ('j' <= (c) && (c) <= 'r') \
-                    || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
 
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+
 int
 main ()
 {
-  int i;
-  for (i = 0; i < 256; i++)
-    if (XOR (islower (i), ISLOWER (i))
-       || toupper (i) != TOUPPER (i))
-      return 2;
+return main ();
+  ;
   return 0;
 }
 _ACEOF
-rm -f conftest$ac_exeext
+rm -f conftest.$ac_objext conftest$ac_exeext
 if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>&5
+  (eval "$ac_link") 2>conftest.er1
   ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (case "(($ac_try" in
+  (exit $ac_status); } && {
+        test -z "$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_raw1394_main=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cv_lib_raw1394_main=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_raw1394_main" >&5
+echo "${ECHO_T}$ac_cv_lib_raw1394_main" >&6; }
+if test $ac_cv_lib_raw1394_main = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBRAW1394 1
+_ACEOF
+
+  LIBS="-lraw1394 $LIBS"
+
+else
+  a=1
+fi
+
+
+{ echo "$as_me:$LINENO: checking for main in -ldc1394_control" >&5
+echo $ECHO_N "checking for main in -ldc1394_control... $ECHO_C" >&6; }
+if test "${ac_cv_lib_dc1394_control_main+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldc1394_control  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+return main ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_try") 2>&5
+  (eval "$ac_link") 2>conftest.er1
   ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  :
+  (exit $ac_status); } && {
+        test -z "$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_dc1394_control_main=yes
 else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
+  echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-( exit $ac_status )
-ac_cv_header_stdc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext conftest.$ac_ext
+       ac_cv_lib_dc1394_control_main=no
 fi
 
-
-fi
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6; }
-if test $ac_cv_header_stdc = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define STDC_HEADERS 1
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_dc1394_control_main" >&5
+echo "${ECHO_T}$ac_cv_lib_dc1394_control_main" >&6; }
+if test $ac_cv_lib_dc1394_control_main = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBDC1394_CONTROL 1
 _ACEOF
 
-fi
-
-
-#From hereon, I use the following conventions:
-#a variable, FOO is saves (for the purpose of testing additions to it) in
-#save_FOO
-#
-#The variable `a' is used throughout as a temporary in tests
-
-
-################################################################################
-#
-# Some notes on autoconf
-
-#This if m4ese for a block comment :-)
-
-
-
-
-all_options="videodisplay jpeg tiff png ffmpeg toon lapack pthreads acml 
globlist"
-dodginess_options=
-
-################################################################################
-#
-#  Some of my own M4 macros
-#
-
-
-################################################################################
-#
-# An OSX specific hack to get at stuff in /sw automatically
-#
-
-if test "$host_vendor" = apple
-then
-       CPPFLAGS="$CPPFLAGS -I /sw/include -I/opt/local/include 
-I/usr/X11R6/include"
-       LIBS="$LIBS -L/sw/lib -L/opt/local/lib"
-       { echo "$as_me:$LINENO: Adding /sw to the build path." >&5
-echo "$as_me: Adding /sw to the build path." >&6;}
-       { echo "$as_me:$LINENO: Adding /opt/local to the build path." >&5
-echo "$as_me: Adding /opt/local to the build path." >&6;}
-       { echo "$as_me:$LINENO: Adding /usr/X11R6/include to the build path." 
>&5
-echo "$as_me: Adding /usr/X11R6/include to the build path." >&6;}
-       osx_hacks=yes
+  LIBS="-ldc1394_control $LIBS"
 
+else
+  a=1
 fi
 
-################################################################################
-#
-#Check for numerics
-#
 
 
-echo
-echo -----------------------------
-echo Checking for numerics support
-echo -----------------------------
+               if test x$a == x
+               then
+                       cat >>confdefs.h <<\_ACEOF
+#define CVD_HAVE_DVBUFFER 1
+_ACEOF
 
+                       have_dvbuffer=yes
 
+                       options="$options dvbuffer"
 
+               else
+                       LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
+               fi
+       fi
 
-###################################################
-#
-#Allow the user to specify the location of TooN
-#
+       if test "$have_dvbuffer" != yes
+       then
+               :
 
-# Check whether --with-TooN was given.
-if test "${with_TooN+set}" = set; then
-  withval=$with_TooN; opt_toon_dir=$withval
-fi
+       fi
 
-toondir="Missing"
 
-if test "$opt_toon_dir" != no
-then
 
-       #Yes is not a useful answer. We know the answer is yes.
-       if test "$opt_toon_dir" = yes
+       if test "$with_v4l1buffer" != no && test "$have_v4l1buffer" != yes
        then
-               opt_toon_dir=
+               if test "$with_v4l1buffer" == ""
+               then
+                       with_v4l1buffer=yes
        fi
 
-       #Check for TooN
-       { echo "$as_me:$LINENO: checking for TooN" >&5
-echo $ECHO_N "checking for TooN... $ECHO_C" >&6; }
-
-       #Check for TooN in a bunch of places
-       save_CPPFLAGS="$CPPFLAGS"
-       for dir in  $opt_toon_dir "" "$HOME/usr/include" "$HOME/code/TooN" 
"$HOME/Src/TooN" "../TooN" ".."
-       do
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
                a=
-               if test "$dir" = ""
-               then
-                       CPPFLAGS="$save_CPPFLAGS"
-               else
-                       CPPFLAGS="$save_CPPFLAGS -I$dir"
-               fi
 
-               cat >conftest.$ac_ext <<_ACEOF
-#include <TooN/TooN.h>
-       int main(){TooN::Vector<2> v;return 0;}
+for ac_header in linux/videodev.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
 _ACEOF
 rm -f conftest.$ac_objext
 if { (ac_try="$ac_compile"
@@ -5971,112 +5642,148 @@
         test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  a=1
+  ac_header_compiler=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-
+       ac_header_compiler=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
 
-               cat >conftest.$ac_ext <<_ACEOF
-#include <numerics.h>
-       int main(){Vector<2> v;return 0;}
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
         test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  old_toon="$old_toon $dir"
+       }; then
+  ac_header_preproc=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-
+  ac_header_preproc=no
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
 
-               if test x$a = x1
-               then
-                       toondir=$dir
-                       break
-               fi
-       done
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, 
rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the 
preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the 
compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be 
compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing 
prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite 
headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf 
documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But 
Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be 
Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the 
preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" 
>&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler 
will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take 
precedence" >&2;}
 
-       if test "$toondir" = ""
-       then
-               { echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
-       else
-               { echo "$as_me:$LINENO: result: $toondir" >&5
-echo "${ECHO_T}$toondir" >&6; }
-       fi
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
 fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
 
-if test "$toondir" = Missing
-then
-       { echo "$as_me:$LINENO: WARNING: TooN is missing. Numerics support 
disabled." >&5
-echo "$as_me: WARNING: TooN is missing. Numerics support disabled." >&2;}
-       if test "$old_toon" != ""
-       then
-       { echo "$as_me:$LINENO: WARNING: You have old versions of TooN 
installed in $old_toon. These are too old for libCVD." >&5
-echo "$as_me: WARNING: You have old versions of TooN installed in $old_toon. 
These are too old for libCVD." >&2;}
-       fi
-       toon=no
 else
-       options="$options toon"
-       toon=yes
+  a=1
+fi
+
+done
+
+
+               if test x$a == x
+               then
        cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_TOON 1
+#define CVD_HAVE_V4L1BUFFER 1
 _ACEOF
 
-       have_toon=yes
+                       have_v4l1buffer=yes
 
-fi
+                       options="$options v4l1buffer"
 
-##################################################
-#
-# Check for BLAS and LAPACK support
-#
-lapack=no
+               else
+                       LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
+               fi
+       fi
 
-# Check whether --with-lapack was given.
-if test "${with_lapack+set}" = set; then
-  withval=$with_lapack; lapack=never
-fi
+       if test "$have_v4l1buffer" != yes
+       then
+               :
+
+       fi
 
 
-acml=no
 
-if test "$toon" = yes && test "$host_vendor" == apple && test "$lapack" != 
never
-then
+       if test "$with_v4l2buffer" != no && test "$have_v4l2buffer" != yes
+       then
+               if test "$with_v4l2buffer" == ""
+               then
+                       with_v4l2buffer=yes
+               fi
 
        save_LIBS="$LIBS"
-       LIBS="$LIBS -framework vecLib"
-
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
 
-       { echo "$as_me:$LINENO: checking vecLib framework" >&5
-echo $ECHO_N "checking vecLib framework... $ECHO_C" >&6; }
-       a=0
+                       { echo "$as_me:$LINENO: checking for v4l2" >&5
+echo $ECHO_N "checking for v4l2... $ECHO_C" >&6; }
        cat >conftest.$ac_ext <<_ACEOF
-#include <TooN/SVD.h>
-int main(){TooN::Matrix<2> m;TooN::SVD<2> svdm(m);return 0;}
+       #include <sys/types.h>
+                                                               #include 
<linux/types.h>
+                                                               #include 
<linux/videodev.h>
+                                                               int 
main(){V4L2_PIX_FMT_GREY;return 0;}
 _ACEOF
 rm -f conftest.$ac_objext
 if { (ac_try="$ac_compile"
@@ -6095,290 +5802,158 @@
         test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  a=1
+  { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-
+       { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }; a=1
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
-       if test x$a     = x1
-       then
-               { echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
-               lapack=yes
-               options="$options lapack"
-       else
-               { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-               LIBS="$save_LIBS"
-       fi
-fi
 
+               if test x$a == x
+               then
+                       cat >>confdefs.h <<\_ACEOF
+#define CVD_HAVE_V4L2BUFFER 1
+_ACEOF
 
+                       have_v4l2buffer=yes
 
-if test "$toon" = yes && test "$lapack" = no
-then
+                       options="$options v4l2buffer"
 
-       #This built-in autoconf macro finds the linker flags needed to
-       #link with Fortran libraries and sets FCLIBS accordingly
-       #AC_FC_LIBRARY_LDFLAGS
-       # TODO: We may also need to use AC_FC_DUMMY_MAIN to see whether a dummy
-       # Fortran main is needed (see the Autoconf manual). Currently, no 
machines
-       # we compile on seem to need this.
+               else
+                       LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
+               fi
+       fi
 
-       save_LIBS="$LIBS"
-       #LIBS="$LIBS $FCLIBS"
+       if test "$have_v4l2buffer" != yes
+       then
+               :
 
+       fi
 
-#      AC_MSG_CHECKING([quality of Ac_FC_LIBRARY_LDFLAGS])
-#      AC_LINK_IFELSE([int main(){return 0;}], [fc=good],[fc=b0rked]);
-#      AC_MSG_RESULT($fc)
 
-       f2c="Missing"
-       fc="b0rked"
-       if test $fc == b0rked
-       then
-               { echo "$as_me:$LINENO: Reverting to old fortran library test." 
>&5
-echo "$as_me: Reverting to old fortran library test." >&6;}
+               { echo "$as_me:$LINENO: checking kernel major number" >&5
+echo $ECHO_N "checking kernel major number... $ECHO_C" >&6; }
+               kernel_major=`uname -r | $AWK -F'[.-]' '{print $1}'`
+               { echo "$as_me:$LINENO: result: $kernel_major" >&5
+echo "${ECHO_T}$kernel_major" >&6; }
+               cat >>confdefs.h <<_ACEOF
+#define CVD_KERNEL_MAJOR $kernel_major
+_ACEOF
 
-               { echo "$as_me:$LINENO: checking for C to fortran library" >&5
-echo $ECHO_N "checking for C to fortran library... $ECHO_C" >&6; }
 
-               #The linking testing function AC_LINK_IFELSE uses LIBS in the
-               #linking stage, so we communicate our requirements by using this
-               LIBS="$save_LIBS -lf2c"
-               cat >conftest.$ac_ext <<_ACEOF
-int main(){return 0;}
+               { echo "$as_me:$LINENO: checking kernel minor number" >&5
+echo $ECHO_N "checking kernel minor number... $ECHO_C" >&6; }
+               kernel_minor=`uname -r | $AWK -F'[.-]' '{print $2}'`
+               { echo "$as_me:$LINENO: result: $kernel_minor" >&5
+echo "${ECHO_T}$kernel_minor" >&6; }
+               cat >>confdefs.h <<_ACEOF
+#define CVD_KERNEL_MINOR $kernel_minor
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  f2c=f2c
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
 
-fi
 
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
 
-               LIBS="$save_LIBS -lg2c"
-               cat >conftest.$ac_ext <<_ACEOF
-int main(){return 0;}
+               { echo "$as_me:$LINENO: checking kernel release number" >&5
+echo $ECHO_N "checking kernel release number... $ECHO_C" >&6; }
+               kernel_release=`uname -r | $AWK -F'[.-]' '{print $3}'`
+               { echo "$as_me:$LINENO: result: $kernel_release" >&5
+echo "${ECHO_T}$kernel_release" >&6; }
+               cat >>confdefs.h <<_ACEOF
+#define CVD_KERNEL_RELEASE $kernel_release
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  f2c=g2c
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
 
+               ;;
 
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-
-               LIBS="$save_LIBS -lgfortran"
-               cat >conftest.$ac_ext <<_ACEOF
-int main(){return 0;}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  f2c=gfortran
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+       *sgi*)
+               os_all_options="o2buffer"
 
+       if test "$with_o2buffer" != no && test "$have_o2buffer" != yes
+       then
+               if test "$with_o2buffer" == ""
+               then
+                       with_o2buffer=yes
+               fi
 
-fi
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
 
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
+                       echo "I hope all SGIs have stuff needed for O2buffer. 
Disable (--without-o2buffer) if I'm wrong."
 
-               { echo "$as_me:$LINENO: result: $f2c" >&5
-echo "${ECHO_T}$f2c" >&6; }
-               LIBS="$save_LIBS -l$f2c"
 
-               #$LIBS should either havf FCLIBS or -l$f2c present
+               if test x$a == x
+               then
+                       cat >>confdefs.h <<\_ACEOF
+#define CVD_HAVE_O2BUFFER 1
+_ACEOF
 
-               opt_acml_dir="no"
+                       have_o2buffer=yes
 
-# Check whether --with-acml was given.
-if test "${with_acml+set}" = set; then
-  withval=$with_acml; opt_acml_dir=$withval
-fi
+                       options="$options o2buffer"
 
+               else
+                       LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
+               fi
+       fi
 
-               if test x$opt_acml_dir == xno
+       if test "$have_o2buffer" != yes
                then
+               :
 
-{ echo "$as_me:$LINENO: checking for dgemm_ in -lblas" >&5
-echo $ECHO_N "checking for dgemm_ in -lblas... $ECHO_C" >&6; }
-if test "${ac_cv_lib_blas_dgemm_+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lblas  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
+       fi
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dgemm_ ();
-int
-main ()
-{
-return dgemm_ ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
+               ;;
 esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_blas_dgemm_=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_cv_lib_blas_dgemm_=no
-fi
 
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_blas_dgemm_" >&5
-echo "${ECHO_T}$ac_cv_lib_blas_dgemm_" >&6; }
-if test $ac_cv_lib_blas_dgemm_ = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBBLAS 1
-_ACEOF
+if test "$host_vendor" == apple
+then
+       CPPFLAGS="$CPPFLAGS -I /sw/include -I/opt/local/include 
-I/usr/X11R6/include"
+       LIBS="$LIBS -L/sw/lib -L/opt/local/lib"
+       { echo "$as_me:$LINENO: Adding /sw to the build path." >&5
+echo "$as_me: Adding /sw to the build path." >&6;}
+       { echo "$as_me:$LINENO: Adding /opt/local to the build path." >&5
+echo "$as_me: Adding /opt/local to the build path." >&6;}
+       { echo "$as_me:$LINENO: Adding /usr/X11R6/include to the build path." 
>&5
+echo "$as_me: Adding /usr/X11R6/include to the build path." >&6;}
+       osx_hacks=yes
 
-  LIBS="-lblas $LIBS"
+       os_all_options="qtbuffer"
 
-fi
 
-               if test x$ac_cv_lib_blas_dgemm_ != xyes
+       if test "$with_qtbuffer" != no && test "$have_qtbuffer" != yes
                then
-                       { echo "$as_me:$LINENO: WARNING: BLAS is missing. Get 
it from www.netlib.org/blas" >&5
-echo "$as_me: WARNING: BLAS is missing. Get it from www.netlib.org/blas" >&2;};
-               else
-
-{ echo "$as_me:$LINENO: checking for dgesvd_ in -llapack" >&5
-echo $ECHO_N "checking for dgesvd_ in -llapack... $ECHO_C" >&6; }
-if test "${ac_cv_lib_lapack_dgesvd_+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-llapack  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dgesvd_ ();
-int
-main ()
-{
-return dgesvd_ ();
-  ;
-  return 0;
-}
+               if test "$with_qtbuffer" == ""
+               then
+                       with_qtbuffer=yes
+               fi
+
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
+
+               LIBS="$LIBS -framework Carbon -framework QuickTime"
+               { echo "$as_me:$LINENO: checking Carbon and QuickTime 
framework" >&5
+echo $ECHO_N "checking Carbon and QuickTime framework... $ECHO_C" >&6; }
+               cat >conftest.$ac_ext <<_ACEOF
+ #include <Carbon/Carbon.h>
+                                                       #include 
<QuickTime/QuickTime.h>
+                                                       int 
main(){InitCursor();EnterMovies();return 0;}
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
@@ -6387,384 +5962,305 @@
   (exit $ac_status); } && {
         test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_lapack_dgesvd_=yes
+       } && test -s conftest.$ac_objext; then
+  { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cv_lib_lapack_dgesvd_=no
+       { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }; a=1
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_lapack_dgesvd_" >&5
-echo "${ECHO_T}$ac_cv_lib_lapack_dgesvd_" >&6; }
-if test $ac_cv_lib_lapack_dgesvd_ = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBLAPACK 1
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+               if test x$a == x
+               then
+                       cat >>confdefs.h <<\_ACEOF
+#define CVD_HAVE_QTBUFFER 1
 _ACEOF
 
-  LIBS="-llapack $LIBS"
+                       have_qtbuffer=yes
 
-fi
+                       options="$options qtbuffer"
 
-                       if test x$ac_cv_lib_lapack_dgesvd_ != xyes
-                       then
-                                 { echo "$as_me:$LINENO: WARNING: LAPACK is 
missing. Get it from www.netlib.org/lapack" >&5
-echo "$as_me: WARNING: LAPACK is missing. Get it from www.netlib.org/lapack" 
>&2;};
                        else
-                         options="$options lapack"
-                         lapack=yes
+                       LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
                        fi
                fi
-               else
-                       { echo "$as_me:$LINENO: Compiling with acml" >&5
-echo "$as_me: Compiling with acml" >&6;}
 
-                       if test x$opt_acml_dir != xyes
+       if test "$have_qtbuffer" != yes
                        then
-                               LDFLAGS="$LDFLAGS -L$opt_acml_dir"
-                       else
-                               LDFLAGS="$LDFLAGS -L/opt/acml/gnu64/lib"
+               :
+
                        fi
 
-                       LIBS="$LIBS -lacml_mv"
+fi
 
+################################################################################
+#
+#Check for optional libraries
+#
 
-{ echo "$as_me:$LINENO: checking for dgemm_ in -lacml" >&5
-echo $ECHO_N "checking for dgemm_ in -lacml... $ECHO_C" >&6; }
-if test "${ac_cv_lib_acml_dgemm_+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lacml  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
+echo
+echo -------------------------------
+echo Checking for optional libraries
+echo -------------------------------
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dgemm_ ();
-int
-main ()
-{
-return dgemm_ ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_acml_dgemm_=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cv_lib_acml_dgemm_=no
+# Check whether --with-videodisplay was given.
+if test "${with_videodisplay+set}" = set; then
+  withval=$with_videodisplay;
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+
+# Check whether --with-pthread was given.
+if test "${with_pthread+set}" = set; then
+  withval=$with_pthread;
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_acml_dgemm_" >&5
-echo "${ECHO_T}$ac_cv_lib_acml_dgemm_" >&6; }
-if test $ac_cv_lib_acml_dgemm_ = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBACML 1
-_ACEOF
 
-  LIBS="-lacml $LIBS"
 
+# Check whether --with-jpeg was given.
+if test "${with_jpeg+set}" = set; then
+  withval=$with_jpeg;
 fi
 
 
-{ echo "$as_me:$LINENO: checking for dgesvd_ in -lacml" >&5
-echo $ECHO_N "checking for dgesvd_ in -lacml... $ECHO_C" >&6; }
-if test "${ac_cv_lib_acml_dgesvd_+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lacml  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
+# Check whether --with-jpegbuffer was given.
+if test "${with_jpegbuffer+set}" = set; then
+  withval=$with_jpegbuffer;
+fi
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dgesvd_ ();
-int
-main ()
-{
-return dgesvd_ ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_acml_dgesvd_=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cv_lib_acml_dgesvd_=no
+# Check whether --with-tiff was given.
+if test "${with_tiff+set}" = set; then
+  withval=$with_tiff;
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+
+# Check whether --with-tiff was given.
+if test "${with_tiff+set}" = set; then
+  withval=$with_tiff;
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_acml_dgesvd_" >&5
-echo "${ECHO_T}$ac_cv_lib_acml_dgesvd_" >&6; }
-if test $ac_cv_lib_acml_dgesvd_ = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBACML 1
-_ACEOF
 
-  LIBS="-lacml $LIBS"
 
+# Check whether --with-png was given.
+if test "${with_png+set}" = set; then
+  withval=$with_png;
+fi
+
+
+# Check whether --with-ffmpeg was given.
+if test "${with_ffmpeg+set}" = set; then
+  withval=$with_ffmpeg;
+fi
+
+
+# Check whether --with-toon was given.
+if test "${with_toon+set}" = set; then
+  withval=$with_toon;
+fi
+
+
+# Check whether --with-lapack was given.
+if test "${with_lapack+set}" = set; then
+  withval=$with_lapack;
+fi
+
+
+# Check whether --with-acml was given.
+if test "${with_acml+set}" = set; then
+  withval=$with_acml; opt_acml_dir=$withval
 fi
 
 
-                       if test x$ac_cv_lib_acml_dgemm_$ac_cv_lib_acml_dgesvd_ 
!= xyesyes
+
+       if test "$with_videodisplay" != no && test "$have_videodisplay" != yes
                        then
-                               { echo "$as_me:$LINENO: WARNING: ACML is 
missing. Get it from www.amd.com/acml" >&5
-echo "$as_me: WARNING: ACML is missing. Get it from www.amd.com/acml" >&2;};
-                       else
-                               options="$options acml lapack"
-                               lapack=yes
-                               acml=yes
-                       fi
-               fi
+               if test "$with_videodisplay" == ""
+               then
+                       with_videodisplay=yes
        fi
 
-       if test "$lapack" = no
-       then
-               LIBS="$save_LIBS"
-       else
-               have_lapack=yes
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
 
-               cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_LAPACK 1
-_ACEOF
+       { echo "$as_me:$LINENO: checking for X" >&5
+echo $ECHO_N "checking for X... $ECHO_C" >&6; }
 
 
-               if test "$acml" = yes
-               then
-                       have_acml=yes
+# Check whether --with-x was given.
+if test "${with_x+set}" = set; then
+  withval=$with_x;
+fi
 
-                       cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_ACML 1
+# $have_x is `yes', `no', `disabled', or empty when we do not yet know.
+if test "x$with_x" = xno; then
+  # The user explicitly disabled X.
+  have_x=disabled
+else
+  case $x_includes,$x_libraries in #(
+    *\'*) { { echo "$as_me:$LINENO: error: Cannot use X directory names 
containing '" >&5
+echo "$as_me: error: Cannot use X directory names containing '" >&2;}
+   { (exit 1); exit 1; }; };; #(
+    *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  # One or both of the vars are not set, and there is no cached value.
+ac_x_includes=no ac_x_libraries=no
+rm -f -r conftest.dir
+if mkdir conftest.dir; then
+  cd conftest.dir
+  cat >Imakefile <<'_ACEOF'
+incroot:
+       @echo incroot='${INCROOT}'
+usrlibdir:
+       @echo usrlibdir='${USRLIBDIR}'
+libdir:
+       @echo libdir='${LIBDIR}'
 _ACEOF
-
+  if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; 
then
+    # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+    for ac_var in incroot usrlibdir libdir; do
+      eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 
's/^$ac_var=//p'\`"
+    done
+    # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
+    for ac_extension in a so sl; do
+      if test ! -f "$ac_im_usrlibdir/libX11.$ac_extension" &&
+        test -f "$ac_im_libdir/libX11.$ac_extension"; then
+       ac_im_usrlibdir=$ac_im_libdir; break
                fi
+    done
+    # Screen out bogus values from the imake configuration.  They are
+    # bogus both because they are the default anyway, and because
+    # using them would break gcc on systems where it needs fixed includes.
+    case $ac_im_incroot in
+       /usr/include) ac_x_includes= ;;
+       *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
+    esac
+    case $ac_im_usrlibdir in
+       /usr/lib | /lib) ;;
+       *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
+    esac
        fi
+  cd ..
+  rm -f -r conftest.dir
 fi
 
+# Standard set of common directories for X headers.
+# Check X11 before X11Rn because it is often a symlink to the current release.
+ac_x_header_dirs='
+/usr/X11/include
+/usr/X11R6/include
+/usr/X11R5/include
+/usr/X11R4/include
 
+/usr/include/X11
+/usr/include/X11R6
+/usr/include/X11R5
+/usr/include/X11R4
 
-cvd_major=`echo $PACKAGE_VERSION | $AWK -F'\\\\.' '{print $1}'`
-cvd_minor=`echo $PACKAGE_VERSION | $AWK -F'\\\\.' '{print $2}'`
-
-cat >>confdefs.h <<_ACEOF
-#define CVD_MAJOR_VERSION $cvd_major
-_ACEOF
-
-major=$cvd_major
-
-cat >>confdefs.h <<_ACEOF
-#define CVD_MINOR_VERSION $cvd_minor
-_ACEOF
-
-minor=$cvd_minor
+/usr/local/X11/include
+/usr/local/X11R6/include
+/usr/local/X11R5/include
+/usr/local/X11R4/include
 
+/usr/local/include/X11
+/usr/local/include/X11R6
+/usr/local/include/X11R5
+/usr/local/include/X11R4
 
-################################################################################
-#
-# platform specific options
-echo
-echo ---------------------------------------
-echo Checking for platform specific features
-echo ---------------------------------------
+/usr/X386/include
+/usr/x386/include
+/usr/XFree86/include/X11
 
-{ echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5
-echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6; }
-if test "${ac_cv_c_bigendian+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  # See if sys/param.h defines the BYTE_ORDER macro.
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <sys/types.h>
-#include <sys/param.h>
+/usr/include
+/usr/local/include
+/usr/unsupported/include
+/usr/athena/include
+/usr/local/x11r5/include
+/usr/lpp/Xamples/include
 
-int
-main ()
-{
-#if  ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \
-       && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN)
- bogus endian macros
-#endif
+/usr/openwin/include
+/usr/openwin/share/include'
 
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  # It does; now see whether it defined to BIG_ENDIAN or not.
-cat >conftest.$ac_ext <<_ACEOF
+if test "$ac_x_includes" = no; then
+  # Guess where to find include files, by looking for Xlib.h.
+  # First, try using that file with no special directory specified.
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <sys/types.h>
-#include <sys/param.h>
-
-int
-main ()
-{
-#if BYTE_ORDER != BIG_ENDIAN
- not big endian
-#endif
-
-  ;
-  return 0;
-}
+#include <X11/Xlib.h>
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+if { (ac_try="$ac_cpp conftest.$ac_ext"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
         test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_c_bigendian=yes
+       }; then
+  # We can compile using X headers with no special include directory.
+ac_x_includes=
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cv_c_bigendian=no
+  for ac_dir in $ac_x_header_dirs; do
+  if test -r "$ac_dir/X11/Xlib.h"; then
+    ac_x_includes=$ac_dir
+    break
+  fi
+done
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+rm -f conftest.err conftest.$ac_ext
+fi # $ac_x_includes = no
 
-       # It does not; compile a test program.
-if test "$cross_compiling" = yes; then
-  # try to guess the endianness by grepping values into an object file
-  ac_cv_c_bigendian=unknown
+if test "$ac_x_libraries" = no; then
+  # Check for the libraries.
+  # See if we find them without any special options.
+  # Don't add to $LIBS permanently.
+  ac_save_LIBS=$LIBS
+  LIBS="-lX11 $LIBS"
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
-short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
-void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; }
-short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
-short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
-void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; }
+#include <X11/Xlib.h>
 int
 main ()
 {
- _ascii (); _ebcdic ();
+XrmInitialize ()
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_link") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
@@ -6773,161 +6269,185 @@
   (exit $ac_status); } && {
         test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then
-  ac_cv_c_bigendian=yes
-fi
-if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
-  if test "$ac_cv_c_bigendian" = unknown; then
-    ac_cv_c_bigendian=no
-  else
-    # finding both strings is unlikely to happen, but who knows?
-    ac_cv_c_bigendian=unknown
-  fi
-fi
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  LIBS=$ac_save_LIBS
+# We can link X programs with no special library path.
+ac_x_libraries=
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
+       LIBS=$ac_save_LIBS
+for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
+do
+  # Don't even attempt the hair of trying to link an X program!
+  for ac_extension in a so sl; do
+    if test -r "$ac_dir/libX11.$ac_extension"; then
+      ac_x_libraries=$ac_dir
+      break 2
+    fi
+  done
+done
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi # $ac_x_libraries = no
+
+case $ac_x_includes,$ac_x_libraries in #(
+  no,* | *,no | *\'*)
+    # Didn't find X, or a directory has "'" in its name.
+    ac_cv_have_x="have_x=no";; #(
+  *)
+    # Record where we found X for the cache.
+    ac_cv_have_x="have_x=yes\
+       ac_x_includes='$ac_x_includes'\
+       ac_x_libraries='$ac_x_libraries'"
+esac
+fi
+;; #(
+    *) have_x=yes;;
+  esac
+  eval "$ac_cv_have_x"
+fi # $with_x != no
 
+if test "$have_x" != yes; then
+  { echo "$as_me:$LINENO: result: $have_x" >&5
+echo "${ECHO_T}$have_x" >&6; }
+  no_x=yes
+else
+  # If each of the values was on the command line, it overrides each guess.
+  test "x$x_includes" = xNONE && x_includes=$ac_x_includes
+  test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
+  # Update the cache value to reflect the command line values.
+  ac_cv_have_x="have_x=yes\
+       ac_x_includes='$x_includes'\
+       ac_x_libraries='$x_libraries'"
+  { echo "$as_me:$LINENO: result: libraries $x_libraries, headers $x_includes" 
>&5
+echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&6; }
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       if test x$x_includes != x
+       then
+               CXXFLAGS="$CXXFLAGS -I$x_includes"
+       fi
+
+       LIBS="$LIBS -L$x_libraries -lX11 -lXext"
+
+{ echo "$as_me:$LINENO: checking for glDrawPixels in -lGL" >&5
+echo $ECHO_N "checking for glDrawPixels in -lGL... $ECHO_C" >&6; }
+if test "${ac_cv_lib_GL_glDrawPixels+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lGL  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-$ac_includes_default
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char glDrawPixels ();
 int
 main ()
 {
-
-  /* Are we little or big endian?  From Harbison&Steele.  */
-  union
-  {
-    long int l;
-    char c[sizeof (long int)];
-  } u;
-  u.l = 1;
-  return u.c[sizeof (long int) - 1] == 1;
-
+return glDrawPixels ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest$ac_exeext
+rm -f conftest.$ac_objext conftest$ac_exeext
 if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_try") 2>&5
+  (eval "$ac_link") 2>conftest.er1
   ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_c_bigendian=no
+  (exit $ac_status); } && {
+        test -z "$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_GL_glDrawPixels=yes
 else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
+  echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-( exit $ac_status )
-ac_cv_c_bigendian=yes
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext conftest.$ac_ext
+       ac_cv_lib_GL_glDrawPixels=no
 fi
 
-
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_GL_glDrawPixels" >&5
+echo "${ECHO_T}$ac_cv_lib_GL_glDrawPixels" >&6; }
+if test $ac_cv_lib_GL_glDrawPixels = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBGL 1
+_ACEOF
+
+  LIBS="-lGL $LIBS"
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5
-echo "${ECHO_T}$ac_cv_c_bigendian" >&6; }
-case $ac_cv_c_bigendian in
-  yes)
 
-cat >>confdefs.h <<\_ACEOF
-#define WORDS_BIGENDIAN 1
-_ACEOF
- ;;
-  no)
-     ;;
-  *)
-    { { echo "$as_me:$LINENO: error: unknown endianness
-presetting ac_cv_c_bigendian=no (or yes) will help" >&5
-echo "$as_me: error: unknown endianness
-presetting ac_cv_c_bigendian=no (or yes) will help" >&2;}
-   { (exit 1); exit 1; }; } ;;
-esac
 
 
-if test x$ac_cv_c_bigendian = xno
-then
+               if test x$a == x
+               then
        cat >>confdefs.h <<\_ACEOF
-#define CVD_ARCH_LITTLE_ENDIAN 1
+#define CVD_HAVE_VIDEODISPLAY 1
 _ACEOF
 
-else
-       cat >>confdefs.h <<\_ACEOF
-#define CVD_ARCH_BIG_ENDIAN 1
-_ACEOF
+                       have_videodisplay=yes
 
-fi
+                       options="$options videodisplay"
 
-case "$host" in
-       *linux*)
+               else
+                       LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
+               fi
+       fi
 
-               os_options="dvbuffer v4l2buffer v4l1buffer"
+       if test "$have_videodisplay" != yes
+       then
+               :
 
+       fi
 
-# Check whether --with-firewire was given.
-if test "${with_firewire+set}" = set; then
-  withval=$with_firewire; if test "$withval" = no; then disable_firewire=yes; 
else disable_firewire=no; fi
-fi
 
-               if test "$disable_firewire" != yes
+
+
+       if test "$with_toon" != no && test "$have_toon" != yes
                then
-                       a=
+               if test "$with_toon" == ""
+               then
+                       with_toon=yes
+               fi
 
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
 
-for ac_header in libraw1394/raw1394.h libdc1394/dc1394_control.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  { echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-else
-  # Is the header compilable?
-{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-#include <$ac_header>
+       { echo "$as_me:$LINENO: checking for TooN" >&5
+echo $ECHO_N "checking for TooN... $ECHO_C" >&6; }
+       cat >conftest.$ac_ext <<_ACEOF
+#include <TooN/TooN.h>
+       int main(){TooN::Vector<2> v;return 0;}
 _ACEOF
 rm -f conftest.$ac_objext
 if { (ac_try="$ac_compile"
@@ -6946,113 +6466,73 @@
         test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  ac_header_compiler=yes
+  { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_header_compiler=no
+       { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }; a=1
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
 
-# Is the header present?
-{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <$ac_header>
+
+
+               if test x$a == x
+               then
+                       cat >>confdefs.h <<\_ACEOF
+#define CVD_HAVE_TOON 1
 _ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       }; then
-  ac_header_preproc=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
 
-  ac_header_preproc=no
-fi
+                       have_toon=yes
 
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
+                       options="$options toon"
 
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in
-  yes:no: )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, 
rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the 
preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the 
compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
-    ac_header_preproc=yes
-    ;;
-  no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be 
compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing 
prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header:     check for missing prerequisite 
headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf 
documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But 
Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be 
Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the 
preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" 
>&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler 
will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take 
precedence" >&2;}
+               else
+                       LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
+               fi
+       fi
 
-    ;;
-esac
-{ echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  eval "$as_ac_Header=\$ac_header_preproc"
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
+       if test "$have_toon" != yes
+       then
+               :
 
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
+       fi
 
-else
-  a=1
-fi
 
-done
+
+       if test "$with_lapack" != no && test "$have_lapack" != yes
+       then
+               if test "$with_lapack" == ""
+               then
+                       with_lapack=yes
+               fi
+
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
+
+       if test "$with_acml" != no
+       then
+               if test "$with_acml" != yes & test "$with_acml" != ""
+               then
+                       LIBS="$LIBS -L $with_acml"
+               else
+                       LIBS="$LIBS -L/opt/acml/gnu64/lib"
+               fi
+               LIBS="$LIBS -lacml_mv"
 
 
-{ echo "$as_me:$LINENO: checking for main in -lraw1394" >&5
-echo $ECHO_N "checking for main in -lraw1394... $ECHO_C" >&6; }
-if test "${ac_cv_lib_raw1394_main+set}" = set; then
+{ echo "$as_me:$LINENO: checking for dgesvd_ in -lacml" >&5
+echo $ECHO_N "checking for dgesvd_ in -lacml... $ECHO_C" >&6; }
+if test "${ac_cv_lib_acml_dgesvd_+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lraw1394  $LIBS"
+LIBS="-lacml  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -7060,11 +6540,17 @@
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dgesvd_ ();
 int
 main ()
 {
-return main ();
+return dgesvd_ ();
   ;
   return 0;
 }
@@ -7087,39 +6573,79 @@
         test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_raw1394_main=yes
+  ac_cv_lib_acml_dgesvd_=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cv_lib_raw1394_main=no
+       ac_cv_lib_acml_dgesvd_=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_raw1394_main" >&5
-echo "${ECHO_T}$ac_cv_lib_raw1394_main" >&6; }
-if test $ac_cv_lib_raw1394_main = yes; then
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_acml_dgesvd_" >&5
+echo "${ECHO_T}$ac_cv_lib_acml_dgesvd_" >&6; }
+if test $ac_cv_lib_acml_dgesvd_ = yes; then
   cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBRAW1394 1
+#define HAVE_LIBACML 1
 _ACEOF
 
-  LIBS="-lraw1394 $LIBS"
+  LIBS="-lacml $LIBS"
 
 else
   a=1
 fi
 
+       else
+               a=1
+       fi
+
 
-{ echo "$as_me:$LINENO: checking for main in -ldc1394_control" >&5
-echo $ECHO_N "checking for main in -ldc1394_control... $ECHO_C" >&6; }
-if test "${ac_cv_lib_dc1394_control_main+set}" = set; then
+               if test x$a == x
+               then
+                       cat >>confdefs.h <<\_ACEOF
+#define CVD_HAVE_LAPACK 1
+_ACEOF
+
+                       have_lapack=yes
+
+                       options="$options lapack"
+
+               else
+                       LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
+               fi
+       fi
+
+       if test "$have_lapack" != yes
+       then
+               :
+
+       fi
+
+
+
+       if test "$with_lapack" != no && test "$have_lapack" != yes
+       then
+               if test "$with_lapack" == ""
+               then
+                       with_lapack=yes
+               fi
+
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
+
+
+{ echo "$as_me:$LINENO: checking for dgesvd_ in -llapack" >&5
+echo $ECHO_N "checking for dgesvd_ in -llapack... $ECHO_C" >&6; }
+if test "${ac_cv_lib_lapack_dgesvd_+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldc1394_control  $LIBS"
+LIBS="-llapack  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -7127,11 +6653,17 @@
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dgesvd_ ();
 int
 main ()
 {
-return main ();
+return dgesvd_ ();
   ;
   return 0;
 }
@@ -7154,87 +6686,110 @@
         test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_dc1394_control_main=yes
+  ac_cv_lib_lapack_dgesvd_=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cv_lib_dc1394_control_main=no
+       ac_cv_lib_lapack_dgesvd_=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_dc1394_control_main" >&5
-echo "${ECHO_T}$ac_cv_lib_dc1394_control_main" >&6; }
-if test $ac_cv_lib_dc1394_control_main = yes; then
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_lapack_dgesvd_" >&5
+echo "${ECHO_T}$ac_cv_lib_lapack_dgesvd_" >&6; }
+if test $ac_cv_lib_lapack_dgesvd_ = yes; then
   cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBDC1394_CONTROL 1
+#define HAVE_LIBLAPACK 1
 _ACEOF
 
-  LIBS="-ldc1394_control $LIBS"
+  LIBS="-llapack $LIBS"
 
 else
   a=1
 fi
 
 
-                       if test x$a = x
+
+               if test x$a == x
                        then
                                cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_DVBUFFER 1
+#define CVD_HAVE_LAPACK 1
 _ACEOF
 
-                               have_dvbuffer=yes
+                       have_lapack=yes
 
-                               options="$options dvbuffer"
+                       options="$options lapack"
+
+               else
+                       LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
                        fi
                fi
 
+       if test "$have_lapack" != yes
+       then
+               :
+
+       fi
+
 
-# Check whether --with-v4l1 was given.
-if test "${with_v4l1+set}" = set; then
-  withval=$with_v4l1; if test "$withval" = no; then disable_v4l1=yes; else 
disable_v4l1=no; fi
-fi
 
-               if test "$disable_v4l1" != yes
+       if test "$with_lapack" != no && test "$have_lapack" != yes
                then
+               if test "$with_lapack" == ""
+               then
+                       with_lapack=yes
+               fi
+
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
                        a=
 
-for ac_header in linux/videodev.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  { echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+       { echo "$as_me:$LINENO: checking if f2c is needed for LAPACK" >&5
+echo $ECHO_N "checking if f2c is needed for LAPACK... $ECHO_C" >&6; },{ echo 
"$as_me:$LINENO: result: " >&5
+echo "${ECHO_T}" >&6; }
+       LIBS="$LIBS -lf2c"
+
+{ echo "$as_me:$LINENO: checking for dgesvd_ in -llapack" >&5
+echo $ECHO_N "checking for dgesvd_ in -llapack... $ECHO_C" >&6; }
+if test "${ac_cv_lib_lapack_dgesvd_+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
 else
-  # Is the header compilable?
-{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-llapack  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-$ac_includes_default
-#include <$ac_header>
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dgesvd_ ();
+int
+main ()
+{
+return dgesvd_ ();
+  ;
+  return 0;
+}
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_link") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
@@ -7243,272 +6798,226 @@
   (exit $ac_status); } && {
         test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_header_compiler=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <$ac_header>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       }; then
-  ac_header_preproc=yes
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_lapack_dgesvd_=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-  ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in
-  yes:no: )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, 
rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the 
preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the 
compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
-    ac_header_preproc=yes
-    ;;
-  no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be 
compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing 
prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header:     check for missing prerequisite 
headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf 
documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But 
Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be 
Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the 
preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" 
>&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler 
will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take 
precedence" >&2;}
-
-    ;;
-esac
-{ echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  eval "$as_ac_Header=\$ac_header_preproc"
+       ac_cv_lib_lapack_dgesvd_=no
 fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
 
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_lapack_dgesvd_" >&5
+echo "${ECHO_T}$ac_cv_lib_lapack_dgesvd_" >&6; }
+if test $ac_cv_lib_lapack_dgesvd_ = yes; then
   cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+#define HAVE_LIBLAPACK 1
 _ACEOF
+
+  LIBS="-llapack $LIBS"
+
+else
  a=1
 fi
 
-done
 
-                       if test "$a" = 1
-                       then
 
+               if test x$a == x
+               then
                                cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_V4L1BUFFER 1
+#define CVD_HAVE_LAPACK 1
 _ACEOF
 
-                               have_v4l1buffer=yes
+                       have_lapack=yes
 
-                               options="$options v4l1buffer"
+                       options="$options lapack"
+
+               else
+                       LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
                        fi
                fi
 
+       if test "$have_lapack" != yes
+       then
+               :
+
+       fi
 
-# Check whether --with-v4l2 was given.
-if test "${with_v4l2+set}" = set; then
-  withval=$with_v4l2; if test "$withval" = no; then disable_v4l2=yes; else 
disable_v4l2=no; fi
-fi
 
-               if test "$disable_v4l2" != yes
+
+       if test "$with_lapack" != no && test "$have_lapack" != yes
                then
-                       a=no
-                       ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext 
$LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
+               if test "$with_lapack" == ""
+               then
+                       with_lapack=yes
+               fi
 
-                       { echo "$as_me:$LINENO: checking for v4l2" >&5
-echo $ECHO_N "checking for v4l2... $ECHO_C" >&6; }
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
 
+       { echo "$as_me:$LINENO: checking if f2c is needed for LAPACK" >&5
+echo $ECHO_N "checking if f2c is needed for LAPACK... $ECHO_C" >&6; },{ echo 
"$as_me:$LINENO: result: " >&5
+echo "${ECHO_T}" >&6; }
+       LIBS="$LIBS -lg2c"
+
+{ echo "$as_me:$LINENO: checking for dgesvd_ in -llapack" >&5
+echo $ECHO_N "checking for dgesvd_ in -llapack... $ECHO_C" >&6; }
+if test "${ac_cv_lib_lapack_dgesvd_+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-llapack  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-       #include <sys/types.h>
-                                                               #include 
<linux/types.h>
-                                                               #include 
<linux/videodev.h>
-                                                               int 
main(){V4L2_PIX_FMT_GREY;return 0;}
+/* confdefs.h.  */
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dgesvd_ ();
+int
+main ()
+{
+return dgesvd_ ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_link") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && {
-        test -z "$ac_c_werror_flag" ||
+        test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  a=yes
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_lapack_dgesvd_=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-
+       ac_cv_lib_lapack_dgesvd_=no
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-                       ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS 
conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-                       { echo "$as_me:$LINENO: result: $a" >&5
-echo "${ECHO_T}$a" >&6; }
-                       if test "$a" = yes
-                       then
-                               cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_V4L2BUFFER 1
-_ACEOF
-
-                               have_v4l2buffer=yes
-
-                               options="$options v4l2buffer"
-                       fi
-               fi
-
-               { echo "$as_me:$LINENO: checking kernel major number" >&5
-echo $ECHO_N "checking kernel major number... $ECHO_C" >&6; }
-               kernel_major=`uname -r | $AWK -F'[.-]' '{print $1}'`
-               { echo "$as_me:$LINENO: result: $kernel_major" >&5
-echo "${ECHO_T}$kernel_major" >&6; }
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_lapack_dgesvd_" >&5
+echo "${ECHO_T}$ac_cv_lib_lapack_dgesvd_" >&6; }
+if test $ac_cv_lib_lapack_dgesvd_ = yes; then
                cat >>confdefs.h <<_ACEOF
-#define CVD_KERNEL_MAJOR $kernel_major
+#define HAVE_LIBLAPACK 1
 _ACEOF
 
+  LIBS="-llapack $LIBS"
 
-               { echo "$as_me:$LINENO: checking kernel minor number" >&5
-echo $ECHO_N "checking kernel minor number... $ECHO_C" >&6; }
-               kernel_minor=`uname -r | $AWK -F'[.-]' '{print $2}'`
-               { echo "$as_me:$LINENO: result: $kernel_minor" >&5
-echo "${ECHO_T}$kernel_minor" >&6; }
-               cat >>confdefs.h <<_ACEOF
-#define CVD_KERNEL_MINOR $kernel_minor
-_ACEOF
-
+else
+  a=1
+fi
 
 
-               { echo "$as_me:$LINENO: checking kernel release number" >&5
-echo $ECHO_N "checking kernel release number... $ECHO_C" >&6; }
-               kernel_release=`uname -r | $AWK -F'[.-]' '{print $3}'`
-               { echo "$as_me:$LINENO: result: $kernel_release" >&5
-echo "${ECHO_T}$kernel_release" >&6; }
-               cat >>confdefs.h <<_ACEOF
-#define CVD_KERNEL_RELEASE $kernel_release
-_ACEOF
 
-       ;;
-       *sgi*)
-               os_options="O2buffer"
+               if test x$a == x
+               then
                cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_O2UBFFER 1
+#define CVD_HAVE_LAPACK 1
 _ACEOF
 
-               have_o2buffer=yes
-
+                       have_lapack=yes
 
+                       options="$options lapack"
 
-# Check whether --with-o2buffer was given.
-if test "${with_o2buffer+set}" = set; then
-  withval=$with_o2buffer; if test "$withval" = no; then disable_o2buffer=yes; 
else disable_o2buffer=no; fi
-fi
+               else
+                       LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
+               fi
+       fi
 
-               if test "$disable_o2buffer" != yes
+       if test "$have_lapack" != yes
                then
-                       echo "I hope all SGIs have stuff needed for O2buffer. 
Disable (--without-o2buffer) if I'm wrong."
-                       options="$options O2buffer"
+               :
+
                fi
-       ;;
-esac
 
-if test "$host_vendor" == apple
-then
-       os_options="qtbuffer"
 
-# Check whether --with-quicktime was given.
-if test "${with_quicktime+set}" = set; then
-  withval=$with_quicktime; if test "$withval" = no; then disable_qtbuffer=yes; 
else disable_qtbuffer=no; fi
-fi
 
-       if test "$disable_qtbuffer" != yes
+       if test "$with_lapack" != no && test "$have_lapack" != yes
+       then
+               if test "$with_lapack" == ""
        then
+                       with_lapack=yes
+               fi
+
                save_LIBS="$LIBS"
-               LIBS="$LIBS -framework Carbon -framework QuickTime"
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
 
-               { echo "$as_me:$LINENO: checking Carbon and QuickTime 
framework" >&5
-echo $ECHO_N "checking Carbon and QuickTime framework... $ECHO_C" >&6; }
-               a=0
-               cat >conftest.$ac_ext <<_ACEOF
- #include <Carbon/Carbon.h>
-                                                       #include 
<QuickTime/QuickTime.h>
-                                                       int 
main(){InitCursor();EnterMovies();return 0;}
+       { echo "$as_me:$LINENO: checking if f2c is needed for LAPACK" >&5
+echo $ECHO_N "checking if f2c is needed for LAPACK... $ECHO_C" >&6; },{ echo 
"$as_me:$LINENO: result: " >&5
+echo "${ECHO_T}" >&6; }
+       LIBS="$LIBS -lgfortran"
+
+{ echo "$as_me:$LINENO: checking for dgesvd_ in -llapack" >&5
+echo $ECHO_N "checking for dgesvd_ in -llapack... $ECHO_C" >&6; }
+if test "${ac_cv_lib_lapack_dgesvd_+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-llapack  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dgesvd_ ();
+int
+main ()
+{
+return dgesvd_ ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_link") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
@@ -7517,61 +7026,76 @@
   (exit $ac_status); } && {
         test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  a=1
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_lapack_dgesvd_=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
+       ac_cv_lib_lapack_dgesvd_=no
+fi
 
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_lapack_dgesvd_" >&5
+echo "${ECHO_T}$ac_cv_lib_lapack_dgesvd_" >&6; }
+if test $ac_cv_lib_lapack_dgesvd_ = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBLAPACK 1
+_ACEOF
+
+  LIBS="-llapack $LIBS"
+
+else
+  a=1
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
-               if test x$a     = x1
+
+               if test x$a == x
                then
-                       { echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
                        cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_QTBUFFER 1
+#define CVD_HAVE_LAPACK 1
 _ACEOF
 
-                       have_qtbuffer=yes
+                       have_lapack=yes
+
+                       options="$options lapack"
 
-                       options="$options qtbuffer"
                else
-                       { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
                        LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
+               fi
                fi
+
+       if test "$have_lapack" != yes
+       then
+               :
+
        fi
-fi
 
 
-################################################################################
-#
-#Check for optional libraries
-#
 
-echo
-echo -------------------------------
-echo Checking for optional libraries
-echo -------------------------------
 
 
-# Check whether --with-threads was given.
-if test "${with_threads+set}" = set; then
-  withval=$with_threads; if test "$withval" = no; then disable_threads=yes; 
else disable_threads=no; fi
-fi
+       if test "$with_pthread" != no && test "$have_pthread" != yes
+       then
+               if test "$with_pthread" == ""
+               then
+                       with_pthread=yes
+               fi
 
-if test "$disable_threads" != yes
-then
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
 
+       CXXFLAGS="$CXXFLAGS -pthread"
+       LIBS="$LIBS -pthread"
        { echo "$as_me:$LINENO: checking for working pthreads" >&5
 echo $ECHO_N "checking for working pthreads... $ECHO_C" >&6; }
-       save_CXXFLAGS="$CXXFLAGS"
-       CXXFLAGS="$CXXFLAGS -pthread"
-       a=0
        cat >conftest.$ac_ext <<_ACEOF
 #include <pthread.h>
                                                void*foo(void*){}
@@ -7594,37 +7118,35 @@
         test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  a=1
+  { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-
+       { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }; a=1
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-       if test $a == 1
+
+
+               if test x$a == x
        then
-               { echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
                cat >>confdefs.h <<\_ACEOF
 #define CVD_HAVE_PTHREAD 1
 _ACEOF
 
                have_pthread=yes
 
-               LIBS="$LIBS -pthread"
-               options="$options pthreads"
+                       options="$options pthread"
 
                # check for existence of pthread_yield
                # Mac OS X only has pthread_yield_np
-
-for ac_func in pthread_yield
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
-if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+       a=
+       { echo "$as_me:$LINENO: checking for pthread_yield" >&5
+echo $ECHO_N "checking for pthread_yield... $ECHO_C" >&6; }
+if test "${ac_cv_func_pthread_yield+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
@@ -7633,12 +7155,12 @@
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-/* Define $ac_func to an innocuous variant, in case <limits.h> declares 
$ac_func.
+/* Define pthread_yield to an innocuous variant, in case <limits.h> declares 
pthread_yield.
    For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define $ac_func innocuous_$ac_func
+#define pthread_yield innocuous_pthread_yield
 
 /* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.
+    which can conflict with char pthread_yield (); below.
     Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
     <limits.h> exists even on freestanding compilers.  */
 
@@ -7648,7 +7170,7 @@
 # include <assert.h>
 #endif
 
-#undef $ac_func
+#undef pthread_yield
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
@@ -7656,18 +7178,18 @@
 #ifdef __cplusplus
 extern "C"
 #endif
-char $ac_func ();
+char pthread_yield ();
 /* The GNU C library defines this for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
-#if defined __stub_$ac_func || defined __stub___$ac_func
+#if defined __stub_pthread_yield || defined __stub___pthread_yield
 choke me
 #endif
 
 int
 main ()
 {
-return $ac_func ();
+return pthread_yield ();
   ;
   return 0;
 }
@@ -7690,38 +7212,31 @@
         test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  eval "$as_ac_var=yes"
+  ac_cv_func_pthread_yield=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       eval "$as_ac_var=no"
+       ac_cv_func_pthread_yield=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 fi
-ac_res=`eval echo '${'$as_ac_var'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
+{ echo "$as_me:$LINENO: result: $ac_cv_func_pthread_yield" >&5
+echo "${ECHO_T}$ac_cv_func_pthread_yield" >&6; }
+if test $ac_cv_func_pthread_yield = yes; then
  cat >>confdefs.h <<\_ACEOF
 #define CVD_HAVE_PTHREAD_YIELD 1
 _ACEOF
 
+else
+  a=1$a
 fi
-done
 
-
-for ac_func in pthread_yield_np
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
-if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+       { echo "$as_me:$LINENO: checking for pthread_yield_np" >&5
+echo $ECHO_N "checking for pthread_yield_np... $ECHO_C" >&6; }
+if test "${ac_cv_func_pthread_yield_np+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
@@ -7730,12 +7245,12 @@
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-/* Define $ac_func to an innocuous variant, in case <limits.h> declares 
$ac_func.
+/* Define pthread_yield_np to an innocuous variant, in case <limits.h> 
declares pthread_yield_np.
    For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define $ac_func innocuous_$ac_func
+#define pthread_yield_np innocuous_pthread_yield_np
 
 /* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.
+    which can conflict with char pthread_yield_np (); below.
     Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
     <limits.h> exists even on freestanding compilers.  */
 
@@ -7745,7 +7260,7 @@
 # include <assert.h>
 #endif
 
-#undef $ac_func
+#undef pthread_yield_np
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
@@ -7753,18 +7268,18 @@
 #ifdef __cplusplus
 extern "C"
 #endif
-char $ac_func ();
+char pthread_yield_np ();
 /* The GNU C library defines this for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
-#if defined __stub_$ac_func || defined __stub___$ac_func
+#if defined __stub_pthread_yield_np || defined __stub___pthread_yield_np
 choke me
 #endif
 
 int
 main ()
 {
-return $ac_func ();
+return pthread_yield_np ();
   ;
   return 0;
 }
@@ -7787,296 +7302,209 @@
         test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  eval "$as_ac_var=yes"
+  ac_cv_func_pthread_yield_np=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       eval "$as_ac_var=no"
+       ac_cv_func_pthread_yield_np=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 fi
-ac_res=`eval echo '${'$as_ac_var'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
+{ echo "$as_me:$LINENO: result: $ac_cv_func_pthread_yield_np" >&5
+echo "${ECHO_T}$ac_cv_func_pthread_yield_np" >&6; }
+if test $ac_cv_func_pthread_yield_np = yes; then
  cat >>confdefs.h <<\_ACEOF
 #define CVD_HAVE_PTHREAD_YIELD_NP 1
 _ACEOF
 
+else
+  a=1$a
 fi
-done
+
+       if test x$a = x11
+       then
+               dodginess_options="$dodginess_options no_pthread_yield"
+       fi
 
        else
-               { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
+                       LIBS="$save_LIBS"
                CXXFLAGS="$save_CXXFLAGS"
        fi
-fi
-
-{ echo "$as_me:$LINENO: checking for X" >&5
-echo $ECHO_N "checking for X... $ECHO_C" >&6; }
-
+       fi
 
-# Check whether --with-x was given.
-if test "${with_x+set}" = set; then
-  withval=$with_x;
-fi
+       if test "$have_pthread" != yes
+       then
+               :
 
-# $have_x is `yes', `no', `disabled', or empty when we do not yet know.
-if test "x$with_x" = xno; then
-  # The user explicitly disabled X.
-  have_x=disabled
-else
-  case $x_includes,$x_libraries in #(
-    *\'*) { { echo "$as_me:$LINENO: error: Cannot use X directory names 
containing '" >&5
-echo "$as_me: error: Cannot use X directory names containing '" >&2;}
-   { (exit 1); exit 1; }; };; #(
-    *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  # One or both of the vars are not set, and there is no cached value.
-ac_x_includes=no ac_x_libraries=no
-rm -f -r conftest.dir
-if mkdir conftest.dir; then
-  cd conftest.dir
-  cat >Imakefile <<'_ACEOF'
-incroot:
-       @echo incroot='${INCROOT}'
-usrlibdir:
-       @echo usrlibdir='${USRLIBDIR}'
-libdir:
-       @echo libdir='${LIBDIR}'
-_ACEOF
-  if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; 
then
-    # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
-    for ac_var in incroot usrlibdir libdir; do
-      eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 
's/^$ac_var=//p'\`"
-    done
-    # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
-    for ac_extension in a so sl; do
-      if test ! -f "$ac_im_usrlibdir/libX11.$ac_extension" &&
-        test -f "$ac_im_libdir/libX11.$ac_extension"; then
-       ac_im_usrlibdir=$ac_im_libdir; break
-      fi
-    done
-    # Screen out bogus values from the imake configuration.  They are
-    # bogus both because they are the default anyway, and because
-    # using them would break gcc on systems where it needs fixed includes.
-    case $ac_im_incroot in
-       /usr/include) ac_x_includes= ;;
-       *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
-    esac
-    case $ac_im_usrlibdir in
-       /usr/lib | /lib) ;;
-       *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
-    esac
   fi
-  cd ..
-  rm -f -r conftest.dir
-fi
 
-# Standard set of common directories for X headers.
-# Check X11 before X11Rn because it is often a symlink to the current release.
-ac_x_header_dirs='
-/usr/X11/include
-/usr/X11R6/include
-/usr/X11R5/include
-/usr/X11R4/include
 
-/usr/include/X11
-/usr/include/X11R6
-/usr/include/X11R5
-/usr/include/X11R4
 
-/usr/local/X11/include
-/usr/local/X11R6/include
-/usr/local/X11R5/include
-/usr/local/X11R4/include
 
-/usr/local/include/X11
-/usr/local/include/X11R6
-/usr/local/include/X11R5
-/usr/local/include/X11R4
 
-/usr/X386/include
-/usr/x386/include
-/usr/XFree86/include/X11
 
-/usr/include
-/usr/local/include
-/usr/unsupported/include
-/usr/athena/include
-/usr/local/x11r5/include
-/usr/lpp/Xamples/include
+       if test "$with_png" != no && test "$have_png" != yes
+       then
+               if test "$with_png" == ""
+               then
+                       with_png=yes
+               fi
 
-/usr/openwin/include
-/usr/openwin/share/include'
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
 
-if test "$ac_x_includes" = no; then
-  # Guess where to find include files, by looking for Xlib.h.
-  # First, try using that file with no special directory specified.
-  cat >conftest.$ac_ext <<_ACEOF
+
+for ac_header in png.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <X11/Xlib.h>
+$ac_includes_default
+#include <$ac_header>
 _ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+  (exit $ac_status); } && {
+        test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
-       }; then
-  # We can compile using X headers with no special include directory.
-ac_x_includes=
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-  for ac_dir in $ac_x_header_dirs; do
-  if test -r "$ac_dir/X11/Xlib.h"; then
-    ac_x_includes=$ac_dir
-    break
-  fi
-done
+       ac_header_compiler=no
 fi
 
-rm -f conftest.err conftest.$ac_ext
-fi # $ac_x_includes = no
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
 
-if test "$ac_x_libraries" = no; then
-  # Check for the libraries.
-  # See if we find them without any special options.
-  # Don't add to $LIBS permanently.
-  ac_save_LIBS=$LIBS
-  LIBS="-lX11 $LIBS"
-  cat >conftest.$ac_ext <<_ACEOF
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <X11/Xlib.h>
-int
-main ()
-{
-XrmInitialize ()
-  ;
-  return 0;
-}
+#include <$ac_header>
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
+if { (ac_try="$ac_cpp conftest.$ac_ext"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  LIBS=$ac_save_LIBS
-# We can link X programs with no special library path.
-ac_x_libraries=
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       LIBS=$ac_save_LIBS
-for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
-do
-  # Don't even attempt the hair of trying to link an X program!
-  for ac_extension in a so sl; do
-    if test -r "$ac_dir/libX11.$ac_extension"; then
-      ac_x_libraries=$ac_dir
-      break 2
-    fi
-  done
-done
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-fi # $ac_x_libraries = no
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
 
-case $ac_x_includes,$ac_x_libraries in #(
-  no,* | *,no | *\'*)
-    # Didn't find X, or a directory has "'" in its name.
-    ac_cv_have_x="have_x=no";; #(
-  *)
-    # Record where we found X for the cache.
-    ac_cv_have_x="have_x=yes\
-       ac_x_includes='$ac_x_includes'\
-       ac_x_libraries='$ac_x_libraries'"
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, 
rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the 
preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the 
compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be 
compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing 
prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite 
headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf 
documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But 
Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be 
Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the 
preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" 
>&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler 
will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take 
precedence" >&2;}
+
+    ;;
 esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
 fi
-;; #(
-    *) have_x=yes;;
-  esac
-  eval "$ac_cv_have_x"
-fi # $with_x != no
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
 
-if test "$have_x" != yes; then
-  { echo "$as_me:$LINENO: result: $have_x" >&5
-echo "${ECHO_T}$have_x" >&6; }
-  no_x=yes
-else
-  # If each of the values was on the command line, it overrides each guess.
-  test "x$x_includes" = xNONE && x_includes=$ac_x_includes
-  test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
-  # Update the cache value to reflect the command line values.
-  ac_cv_have_x="have_x=yes\
-       ac_x_includes='$x_includes'\
-       ac_x_libraries='$x_libraries'"
-  { echo "$as_me:$LINENO: result: libraries $x_libraries, headers $x_includes" 
>&5
-echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&6; }
 fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
 
+fi
 
-save_CXXFLAGS="$CXXFLAGS"
-save_LIBS="$LIBS"
-if test "x$ac_cv_have_x" != x
-then
-       LIBS="-L$x_libraries -lX11 -lXext $LIBS"
-       if test "x$x_includes" != x
-       then
-               CXXFLAGS="$CXXFLAGS -I$x_includes"
-       fi
+done
 
 
-{ echo "$as_me:$LINENO: checking for glDrawPixels in -lGL" >&5
-echo $ECHO_N "checking for glDrawPixels in -lGL... $ECHO_C" >&6; }
-if test "${ac_cv_lib_GL_glDrawPixels+set}" = set; then
+{ echo "$as_me:$LINENO: checking for png_init_io in -lpng" >&5
+echo $ECHO_N "checking for png_init_io in -lpng... $ECHO_C" >&6; }
+if test "${ac_cv_lib_png_png_init_io+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lGL  $LIBS"
+LIBS="-lpng  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -8090,11 +7518,11 @@
 #ifdef __cplusplus
 extern "C"
 #endif
-char glDrawPixels ();
+char png_init_io ();
 int
 main ()
 {
-return glDrawPixels ();
+return png_init_io ();
   ;
   return 0;
 }
@@ -8117,63 +7545,66 @@
         test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_GL_glDrawPixels=yes
+  ac_cv_lib_png_png_init_io=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cv_lib_GL_glDrawPixels=no
+       ac_cv_lib_png_png_init_io=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_GL_glDrawPixels" >&5
-echo "${ECHO_T}$ac_cv_lib_GL_glDrawPixels" >&6; }
-if test $ac_cv_lib_GL_glDrawPixels = yes; then
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_png_png_init_io" >&5
+echo "${ECHO_T}$ac_cv_lib_png_png_init_io" >&6; }
+if test $ac_cv_lib_png_png_init_io = yes; then
   cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBGL 1
+#define HAVE_LIBPNG 1
 _ACEOF
 
-  LIBS="-lGL $LIBS"
+  LIBS="-lpng $LIBS"
 
 fi
 
 
-       if test "$ac_cv_lib_GL_glDrawPixels" != no
+
+               if test x$a == x
        then
                cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_VIDEODISPLAY 1
+#define CVD_HAVE_PNG 1
 _ACEOF
 
-               options="$options videodisplay"
-               have_videodisplay=yes
+                       have_png=yes
+
+                       options="$options png"
 
-               LIBS="-lGL $LIBS"
        else
                LIBS="$save_LIBS"
-               CXXFLAGS="$CXXFLAGS"
+                       CXXFLAGS="$save_CXXFLAGS"
+               fi
        fi
-fi
 
-#Put this before TIFF. If libjpeg is static, then this will ensure
-#(hopefully) that it selected before libtiff is tested (libtiff may
-#depend on libjpeg)
+       if test "$have_png" != yes
+       then
+               :
 
-# Check whether --with-jpeg was given.
-if test "${with_jpeg+set}" = set; then
-  withval=$with_jpeg; if test "$withval" = no; then disable_jpeg=yes; else 
disable_jpeg=no; fi
-fi
+       fi
 
 
-# Check whether --with-jpegbuffer was given.
-if test "${with_jpegbuffer+set}" = set; then
-  withval=$with_jpegbuffer; jpegbuffersize="$withval";
-fi
 
-if test "$disable_jpeg" != yes
-then
+       if test "$with_jpeg" != no && test "$have_jpeg" != yes
+       then
+               if test "$with_jpeg" == ""
+               then
+                       with_jpeg=yes
+               fi
+
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
+
 
 for ac_header in jpeglib.h
 do
@@ -8385,26 +7816,23 @@
 
 fi
 
-       if test "$ac_cv_header_jpeglib_h" = yes && test 
"$ac_cv_lib_jpeg_jpeg_destroy_decompress" = yes
+
+
+               if test x$a == x
        then
                cat >>confdefs.h <<\_ACEOF
-#define CVD_IMAGE_HAVE_JPEG JPEG,
+#define CVD_HAVE_JPEG 1
 _ACEOF
 
                have_jpeg=yes
 
                options="$options jpeg"
 
+
                { echo "$as_me:$LINENO: checking JPEG read buffer size" >&5
 echo $ECHO_N "checking JPEG read buffer size... $ECHO_C" >&6; }
 
-               if test "$jpegbuffersize" == yes
-               then
-                       jpegbuffersize=8192
-               elif test "$jpegbuffersize" == no || test "$jpegbuffersize" == 
""
-               then
-                       jpegbuffersize=1
-               fi
+       jpegbuffersize="`echo $with_jpegbuffer | awk '$1 = ($1+0<= 0)?1:$1'`"
 
                if test "$jpegbuffersize" -gt 1
                then
@@ -8416,43 +7844,37 @@
                        { echo "$as_me:$LINENO: result: 1 (safe reading)" >&5
 echo "${ECHO_T}1 (safe reading)" >&6; };
                fi
-
                cat >>confdefs.h <<_ACEOF
 #define CVD_INTERNAL_JPEG_BUFFER_SIZE $jpegbuffersize
 _ACEOF
 
-       fi
-fi
-
 
-tiffarg=
-#AC_ARG_WITH(tiff, [  --without-tiff       compile without TIFF support],[if 
test "$withval" = no; then disable_tiff=yes; else disable_tiff=no; fi])
+               else
+                       LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
+               fi
+       fi
 
-# Check whether --with-tiff was given.
-if test "${with_tiff+set}" = set; then
-  withval=$with_tiff; tiffarg="$withval";
-fi
+       if test "$have_jpeg" != yes
+       then
+               :
 
+       fi
 
-# Check whether --with-tiff was given.
-if test "${with_tiff+set}" = set; then
-  withval=$with_tiff; tiffarg="$withval";
-fi
 
 
 
+       if test "$with_tiff" != no && test "$have_tiff" != yes
+       then
+               if test "$with_tiff" == ""
+               then
+                       with_tiff=yes
+               fi
 
-disable_tiff=no
-if test "$tiffarg" = no
-then
-       disable_tiff=yes
-elif test "$tiffarg" = forceold
-then
-       force_old_tiff=yes
-fi
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
 
-if test "$disable_tiff" != yes
-then
 
 for ac_header in tiffio.h
 do
@@ -8586,104 +8008,15 @@
 fi
 if test `eval echo '${'$as_ac_Header'}'` = yes; then
   cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-       if test "$ac_cv_header_tiffio_h" = yes
-       then
-
-               foo_LIBS="$LIBS"
-               tiff_works=
-
-               #Repeat twice, once for normal checking
-               #and once with an additional check for zlib
-               for i in 1 2
-               do
-
-                       #Check first for new style tiff
-
-                       if test "$force_old_tiff" != yes
-                       then
-
-{ echo "$as_me:$LINENO: checking for TIFFReadRGBAImageOriented in -ltiff" >&5
-echo $ECHO_N "checking for TIFFReadRGBAImageOriented in -ltiff... $ECHO_C" 
>&6; }
-if test "${ac_cv_lib_tiff_TIFFReadRGBAImageOriented+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ltiff  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char TIFFReadRGBAImageOriented ();
-int
-main ()
-{
-return TIFFReadRGBAImageOriented ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_tiff_TIFFReadRGBAImageOriented=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_cv_lib_tiff_TIFFReadRGBAImageOriented=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_tiff_TIFFReadRGBAImageOriented" >&5
-echo "${ECHO_T}$ac_cv_lib_tiff_TIFFReadRGBAImageOriented" >&6; }
-if test $ac_cv_lib_tiff_TIFFReadRGBAImageOriented = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBTIFF 1
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
 
-  LIBS="-ltiff $LIBS"
-
+else
+  a=1
 fi
 
-                               test x$ac_cv_lib_tiff_TIFFReadRGBAImageOriented 
== xyes && tiff_works=yes
-                       fi
+done
 
-                       if test x$tiff_works == x
-                       then
 
 { echo "$as_me:$LINENO: checking for TIFFReadRGBAImage in -ltiff" >&5
 echo $ECHO_N "checking for TIFFReadRGBAImage in -ltiff... $ECHO_C" >&6; }
@@ -8753,146 +8086,54 @@
 
   LIBS="-ltiff $LIBS"
 
-fi
-
-                               test x$ac_cv_lib_tiff_TIFFReadRGBAImage == xyes 
&& tiff_works=old
-                       fi
-
-                       if test x$tiff_works == x && test $i == 1
-                       then
-                               { echo "$as_me:$LINENO: checking if perhaps 
libtiff requires zlib" >&5
-echo $ECHO_N "checking if perhaps libtiff requires zlib... $ECHO_C" >&6; }
-                               { echo "$as_me:$LINENO: result: " >&5
-echo "${ECHO_T}" >&6; }
-
-{ echo "$as_me:$LINENO: checking for deflate in -lz" >&5
-echo $ECHO_N "checking for deflate in -lz... $ECHO_C" >&6; }
-if test "${ac_cv_lib_z_deflate+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lz  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char deflate ();
-int
-main ()
-{
-return deflate ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_cxx_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_z_deflate=yes
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_cv_lib_z_deflate=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+  a=1
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_z_deflate" >&5
-echo "${ECHO_T}$ac_cv_lib_z_deflate" >&6; }
-if test $ac_cv_lib_z_deflate = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBZ 1
-_ACEOF
-
-  LIBS="-lz $LIBS"
 
-fi
 
-                               unset ac_cv_lib_tiff_TIFFReadRGBAImage
-                               unset ac_cv_lib_tiff_TIFFReadRGBAImageOriented
-                               tiff_needs_zlib=1
-                       else
-                               break
-                       fi
-               done
 
-               if test x$tiff_works == x
+               if test x$a == x
                then
-                       #This removes the extraneous zlib
-                       LIBS=$foo_LIBS
-               else
                        cat >>confdefs.h <<\_ACEOF
-#define CVD_IMAGE_HAVE_TIFF TIFF,
+#define CVD_HAVE_TIFF 1
 _ACEOF
 
                        have_tiff=yes
 
                        options="$options tiff"
 
-                       if test x$tiff_works == xold
-                       then
-                               { echo "$as_me:$LINENO: WARNING: libtiff is 
present but old. Loading large TIFFs might be slow." >&5
-echo "$as_me: WARNING: libtiff is present but old. Loading large TIFFs might 
be slow." >&2;}
-                               dodginess_options="$dodginess_options oldtiff"
                        else
-                               cat >>confdefs.h <<\_ACEOF
-#define CVD_INTERNAL_HAVE_TIFF_ORIENTED TIFF,
-_ACEOF
-
+                       LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
+               fi
                        fi
 
-                       if test x$tiff_needs_zlib != x
+       if test "$have_tiff" != yes
                        then
-                               { echo "$as_me:$LINENO: WARNING: libtiff is 
present but requires zlib to be specified manually. Something is odd about your 
build system" >&5
-echo "$as_me: WARNING: libtiff is present but requires zlib to be specified 
manually. Something is odd about your build system" >&2;}
-                               dodginess_options="$dodginess_options 
tiff_needs_zlib"
-                       fi
-               fi
+               :
+
        fi
-fi
 
 
 
-#Put this before TIFF. If libjpeg is static, then this will ensure
-#(hopefully) that it selected before libtiff is tested (libtiff may
-#depend on libjpeg)
+       if test "$with_tiff" != no && test "$have_tiff" != yes
+       then
+               if test "$with_tiff" == ""
+               then
+                       with_tiff=yes
+               fi
 
-# Check whether --with-png was given.
-if test "${with_png+set}" = set; then
-  withval=$with_png; if test "$withval" = no; then disable_png=yes; else 
disable_png=no; fi
-fi
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
 
-if test "$disable_png" != yes
-then
+       { echo "$as_me:$LINENO: checking if perhaps libtiff requires zlib" >&5
+echo $ECHO_N "checking if perhaps libtiff requires zlib... $ECHO_C" >&6; }
+       { echo "$as_me:$LINENO: result: " >&5
+echo "${ECHO_T}" >&6; }
+       unset ac_cv_lib_tiff_TIFFReadRGBAImage
 
-for ac_header in png.h
+for ac_header in tiffio.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
@@ -9015,30 +8256,209 @@
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  eval "$as_ac_Header=\$ac_header_preproc"
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+else
+  a=1
+fi
+
+done
+
+
+{ echo "$as_me:$LINENO: checking for deflate in -lz" >&5
+echo $ECHO_N "checking for deflate in -lz... $ECHO_C" >&6; }
+if test "${ac_cv_lib_z_deflate+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lz  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char deflate ();
+int
+main ()
+{
+return deflate ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_z_deflate=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cv_lib_z_deflate=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_z_deflate" >&5
+echo "${ECHO_T}$ac_cv_lib_z_deflate" >&6; }
+if test $ac_cv_lib_z_deflate = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBZ 1
+_ACEOF
+
+  LIBS="-lz $LIBS"
+
+else
+  a=1
+fi
+
+
+{ echo "$as_me:$LINENO: checking for TIFFReadRGBAImage in -ltiff" >&5
+echo $ECHO_N "checking for TIFFReadRGBAImage in -ltiff... $ECHO_C" >&6; }
+if test "${ac_cv_lib_tiff_TIFFReadRGBAImage+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ltiff  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char TIFFReadRGBAImage ();
+int
+main ()
+{
+return TIFFReadRGBAImage ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_tiff_TIFFReadRGBAImage=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cv_lib_tiff_TIFFReadRGBAImage=no
 fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
 
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_tiff_TIFFReadRGBAImage" >&5
+echo "${ECHO_T}$ac_cv_lib_tiff_TIFFReadRGBAImage" >&6; }
+if test $ac_cv_lib_tiff_TIFFReadRGBAImage = yes; then
   cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+#define HAVE_LIBTIFF 1
 _ACEOF
 
+  LIBS="-ltiff $LIBS"
+
+else
+  a=1
 fi
 
-done
 
 
-{ echo "$as_me:$LINENO: checking for png_init_io in -lpng" >&5
-echo $ECHO_N "checking for png_init_io in -lpng... $ECHO_C" >&6; }
-if test "${ac_cv_lib_png_png_init_io+set}" = set; then
+               if test x$a == x
+               then
+                       cat >>confdefs.h <<\_ACEOF
+#define CVD_HAVE_TIFF 1
+_ACEOF
+
+                       have_tiff=yes
+
+                       options="$options tiff"
+
+       dodginess_options="$dodginess_options tiff_needs_zlib"
+
+               else
+                       LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
+               fi
+       fi
+
+       if test "$have_tiff" != yes
+       then
+               :
+
+       fi
+
+
+if test "$have_tiff" == yes
+then
+       a=
+       if test "$with_tiff" != forceold
+       then
+               { echo "$as_me:$LINENO: checking for TIFFReadRGBAImageOriented 
in -ltiff" >&5
+echo $ECHO_N "checking for TIFFReadRGBAImageOriented in -ltiff... $ECHO_C" 
>&6; }
+if test "${ac_cv_lib_tiff_TIFFReadRGBAImageOriented+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpng  $LIBS"
+LIBS="-ltiff  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -9052,11 +8472,11 @@
 #ifdef __cplusplus
 extern "C"
 #endif
-char png_init_io ();
+char TIFFReadRGBAImageOriented ();
 int
 main ()
 {
-return png_init_io ();
+return TIFFReadRGBAImageOriented ();
   ;
   return 0;
 }
@@ -9079,62 +8499,61 @@
         test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_png_png_init_io=yes
+  ac_cv_lib_tiff_TIFFReadRGBAImageOriented=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cv_lib_png_png_init_io=no
+       ac_cv_lib_tiff_TIFFReadRGBAImageOriented=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_png_png_init_io" >&5
-echo "${ECHO_T}$ac_cv_lib_png_png_init_io" >&6; }
-if test $ac_cv_lib_png_png_init_io = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBPNG 1
-_ACEOF
-
-  LIBS="-lpng $LIBS"
-
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_tiff_TIFFReadRGBAImageOriented" >&5
+echo "${ECHO_T}$ac_cv_lib_tiff_TIFFReadRGBAImageOriented" >&6; }
+if test $ac_cv_lib_tiff_TIFFReadRGBAImageOriented = yes; then
+  a=1
 fi
 
-       if test "$ac_cv_header_png_h" = yes && test 
"$ac_cv_lib_png_png_init_io" = yes
+       fi
+
+       if test x$a = x
        then
+               dodginess_options="$dodginess_options oldtiff"
+       else
                cat >>confdefs.h <<\_ACEOF
-#define CVD_IMAGE_HAVE_PNG PNG,
+#define CVD_INTERNAL_HAVE_TIFF_ORIENTED 1
 _ACEOF
 
-               have_png=yes
-
-               options="$options png"
        fi
 fi
 
 
-# Check whether --with-ffmpeg was given.
-if test "${with_ffmpeg+set}" = set; then
-  withval=$with_ffmpeg; if test "$withval" = no; then use_ffmpeg=no; else 
use_ffmpeg="$withval"; fi
-fi
 
-if test "$use_ffmpeg" != no
-then
-       save_LIBS="$LIBS"
-       if test x"$use_ffmpeg" != x
+
+
+       if test "$with_ffmpeg" != no && test "$have_ffmpeg" != yes
+       then
+               if test "$with_ffmpeg" == ""
        then
-               LIBS="$LIBS -L $use_ffmpeg"
+                       with_ffmpeg=yes
        fi
 
-       gxx_version=`$CXX -dumpversion`
-       if test $gxx_version = 4.1.0
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
+
+       if test "$with_ffmpeg" != yes
+       then
+               LIBS="$LIBS -L $with_ffmpeg"
+       fi
+       if test "`$CXX -dumpversion`" = 4.1.0
        then
                CXXFLAGS="$CXXFLAGS -D__STDC_CONSTANT_MACROS"
        fi
 
-       a=
 
 
 for ac_header in ffmpeg/avcodec.h ffmpeg/avformat.h
@@ -9273,7 +8692,7 @@
 _ACEOF
 
 else
-  break
+  a=1
 fi
 
 done
@@ -9341,6 +8760,8 @@
 
   LIBS="-lavutil $LIBS"
 
+else
+  a=1
 fi
 
 
@@ -9412,10 +8833,11 @@
 
   LIBS="-lavformat $LIBS"
 
+else
+  a=1
 fi
 
-
-{ echo "$as_me:$LINENO: checking for av_read_frame in -lavformat" >&5
+       { echo "$as_me:$LINENO: checking for av_read_frame in -lavformat" >&5
 echo $ECHO_N "checking for av_read_frame in -lavformat... $ECHO_C" >&6; }
 if test "${ac_cv_lib_avformat_av_read_frame+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -9477,12 +8899,9 @@
 { echo "$as_me:$LINENO: result: $ac_cv_lib_avformat_av_read_frame" >&5
 echo "${ECHO_T}$ac_cv_lib_avformat_av_read_frame" >&6; }
 if test $ac_cv_lib_avformat_av_read_frame = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBAVFORMAT 1
-_ACEOF
-
-  LIBS="-lavformat $LIBS"
-
+  ffmpeg_recent=yes
+else
+  a=1
 fi
  #only in >= 0.4.9
 
@@ -9554,11 +8973,18 @@
 
   LIBS="-lavcodec $LIBS"
 
+else
+  a=1
 fi
 
-       if test 
"$ac_cv_lib_avcodec_avcodec_open$ac_cv_lib_avformat_av_open_input_file" = yesyes
+
+       if test x$ffmpeg_recent$a = x1
        then
-               if test "$ac_cv_lib_avformat_av_read_frame" = yes
+               echo "You have FFMPEG, but the version is too old. Version 
0.4.9 or newer is required."
+       fi
+
+
+               if test x$a == x
                then
                        cat >>confdefs.h <<\_ACEOF
 #define CVD_HAVE_FFMPEG 1
@@ -9567,34 +8993,57 @@
                        have_ffmpeg=yes
 
                        options="$options ffmpeg"
-                       save_LIBS="$LIBS"
+
                else
-                       echo "You have FFMPEG, but the version is too old. 
Version 0.4.9 or newer is required."
+                       LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
                fi
        fi
 
-       LIBS="$save_LIBS"
-fi
+       if test "$have_ffmpeg" != yes
+       then
+               :
+
+       fi
+
+
 
 
################################################################################
 #
 # platform compatibility
+# All of these ought to be yes
 echo
 echo -----------------------------------
 echo Checking for platform compatibility
 echo -----------------------------------
 
 
-
 # Check whether --with-glob was given.
 if test "${with_glob+set}" = set; then
-  withval=$with_glob; have_glob="$withval"
+  withval=$with_glob;
 fi
 
-have_glob="${have_glob:-yes}"
 
-if test "$have_glob" = yes
-then
+# Check whether --with-memalign was given.
+if test "${with_memalign+set}" = set; then
+  withval=$with_memalign;
+fi
+
+
+
+
+
+       if test "$with_glob" != no && test "$have_glob" != yes
+       then
+               if test "$with_glob" == ""
+               then
+                       with_glob=yes
+               fi
+
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
+
 
 for ac_header in glob.h
 do
@@ -9730,24 +9179,40 @@
   cat >>confdefs.h <<_ACEOF
 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
- glob_headers=yes
+
+else
+  a=1
 fi
 
 done
 
-       { echo "$as_me:$LINENO: checking for glob in -lc" >&5
-echo $ECHO_N "checking for glob in -lc... $ECHO_C" >&6; }
-if test "${ac_cv_lib_c_glob+set}" = set; then
+       { echo "$as_me:$LINENO: checking for glob" >&5
+echo $ECHO_N "checking for glob... $ECHO_C" >&6; }
+if test "${ac_cv_func_glob+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lc  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
+/* Define glob to an innocuous variant, in case <limits.h> declares glob.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define glob innocuous_glob
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char glob (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef glob
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
@@ -9756,6 +9221,13 @@
 extern "C"
 #endif
 char glob ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_glob || defined __stub___glob
+choke me
+#endif
+
 int
 main ()
 {
@@ -9782,43 +9254,39 @@
         test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_c_glob=yes
+  ac_cv_func_glob=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cv_lib_c_glob=no
+       ac_cv_func_glob=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_c_glob" >&5
-echo "${ECHO_T}$ac_cv_lib_c_glob" >&6; }
-if test $ac_cv_lib_c_glob = yes; then
-  glob_lib=yes
+{ echo "$as_me:$LINENO: result: $ac_cv_func_glob" >&5
+echo "${ECHO_T}$ac_cv_func_glob" >&6; }
+if test $ac_cv_func_glob = yes; then
+  :
+else
+  a=1
 fi
 
-       if test x$glob_headers$glob_lib != xyesyes
-       then
-               have_glob=no
-       fi
-fi
 
-if test "$have_glob" == yes
-then
-       have_glob=yes
 
+               if test x$a == x
+               then
        cat >>confdefs.h <<\_ACEOF
 #define CVD_HAVE_GLOB 1
 _ACEOF
 
-       options="$options globlist"
+                       have_glob=yes
+
+                       options="$options glob"
 
        { echo "$as_me:$LINENO: checking for GLOB_BRACE and GLOB_TILDE in 
glob.h" >&5
 echo $ECHO_N "checking for GLOB_BRACE and GLOB_TILDE in glob.h... $ECHO_C" 
>&6; }
-       a=
        cat >conftest.$ac_ext <<_ACEOF
 #include <glob.h>
        int main(){glob(0, GLOB_BRACE|GLOB_TILDE,0,0);}
@@ -9840,34 +9308,40 @@
         test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  a=1
+  { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-       if test x$a = x1
-       then
-               { echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
-       else
                { echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6; }
-               { echo "$as_me:$LINENO: WARNING: glob matching is only partly 
functional. Your existing globs may not work." >&5
-echo "$as_me: WARNING: glob matching is only partly functional. Your existing 
globs may not work." >&2;}
                cat >>confdefs.h <<\_ACEOF
 #define CVD_INTERNAL_GLOB_IS_BAD 1
 _ACEOF
 
                dodginess_options="$dodginess_options broken_glob"
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+               else
+                       LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
        fi
-else
+       fi
+
+       if test "$have_glob" != yes
+       then
+               :
+
        dodginess_options="$dodginess_options no_glob"
-fi
+
+       fi
+
+
 
 a=
 { echo "$as_me:$LINENO: checking whether feenableexcept is declared" >&5
@@ -9935,25 +9409,80 @@
 #define CVD_HAVE_FENV_H 1
 _ACEOF
 
-else
-       dodginess_options="$dodginess_options missing_c99_feenableexcept"
-fi
+else
+       dodginess_options="$dodginess_options missing_c99_feenableexcept"
+fi
+
+
+       if test "$with_memalign" != no && test "$have_memalign" != yes
+       then
+               if test "$with_memalign" == ""
+               then
+                       with_memalign=yes
+               fi
+
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
+
+       { echo "$as_me:$LINENO: checking for posix_memalign" >&5
+echo $ECHO_N "checking for posix_memalign... $ECHO_C" >&6; }
+if test "${ac_cv_func_posix_memalign+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define posix_memalign to an innocuous variant, in case <limits.h> declares 
posix_memalign.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define posix_memalign innocuous_posix_memalign
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char posix_memalign (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef posix_memalign
 
-{ echo "$as_me:$LINENO: checking for posix_memalign" >&5
-echo $ECHO_N "checking for posix_memalign... $ECHO_C" >&6; }
-a=0
-cat >conftest.$ac_ext <<_ACEOF
-#include <stdlib.h>
-                               int main(){void* mem; 
posix_memalign(&mem,16,100); return 0;}
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char posix_memalign ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_posix_memalign || defined __stub___posix_memalign
+choke me
+#endif
+
+int
+main ()
+{
+return posix_memalign ();
+  ;
+  return 0;
+}
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_link") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
@@ -9962,33 +9491,50 @@
   (exit $ac_status); } && {
         test -z "$ac_cxx_werror_flag" ||
         test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  a=1
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_func_posix_memalign=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
+       ac_cv_func_posix_memalign=no
+fi
 
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_func_posix_memalign" >&5
+echo "${ECHO_T}$ac_cv_func_posix_memalign" >&6; }
+if test $ac_cv_func_posix_memalign = yes; then
+  :
+else
+  a=1
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-if test $a == 1
-then
-       { echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
+
+
+               if test x$a == x
+               then
        cat >>confdefs.h <<\_ACEOF
 #define CVD_HAVE_MEMALIGN 1
 _ACEOF
 
        have_memalign=yes
 
-else
-       { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-       have_memalign=no
+                       options="$options memalign"
+
+               else
+                       LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
+               fi
+       fi
 
+       if test "$have_memalign" != yes
+       then
+               :
        dodginess_options="$dodginess_options no_posix_memalign"
-fi
+       fi
 
 
 
################################################################################
@@ -10014,186 +9560,255 @@
   enableval=$enable_ssefast12;
 fi
 
-
-if test "$enable_ssefast9"  != "no"
-then
-       have_faster9=yes
-
+# Check whether --enable-fast7 was given.
+if test "${enable_fast7+set}" = set; then
+  enableval=$enable_fast7;
 fi
 
-if test "$enable_ssefast10"  != "no"
-then
-       have_faster10=yes
-
+# Check whether --enable-fast8 was given.
+if test "${enable_fast8+set}" = set; then
+  enableval=$enable_fast8;
 fi
 
-if test "$enable_ssefast12"  != "no"
-then
-       have_faster12=yes
+# Check whether --enable-fast9 was given.
+if test "${enable_fast9+set}" = set; then
+  enableval=$enable_fast9;
+fi
 
+# Check whether --enable-fast10 was given.
+if test "${enable_fast10+set}" = set; then
+  enableval=$enable_fast10;
 fi
 
-if test "$enable_ssefast12$enable_ssefast10$enable_ssefast9" != "nonono" && 
test
-then
-       hidden_options="$hidden_options faster_test";
+# Check whether --enable-fast11 was given.
+if test "${enable_fast11+set}" = set; then
+  enableval=$enable_fast11;
 fi
 
-{ echo "$as_me:$LINENO: checking \"FAST detectors\"" >&5
-echo $ECHO_N "checking \"FAST detectors\"... $ECHO_C" >&6; }
-allfasts="7 8 9 10 11 12"
-# Check whether --enable-missingfast was given.
-if test "${enable_missingfast+set}" = set; then
-  enableval=$enable_missingfast;
+# Check whether --enable-fast12 was given.
+if test "${enable_fast12+set}" = set; then
+  enableval=$enable_fast12;
 fi
 
-wfasts="`echo $enable_missingfast | sed -e's/,/ /g'`"
-fasts="`echo $allfasts $wfasts |  tr ' ' '\n' | sort -n | uniq -u | tr '\n' ' 
'`"
 
-{ echo "$as_me:$LINENO: result: $fasts" >&5
-echo "${ECHO_T}$fasts" >&6; }
 
-if echo $fasts | grep -q 7
-then
-       have_FAST_7=yes
+test "$enable_fast7" != no && have_fast7=yes
 
-       cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_FAST_7 1
-_ACEOF
+test "$enable_fast8" != no && have_fast8=yes
 
+test "$enable_fast9" != no && have_fast9=yes
 
-fi
-if echo $fasts | grep -q 8
-then
-       have_FAST_8=yes
+test "$enable_fast10" != no && have_fast10=yes
 
-       cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_FAST_8 1
-_ACEOF
+test "$enable_fast11" != no && have_fast11=yes
 
-fi
-if echo $fasts | grep -q 9
-then
-       have_FAST_9=yes
+test "$enable_fast12" != no && have_fast12=yes
 
-       cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_FAST_9 1
-_ACEOF
 
-fi
-if echo $fasts | grep -q 10
-then
-       have_FAST_10=yes
+test "$enable_ssefast9" != no && have_ssefast9=yes
 
-       cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_FAST_10 1
-_ACEOF
+test "$enable_ssefast10" != no && have_ssefast10=yes
 
-fi
-if echo $fasts | grep -q 11
-then
-       have_FAST_11=yes
+test "$enable_ssefast12" != no && have_ssefast12=yes
 
-       cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_FAST_11 1
-_ACEOF
 
-fi
-if echo $fasts | grep -q 12
-then
-       have_FAST_12=yes
+################################################################################
+#
+# Compute dependencies
+#
 
-       cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_FAST_12 1
-_ACEOF
+#First, extract all the have_* variables
+for i in `echo $ac_subst_vars | tr ' ' '\n' | grep have_`
+do
+       eval echo $i \$$i
+done > config.have_bits
 
-fi
 
 
+#The dependency list
+#The file format is as follows:
+#
+# have_feature1 [yes]
+#
+# dependee_list_1 dependency_list_1
+# dependee_list_2 dependency_list_2
+#  ...
+# dependee_list_N dependee_list_N END
+#
+#
+# dependee_list is comma separated. dependency_list is whitespace separated.
+# If all the dependencies in dependency list are present (have_* is yes), then
+# dependee list is buildable. The lowest numbered dependee list is selected.
+#
+# The dependee list has a comma separated list of object files (minus the .o)
+# to be build. If a `file' is all caps, it is treated as a define, instead.
+#
+# Blank lines, and those starting with # are ignored
+cat config.have_bits - <<ENDDEPS  | awk -f make/compile_deps.awk > 
config.dep_tmp
+
+#SIMD dependencies
+cvd_src/i686/yuv411_to_stuff_MMX                       mmxext 32bit x86
+cvd_src/yuv411_to_stuff                                                END
 
-# Extract the first word of "doxygen", so it can be a program name with args.
-set dummy doxygen; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_docs+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$docs"; then
-  ac_cv_prog_docs="$docs" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
+cvd_src/i686/halfsample,HALFSAMPLE_MMX8                mmx 32bit x86 END
+HALFSAMPLE_SSE16                                                       sse2 END
+
+YV402P_MMX                                                                     
mmx END
+
+cvd_src/i686/rgb_to_gray,cvd_src/i686/convert_rgb_to_y 32bit mmxext x86
+cvd_src/noarch/convert_rgb_to_y                                        END
+
+
+cvd_src/i686/convolve_gaussian                         sse2
+cvd_src/noarch/convolve_gaussian                       END
+
+
+cvd_src/i686/gradient                                          sse2
+cvd_src/noarch/gradient                                                END
+
+cvd_src/i686/yuv422_to_rgb,cvd_src/i686/yuv422_to_grey,cvd_src/i686/yuv422_wrapper
 mmxext 32bit x86
+cvd_src/noarch/yuv422_wrapper                                          END
+
+cvd_src/i686/median_3x3                                                sse2
+cvd_src/noarch/median_3x3                                      END
+
+
+cvd_src/i686/utility_float                                     sse
+cvd_src/noarch/utility_float                           END
+
+cvd_src/i686/utility_byte_differences          mmx
+cvd_src/noarch/utility_byte_differences        END
+
+cvd_src/i686/utility_double_int                                sse2
+cvd_src/noarch/utility_double_int                      END
+
+#FAST corner detection specifics
+cvd_src/fast/fast_7_detect,cvd_src/fast/fast_7_score           fast7  END
+cvd_src/fast/fast_8_detect,cvd_src/fast/fast_8_score           fast8  END
+cvd_src/fast/fast_9_detect,cvd_src/fast/fast_9_score   fast9  END
+cvd_src/fast/fast_10_detect,cvd_src/fast/fast_10_score fast10  END
+cvd_src/fast/fast_11_detect,cvd_src/fast/fast_11_score fast11  END
+cvd_src/fast/fast_12_detect,cvd_src/fast/fast_12_score fast12  END
+
+cvd_src/faster_corner_9                                                        
sse2 ssefast9 fast9
+cvd_src/slower_corner_9                                                        
fast9                                                   END
+
+cvd_src/faster_corner_10                                               sse2 
ssefast10 fast10
+cvd_src/slower_corner_10                                               fast10  
                                                END
+
+cvd_src/faster_corner_12                                               sse2 
ssefast12 fast12
+cvd_src/slower_corner_12                                               fast12  
                                                END
+
+#General OS specific bits
+cvd_src/Linux/dvbuffer                                                 
dvbuffer END
+cvd_src/Linux/v4l1buffer                                               
v4l1buffer END
+cvd_src/Linux/v4lbuffer                                                        
v4l1buffer END
+cvd_src/Linux/v4l2buffer                               v4l2buffer END
+cvd_src/IRIX/O2buffer,cvd_src/IRIX/sgi-video   o2buffer END
+cvd_src/OSX/qtbuffer                                                   qtbffer 
END
+
+#Libraries
+cvd_src/synchronized,cvd_src/eventobject,cvd_src/thread                pthread 
END
+cvd_src/videodisplay,cvd_src/glwindow                  videodisplay END
+pnm_src/jpeg                                                                   
jpeg END
+pnm_src/tiff                                                                   
tiff END
+pnm_src/png                                                                    
        png END
+cvd_src/videofilebuffer                                                        
ffmpeg END
+cvd_src/globlist                                                       glob END
+
+ENDDEPS
+
+#Split in to object files and defines
+#[ is a quadrigraph for [
+dep_objects="`awk -vORS=' ' '/[a-z]/{print $0".o"}' config.dep_tmp`"
+
+
+for i in `awk '!/[a-z]/{print "CVD_INTERNAL_HAVE_"$0}' config.dep_tmp`
 do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x 
"$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_docs="docs"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
+       cat >>confdefs.h <<_ACEOF
+#define $i 1
+_ACEOF
+
 done
-IFS=$as_save_IFS
 
-  test -z "$ac_cv_prog_docs" && ac_cv_prog_docs="no"
-fi
-fi
-docs=$ac_cv_prog_docs
-if test -n "$docs"; then
-  { echo "$as_me:$LINENO: result: $docs" >&5
-echo "${ECHO_T}$docs" >&6; }
-else
-  { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
 
 
 
-if test "$cpu" == ""
-then
-       cpu=generic
-fi
+cat config.have_bits - << ENDPROGS | awk -f make/compile_deps.awk > 
config.dep_progs
+progs/se3_exp              toon          lapack        END
+progs/se3_ln               toon          lapack        END
+progs/se3_pre_mul          toon          lapack        END
+progs/se3_post_mul         toon          lapack     END
+progs/se3_inv              toon                         lapack         END
+progs/calibrate                   toon          videodisplay lapack v4l2buffer 
END
+progs/img_play             videodisplay                END
+progs/cvd_display_image    videodisplay                END
+progs/img_play_bw          videodisplay                END
+progs/img_play_deinterlace videodisplay                END
+progs/video_play           videodisplay  ffmpeg        END
+progs/video_play_bw        videodisplay  ffmpeg        END
+ENDPROGS
+
+progs="`cat config.dep_progs | tr '\n' ' ' `"
+
+
+
+cat config.have_bits - << ENDPROGS | awk -f make/compile_deps.awk > 
config.dep_testprogs
+test/fast_test                                 videodisplay faster_test sse2   
END
+test/diskbuffer2                               videodisplay                    
                END
+test/dvbuffer_mono                     videodisplay dvbuffer                   
END
+test/dvbuffer_yuvrgb                   videodisplay dvbuffer                   
END
+test/test_images                                                               
                                END
+test/v4l1buffer_mono                   videodisplay v4l1buffer                 
END
+test/v4l2buffer                                        videodisplay v4l2buffer 
                END
+test/dvbuffer_controls                         videodisplay dvbuffer           
        END
+test/dvbuffer_rgb                      videodisplay dvbuffer                   
END
+test/o2buffer                          videodisplay o2buffer                   
END
+test/v4l1buffer_bayer                  videodisplay v4l1buffer                 
END
+test/v4l1buffer_rgb                    videodisplay v4l1buffer                 
END
+test/qtbuffer_yuvrgb            videodisplay qtbuffer                  END
+ENDPROGS
+testprogs="`cat config.dep_testprogs | tr '\n' ' ' `"
+
+
 
-cpu=$cpu
+echo
+echo
+echo Options:
+echo $options $os_options
+echo
+echo Missing options for $host_os:
+echo $options $all_options $os_all_options |  tr ' ' '\n' | sort | uniq -u | 
xargs echo
+echo
+echo Dodgy things:
+echo $dodginess_options
+echo
+echo
+echo SIMD support:
+echo $simd_options
+echo
+echo Missing SIMD support for $host:
+echo $simd_all_options $simd_options | tr ' ' '\n' |  sort | uniq -u | xargs 
echo
+echo
 
 
 
-D_PROGS='progs/se3_exp             toon          lapack
-               progs/se3_ln               toon          lapack
-               progs/se3_pre_mul          toon          lapack
-               progs/se3_post_mul         toon          lapack
-               progs/se3_inv              toon                  lapack
-               progs/calibrate            toon          videodisplay lapack 
v4l2buffer
-               progs/img_play             videodisplay
-               progs/cvd_display_image    videodisplay
-               progs/img_play_bw          videodisplay
-               progs/img_play_deinterlace videodisplay
-               progs/video_play           videodisplay  ffmpeg
-               progs/video_play_bw        videodisplay  ffmpeg '
-progs="`echo $options $D_PROGS | $AWK -v stub=progs -f 
make/prog_dependencies.awk`"
-progs=$progs
+CXXFLAGS=$CXXFLAGS
 
+OFLAGS=$OFLAGS
 
 
-echo $options $D_PROGS > foo
-
-T_PROGS='
-test/fast_test                                 videodisplay faster_test sse2
-test/diskbuffer2                               videodisplay
-test/dvbuffer_mono                     videodisplay dvbuffer
-test/dvbuffer_yuvrgb                   videodisplay dvbuffer
-test/test_images
-test/v4l1buffer_mono                   videodisplay v4l1buffer
-test/v4l2buffer                                        videodisplay v4l2buffer
-test/dvbuffer_controls                         videodisplay dvbuffer
-test/dvbuffer_rgb                      videodisplay dvbuffer
-test/o2buffer                          videodisplay o2buffer
-test/v4l1buffer_bayer                  videodisplay v4l1buffer
-test/v4l1buffer_rgb                    videodisplay v4l1buffer
-test/qtbuffer_yuvrgb            videodisplay qtbuffer '
-testprogs="`echo $simd_options $hidden_options $options $T_PROGS | $AWK -v 
stub=test -f make/prog_dependencies.awk`"
-testprogs=$testprogs
+echo $CXXFLAGS
+echo $LIBS
 
+cat << FOO > cvd/config.h
+#ifndef CVD_CONFIG_H
+#define CVD_CONFIG_H
+FOO
+echo '#define CVD_HAVE_CPU_'$host_cpu 1 | cat - confdefs.h | grep CVD_ | sort 
| sed 's/#define CVD_.*HAVE_\(.*\) .*/#ifndef CVD_DISABLE_\1\
+    &\
+#endif/' >> cvd/config.h
+echo '#endif' >> cvd/config.h
 
 ac_config_files="$ac_config_files Makefile"
 
@@ -10850,19 +10465,23 @@
 host_alias!$host_alias$ac_delim
 target_alias!$target_alias$ac_delim
 AWK!$AWK$ac_delim
-CC!$CC$ac_delim
-CFLAGS!$CFLAGS$ac_delim
+CXX!$CXX$ac_delim
+CXXFLAGS!$CXXFLAGS$ac_delim
 LDFLAGS!$LDFLAGS$ac_delim
 CPPFLAGS!$CPPFLAGS$ac_delim
-ac_ct_CC!$ac_ct_CC$ac_delim
+ac_ct_CXX!$ac_ct_CXX$ac_delim
 EXEEXT!$EXEEXT$ac_delim
 OBJEXT!$OBJEXT$ac_delim
-CXX!$CXX$ac_delim
-CXXFLAGS!$CXXFLAGS$ac_delim
-ac_ct_CXX!$ac_ct_CXX$ac_delim
+INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim
+INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim
+INSTALL_DATA!$INSTALL_DATA$ac_delim
+LN_S!$LN_S$ac_delim
+RANLIB!$RANLIB$ac_delim
 CXXCPP!$CXXCPP$ac_delim
 GREP!$GREP$ac_delim
 EGREP!$EGREP$ac_delim
+major!$major$ac_delim
+minor!$minor$ac_delim
 build!$build$ac_delim
 build_cpu!$build_cpu$ac_delim
 build_vendor!$build_vendor$ac_delim
@@ -10871,44 +10490,40 @@
 host_cpu!$host_cpu$ac_delim
 host_vendor!$host_vendor$ac_delim
 host_os!$host_os$ac_delim
+have_x86!$have_x86$ac_delim
 have_mmx!$have_mmx$ac_delim
 have_mmxext!$have_mmxext$ac_delim
 have_sse!$have_sse$ac_delim
 have_sse2!$have_sse2$ac_delim
-have_64bit!$have_64bit$ac_delim
-OFLAGS!$OFLAGS$ac_delim
-INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim
-INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim
-INSTALL_DATA!$INSTALL_DATA$ac_delim
-LN_S!$LN_S$ac_delim
-RANLIB!$RANLIB$ac_delim
-osx_hacks!$osx_hacks$ac_delim
-have_toon!$have_toon$ac_delim
-have_lapack!$have_lapack$ac_delim
-have_acml!$have_acml$ac_delim
-major!$major$ac_delim
-minor!$minor$ac_delim
+have_sse3!$have_sse3$ac_delim
+have_32bit!$have_32bit$ac_delim
 have_dvbuffer!$have_dvbuffer$ac_delim
 have_v4l1buffer!$have_v4l1buffer$ac_delim
 have_v4l2buffer!$have_v4l2buffer$ac_delim
 have_o2buffer!$have_o2buffer$ac_delim
+osx_hacks!$osx_hacks$ac_delim
 have_qtbuffer!$have_qtbuffer$ac_delim
-have_pthread!$have_pthread$ac_delim
 XMKMF!$XMKMF$ac_delim
 have_videodisplay!$have_videodisplay$ac_delim
+have_toon!$have_toon$ac_delim
+have_lapack!$have_lapack$ac_delim
+have_pthread!$have_pthread$ac_delim
+have_png!$have_png$ac_delim
 have_jpeg!$have_jpeg$ac_delim
 have_tiff!$have_tiff$ac_delim
-have_png!$have_png$ac_delim
 have_ffmpeg!$have_ffmpeg$ac_delim
 have_glob!$have_glob$ac_delim
 have_memalign!$have_memalign$ac_delim
-have_faster9!$have_faster9$ac_delim
-have_faster10!$have_faster10$ac_delim
-have_faster12!$have_faster12$ac_delim
-have_FAST_7!$have_FAST_7$ac_delim
-have_fast_7!$have_fast_7$ac_delim
-have_FAST_8!$have_FAST_8$ac_delim
-have_FAST_9!$have_FAST_9$ac_delim
+have_fast7!$have_fast7$ac_delim
+have_fast8!$have_fast8$ac_delim
+have_fast9!$have_fast9$ac_delim
+have_fast10!$have_fast10$ac_delim
+have_fast11!$have_fast11$ac_delim
+have_fast12!$have_fast12$ac_delim
+have_ssefast9!$have_ssefast9$ac_delim
+have_ssefast10!$have_ssefast10$ac_delim
+have_ssefast12!$have_ssefast12$ac_delim
+dep_objects!$dep_objects$ac_delim
 _ACEOF
 
   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -10950,18 +10565,14 @@
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   cat >conf$$subs.sed <<_ACEOF
-have_FAST_10!$have_FAST_10$ac_delim
-have_FAST_11!$have_FAST_11$ac_delim
-have_FAST_12!$have_FAST_12$ac_delim
-docs!$docs$ac_delim
-cpu!$cpu$ac_delim
 progs!$progs$ac_delim
 testprogs!$testprogs$ac_delim
+OFLAGS!$OFLAGS$ac_delim
 LIBOBJS!$LIBOBJS$ac_delim
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 9; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 5; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
@@ -11390,60 +11001,3 @@
   $ac_cs_success || { (exit 1); exit 1; }
 fi
 
-
-
-cat << FOO > cvd/config.h
-#ifndef CVD_CONFIG_H
-#define CVD_CONFIG_H
-FOO
-echo '#define CVD_HAVE_CPU_'$host_cpu 1 | cat - confdefs.h | grep CVD_ | sort 
| sed 's/#define CVD_.*HAVE_\(.*\) .*/#ifndef CVD_DISABLE_\1\
-    &\
-#endif/' >> cvd/config.h
-echo '#endif' >> cvd/config.h
-
-
-debug_options=$options
-
-all_opts="$all_options $os_options"
-debug_all_options="$all_opts"
-
-
-if test ! -r .deps
-then
-echo > .deps
-fi
-
-
-
-echo
-echo Options:
-echo $options
-echo
-echo Missing options for $host_os:
-echo $options $all_options $os_options |  tr ' ' '\n' | sort | uniq -u | xargs 
echo
-echo
-echo Dodgy things:
-echo $dodginess_options
-echo
-echo SIMD support:
-echo $simd_options
-echo
-echo Missing SIMD support for $host:
-echo $simd_possible_options $simd_options | tr ' ' '\n' |  sort | uniq -u | 
xargs echo
-echo
-
-
-
-echo
-echo Programs:
-echo $progs | sed -e's!progs/!!g'
-echo
-echo Missing programs:
-echo "$progs $D_PROGS" | xargs -n1 echo | awk -F/ '/progs/{print $2}' |  sort  
| uniq -u | xargs echo
-echo
-
-echo Debug:
-echo CPPFLAGS="$CPPFLAGS"
-echo CXXFLAGS="$CXXFLAGS"
-echo OFLAGS="$OFLAGS"
-echo LIBS="$LIBS"

Index: configure.in
===================================================================
RCS file: /cvsroot/libcvd/libcvd/configure.in,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -b -r1.103 -r1.104
--- configure.in        25 Feb 2008 23:41:26 -0000      1.103
+++ configure.in        28 Feb 2008 00:27:21 -0000      1.104
@@ -1,139 +1,228 @@
 AC_INIT(CVD,0.7)
 AC_COPYRIGHT(Copyright foo)
-
-
-
-orig_CXXFLAGS="$CXXFLAGS"
-
 #Use builtin autoconf checks for all the programs we need.
 AC_PROG_AWK
-AC_PROG_CC
 AC_PROG_CXX
-
-
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_RANLIB
 #Switch testing language to C++
 AC_LANG(C++)
+#Start the compiler
+AC_CONFIG_HEADERS
+AC_HEADER_STDC
+
+cvd_major=`echo $PACKAGE_VERSION | $AWK -F'\\\\.' '{print $1}'`
+cvd_minor=`echo $PACKAGE_VERSION | $AWK -F'\\\\.' '{print $2}'`
+
+AC_DEFINE_UNQUOTED(CVD_MAJOR_VERSION,$cvd_major)
+AC_SUBST(major, $cvd_major)
+AC_DEFINE_UNQUOTED(CVD_MINOR_VERSION,$cvd_minor)
+AC_SUBST(minor, $cvd_minor)
 
-###################################################
+
+
+################################################################################
+#
+#Lists of  optional components
 #
-# Check for g++ version >= 3
 
-if test x$GXX = xyes
-then
-       good_gcc=0
+all_options="videodisplay jpeg tiff png ffmpeg toon lapack pthread glob 
memalign"
+dodginess_options=
+options=
+simd_all_options=
+simd_options=
+os_all_options=
 
-       AC_MSG_CHECKING([g++ version])
-       changequote(,)
-       gxx_major_version=`$CXX -v 2>&1 | $AWK -F '[ .]' '/version/{print $3}'`
-       changequote([,])
+################################################################################
+#
+# Useful macros
+#
+
+dnl APPEND(var, value)
+dnl This appends vale to a shell variable var
+define(APPEND, [$1="$$1 $2"])
 
 
-       if test "$gxx_major_version" -lt 3
-       then
-               AC_MSG_RESULT([$gxx_major_version (failed)])
-               AC_MSG_CHECKING([for other possibilities for g++ version >= 3])
-               AC_MSG_RESULT([])
-               #Check for some other possible G++s
-               #Uncache che checks
-               unset CXX
-               unset ac_ct_CXX
-               unset ac_cv_prog_ac_ct_CXX 
-               unset ac_cv_prog_cxx_g
-               unset GXX
-               unset ac_cv_cxx_compiler_gnu
-
-               #echo is a dummy target, which will always succeed.
-               #If the c++ compiler is set to echo, then we know that
-               #none of the proper ones worked.
-               AC_PROG_CXX([g++-4 g++-3 echo])
 
-               if test $ac_cv_prog_ac_ct_CXX = echo
+dnl TEST_AND_SET_CXXFLAG(flag, [program])
+dnl
+dnl This attempts to compile a and run program with a certain compiler flag.
+dnl If no program is given, then the minimal C++ program is compiled, and 
+dnl this tests just the validity of the compiler flag. 
+dnl
+define([TEST_AND_SET_CXXFLAG],[
+       if test "$3" == ""
                then
-                       AC_MSG_ERROR([g++ version >= 3.0 is required.])
-               fi
+               AC_MSG_CHECKING([if compiler flag $1 works])    
        else
-               AC_MSG_RESULT([$gxx_major_version (ok)])
+               AC_MSG_CHECKING([$3])   
        fi
-fi
+       save_CXXFLAGS="$CXXFLAGS"
+       APPEND(CXXFLAGS, [$1])
 
+       m4_if([$2],[],[pushdef(prog, [int main(){}])], [pushdef(prog, [$2])])
+       AC_RUN_IFELSE([prog], [cvd_conf_test=1],[cvd_conf_test=0])
+       popdef([prog])
 
+       if test $cvd_conf_test = 1
+       then
+               AC_MSG_RESULT(yes)
+               ts_success=yes
+       else
+               AC_MSG_RESULT(no)
+               CXXFLAGS="$save_CXXFLAGS"
+               ts_success=no
+       fi
+])
 
-AC_ARG_WITH(debug,   [  --without-debug         compile without debug 
support],[debug=no], [])
-AC_ARG_WITH(debug,   [  --with-debug=flags      compile with debug 
support],[debug="$withval"], [])
-AC_ARG_WITH(profile, [  --with-profile=flags    compile with profile 
support],[profile="$withval"], [profile=no])
 
-###################################################
-#
-# Deal with profiling and debugging
-#
-#
-if test "$debug" != no || test "$profile" != no
-then
-       if test "$debug" == ""
+dnl CHECK_FOR_LIBRARY(option, code, [success], [fail])
+dnl option corresponds to the first parameter for the corresponding
+dnl AC_ARG_WITH. If the library is present, then have_option and 
CVD_HAVE_OPTION
+dnl are set. If with_option is "", it will be set to yes.
+dnl
+dnl The test code shall do nothing on success, and set the shell variable a to 
1
+dnl on failure. For convenience, LIBS  and CXXFLAGS are checkpointed 
+dnl automatically. On failure, they are restored automatically.
+dnl
+dnl On success, "option" is appended to options, and the code "success" is run
+dnl On failure including --without) fail is run.
+define(CHECK_FOR_LIBRARY,[
+       if test "$with_$1" != no && test "$have_$1" != yes
        then
-               if test "$ac_cv_cxx_compiler_gnu" = yes
+               if test "$with_$1" == ""
                then
-                       CXXFLAGS="$orig_CXXFLAGS -g -ggdb"
+                       with_$1=yes
                fi
+
+               save_LIBS="$LIBS"
+               save_CXXFLAGS="$CXXFLAGS"
+               a=
+               $2
+               
+               if test x$a == x
+               then
+                       AC_DEFINE(CVD_HAVE_[]m4_toupper($1), 1)
+                       AC_SUBST(have_$1, yes)
+                       APPEND(options, $1)
+                       $3
        else
-               CXXFLAGS="$orig_CXXFLAGS $debug"
+                       LIBS="$save_LIBS"
+                       CXXFLAGS="$save_CXXFLAGS"
+               fi
        fi
-elif test "$debug" = no
-then
-       #Remove debugging
-       CXXFLAGS="$orig_CXXFLAGS"
-fi
 
-if test "$profile" != no
-then
-       if test "$profile" = yes
+       if test "$have_$1" != yes
        then
-               if test "$ac_cv_cxx_compiler_gnu" = yes
+               :
+               $4
+       fi
+       ])
+
+
+dnl SIMD_TEST(name, flag, code)
+dnl This tests for SIMD code (with name), using the compiler flag "flag"
+dnl and the provided test code. It respects with_simd and with_name
+dnl
+dnl On success, "name" is appended to simd_options
+define(SIMD_TEST, [
+       if test "$with_simd" != no
                then
-                       CXXFLAGS="$CXXFLAGS -p -pg"
-                       CFLAGS="$CFLAGS -p -pg"
-               else 
-                       AC_MSG_WARN([I don't know how to switch on profiling 
for this compiler])
+               if test "$with_$1" == "yes"
+               then
+                       have_$1=yes
+               elif test "$with_$1" != "no"
+               then
+                       TEST_AND_SET_CXXFLAG([$2], [$3], [for $1 support])
+                       have_$1="$ts_success"
                fi
-       else
-               CXXFLAGS="$CXXFLAGS $profile"
-               CFLAGS="$CFLAGS $profile"
+
+               if test "$have_$1" == yes
+               then
+                       AC_DEFINE(CVD_HAVE_$1, 1)
+                       AC_SUBST(have_[]m4_tolower($1), yes)
+                       APPEND(simd_options, m4_tolower($1))
        fi
-fi
+       fi])
+
+
 
 
################################################################################
 #
-# Make position independent code
+# Compiler flags and optimization
+#
 #
+TEST_AND_SET_CXXFLAG(-Wall)
+TEST_AND_SET_CXXFLAG(-Wextra)
+
 
-if test x$GXX = xyes
+########################################
+#
+# Remove -O2 from CXXFLAGS
+# 
+CXXFLAGS="$(echo "$CXXFLAGS" | sed -e's/-O2//')"
+
+########################################
+#
+# Extra debugging
+#
+AC_ARG_WITH(debug,   [  --with-debug=flags      compile with debug 
support],[debug="$withval"], [debug=yes])
+if test "$debug" = yes
+then
+       TEST_AND_SET_CXXFLAG(-ggdb)
+elif test "$debug" != no
 then
-       CXXFLAGS="$CXXFLAGS -fPIC"
+       APPEND(CXXFLAGS, $debug)
 fi
 
-#Start the compiler
-AC_CHECK_HEADERS(stdio.h, [], [])
-
-##################################################
+########################################
 #
-# Cpu type detection and optimization
+# Position independent code
 #
 
+TEST_AND_SET_CXXFLAG(-fPIC)
+if test $ts_success == no
+then
+       AC_MSG_WARN([I don't know how to compile position independent code.])
+fi
+
+
 #Host detection
 AC_CANONICAL_HOST
 
+########################################
+#
+# CPU type detection and optimization
+#
+noopt_CXXFLAGS="$CXXFLAGS"
+CXXFLAGS=
+
+AC_ARG_WITH(optimize,   [  --without-optimize      compile without 
optimizations ],[optimize=no],[])
+AC_ARG_WITH(optimize,   [  --with-optimize=flags   compile with optimization 
flags],[optimize="$withval"], [optimize=-O3])
 
-#Custom host CPU detection
-AC_MSG_CHECKING([CPU type])
-AC_ARG_WITH(cpu, [  --with-cpu=[type]         Specify pocessor type:
+if test "$optimize" != no
+then
+       AC_MSG_CHECKING([for best optimize flags])
+       AC_MSG_RESULT([])
+       
+       TEST_AND_SET_CXXFLAG(-O3)
+       if test $ts_success == no
+       then
+               AC_MSG_WARN([I do not know how to switch on optimizing for this 
compiler])
+       fi
+
+       AC_MSG_CHECKING([CPU type])
+       AC_ARG_WITH(cpu, [  --with-cpu=[type]         Specify pocessor type for 
optimization selection:
                             X86:
                               p3 p4 p4_64 xeon pM core2 core2_64 opteron
                               opteron_64 athlon athlon64 athlon64_64
                             SPARC:
                               sparc
                           Autodetection works on Linux only.])
-if test "$with_cpu" == ""
-then 
+
+       if test "$with_cpu" == ""
+       then 
        case "$host" in
                *86*linux*)
                        cpu="`awk '
@@ -152,640 +241,172 @@
                        cpu=sparc
                        ;;
        esac
-else
-       cpu="$with_cpu"
-fi
 
-AC_MSG_RESULT($cpu)
-
-AC_ARG_WITH(simd, [  --without-simd          disable SIMD code])
-
-if test "$with_simd" != "no"
-then
-       case "$host" in
-               *86*linux*)
-                       simd_possible_options="sse2 sse mmxext mmx"
-                       simd_options=
-
-                       for dummyvar in 1
-                       do
-
-                               save_CPPFLAGS="$CPPFLAGS"
-
-                               AC_ARG_WITH(mmx, [    --with-mmx            
force presence or absence of MMX  (x86 only)])      
-                               if test "$with_mmx" != yes && test "$with_mmx" 
!= no 
-                               then
-                                       save_CXXFLAGS="$CXXFLAGS"
-                                       CXXFLAGS="$CXXFLAGS -mmmx"
-                                       CPPFLAGS="$CPPFLAGS -mmmx"
-                                       AC_CHECK_HEADERS(mmintrin.h, [], [])
-                                       AC_MSG_CHECKING(for MMX support)
-                                       AC_RUN_IFELSE([
-                                               #include <mmintrin.h>
-                                               int main()
-                                               {
-                                                       __m64 a;
-                                                       a = _mm_setzero_si64();
-                                                       a = _mm_and_si64(a, a);
-                                                       return 0;
-                                               }], [mmx=yes], [mmx=no])
-                                       AC_MSG_RESULT($mmx)
-                               else
-                                       mmx="$with_mmx"
-                               fi
-
-                               if test $mmx = no
-                               then
-                                       CXXFLAGS="$save_CXXFLAGS"
-                                       break
-                               else    
-                                       AC_DEFINE(CVD_HAVE_MMINTRIN)
-                                       AC_SUBST(have_mmx,yes)
-                                       simd_options="$simd_options mmx"
-                               fi
-
-                               
-
-                               #MMXEXT is pretty muxh the intersection of SSE 
nad 3Dnow!
-                               #and includes pshufw, movnta and prefetchnta
-                               save_CXXFLAGS="$CXXFLAGS"
-                               CXXFLAGS="$CXXFLAGS -msse"
-                               CPPFLAGS="$CPPFLAGS -msse"
-                               AC_ARG_WITH(mmxext, [    --with-mmxext         
force presence or absence of MMXEXT (x86 only) ])        
-                               if test "$with_mmxext" != yes && test 
"$with_mmxext" != no 
-                               then
-                                       AC_CHECK_HEADERS(xmmintrin.h, [], [])
-                                       AC_MSG_CHECKING(for MMXEXT support)
-                                       AC_RUN_IFELSE([
-                                               #include <xmmintrin.h>
-                                               int main()
-                                               {
-                                                       __m64 a;
-                                                       a = _mm_setzero_si64();
-                                                       a = _mm_shuffle_pi16(a, 
0);
-                                                       return 0;
-                                               }], [mmxext=yes], [mmxext=no])
-                                       AC_MSG_RESULT($mmxext)
-                               else
-                                       mmxext="$with_mmxext"
-                               fi
-
-                               if test $mmxext = no
-                               then
-                                       CXXFLAGS="$save_CXXFLAGS"
-                                       break
-                               else    
-                                       AC_DEFINE(CVD_HAVE_XMMINTRIN)
-                                       AC_DEFINE(CVD_HAVE_MMXEXT)
-                                       AC_SUBST(have_mmxext,yes)
-                                       simd_options="$simd_options mmxext"
-                               fi
-
-                               AC_ARG_WITH(sse, [    --with-sse            
force presence or absence of SSE  (x86 only)])      
-                               if test "$with_sse" != yes && test "$with_sse" 
!= no 
-                               then
-                                       AC_MSG_CHECKING(for SSE support)
-                                       AC_RUN_IFELSE([
-                                               #include <xmmintrin.h>
-                                               int main()
-                                               {
-                                                       __m128 a;
-                                                       a = _mm_setzero_ps();
-                                                       a = _mm_add_ps(a, a);
-                                                       return 0;
-                                               }], [sse=yes], [sse=no])
-                                       AC_MSG_RESULT($sse)
-                               else
-                                       sse="$with_sse"
-                               fi
-
-                               if test $sse = no
-                               then
-                                       break
-                               else    
-                                       AC_SUBST(have_sse,yes)
-                                       AC_DEFINE(CVD_HAVE_SSE)
-                                       simd_options="$simd_options sse"
-                               fi
-
-
-
-
-                               save_CXXFLAGS="$CXXFLAGS"
-                               CXXFLAGS="$CXXFLAGS -msse2"
-                               CPPFLAGS="$CPPFLAGS -msse2"
-                                
-                               AC_ARG_WITH(sse2, [    --with-sse2           
force presence or absence of SSE2  (x86 only)])    
-                               if test "$with_sse2" != yes && test 
"$with_sse2" != no 
-                               then
-                                       AC_CHECK_HEADERS(emmintrin.h, [], [])
-                                       AC_MSG_CHECKING(for SSE2 support)
-                                       AC_RUN_IFELSE([
-                                               #include <emmintrin.h>
-                                               int main()
-                                               {
-                                                       __m128d a;
-                                                       a = _mm_setzero_pd();
-                                                       a = _mm_add_pd(a, a);
-                                                       return 0;
-                                               }], [sse2=yes], [sse2=no])
-                                       AC_MSG_RESULT($sse2)
-                               else
-                                       sse2="$with_sse2"
-                               fi
-
-                               if test $sse2 = no
-                               then
-                                       CXXFLAGS="$save_CXXFLAGS"
-                                       break
+               cpu="${cpu:-unknown}"
                                else    
-                                       AC_SUBST(have_sse2,yes)
-                                       AC_DEFINE(CVD_HAVE_SSE2)
-                                       AC_DEFINE(CVD_HAVE_EMMINTRIN)
-                                       simd_options="$simd_options sse2"
-                               fi
-                       done
-                       
-                       CPPFLAGS="$save_CPPFLAGS"
-
-
-                       #Also check whether we have a 64-bit processor
-                       #(since some Pentium 4s have EM64T, and some don't)
-                       #At least AMD name their processors with x86_64 
something different!
-                       AC_MSG_CHECKING([for 64-bit extensions])
-                       if grep -q lm /proc/cpuinfo
-                       then
-                               AC_MSG_RESULT(yes)
-                               AC_SUBST(have_64bit,yes)
-                               AC_DEFINE(CVD_HAVE_64BIT)
-                               # Append _64 onto the CPU name so that we can 
look up the right flags
-                               # if it is a pentuim 4
-                               cpu=$cpu"_64"
-                       else
-                               AC_MSG_RESULT(no)
-                               bit64=""
+               cpu="$with_cpu"
                        fi
                        
-               ;;
-       esac
-fi
+       AC_MSG_RESULT($cpu)
 
-if test "$cpu" == ""
-then
-       cpu=Unknown
-fi
-
-
-AC_ARG_WITH(optimize,   [  --without-optimize      compile without 
optimizations ],[optimize=no],[])
-AC_ARG_WITH(optimize,   [  --with-optimize=flags   compile with optimization 
flags],[optimize="$withval"], [])
-
-if test "$optimize" != no
-then
-       if test "$optimize" != ""
-       then
-               OFLAGS="$optimize"
-       elif test "$ac_cv_cxx_compiler_gnu" = yes
-       then
-               AC_MSG_CHECKING([for best optimize flags])
-               AC_MSG_RESULT([])
                
                #Find possible lest of compiler flags
                #FIXME, only GCC is currently supported
                cpuoptlist="`$AWK '/^'$cpu'/{$1=""; print}' make/march_flags`"
                
-               #Test list in order to find the best compiler option
-               save_CXXFLAGS="$CXXFLAGS"
                for mwhat in -march= -mcpu=
                do
                        for i in $cpuoptlist
                        do
-                               i="$mwhat$i"
-                               AC_MSG_CHECKING([$CXX supports $i]) 
-                               
-                               CXXFLAGS="$save_CXXFLAGS $i" 
-                               AC_COMPILE_IFELSE([int main(){}], [a=1], [a=0])
-
-                               if test $a = 1
+                       TEST_AND_SET_CXXFLAG($mwhat$i)
+                       if test $ts_success == yes
                                then
-                                       AC_MSG_RESULT([yes])
-                                       cpuopt=$i
                                        break 2
-                               else
-                                       AC_MSG_RESULT([no])
                                fi
                        done
                done
-               CXXFLAGS="$save_CXXFLAGS"
-               
                
-               opt="-O3 $cpuopt"
-               if test "$cpuopt" = ""
+       if test $ts_success == no
                then
                        AC_MSG_WARN([I do not know what the best flags are for 
this processor ($cpu).])
                fi
-               OFLAGS="$opt"
-       else
-               AC_MSG_WARN([I do not know how to switch on optimizing for this 
compiler])
-       fi
-fi
-
-AC_SUBST(OFLAGS,[$OFLAGS])
-
-AC_PROG_INSTALL
-AC_PROG_LN_S
-AC_PROG_RANLIB
-
-
-
-AC_CONFIG_HEADERS
-AC_HEADER_STDC
-
-#From hereon, I use the following conventions:
-#a variable, FOO is saves (for the purpose of testing additions to it) in
-#save_FOO
-#
-#The variable `a' is used throughout as a temporary in tests
-
-
-################################################################################
-#
-# Some notes on autoconf
-
-#This if m4ese for a block comment :-)
-changequote(<<,>>)
-m4_if(<<
-
-Quoting characters are [ and ]. There is no way to escape them, except by 
-changing the quote character (see above). This is why I mostly use the 
-shell construct:
-if test foo
-
-as opposed to 
-
-if [ foo ]
-
-
-
-
-
-AC_CHECK_LIB(library, function, success, failure)
-
-Used to check for existence function a library. On success, it sets the
-variable ac_cv_lib_library_function=yes (empty on failure). If the success
-argument is missing of blank, eg:
-
-AC_CHECK_LIB(library, function, [], [beep])
-
-then the -llibrary is added to $LIBS automatically. Testing for the function
-main is an easy way of checking that linking against a library works without
-looking for a specific function.
-
-
-
-
-
-
-AC_SUBST(a, b)
-
-will substiture b for @a@ in a .in file, such as makefile.in
-
-
-
-AC_DEFINE(a, b)
-
-will make a #define a b. AC_DEFINE_UNQUOTED is needed if b is a shell expansion
-
-
-
-
-
-
->>)
-changequote([,])
-
-all_options="videodisplay jpeg tiff png ffmpeg toon lapack pthreads acml 
globlist"
-dodginess_options=
-
-################################################################################
-#
-#  Some of my own M4 macros
-#
-
-
-################################################################################
-#
-# An OSX specific hack to get at stuff in /sw automatically
-# 
-
-if test "$host_vendor" = apple
-then
-       CPPFLAGS="$CPPFLAGS -I /sw/include -I/opt/local/include 
-I/usr/X11R6/include"
-       LIBS="$LIBS -L/sw/lib -L/opt/local/lib"
-       AC_MSG_NOTICE([Adding /sw to the build path.])
-       AC_MSG_NOTICE([Adding /opt/local to the build path.])
-       AC_MSG_NOTICE([Adding /usr/X11R6/include to the build path.])
-       AC_SUBST(osx_hacks,yes)
 fi
+OFLAGS="$CXXFLAGS"
+CXXFLAGS="$noopt_CXXFLAGS"
 
 
################################################################################
 #
-#Check for numerics
+# Processor/Platform specific parts
 #
 
-
 echo 
-echo -----------------------------
-echo Checking for numerics support
-echo -----------------------------
-
-
-
-
-###################################################
-#
-#Allow the user to specify the location of TooN
-#
-AC_ARG_WITH(TooN, [  --with-TooN=directory   Specify location for TooN ], 
[opt_toon_dir=$withval])
-toondir="Missing"
-
-if test "$opt_toon_dir" != no
-then
-
-       #Yes is not a useful answer. We know the answer is yes.
-       if test "$opt_toon_dir" = yes
-       then
-               opt_toon_dir=
-       fi
-
-       #Check for TooN
-       AC_MSG_CHECKING([for TooN])
-
-       #Check for TooN in a bunch of places
-       save_CPPFLAGS="$CPPFLAGS"
-       for dir in  $opt_toon_dir "" "$HOME/usr/include" "$HOME/code/TooN" 
"$HOME/Src/TooN" "../TooN" ".."
-       do
-               a=
-               if test "$dir" = ""
-               then
-                       CPPFLAGS="$save_CPPFLAGS"
-               else
-                       CPPFLAGS="$save_CPPFLAGS -I$dir"
-               fi
-
-               AC_COMPILE_IFELSE([#include <TooN/TooN.h>
-       int main(){TooN::Vector<2> v;return 0;}], [a=1]) 
-
-               AC_COMPILE_IFELSE([#include <numerics.h>
-       int main(){Vector<2> v;return 0;}], [old_toon="$old_toon $dir"]) 
-               
-               if test x$a = x1
-               then
-                       toondir=$dir
-                       break
-               fi
-       done
+echo ------------------------------------
+echo Checking processor specific features
+echo ------------------------------------
+echo
 
-       if test "$toondir" = ""
-       then
-               AC_MSG_RESULT(yes)
-       else
-               AC_MSG_RESULT($toondir)
-       fi
-fi 
+AC_C_BIGENDIAN
 
-if test "$toondir" = Missing
+if test x$ac_cv_c_bigendian = xno
 then
-       AC_MSG_WARN(TooN is missing. Numerics support disabled.)
-       if test "$old_toon" != ""
-       then
-       AC_MSG_WARN(You have old versions of TooN installed in $old_toon. These 
are too old for libCVD.)
-       fi
-       toon=no
+       AC_DEFINE(CVD_ARCH_LITTLE_ENDIAN)
 else
-       options="$options toon"
-       toon=yes
-       AC_DEFINE(CVD_HAVE_TOON)
-       AC_SUBST(have_toon,yes)
-fi
-
-##################################################
-#
-# Check for BLAS and LAPACK support
-#
-lapack=no
-AC_ARG_WITH(lapack, [  --without-lapack        Disable BLAS and LAPACK.], 
[lapack=never])
-
-acml=no
-
-if test "$toon" = yes && test "$host_vendor" == apple && test "$lapack" != 
never
-then
-       
-       save_LIBS="$LIBS"
-       LIBS="$LIBS -framework vecLib"
-
-
-       AC_MSG_CHECKING(vecLib framework)
-       a=0
-       AC_COMPILE_IFELSE([#include <TooN/SVD.h>
-int main(){TooN::Matrix<2> m;TooN::SVD<2> svdm(m);return 0;}], [a=1]) 
-
-       if test x$a     = x1
-       then
-               AC_MSG_RESULT(yes)
-               lapack=yes
-               options="$options lapack"
-       else
-               AC_MSG_RESULT(no)
-               LIBS="$save_LIBS"
-       fi
+       AC_DEFINE(CVD_ARCH_BIG_ENDIAN)
 fi
 
-define([ER_M4_PASTE], [$1$2])
-
-if test "$toon" = yes && test "$lapack" = no
-then
-
-       #This built-in autoconf macro finds the linker flags needed to
-       #link with Fortran libraries and sets FCLIBS accordingly
-       #AC_FC_LIBRARY_LDFLAGS
-       # TODO: We may also need to use AC_FC_DUMMY_MAIN to see whether a dummy
-       # Fortran main is needed (see the Autoconf manual). Currently, no 
machines
-       # we compile on seem to need this.
-
-       save_LIBS="$LIBS"
-       #LIBS="$LIBS $FCLIBS"
-
-
-#      AC_MSG_CHECKING([quality of Ac_FC_LIBRARY_LDFLAGS])
-#      AC_LINK_IFELSE([int main(){return 0;}], [fc=good],[fc=b0rked]);
-#      AC_MSG_RESULT($fc)
-
-       f2c="Missing"
-       fc="b0rked"
-       if test $fc == b0rked
-       then
-               AC_MSG_NOTICE(Reverting to old fortran library test.)
-
-               AC_MSG_CHECKING([for C to fortran library])
-
-               #The linking testing function AC_LINK_IFELSE uses LIBS in the 
-               #linking stage, so we communicate our requirements by using this
-               LIBS="$save_LIBS -lf2c"
-               AC_LINK_IFELSE([int main(){return 0;}], [f2c=f2c])
-
-               LIBS="$save_LIBS -lg2c"
-               AC_LINK_IFELSE([int main(){return 0;}], [f2c=g2c])
-
-               LIBS="$save_LIBS -lgfortran"
-               AC_LINK_IFELSE([int main(){return 0;}], [f2c=gfortran])
-
-               AC_MSG_RESULT($f2c)
-               LIBS="$save_LIBS -l$f2c"
-
-               #$LIBS should either havf FCLIBS or -l$f2c present
-
-               opt_acml_dir="no"
-               AC_ARG_WITH(acml, [  --with-acml[[=directory]] Use BLAS and 
LAPACK routines from the ACML library [[located in the specified directory]] ], 
[opt_acml_dir=$withval])
-
-               if test x$opt_acml_dir == xno
-               then
-               AC_CHECK_LIB(blas,  dgemm_)
-               if test x$ac_cv_lib_blas_dgemm_ != xyes
-               then
-                       AC_MSG_WARN(BLAS is missing. Get it from 
www.netlib.org/blas);
-               else
-                       AC_CHECK_LIB(lapack,  dgesvd_)
-                       if test x$ac_cv_lib_lapack_dgesvd_ != xyes
-                       then
-                                 AC_MSG_WARN(LAPACK is missing. Get it from 
www.netlib.org/lapack);
-                       else
-                         options="$options lapack"
-                         lapack=yes
-                       fi
-               fi
-               else
-                       AC_MSG_NOTICE(Compiling with acml)
-
-                       if test x$opt_acml_dir != xyes
-                       then
-                               LDFLAGS="$LDFLAGS -L$opt_acml_dir"
-                       else
-                               LDFLAGS="$LDFLAGS -L/opt/acml/gnu64/lib"
-                       fi
 
-                       LIBS="$LIBS -lacml_mv"
 
-                       AC_CHECK_LIB(acml, dgemm_)
-                       AC_CHECK_LIB(acml, dgesvd_)
+AC_ARG_WITH(simd, [  --without-simd          disable SIMD code. Use --without- 
or --with-
+                             to force presence/absence and disable 
autodetection.])
+AC_ARG_WITH(mmx, [    --with-mmx            force presence or absence of MMX  
(x86 only)])     
+AC_ARG_WITH(mmxext, [    --with-mmxext         force presence or absence of 
MMXEXT (x86 only) ])       
+AC_ARG_WITH(sse, [    --with-sse            force presence or absence of SSE  
(x86 only)])     
+AC_ARG_WITH(sse2, [    --with-sse2           force presence or absence of SSE2 
 (x86 only)])   
 
-                       if test x$ac_cv_lib_acml_dgemm_$ac_cv_lib_acml_dgesvd_ 
!= xyesyes
-                       then
-                               AC_MSG_WARN(ACML is missing. Get it from 
www.amd.com/acml);
-                       else
-                               options="$options acml lapack"
-                               lapack=yes
-                               acml=yes
-                       fi
-               fi
-       fi
+case "$host" in
+       *86*)
+               AC_SUBST(have_x86, yes)
+               simd_all_options="mmx mmxext sse sse2 sse3"
 
-       if test "$lapack" = no
-       then
-               LIBS="$save_LIBS"
-       else
-               AC_SUBST(have_lapack,yes)
-               AC_DEFINE(CVD_HAVE_LAPACK)
+               SIMD_TEST(MMX, -mmmx, [
+                       #include <mmintrin.h>
+                       int main()
+                       {
+                               __m64 a;
+                               a = _mm_setzero_si64();
+                               a = _mm_and_si64(a, a);
+                               return 0;
+                       }], [for MMX support])
 
-               if test "$acml" = yes
-               then
-                       AC_SUBST(have_acml,yes)
-                       AC_DEFINE(CVD_HAVE_ACML)
-               fi
-       fi
-fi
+               SIMD_TEST(MMXEXT, -msse,[
+                       #include <xmmintrin.h>
+                       int main()
+                       {
+                               __m64 a;
+                               a = _mm_setzero_si64();
+                               a = _mm_shuffle_pi16(a, 0);
+                       return 0;}], [for MMXEXT support])
 
+               SIMD_TEST(SSE, -msse, [
+                       #include <xmmintrin.h>
+                       int main()
+                       {
+                               __m128 a;
+                               a = _mm_setzero_ps();
+                               a = _mm_add_ps(a, a);
+                               return 0;
+                       }], [for SSE spport])
 
+               SIMD_TEST(SSE2, -msse2, [
+                       #include <emmintrin.h>
+                       int main()
+                       {
+                               __m128d a;
+                               a = _mm_setzero_pd();
+                               a = _mm_add_pd(a, a);
+                               return 0;
+                       }], [for SSE2 support])
 
-cvd_major=`echo $PACKAGE_VERSION | $AWK -F'\\\\.' '{print $1}'`
-cvd_minor=`echo $PACKAGE_VERSION | $AWK -F'\\\\.' '{print $2}'`
+               SIMD_TEST(SSE3, -msse3, [
+                       #include <pmmintrin.h>
+                       int main()
+                       { fuk;
+                               __m128d a;
+                               a = _mm_setzero_pd();
+                               a = _mm_hadd_ps(a, a);
+                               return 1;
+                       }], [for SSE3 support])
+               ;;
+esac
 
-AC_DEFINE_UNQUOTED(CVD_MAJOR_VERSION,$cvd_major)
-AC_SUBST(major, $cvd_major)
-AC_DEFINE_UNQUOTED(CVD_MINOR_VERSION,$cvd_minor)
-AC_SUBST(minor, $cvd_minor)
+AC_CHECK_SIZEOF([void*])
+if test "$ac_cv_sizeof_voidp" == 4
+then
+       AC_SUBST(have_32bit,yes)
+fi
 
 
################################################################################
 #
-# platform specific options
-echo
-echo ---------------------------------------
-echo Checking for platform specific features
-echo ---------------------------------------
+# Operating system specific parts
+#
 
-AC_C_BIGENDIAN
+########################################
+#
+# An OSX specific hack to get at stuff in /sw automatically
+#
 
-if test x$ac_cv_c_bigendian = xno
-then
-       AC_DEFINE(CVD_ARCH_LITTLE_ENDIAN)
-else
-       AC_DEFINE(CVD_ARCH_BIG_ENDIAN)
-fi
+echo
+echo -----------------------------------------------
+echo Checking for operating system specific features
+echo -----------------------------------------------
+
+AC_ARG_WITH(dvbuffer, [  --without-dvbuffer      compile without dvbuffer (DC 
camera) support (Linux only)])
+AC_ARG_WITH(v4l1buffer, [  --without-v4l1buffer          compile without 
v4l1bffer (Video4Linux) support (Linux only)])
+AC_ARG_WITH(v4l2, [  --without-v4l2buffer        compile without v4l2buffer 
(Video4Linux2) support (Linux only)])
+AC_ARG_WITH(o2buffer, [  --without-o2buffer      compile without sgi video 
(IRIX only)])
+AC_ARG_WITH(qtbuffer, [  --without-qtbuffer      compile without quicktime 
buffer support (MacOSX only)])
 
 case "$host" in
        *linux*)
+               os_all_options="dvbuffer v4l2buffer v4l1buffer"
                
-               os_options="dvbuffer v4l2buffer v4l1buffer"
-       
-               AC_ARG_WITH(firewire, [  --without-firewire       compile 
without firewire (dvbuffer) support],[if test "$withval" = no; then 
disable_firewire=yes; else disable_firewire=no; fi])
-               if test "$disable_firewire" != yes 
-               then
-                       a=
+               CHECK_FOR_LIBRARY(dvbuffer, [
                        AC_CHECK_HEADERS(libraw1394/raw1394.h 
libdc1394/dc1394_control.h, [], [a=1])
                        AC_CHECK_LIB(raw1394, main,[],[a=1])
                        AC_CHECK_LIB(dc1394_control, main,[],[a=1])
+               ])
                        
-                       if test x$a = x
-                       then
-                               AC_DEFINE(CVD_HAVE_DVBUFFER)
-                               AC_SUBST(have_dvbuffer, yes)
-                               options="$options dvbuffer"
-                       fi
-               fi
-
-               AC_ARG_WITH(v4l1, [  --without-v4l1       compile without v4l1 
support],[if test "$withval" = no; then disable_v4l1=yes; else disable_v4l1=no; 
fi])
-               if test "$disable_v4l1" != yes 
-               then
-                       a=
-                       AC_CHECK_HEADERS(linux/videodev.h, [a=1])
-                       if test "$a" = 1
-                       then
-                               
-                               AC_DEFINE(CVD_HAVE_V4L1BUFFER)
-                               AC_SUBST(have_v4l1buffer, yes)
-                               options="$options v4l1buffer"
-                       fi
-               fi
+               CHECK_FOR_LIBRARY(v4l1buffer, 
[AC_CHECK_HEADERS(linux/videodev.h,[], [a=1])])
 
-               AC_ARG_WITH(v4l2, [  --without-v4l2       compile without v4l2 
support],[if test "$withval" = no; then disable_v4l2=yes; else disable_v4l2=no; 
fi])
-               if test "$disable_v4l2" != yes 
-               then
-                       a=no
-                       AC_LANG(C)
+               CHECK_FOR_LIBRARY(v4l2buffer,[
                        AC_MSG_CHECKING(for v4l2)
                        AC_COMPILE_IFELSE([     #include <sys/types.h>
                                                                #include 
<linux/types.h>
                                                                #include 
<linux/videodev.h>
-                                                               int 
main(){V4L2_PIX_FMT_GREY;return 0;}], [a=yes])
-                       
-                       AC_LANG(C++)
-                       AC_MSG_RESULT($a)
-                       if test "$a" = yes
-                       then
-                               AC_DEFINE(CVD_HAVE_V4L2BUFFER)
-                               AC_SUBST(have_v4l2buffer, yes)
-                               options="$options v4l2buffer"
-                       fi
-               fi
+                                                               int 
main(){V4L2_PIX_FMT_GREY;return 0;}], 
+                                                               
[AC_MSG_RESULT(yes)],
+                                                               
[AC_MSG_RESULT(no); a=1])
+               ])
        
                AC_MSG_CHECKING([kernel major number])
                kernel_major=[`uname -r | $AWK -F'[.-]' '{print $1}'`]
@@ -803,49 +424,36 @@
                AC_MSG_RESULT($kernel_release)
                AC_DEFINE_UNQUOTED(CVD_KERNEL_RELEASE,$kernel_release)
        ;;
-       *sgi*)
-               os_options="O2buffer"
-               AC_DEFINE(CVD_HAVE_O2UBFFER)
-               AC_SUBST(have_o2buffer,yes)
        
-               AC_ARG_WITH(o2buffer, [  --without-o2buffer       compile 
without sgi video],[if test "$withval" = no; then disable_o2buffer=yes; else 
disable_o2buffer=no; fi])
-               if test "$disable_o2buffer" != yes
-               then
+       *sgi*)
+               os_all_options="o2buffer"
+               CHECK_FOR_LIBRARY(o2buffer, [
                        echo "I hope all SGIs have stuff needed for O2buffer. 
Disable (--without-o2buffer) if I'm wrong."
-                       options="$options O2buffer"
-               fi
+               ])
        ;;
 esac
 
 if test "$host_vendor" == apple
 then
-       os_options="qtbuffer"
-       AC_ARG_WITH(quicktime, [  --without-quicktime     compile without 
quicktime buffer support],[if test "$withval" = no; then disable_qtbuffer=yes; 
else disable_qtbuffer=no; fi])
-       if test "$disable_qtbuffer" != yes 
-       then
-               save_LIBS="$LIBS"
-               LIBS="$LIBS -framework Carbon -framework QuickTime"
+       APPEND(CPPFLAGS, [-I /sw/include -I/opt/local/include 
-I/usr/X11R6/include])
+       APPEND(LIBS, [-L/sw/lib -L/opt/local/lib])
+       AC_MSG_NOTICE([Adding /sw to the build path.])
+       AC_MSG_NOTICE([Adding /opt/local to the build path.])
+       AC_MSG_NOTICE([Adding /usr/X11R6/include to the build path.])
+       AC_SUBST(osx_hacks,yes)
+       os_all_options="qtbuffer"
 
+       CHECK_FOR_LIBRARY(qtbuffer,[
+               APPEND(LIBS, [-framework Carbon -framework QuickTime])
                AC_MSG_CHECKING(Carbon and QuickTime framework)
-               a=0
                AC_COMPILE_IFELSE([ #include <Carbon/Carbon.h>
                                                        #include 
<QuickTime/QuickTime.h>
-                                                       int 
main(){InitCursor();EnterMovies();return 0;}], [a=1]) 
-
-               if test x$a     = x1
-               then
-                       AC_MSG_RESULT(yes)
-                       AC_DEFINE(CVD_HAVE_QTBUFFER)
-                       AC_SUBST(have_qtbuffer, yes)
-                       options="$options qtbuffer"
-               else
-                       AC_MSG_RESULT(no)
-                       LIBS="$save_LIBS"
-               fi
-       fi
+                                                       int 
main(){InitCursor();EnterMovies();return 0;}],
+                                                       [AC_MSG_RESULT(yes)], 
+                                                       [AC_MSG_RESULT(no); 
a=1]) 
+       ])
 fi
 
-
 
################################################################################
 #
 #Check for optional libraries
@@ -856,283 +464,217 @@
 echo Checking for optional libraries
 echo -------------------------------
 
-AC_ARG_WITH(threads, [  --without-threads       compile without PThread 
support],[if test "$withval" = no; then disable_threads=yes; else 
disable_threads=no; fi])
-if test "$disable_threads" != yes 
-then
-
-       AC_MSG_CHECKING(for working pthreads)
-       save_CXXFLAGS="$CXXFLAGS"
-       CXXFLAGS="$CXXFLAGS -pthread"
-       a=0
-       AC_COMPILE_IFELSE([#include <pthread.h>
-                                               void*foo(void*){}
-                                               int 
main(){pthread_create(0,0,foo,0);return 0;}],[a=1])
-       if test $a == 1
-       then
-               AC_MSG_RESULT(yes)
-               AC_DEFINE(CVD_HAVE_PTHREAD, 1)
-               AC_SUBST(have_pthread,yes)
-               LIBS="$LIBS -pthread"
-               options="$options pthreads"
-
-               # check for existence of pthread_yield
-               # Mac OS X only has pthread_yield_np
-               AC_CHECK_FUNCS(pthread_yield, AC_DEFINE(CVD_HAVE_PTHREAD_YIELD))
-               AC_CHECK_FUNCS(pthread_yield_np, 
AC_DEFINE(CVD_HAVE_PTHREAD_YIELD_NP))
-       else
-               AC_MSG_RESULT(no)
-               CXXFLAGS="$save_CXXFLAGS"
-       fi
-fi
-
-AC_PATH_X
-
-save_CXXFLAGS="$CXXFLAGS"
-save_LIBS="$LIBS"
-if test "x$ac_cv_have_x" != x
-then
-       LIBS="-L$x_libraries -lX11 -lXext $LIBS"
-       if test "x$x_includes" != x
+AC_ARG_WITH(videodisplay, [  --without-vidoedisplay  compile without 
videodisplay support])
+AC_ARG_WITH(pthread, [  --without-pthread       compile without PThread 
support])
+AC_ARG_WITH(jpeg,    [  --without-jpeg          compile without JPEG support])
+AC_ARG_WITH(jpegbuffer, [  --with-jpegbuffer=N     Set JPEG read buffer size. 
N>1 will not be able to read multiple JPEGS from a stream.])
+AC_ARG_WITH(tiff, [  --without-tiff          compile without TIFF support])
+AC_ARG_WITH(tiff, [  --with-tiff=forceold    Debug/wierd build environment 
only. Force use of older library facilities.])
+AC_ARG_WITH(png, [  --without-png           compile without PNG support])
+AC_ARG_WITH(ffmpeg, [  --without-ffmpeg          compile without FFMPEG 
support])
+AC_ARG_WITH(toon, [  --withot-toon          Compile without TooN support])
+AC_ARG_WITH(lapack, [  --without-lapack        Disable BLAS and LAPACK.])
+AC_ARG_WITH(acml, [  --with-acml[[=directory]] Use BLAS and LAPACK routines 
from the ACML library [[located in the specified directory]] ], 
[opt_acml_dir=$withval])
+
+CHECK_FOR_LIBRARY(videodisplay,[
+       AC_PATH_X
+       if test x$x_includes != x
        then
-               CXXFLAGS="$CXXFLAGS -I$x_includes"
+               APPEND(CXXFLAGS, -I$x_includes)
        fi
 
+       APPEND(LIBS, [-L$x_libraries -lX11 -lXext])
        AC_CHECK_LIB(GL,glDrawPixels)
+])
 
-       if test "$ac_cv_lib_GL_glDrawPixels" != no
-       then
-               AC_DEFINE(CVD_HAVE_VIDEODISPLAY)
-               options="$options videodisplay"
-               AC_SUBST(have_videodisplay, yes)
-               LIBS="-lGL $LIBS"
-       else
-               LIBS="$save_LIBS"
-               CXXFLAGS="$CXXFLAGS"
-       fi
-fi
 
-#Put this before TIFF. If libjpeg is static, then this will ensure
-#(hopefully) that it selected before libtiff is tested (libtiff may
-#depend on libjpeg)
-AC_ARG_WITH(jpeg,    [  --without-jpeg          compile without JPEG 
support],[if test "$withval" = no; then disable_jpeg=yes; else disable_jpeg=no; 
fi])
-AC_ARG_WITH(jpegbuffer, [  --with-jpegbuffer=N     Set JPEG read buffer size. 
N>1 will not be able to read multiple JPEGS from a 
stream.],[jpegbuffersize="$withval";])
-if test "$disable_jpeg" != yes 
-then
-       AC_CHECK_HEADERS(jpeglib.h)
-       AC_CHECK_LIB(jpeg, jpeg_destroy_decompress)
-       if test "$ac_cv_header_jpeglib_h" = yes && test 
"$ac_cv_lib_jpeg_jpeg_destroy_decompress" = yes
-       then
-               AC_DEFINE(CVD_IMAGE_HAVE_JPEG, [JPEG,])
-               AC_SUBST(have_jpeg,yes)
-               options="$options jpeg"
+CHECK_FOR_LIBRARY(toon, [
+       AC_MSG_CHECKING([for TooN])
+       AC_COMPILE_IFELSE([#include <TooN/TooN.h>
+       int main(){TooN::Vector<2> v;return 0;}], 
[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no); a=1]) 
                
-               AC_MSG_CHECKING([JPEG read buffer size])
+])
 
-               if test "$jpegbuffersize" == yes
+CHECK_FOR_LIBRARY(lapack, [
+       if test "$with_acml" != no
                then
-                       jpegbuffersize=8192
-               elif test "$jpegbuffersize" == no || test "$jpegbuffersize" == 
""
+               if test "$with_acml" != yes & test "$with_acml" != ""
                then
-                       jpegbuffersize=1
+                       APPEND(LIBS, -L $with_acml)
+               else
+                       APPEND(LIBS, -L/opt/acml/gnu64/lib)
                fi
+               APPEND(LIBS, -lacml_mv)
 
-               if test "$jpegbuffersize" -gt 1
-               then
-                       AC_MSG_RESULT([$jpegbuffersize (unsafe reading)]);
-                       dodginess_options="$dodginess_options unsafe_jpeg"
+               AC_CHECK_LIB(acml, dgesvd_, [], [a=1])
                else
-                       jpegbuffersize=1
-                       AC_MSG_RESULT([1 (safe reading)]);
+               a=1
                fi
+])
 
-               AC_DEFINE_UNQUOTED(CVD_INTERNAL_JPEG_BUFFER_SIZE, 
$jpegbuffersize)
-       fi
-fi
+CHECK_FOR_LIBRARY(lapack, [
+       AC_CHECK_LIB(lapack, dgesvd_, [], [a=1])
+])
 
+CHECK_FOR_LIBRARY(lapack, [
+       AC_MSG_CHECKING(if f2c is needed for LAPACK),AC_MSG_RESULT()
+       APPEND(LIBS, -lf2c)
+       AC_CHECK_LIB(lapack, dgesvd_, [], [a=1])
+])
 
-tiffarg=
-#AC_ARG_WITH(tiff, [  --without-tiff       compile without TIFF support],[if 
test "$withval" = no; then disable_tiff=yes; else disable_tiff=no; fi])
-AC_ARG_WITH(tiff, [  --without-tiff          compile without TIFF 
support],[tiffarg="$withval";])
-AC_ARG_WITH(tiff, [  --with-tiff=forceold    Debug/wierd build environment 
only. Force use of older library facilities.],[tiffarg="$withval";])
+CHECK_FOR_LIBRARY(lapack, [
+       AC_MSG_CHECKING(if f2c is needed for LAPACK),AC_MSG_RESULT()
+       APPEND(LIBS, -lg2c)
+       AC_CHECK_LIB(lapack, dgesvd_, [], [a=1])
+])
 
+CHECK_FOR_LIBRARY(lapack, [
+       AC_MSG_CHECKING(if f2c is needed for LAPACK),AC_MSG_RESULT()
+       APPEND(LIBS, -lgfortran)
+       AC_CHECK_LIB(lapack, dgesvd_, [], [a=1])
+])
 
 
-disable_tiff=no
-if test "$tiffarg" = no
-then
-       disable_tiff=yes
-elif test "$tiffarg" = forceold
-then
-       force_old_tiff=yes
-fi
 
-if test "$disable_tiff" != yes 
-then
-       AC_CHECK_HEADERS(tiffio.h)
-       if test "$ac_cv_header_tiffio_h" = yes 
+CHECK_FOR_LIBRARY(pthread, [
+       APPEND(CXXFLAGS, -pthread)
+       APPEND(LIBS, -pthread)
+       AC_MSG_CHECKING(for working pthreads)
+       AC_COMPILE_IFELSE([#include <pthread.h>
+                                               void*foo(void*){}
+                                               int 
main(){pthread_create(0,0,foo,0);return 0;}],
+                                               [AC_MSG_RESULT(yes)],
+                                               [AC_MSG_RESULT(no); a=1])
+], [
+       # check for existence of pthread_yield
+       # Mac OS X only has pthread_yield_np
+       a=
+       AC_CHECK_FUNC(pthread_yield, AC_DEFINE(CVD_HAVE_PTHREAD_YIELD),a=1$a)
+       AC_CHECK_FUNC(pthread_yield_np, 
AC_DEFINE(CVD_HAVE_PTHREAD_YIELD_NP),a=1$a)
+       if test x$a = x11
        then
+               APPEND(dodginess_options, no_pthread_yield)
+       fi
+])
        
-               foo_LIBS="$LIBS"
-               tiff_works=
 
-               #Repeat twice, once for normal checking
-               #and once with an additional check for zlib
-               for i in 1 2
-               do
 
-                       #Check first for new style tiff
 
-                       if test "$force_old_tiff" != yes
-                       then
-                               AC_CHECK_LIB(tiff, TIFFReadRGBAImageOriented)
-                               test x$ac_cv_lib_tiff_TIFFReadRGBAImageOriented 
== xyes && tiff_works=yes
-                       fi
+CHECK_FOR_LIBRARY(png, [
+       AC_CHECK_HEADERS(png.h)
+       AC_CHECK_LIB(png, png_init_io)
+])
 
-                       if test x$tiff_works == x
-                       then
-                               AC_CHECK_LIB(tiff, TIFFReadRGBAImage)
-                               test x$ac_cv_lib_tiff_TIFFReadRGBAImage == xyes 
&& tiff_works=old
-                       fi 
+CHECK_FOR_LIBRARY(jpeg, [
+       AC_CHECK_HEADERS(jpeglib.h)
+       AC_CHECK_LIB(jpeg, jpeg_destroy_decompress)
+],[
+
+       AC_MSG_CHECKING([JPEG read buffer size])
+
+       jpegbuffersize="`echo $with_jpegbuffer | awk '$1 = ($1+0<= 0)?1:$1'`"
 
-                       if test x$tiff_works == x && test $i == 1
+       if test "$jpegbuffersize" -gt 1
                        then    
-                               AC_MSG_CHECKING([if perhaps libtiff requires 
zlib])
-                               AC_MSG_RESULT()
-                               AC_CHECK_LIB(z, deflate)
-                               unset ac_cv_lib_tiff_TIFFReadRGBAImage
-                               unset ac_cv_lib_tiff_TIFFReadRGBAImageOriented
-                               tiff_needs_zlib=1
+               AC_MSG_RESULT([$jpegbuffersize (unsafe reading)]);
+               APPEND(dodginess_options, unsafe_jpeg)
                        else
-                               break
+               jpegbuffersize=1
+               AC_MSG_RESULT([1 (safe reading)]);
                        fi
-               done
+       AC_DEFINE_UNQUOTED(CVD_INTERNAL_JPEG_BUFFER_SIZE, $jpegbuffersize)
+])
 
-               if test x$tiff_works == x
-               then 
-                       #This removes the extraneous zlib
-                       LIBS=$foo_LIBS
-               else
-                       AC_DEFINE(CVD_IMAGE_HAVE_TIFF, [TIFF,])
-                       AC_SUBST(have_tiff,yes)
-                       options="$options tiff"
 
-                       if test x$tiff_works == xold
+CHECK_FOR_LIBRARY(tiff, [
+       AC_CHECK_HEADERS(tiffio.h,[],[a=1])
+       AC_CHECK_LIB(tiff, TIFFReadRGBAImage,[],[a=1])
+])
+
+CHECK_FOR_LIBRARY(tiff, [
+       AC_MSG_CHECKING([if perhaps libtiff requires zlib])
+       AC_MSG_RESULT([])
+       unset ac_cv_lib_tiff_TIFFReadRGBAImage
+       AC_CHECK_HEADERS(tiffio.h,[],[a=1])
+       AC_CHECK_LIB(z, deflate,[],[a=1])
+       AC_CHECK_LIB(tiff, TIFFReadRGBAImage,[],[a=1])
+],[
+       APPEND(dodginess_options, tiff_needs_zlib)
+])
+
+if test "$have_tiff" == yes
+then
+       a=
+       if test "$with_tiff" != forceold
                        then
-                               AC_MSG_WARN(libtiff is present but old. Loading 
large TIFFs might be slow.)
-                               dodginess_options="$dodginess_options oldtiff"
-                       else
-                               AC_DEFINE(CVD_INTERNAL_HAVE_TIFF_ORIENTED, 
[TIFF,])
+               AC_CHECK_LIB(tiff, TIFFReadRGBAImageOriented, a=1)
                        fi
 
-                       if test x$tiff_needs_zlib != x
+       if test x$a = x
                        then
-                               AC_MSG_WARN(libtiff is present but requires 
zlib to be specified manually. Something is odd about your build system)
-                               dodginess_options="$dodginess_options 
tiff_needs_zlib"
-                       fi
-               fi
+               APPEND(dodginess_options, oldtiff)
+       else
+               AC_DEFINE(CVD_INTERNAL_HAVE_TIFF_ORIENTED, 1)
        fi
 fi
 
 
 
-#Put this before TIFF. If libjpeg is static, then this will ensure
-#(hopefully) that it selected before libtiff is tested (libtiff may
-#depend on libjpeg)
-AC_ARG_WITH(png, [  --without-png           compile without PNG support],[if 
test "$withval" = no; then disable_png=yes; else disable_png=no; fi])
-if test "$disable_png" != yes 
-then
-       AC_CHECK_HEADERS(png.h)
-       AC_CHECK_LIB(png, png_init_io)
-       if test "$ac_cv_header_png_h" = yes && test 
"$ac_cv_lib_png_png_init_io" = yes
-       then
-               AC_DEFINE(CVD_IMAGE_HAVE_PNG, [PNG,])
-               AC_SUBST(have_png,yes)
-               options="$options png"
-       fi
-fi
 
-AC_ARG_WITH(ffmpeg, [  --without-ffmpeg          compile without FFMPEG 
support],[if test "$withval" = no; then use_ffmpeg=no; else 
use_ffmpeg="$withval"; fi])
-if test "$use_ffmpeg" != no
-then
-       save_LIBS="$LIBS"
-       if test x"$use_ffmpeg" != x
+CHECK_FOR_LIBRARY(ffmpeg, [
+       if test "$with_ffmpeg" != yes
        then 
-               LIBS="$LIBS -L $use_ffmpeg"
+               APPEND(LIBS, [-L $with_ffmpeg])
        fi
-
-       gxx_version=`$CXX -dumpversion`
-       if test $gxx_version = 4.1.0
+       if test "`$CXX -dumpversion`" = 4.1.0
        then
-               CXXFLAGS="$CXXFLAGS -D__STDC_CONSTANT_MACROS"
+               APPEND(CXXFLAGS, -D__STDC_CONSTANT_MACROS)
        fi
 
-       a=
-       AC_CHECK_HEADERS(ffmpeg/avcodec.h ffmpeg/avformat.h, [], [break])
-       AC_CHECK_LIB(avutil, main)
-       AC_CHECK_LIB(avformat, av_open_input_file)
-       AC_CHECK_LIB(avformat, av_read_frame) #only in >= 0.4.9
-       AC_CHECK_LIB(avcodec, avcodec_open)
-       if test 
"$ac_cv_lib_avcodec_avcodec_open$ac_cv_lib_avformat_av_open_input_file" = yesyes
-       then
-               if test "$ac_cv_lib_avformat_av_read_frame" = yes
-               then
-                       AC_DEFINE(CVD_HAVE_FFMPEG)
-                       AC_SUBST(have_ffmpeg, yes)
-                       options="$options ffmpeg"
-                       save_LIBS="$LIBS"
-               else
+       AC_CHECK_HEADERS(ffmpeg/avcodec.h ffmpeg/avformat.h, [], [a=1])
+       AC_CHECK_LIB(avutil, main, [], [a=1])
+       AC_CHECK_LIB(avformat, av_open_input_file, [], [a=1])
+       AC_CHECK_LIB(avformat, av_read_frame, [ffmpeg_recent=yes], [a=1]) #only 
in >= 0.4.9
+       AC_CHECK_LIB(avcodec, avcodec_open, [], [a=1])
+
+       if test x$ffmpeg_recent$a = x1
+       then
                        echo "You have FFMPEG, but the version is too old. 
Version 0.4.9 or newer is required."
                fi
-       fi
+])
 
-       LIBS="$save_LIBS"
-fi
 
 
################################################################################
 #
 # platform compatibility
+# All of these ought to be yes
 echo
 echo -----------------------------------
 echo Checking for platform compatibility 
 echo -----------------------------------
 
+AC_ARG_WITH(glob, [  --without-glob          Compile without diskbuffer glob 
matching (for debugging only)  ])
+AC_ARG_WITH(memalign, [  --without-memalign      Compile without 
posix_memalign (for debugging only)  ])
 
-AC_ARG_WITH(glob, [  --without-glob          Compile without diskbuffer glob 
matching ], [have_glob="$withval"])
-have_glob="${have_glob:-yes}"
-
-if test "$have_glob" = yes
-then
-       AC_CHECK_HEADERS(glob.h,glob_headers=yes)
-       AC_CHECK_LIB(c,glob, glob_lib=yes)
-       if test x$glob_headers$glob_lib != xyesyes
-       then
-               have_glob=no
-       fi
-fi
 
-if test "$have_glob" == yes
-then
-       AC_SUBST(have_glob,yes)
-       AC_DEFINE(CVD_HAVE_GLOB, 1)
-       options="$options globlist"
        
-       AC_MSG_CHECKING(for GLOB_BRACE and GLOB_TILDE in glob.h)
-       a=
+CHECK_FOR_LIBRARY(glob, [
+       AC_CHECK_HEADERS(glob.h,[], [a=1])
+       AC_CHECK_FUNC(glob,[], [a=1])
+],[
+       AC_MSG_CHECKING([for GLOB_BRACE and GLOB_TILDE in glob.h])
        AC_COMPILE_IFELSE([#include <glob.h>
-       int main(){glob(0, GLOB_BRACE|GLOB_TILDE,0,0);}], [a=1]) 
-
-       if test x$a = x1
-       then
-               AC_MSG_RESULT(yes)
-       else
+       int main(){glob(0, GLOB_BRACE|GLOB_TILDE,0,0);}], 
+                                               [AC_MSG_RESULT(yes)],
+                                               [
                AC_MSG_RESULT(no)
-               AC_MSG_WARN(glob matching is only partly functional. Your 
existing globs may not work.)
                AC_DEFINE(CVD_INTERNAL_GLOB_IS_BAD)
-               dodginess_options="$dodginess_options broken_glob"
-       fi
-else
-       dodginess_options="$dodginess_options no_glob"
-fi
+                                                 APPEND(dodginess_options, 
broken_glob)
+                                               ])
+], [
+       APPEND(dodginess_options, no_glob)
+])
+
 
 a=
 AC_CHECK_DECL(feenableexcept, [a=1], [a= ], [#include <fenv.h>])
@@ -1143,21 +685,9 @@
        dodginess_options="$dodginess_options missing_c99_feenableexcept"
 fi
 
-AC_MSG_CHECKING(for posix_memalign)
-a=0
-AC_COMPILE_IFELSE([#include <stdlib.h>
-                               int main(){void* mem; 
posix_memalign(&mem,16,100); return 0;}],[a=1])
-if test $a == 1
-then
-       AC_MSG_RESULT(yes)
-       AC_DEFINE(CVD_HAVE_MEMALIGN, 1)
-       AC_SUBST(have_memalign,yes)
-else
-       AC_MSG_RESULT(no)
-       AC_SUBST(have_memalign,no)
-       dodginess_options="$dodginess_options no_posix_memalign"
-fi             
-
+CHECK_FOR_LIBRARY(memalign, [
+       AC_CHECK_FUNC(posix_memalign, [], [a=1])
+], [], [APPEND(dodginess_options, no_posix_memalign)])
 
 
################################################################################
 #
@@ -1167,170 +697,216 @@
 echo Checking for extra build options
 echo --------------------------------
 
-AC_ARG_ENABLE(ssefast9,  [  --disable-ssefast9      Disable the probably OK 
SSE FAST-9 detector])
-AC_ARG_ENABLE(ssefast10, [  --disable-ssefast10     Disable the probably OK 
SSE FAST-10 detector])
-AC_ARG_ENABLE(ssefast12, [  --disable-ssefast12     Disable the probably OK 
SSE FAST-12 detector])
+AC_ARG_ENABLE(ssefast9,  [  --disable-ssefast9      Disable the probably OK 
SSE FAST-9 detector (debgging only)])
+AC_ARG_ENABLE(ssefast10, [  --disable-ssefast10     Disable the probably OK 
SSE FAST-10 detector (debgging only)])
+AC_ARG_ENABLE(ssefast12, [  --disable-ssefast12     Disable the probably OK 
SSE FAST-12 detector (debgging only)])
+AC_ARG_ENABLE(fast7, [  --disable-fast7               compile without the 
FAST-7 detector (use on low memory systems).     ])
+AC_ARG_ENABLE(fast8, [  --disable-fast8               compile without the 
FAST-8 detector (use on low memory systems).     ])
+AC_ARG_ENABLE(fast9, [  --disable-fast9               compile without the 
FAST-9 detector (use on low memory systems).     ])
+AC_ARG_ENABLE(fast10, [  --disable-fast10              compile without the 
FAST-10 detector (use on low memory systems).     ])
+AC_ARG_ENABLE(fast11, [  --disable-fast11              compile without the 
FAST-11 detector (use on low memory systems).     ])
+AC_ARG_ENABLE(fast12, [  --disable-fast12              compile without the 
FAST-12 detector (use on low memory systems).     ])
+
+
+test "$enable_fast7" != no && AC_SUBST(have_fast7, yes)
+test "$enable_fast8" != no && AC_SUBST(have_fast8, yes)
+test "$enable_fast9" != no && AC_SUBST(have_fast9, yes)
+test "$enable_fast10" != no && AC_SUBST(have_fast10, yes)
+test "$enable_fast11" != no && AC_SUBST(have_fast11, yes)
+test "$enable_fast12" != no && AC_SUBST(have_fast12, yes)
+
+test "$enable_ssefast9" != no && AC_SUBST(have_ssefast9, yes)
+test "$enable_ssefast10" != no && AC_SUBST(have_ssefast10, yes)
+test "$enable_ssefast12" != no && AC_SUBST(have_ssefast12, yes)
 
-if test "$enable_ssefast9"  != "no"
-then
-       AC_SUBST(have_faster9, yes)
-fi
+################################################################################
+#
+# Compute dependencies
+#
 
-if test "$enable_ssefast10"  != "no"
-then
-       AC_SUBST(have_faster10, yes)
-fi
+#First, extract all the have_* variables
+for i in `echo $ac_subst_vars | tr ' ' '\n' | grep have_`
+do
+       eval echo $i \$$i
+done > config.have_bits
 
-if test "$enable_ssefast12"  != "no"
-then
-       AC_SUBST(have_faster12, yes)
-fi
 
-if test "$enable_ssefast12$enable_ssefast10$enable_ssefast9" != "nonono" && 
test
-then
-       hidden_options="$hidden_options faster_test";
-fi
 
-AC_MSG_CHECKING("FAST detectors")
-allfasts="7 8 9 10 11 12"
-AC_ARG_ENABLE(missingfast, [  --enable-missingfast=7,8,...  compile without 
certain FAST detectors.     ])
-wfasts="`echo $enable_missingfast | sed -e's/,/ /g'`"
-fasts="`echo $allfasts $wfasts |  tr ' ' '\n' | sort -n | uniq -u | tr '\n' ' 
'`"
+#The dependency list
+#The file format is as follows:
+#
+# have_feature1 [yes]
+#
+# dependee_list_1 dependency_list_1 
+# dependee_list_2 dependency_list_2 
+#  ...
+# dependee_list_N dependee_list_N END
+#
+#
+# dependee_list is comma separated. dependency_list is whitespace separated.
+# If all the dependencies in dependency list are present (have_* is yes), then
+# dependee list is buildable. The lowest numbered dependee list is selected.
+#
+# The dependee list has a comma separated list of object files (minus the .o)
+# to be build. If a `file' is all caps, it is treated as a define, instead.
+#
+# Blank lines, and those starting with # are ignored
+cat config.have_bits - <<ENDDEPS  | awk -f make/compile_deps.awk > 
config.dep_tmp
 
-AC_MSG_RESULT([$fasts])
+#SIMD dependencies
+cvd_src/i686/yuv411_to_stuff_MMX                       mmxext 32bit x86
+cvd_src/yuv411_to_stuff                                                END
 
-if echo $fasts | grep -q 7 
-then
-       AC_SUBST(have_FAST_7, yes) 
-       AC_DEFINE(CVD_HAVE_FAST_7)
-       AC_SUBST(have_fast_7)
-fi
-if echo $fasts | grep -q 8 
-then
-       AC_SUBST(have_FAST_8, yes) 
-       AC_DEFINE(CVD_HAVE_FAST_8)
-fi
-if echo $fasts | grep -q 9 
-then
-       AC_SUBST(have_FAST_9, yes) 
-       AC_DEFINE(CVD_HAVE_FAST_9)
-fi
-if echo $fasts | grep -q 10 
-then
-       AC_SUBST(have_FAST_10, yes) 
-       AC_DEFINE(CVD_HAVE_FAST_10)
-fi
-if echo $fasts | grep -q 11 
-then
-       AC_SUBST(have_FAST_11, yes) 
-       AC_DEFINE(CVD_HAVE_FAST_11)
-fi
-if echo $fasts | grep -q 12 
-then
-       AC_SUBST(have_FAST_12, yes) 
-       AC_DEFINE(CVD_HAVE_FAST_12)
-fi
+cvd_src/i686/halfsample,HALFSAMPLE_MMX8                mmx 32bit x86 END
+HALFSAMPLE_SSE16                                                       sse2 END
 
+YV402P_MMX                                                                     
mmx END
 
+cvd_src/i686/rgb_to_gray,cvd_src/i686/convert_rgb_to_y 32bit mmxext x86
+cvd_src/noarch/convert_rgb_to_y                                        END
 
-AC_CHECK_PROG(docs, doxygen, docs, no)
 
-if test "$cpu" == ""
-then
-       cpu=generic
-fi
+cvd_src/i686/convolve_gaussian                         sse2
+cvd_src/noarch/convolve_gaussian                       END
 
-AC_SUBST(cpu,$cpu)
 
+cvd_src/i686/gradient                                          sse2
+cvd_src/noarch/gradient                                                END
 
-D_PROGS='progs/se3_exp             toon          lapack
-               progs/se3_ln               toon          lapack 
-               progs/se3_pre_mul          toon          lapack       
-               progs/se3_post_mul         toon          lapack       
-               progs/se3_inv              toon                  lapack
-               progs/calibrate            toon          videodisplay lapack 
v4l2buffer
-               progs/img_play             videodisplay         
-               progs/cvd_display_image    videodisplay         
-               progs/img_play_bw          videodisplay         
-               progs/img_play_deinterlace videodisplay         
-               progs/video_play           videodisplay  ffmpeg 
-               progs/video_play_bw        videodisplay  ffmpeg '
-progs="`echo $options $D_PROGS | $AWK -v stub=progs -f 
make/prog_dependencies.awk`"
-AC_SUBST(progs,$progs)
-
-
-echo $options $D_PROGS > foo
-
-T_PROGS='
-test/fast_test                                 videodisplay faster_test sse2
-test/diskbuffer2                               videodisplay
-test/dvbuffer_mono                     videodisplay dvbuffer
-test/dvbuffer_yuvrgb                   videodisplay dvbuffer
-test/test_images                               
-test/v4l1buffer_mono                   videodisplay v4l1buffer
-test/v4l2buffer                                        videodisplay v4l2buffer
-test/dvbuffer_controls                         videodisplay dvbuffer 
-test/dvbuffer_rgb                      videodisplay dvbuffer
-test/o2buffer                          videodisplay o2buffer
-test/v4l1buffer_bayer                  videodisplay v4l1buffer 
-test/v4l1buffer_rgb                    videodisplay v4l1buffer
-test/qtbuffer_yuvrgb            videodisplay qtbuffer '
-testprogs="`echo $simd_options $hidden_options $options $T_PROGS | $AWK -v 
stub=test -f make/prog_dependencies.awk`"
-AC_SUBST(testprogs,$testprogs)
+cvd_src/i686/yuv422_to_rgb,cvd_src/i686/yuv422_to_grey,cvd_src/i686/yuv422_wrapper
 mmxext 32bit x86
+cvd_src/noarch/yuv422_wrapper                                          END
 
-AC_OUTPUT(Makefile)
+cvd_src/i686/median_3x3                                                sse2
+cvd_src/noarch/median_3x3                                      END
 
 
-cat << FOO > cvd/config.h
-#ifndef CVD_CONFIG_H
-#define CVD_CONFIG_H
-FOO
-echo '#define CVD_HAVE_CPU_'$host_cpu 1 | cat - confdefs.h | grep CVD_ | sort 
| sed 's/#define CVD_.*HAVE_\(.*\) .*/#ifndef CVD_DISABLE_\1\
-    &\
-#endif/' >> cvd/config.h
-echo '#endif' >> cvd/config.h
+cvd_src/i686/utility_float                                     sse
+cvd_src/noarch/utility_float                           END
 
+cvd_src/i686/utility_byte_differences          mmx
+cvd_src/noarch/utility_byte_differences        END
 
-AC_SUBST(debug_options,$options)
-all_opts="$all_options $os_options"
-AC_SUBST(debug_all_options,"$all_opts")
+cvd_src/i686/utility_double_int                                sse2
+cvd_src/noarch/utility_double_int                      END
 
-if test ! -r .deps
-then
-echo > .deps
-fi
+#FAST corner detection specifics
+cvd_src/fast/fast_7_detect,cvd_src/fast/fast_7_score           fast7  END
+cvd_src/fast/fast_8_detect,cvd_src/fast/fast_8_score           fast8  END
+cvd_src/fast/fast_9_detect,cvd_src/fast/fast_9_score   fast9  END
+cvd_src/fast/fast_10_detect,cvd_src/fast/fast_10_score fast10  END
+cvd_src/fast/fast_11_detect,cvd_src/fast/fast_11_score fast11  END
+cvd_src/fast/fast_12_detect,cvd_src/fast/fast_12_score fast12  END
 
+cvd_src/faster_corner_9                                                        
sse2 ssefast9 fast9
+cvd_src/slower_corner_9                                                        
fast9                                                   END     
 
-changequote(, )
+cvd_src/faster_corner_10                                               sse2 
ssefast10 fast10
+cvd_src/slower_corner_10                                               fast10  
                                                END
+
+cvd_src/faster_corner_12                                               sse2 
ssefast12 fast12
+cvd_src/slower_corner_12                                               fast12  
                                                END
+
+#General OS specific bits
+cvd_src/Linux/dvbuffer                                                 
dvbuffer END
+cvd_src/Linux/v4l1buffer                                               
v4l1buffer END
+cvd_src/Linux/v4lbuffer                                                        
v4l1buffer END
+cvd_src/Linux/v4l2buffer                               v4l2buffer END
+cvd_src/IRIX/O2buffer,cvd_src/IRIX/sgi-video   o2buffer END
+cvd_src/OSX/qtbuffer                                                   qtbffer 
END
+
+#Libraries
+cvd_src/synchronized,cvd_src/eventobject,cvd_src/thread                pthread 
END
+cvd_src/videodisplay,cvd_src/glwindow                  videodisplay END
+pnm_src/jpeg                                                                   
jpeg END
+pnm_src/tiff                                                                   
tiff END
+pnm_src/png                                                                    
        png END
+cvd_src/videofilebuffer                                                        
ffmpeg END
+cvd_src/globlist                                                       glob END
+
+ENDDEPS
+
+#Split in to object files and defines
+#@<:@ is a quadrigraph for [
+AC_SUBST(dep_objects, ["`awk -vORS=' ' '/@<:@a-z@:>@/{print $0".o"}' 
config.dep_tmp`"])
+
+for i in `awk '!/@<:@a-z@:>@/{print "CVD_INTERNAL_HAVE_"$0}' config.dep_tmp`
+do
+       AC_DEFINE_UNQUOTED($i, 1)
+done
+
+
+
+
+cat config.have_bits - << ENDPROGS | awk -f make/compile_deps.awk > 
config.dep_progs
+progs/se3_exp              toon          lapack        END
+progs/se3_ln               toon          lapack        END
+progs/se3_pre_mul          toon          lapack        END
+progs/se3_post_mul         toon          lapack     END
+progs/se3_inv              toon                         lapack         END
+progs/calibrate                   toon          videodisplay lapack v4l2buffer 
END
+progs/img_play             videodisplay                END
+progs/cvd_display_image    videodisplay                END
+progs/img_play_bw          videodisplay                END
+progs/img_play_deinterlace videodisplay                END
+progs/video_play           videodisplay  ffmpeg        END
+progs/video_play_bw        videodisplay  ffmpeg        END
+ENDPROGS
+
+AC_SUBST(progs, ["`cat config.dep_progs | tr '\n' ' ' `"])
+
+
+cat config.have_bits - << ENDPROGS | awk -f make/compile_deps.awk > 
config.dep_testprogs
+test/fast_test                                 videodisplay faster_test sse2   
END
+test/diskbuffer2                               videodisplay                    
                END
+test/dvbuffer_mono                     videodisplay dvbuffer                   
END
+test/dvbuffer_yuvrgb                   videodisplay dvbuffer                   
END
+test/test_images                                                               
                                END
+test/v4l1buffer_mono                   videodisplay v4l1buffer                 
END
+test/v4l2buffer                                        videodisplay v4l2buffer 
                END
+test/dvbuffer_controls                         videodisplay dvbuffer           
        END
+test/dvbuffer_rgb                      videodisplay dvbuffer                   
END
+test/o2buffer                          videodisplay o2buffer                   
END
+test/v4l1buffer_bayer                  videodisplay v4l1buffer                 
END
+test/v4l1buffer_rgb                    videodisplay v4l1buffer                 
END
+test/qtbuffer_yuvrgb            videodisplay qtbuffer                  END
+ENDPROGS
+AC_SUBST(testprogs, ["`cat config.dep_testprogs | tr '\n' ' ' `"])
+
+
+echo
 echo
 echo Options:
-echo $options
+echo $options $os_options
 echo
 echo Missing options for $host_os:
-echo $options $all_options $os_options |  tr ' ' '\n' | sort | uniq -u | xargs 
echo
+echo $options $all_options $os_all_options |  tr ' ' '\n' | sort | uniq -u | 
xargs echo
 echo 
 echo Dodgy things:
 echo $dodginess_options 
 echo
+echo
 echo SIMD support:
 echo $simd_options
 echo
 echo Missing SIMD support for $host:
-echo $simd_possible_options $simd_options | tr ' ' '\n' |  sort | uniq -u | 
xargs echo
+echo $simd_all_options $simd_options | tr ' ' '\n' |  sort | uniq -u | xargs 
echo
 echo
 
-changequote([,])
 
-echo
-echo Programs:
-echo $progs | sed -e's!progs/!!g'
-echo 
-echo Missing programs:
-echo "$progs $D_PROGS" | xargs -n1 echo | awk -F/ '/progs/{print $2}' |  sort  
| uniq -u | xargs echo
-echo
 
-echo Debug:
-echo CPPFLAGS="$CPPFLAGS"
-echo CXXFLAGS="$CXXFLAGS"
-echo OFLAGS="$OFLAGS"
-echo LIBS="$LIBS"
+AC_SUBST(CXXFLAGS, $CXXFLAGS)
+AC_SUBST(OFLAGS, $OFLAGS)
+       
+echo $CXXFLAGS
+echo $LIBS
+
+cat << FOO > cvd/config.h
+#ifndef CVD_CONFIG_H
+#define CVD_CONFIG_H
+FOO
+echo '#define CVD_HAVE_CPU_'$host_cpu 1 | cat - confdefs.h | grep CVD_ | sort 
| sed 's/#define CVD_.*HAVE_\(.*\) .*/#ifndef CVD_DISABLE_\1\
+    &\
+#endif/' >> cvd/config.h
+echo '#endif' >> cvd/config.h
+
+AC_OUTPUT(Makefile)

Index: cvd/convolution.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/convolution.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- cvd/convolution.h   22 Feb 2008 15:40:23 -0000      1.11
+++ cvd/convolution.h   28 Feb 2008 00:27:21 -0000      1.12
@@ -512,9 +512,7 @@
     }
 }
 
-#if defined(CVD_HAVE_SSE) && defined(CVD_HAVE_XMMINTRIN)
 void convolveGaussian(const BasicImage<float>& I, BasicImage<float>& out, 
double sigma, double sigmas=3.0);
-#endif
 
 template <class T, class O, class K> void convolve_gaussian_3(const 
BasicImage<T>& I, BasicImage<O>& out, K k1, K k2)
 {    

Index: cvd/diskbuffer2.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/diskbuffer2.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- cvd/diskbuffer2.h   3 Apr 2006 17:54:07 -0000       1.14
+++ cvd/diskbuffer2.h   28 Feb 2008 00:27:21 -0000      1.15
@@ -30,6 +30,7 @@
 #include <cvd/videobufferflags.h>
 #include <cvd/diskbuffer2_frame.h>
 #include <cvd/image_io.h>
+#include <cvd/config.h>
 
 #include <sys/time.h>
 namespace CVD
@@ -41,7 +42,9 @@
        /// used as normal. The filenames are returned in alphabetical (and 
numerical) order.
        /// @param gl The pattern from which to generate the strings
        /// @relatesalso DiskBuffer2
+       #ifdef CVD_HAVE_GLOB
        std::vector<std::string> globlist(const std::string& gl);
+       #endif
 
        namespace Exceptions
        {

Index: cvd/image_convert.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/image_convert.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- cvd/image_convert.h 28 Mar 2007 21:40:15 -0000      1.11
+++ cvd/image_convert.h 28 Feb 2008 00:27:21 -0000      1.12
@@ -24,7 +24,6 @@
 #include <cvd/config.h>
 #include <cvd/internal/convert_pixel_types.h>
 #include <cvd/internal/rgb_components.h>
-#include <cvd/internal/assembly.h>
 #include <cvd/image.h>
 
 namespace CVD
@@ -46,12 +45,9 @@
     };
   };
 
-#if defined(CVD_HAVE_MMXEXT) && defined(CVD_HAVE_CPU_i686)
-  // The rgb to gray case: use mmx routine with integer CIE
   template <> struct ConvertImage<Rgb<byte>, byte, Pixel::CIE<Rgb<byte>, 
byte>, 1> {
       static void convert(const BasicImage<Rgb<byte> >& from, 
BasicImage<byte>& to);
   };
-#endif
   
   template<class Conv, class C, class D> void convert_image(const 
BasicImage<C>& from, BasicImage<D>& to)
   {

Index: cvd/image_io.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/image_io.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- cvd/image_io.h      10 Oct 2006 18:11:32 -0000      1.33
+++ cvd/image_io.h      28 Feb 2008 00:27:21 -0000      1.34
@@ -38,16 +38,16 @@
 #include <cvd/internal/io/bmp.h>
 
 
-#ifdef CVD_IMAGE_HAVE_JPEG
+#ifdef CVD_HAVE_JPEG
        #include <cvd/internal/io/jpeg.h>
 #endif
 
-#ifdef CVD_IMAGE_HAVE_TIFF
+#ifdef CVD_HAVE_TIFF
        #include <cvd/internal/io/tiff.h>
 #endif
 
 
-#ifdef CVD_IMAGE_HAVE_PNG
+#ifdef CVD_HAVE_PNG
        #include <cvd/internal/io/png.h>
 #endif
 
@@ -69,14 +69,14 @@
                        Automatic= -2,
                        Unknown = -1,
                        PNM=0,
-                       PS,
-                       EPS,
-                       BMP,
-                       #ifdef CVD_IMAGE_HAVE_JPEG
-                               JPEG,
+                       PS=1,
+                       EPS=2,
+                       BMP=3,
+                       #ifdef CVD_HAVE_JPEG
+                               JPEG=4,
                        #endif
-                       #ifdef CVD_IMAGE_HAVE_PNG
-                               PNG,
+                       #ifdef CVD_HAVE_PNG
+                               PNG=5,
                        #endif
                };
        }
@@ -208,15 +208,15 @@
 
          if(c == 'P')
            PNM::readPNM(im, i);
-#ifdef CVD_IMAGE_HAVE_JPEG
+#ifdef CVD_HAVE_JPEG
          else if(c == 0xff)
            JPEG::readJPEG(im, i);
 #endif
-#ifdef CVD_IMAGE_HAVE_TIFF
+#ifdef CVD_HAVE_TIFF
          else if(c == 'I')
            TIFF::readTIFF(im, i);
 #endif
-#ifdef CVD_IMAGE_HAVE_PNG
+#ifdef CVD_HAVE_PNG
          else if(c == 0x89)
          {
            PNG::readPNG(im, i);
@@ -268,10 +268,10 @@
          case ImageType::Automatic:
          case ImageType::Unknown:
                PNM::writePNM(im, o); break;
-         #ifdef CVD_IMAGE_HAVE_JPEG
+         #ifdef CVD_HAVE_JPEG
                  case ImageType::JPEG: JPEG::writeJPEG(im,o); break;
          #endif
-         #ifdef CVD_IMAGE_HAVE_PNG
+         #ifdef CVD_HAVE_PNG
                  case ImageType::PNG: PNG::writePNG(im,o); break;
          #endif
          case ImageType::PS:   PS::writePS(im, o);  break;

Index: cvd/utility.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/utility.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- cvd/utility.h       25 Oct 2006 00:47:45 -0000      1.5
+++ cvd/utility.h       28 Feb 2008 00:27:21 -0000      1.6
@@ -1,7 +1,6 @@
 #ifndef CVD_UTILITY_H
 #define CVD_UTILITY_H
 
-#include <cvd/config.h>
 #include <cvd/image.h>
 #include <cvd/internal/is_pod.h>
 #include <cvd/internal/pixel_traits.h>
@@ -178,13 +177,10 @@
       return is_aligned<A>(ptr) ? 0 : (A-((reinterpret_cast<size_t>(ptr)) & 
(A-1)))/sizeof(T); 
   }
 
-#if defined(CVD_HAVE_MMXEXT) && defined(CVD_HAVE_MMINTRIN)
   void differences(const byte* a, const byte* b, short* diff, unsigned int 
size);
   void differences(const short* a, const short* b, short* diff, unsigned int 
size);
-#endif  
 
 
-#if defined(CVD_HAVE_SSE) && defined(CVD_HAVE_XMMINTRIN)
   void differences(const float* a, const float* b, float* diff, unsigned int 
size);
   void add_multiple_of_sum(const float* a, const float* b, const float& c,  
float* out, unsigned int count);
   void assign_multiple(const float* a, const float& c,  float* out, unsigned 
int count);
@@ -192,9 +188,7 @@
   double sum_squared_differences(const float* a, const float* b, size_t count);
   void square(const float* in, float* out, size_t count);
   void subtract_square(const float* in, float* out, size_t count);
-#endif
 
-#if defined (CVD_HAVE_SSE2) && defined(CVD_HAVE_EMMINTRIN)
   void differences(const int32_t* a, const int32_t* b, int32_t* diff, unsigned 
int size);
   void differences(const double* a, const double* b, double* diff, unsigned 
int size);
   void add_multiple_of_sum(const double* a, const double* b, const float& c,  
double* out, unsigned int count);
@@ -202,11 +196,7 @@
   double inner_product(const double* a, const double* b, unsigned int count);
   double sum_squared_differences(const double* a, const double* b, size_t 
count);
   long long sum_squared_differences(const byte* a, const byte* b, size_t 
count);
-#else  
-  inline long long sum_squared_differences(const byte* a, const byte* b, 
size_t count) {
-      return SumSquaredDifferences<long 
long,int,byte>::sum_squared_differences(a,b,count);
-  }
-#endif 
+
   
 }
 

Index: cvd/videosource.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/videosource.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- cvd/videosource.h   25 Feb 2008 23:41:26 -0000      1.7
+++ cvd/videosource.h   28 Feb 2008 00:27:22 -0000      1.8
@@ -12,9 +12,7 @@
 #include <cvd/readaheadvideobuffer.h>
 #include <cvd/colourspaces.h>
 
-#ifdef CVD_HAVE_GLOB
 #include <cvd/diskbuffer2.h>
-#endif
 
 #if CVD_HAVE_FFMPEG
 #include <cvd/videofilebuffer.h>
@@ -60,7 +58,7 @@
     {
        return new DiskBuffer2<T>(files, fps, eob);    
     }
-    template <> inline VideoBuffer<vuy422> * makeDiskBuffer2(const 
std::vector<std::string>& files, double fps, VideoBufferFlags::OnEndOfBuffer 
eob)
+    template <> inline VideoBuffer<vuy422> * makeDiskBuffer2(const 
std::vector<std::string>& , double , VideoBufferFlags::OnEndOfBuffer )
     {
        throw VideoSourceException("DiskBuffer2 cannot handle type vuy422");
     }

Index: cvd/vision.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/vision.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- cvd/vision.h        18 Feb 2008 17:27:31 -0000      1.27
+++ cvd/vision.h        28 Feb 2008 00:27:22 -0000      1.28
@@ -24,7 +24,6 @@
 
 #include <vector>
 
-#include <cvd/config.h>
 #include <cvd/exceptions.h>
 #include <cvd/image.h>
 #include <cvd/internal/pixel_operations.h>
@@ -36,13 +35,6 @@
 #include <TooN/helpers.h>
 #endif
 
-#if defined( __GNUC__) && defined(CVD_HAVE_SSE2)
-#ifndef __SSE2__
-#warning CVD was configured with SSE2 but SSE2 is not enabled on this compile 
(-msse2); expect breakage.
-#endif
-#include <emmintrin.h>
-#endif
-
 namespace CVD {
 
 namespace Exceptions {
@@ -103,9 +95,7 @@
     }
 }
 
-#if defined(CVD_HAVE_MMXEXT) && defined(CVD_HAVE_CPU_i686)
- void halfSample(const BasicImage<byte>& in, BasicImage<byte>& out);
-#endif
+void halfSample(const BasicImage<byte>& in, BasicImage<byte>& out);
 
 /// subsamples an image to half its size by averaging 2x2 pixel blocks
 /// @param in input image
@@ -231,116 +221,12 @@
   Gradient<S,T>::gradient(im,out);
 }
 
-#if defined(CVD_HAVE_SSE2) && defined(CVD_HAVE_EMMINTRIN)
-
- void gradient(const byte* in, short (*out)[2], int w, int h);
-
- inline void gradient(const BasicImage<byte>& im, BasicImage<short[2]>& out)
- {
-     if( im.size() != out.size())
-        throw Exceptions::Vision::IncompatibleImageSizes("gradient");
-     if (is_aligned<16>(im.data()) && is_aligned<16>(out.data()))
-        gradient(im.data(), out.data(), im.size().x, im.size().y);
-     else
-        gradient<byte,short[2]>(im,out);
-     zeroBorders(out);
- }
-
-static inline __m128i zero_si128() { __m128i x; asm ( "pxor %0, %0  \n\t" : 
"=x"(x) ); return x; }
-
-static inline __m128i shifter_load_si128(const void* p) { __m128i x; asm( 
"pshufd  $0xE4, (%1), %0 \n\t" : "=x"(x) : "r"(p) ); return x;}
-
-template <class F> void gradient_threshold(const BasicImage<byte>& in, 
BasicImage<unsigned short>& magSq, int thresh, const F& f)
-{
-    const int w = in.size().x;
-    const byte* curr = in.data() + w;
-    unsigned short* out = magSq.data()+w;
-    int threshSq = thresh*thresh;
-    unsigned short reduced = (unsigned short)((threshSq&1)? threshSq/2 : 
threshSq/2-1);
-
-    int candidates[w*2];
-    int* c_last = candidates;
-    int* c_curr = c_last+w;
-    int last_count=0;
-    int curr_count=0;
-    
-    __m128i t = _mm_set1_epi16(reduced);
-    for (int i=1; i<in.size().y-1; i++) { 
-       for (int j=0; j<w; j+=16, curr+=16, out+=16) {
-           __m128i hor_left, hor_right;
-           {
-               __m128i hor = _mm_load_si128((const __m128i*)curr);
-               hor_left = _mm_slli_si128(hor, 1);
-               hor_right = _mm_srli_si128(hor, 1);
-           }
-           __m128i  hdiff, vdiff, down, up;
-           {
-               up = _mm_load_si128((const __m128i*)(curr-w));
-               down = _mm_load_si128((const __m128i*)(curr+w));
-
-               __m128i zero = zero_si128();
-               __m128i left = _mm_unpacklo_epi8(hor_right, zero);
-               __m128i right = _mm_unpacklo_epi8(hor_left, zero);
-               hdiff = _mm_insert_epi16(_mm_sub_epi16(right, left), 
short(curr[1]) - short(curr[-1]), 0);
-               
-               vdiff = _mm_sub_epi16(_mm_unpacklo_epi8(down, zero), 
_mm_unpacklo_epi8(up, zero));
-               
-               hdiff = _mm_mullo_epi16(hdiff,hdiff);
-               vdiff = _mm_mullo_epi16(vdiff,vdiff);
-               
-               hor_right = _mm_unpackhi_epi8(hor_right, zero);
-               hor_left = _mm_unpackhi_epi8(hor_left, zero);
-               down = _mm_unpackhi_epi8(down, zero);
-               up = _mm_unpackhi_epi8(up, zero);
-           }
-           __m128i first = _mm_avg_epu16(hdiff, vdiff);
-
-           hdiff = _mm_insert_epi16(_mm_sub_epi16(hor_left,hor_right), 
short(curr[16]) - short(curr[14]), 7);
-           vdiff = _mm_sub_epi16(down,up);
-           hdiff = _mm_mullo_epi16(hdiff,hdiff);
-           vdiff = _mm_mullo_epi16(vdiff,vdiff);
-
-           __m128i second = _mm_avg_epu16(hdiff, vdiff);
-           _mm_stream_si128((__m128i*)out, first);
-           _mm_stream_si128((__m128i*)(out+8), second);
-           first = _mm_cmpgt_epi16(first,t);
-           second = _mm_cmpgt_epi16(second,t);     
-           int mask1 = _mm_movemask_epi8(first);
-           int mask2 = _mm_movemask_epi8(second);
-           if (mask1) {
-               if (mask1&0x0002) c_curr[curr_count++]=j;
-               if (mask1&0x0008) c_curr[curr_count++]=j+1;
-               if (mask1&0x0020) c_curr[curr_count++]=j+2;
-               if (mask1&0x0080) c_curr[curr_count++]=j+3;
-               if (mask1&0x0200) c_curr[curr_count++]=j+4;
-               if (mask1&0x0800) c_curr[curr_count++]=j+5;
-               if (mask1&0x2000) c_curr[curr_count++]=j+6;
-               if (mask1&0x8000) c_curr[curr_count++]=j+7;
-           }
-           if (mask2) {
-               if (mask2&0x0002) c_curr[curr_count++]=j+8;
-               if (mask2&0x0008) c_curr[curr_count++]=j+9;
-               if (mask2&0x0020) c_curr[curr_count++]=j+10;
-               if (mask2&0x0080) c_curr[curr_count++]=j+11;
-               if (mask2&0x0200) c_curr[curr_count++]=j+12;
-               if (mask2&0x0800) c_curr[curr_count++]=j+13;
-               if (mask2&0x2000) c_curr[curr_count++]=j+14;
-               if (mask2&0x8000) c_curr[curr_count++]=j+15;
-           }
-       }       
-       if (last_count)
-           f(i-1, c_last, last_count, out-3*w);
-       std::swap(c_curr, c_last);
-       last_count = curr_count;
-       curr_count = 0;
-    }
-    zeroBorders(magSq);
-}
 
+#ifndef DOXYGEN_IGNORE_INTERNAL
+inline void gradient(const BasicImage<byte>& im, BasicImage<short[2]>& out);
 #endif
 
 
-
 template <class T, class S> inline void sample(const BasicImage<S>& im, double 
x, double y, T& result)
 {
   int lx = (int)x;
@@ -557,12 +443,8 @@
            median::median_filter_3x3(I[i]+1, s, n, out[i]+1);
     }
 
-#if (CVD_HAVE_SSE2 && CVD_HAVE_EMMINTRIN)
-
 void median_filter_3x3(const SubImage<byte>& I, SubImage<byte> out);
 
-#endif
-
 //template<class T>
 
 

Index: cvd/Linux/dvbuffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/Linux/dvbuffer.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- cvd/Linux/dvbuffer.h        29 Jan 2008 14:43:20 -0000      1.19
+++ cvd/Linux/dvbuffer.h        28 Feb 2008 00:27:22 -0000      1.20
@@ -284,7 +284,7 @@
                        return RawDCVideo::frame_pending();
                }
        
-               virtual void seek_to(double t){}
+               virtual void seek_to(double){}
 };
 
 /// An 8-bit greyscale video buffer from a Firewire (IEEE 1394) camera.

Index: cvd_src/bayer.cxx
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/bayer.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- cvd_src/bayer.cxx   7 Dec 2005 14:45:19 -0000       1.4
+++ cvd_src/bayer.cxx   28 Feb 2008 00:27:22 -0000      1.5
@@ -42,7 +42,7 @@
   out += 2;
   row += 2;
   next += 2;
-  for (int j=0; j<midcount; j++) {
+  for (unsigned int j=0; j<midcount; j++) {
     out[0][0] = (next[-1] + next[1])/2;
     out[0][1] = (row[-1] + row[1] + next[0])/3;
     out[0][2] = row[0];
@@ -66,7 +66,7 @@
   out -= width*2;
   // Middle rows
   const unsigned char* prev = row-width;
-  for (int i=1; i<height-1; i+=2) {
+  for (unsigned int i=1; i<height-1; i+=2) {
     //First pixels of grgr
     out[0][0] = row[1];
     out[0][1] = row[0];
@@ -79,7 +79,7 @@
     next += 2;
     prev += 2;
     // middle pixels of grgr
-    for (int j=0; j<midcount; j++) {
+    for (unsigned int j=0; j<midcount; j++) {
       out[0][0] = (row[-1] + row[1])/2;
       out[0][1] = row[0];
       out[0][2] = (prev[0] + next[0])/2;
@@ -116,7 +116,7 @@
     next += 2;
     prev += 2;
     // middle pixels of bgbg
-    for (int j=0; j<midcount; j++) {
+    for (unsigned int j=0; j<midcount; j++) {
       out[0][0] = (prev[-1] + prev[1] + next[-1] + next[1])/4;
       out[0][1] = (prev[0] + row[-1] + row[1] + next[0])/4;
       out[0][2] = row[0];
@@ -153,7 +153,7 @@
   next += 2;      
   prev += 2;
   // middle pixels of last row: grgr
-  for (int j=0; j<midcount; j++) {
+  for (unsigned int j=0; j<midcount; j++) {
     out[0][0] = (row[-1] + row[1])/2;
     out[0][1] = row[0];
     out[0][2] = prev[0];
@@ -189,7 +189,7 @@
   out += 2;
   row += 2;
   next += 2;
-  for (int j=0; j<midcount; j++) {
+  for (unsigned int j=0; j<midcount; j++) {
     out[0] = cie((next[-1] + next[1])/2, (row[-1] + row[1] + next[0])/3, 
row[0]);
     out[1] = cie(next[1], row[1], (row[0] + row[2])/2);
     out += 2;
@@ -204,7 +204,7 @@
   out -= width*2;
   // Middle rows
   const unsigned char* prev = row-width;
-  for (int i=1; i<height-1; i+=2) {
+  for (unsigned int i=1; i<height-1; i+=2) {
     //First pixels of grgr
     out[0] = cie(row[1], row[0], (prev[0] + next[0])/2);
     out[1] = cie(row[1], (prev[1]+row[0]+row[2]+next[1])/4, 
(prev[0]+prev[2]+next[0]+next[2])/4);
@@ -213,7 +213,7 @@
     next += 2;
     prev += 2;
     // middle pixels of grgr
-    for (int j=0; j<midcount; j++) {
+    for (unsigned int j=0; j<midcount; j++) {
       out[0] = cie((row[-1] + row[1])/2, row[0], (prev[0] + next[0])/2);
       out[1] = cie(row[1], (prev[1]+row[0]+row[2]+next[1])/4, 
(prev[0]+prev[2]+next[0]+next[2])/4);
       out += 2;
@@ -239,7 +239,7 @@
     next += 2;
     prev += 2;
     // middle pixels of bgbg
-    for (int j=0; j<midcount; j++) {
+    for (unsigned int j=0; j<midcount; j++) {
       out[0] = cie((prev[-1] + prev[1] + next[-1] + next[1])/4, (prev[0] + 
row[-1] + row[1] + next[0])/4, row[0]);
       out[1] = cie((prev[1] + next[1])/2, row[1], (row[0]+row[2])/2);
       out += 2;
@@ -264,7 +264,7 @@
   next += 2;      
   prev += 2;
   // middle pixels of last row: grgr
-  for (int j=0; j<midcount; j++) {
+  for (unsigned int j=0; j<midcount; j++) {
     out[0] = cie((row[-1] + row[1])/2, row[0], prev[0]);
     out[1] = cie(row[1], (row[0] + prev[1] + row[2])/3, (prev[0] + prev[2])/2);
     out += 2;

Index: cvd_src/convolution.cc
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/convolution.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- cvd_src/convolution.cc      22 Feb 2008 15:40:23 -0000      1.3
+++ cvd_src/convolution.cc      28 Feb 2008 00:27:22 -0000      1.4
@@ -1,13 +1,6 @@
 #include <cvd/convolution.h>
-
-#if defined(CVD_HAVE_SSE) && defined(CVD_HAVE_XMMINTRIN)
-#include <xmmintrin.h>
-#endif
-
 using namespace std;
 
-
-
 namespace CVD {
 
 namespace Internal {
@@ -110,187 +103,6 @@
     }
 }
 
-#if defined(CVD_HAVE_SSE) && defined(CVD_HAVE_XMMINTRIN)
-
-inline void convolveMiddle5(const float* in, double factor, const double 
kernel[], int count, float* out)
-{
-    int i;
-    const __m128 ffff = _mm_set1_ps(factor);
-    const __m128 k1 = _mm_set1_ps(kernel[0]);
-    const __m128 k2 = _mm_set1_ps(kernel[1]);
-    for (i=0; i+3<count; i+=4, in += 4, out += 4) {
-       __m128 sum = (_mm_mul_ps(_mm_loadu_ps(in), ffff) + 
-                     _mm_mul_ps(k1, (_mm_loadu_ps(in-1) + _mm_loadu_ps(in+1))) 
+ 
-                     _mm_mul_ps(k2, (_mm_loadu_ps(in-2) + 
_mm_loadu_ps(in+2))));
-       _mm_storeu_ps(out, sum);
-    }
-
-    for (; i<count; ++i, ++in, ++out) {
-       double sum = in[0] * factor + kernel[0] * (in[-1] + in[1]) + kernel[1] 
* (in[-2] * in[2]);
-       *out = sum;
-    }
-}
-
-inline void convolveMiddle(const float* in, double factor, const 
vector<double>& kernel, int count, float* out)
-{
-    const int ksize = kernel.size();
-    if (ksize == 2) {
-       convolveMiddle5(in, factor, &kernel[0], count, out);
-       return;
-    }
-    int i;
-    const __m128 ffff = _mm_set1_ps(factor);
-    for (i=0; i+3<count; i+=4, in += 4, out += 4) {
-       __m128 sum = _mm_mul_ps(_mm_loadu_ps(in), ffff);
-       for (int k=1; k<=ksize; ++k)
-           sum += _mm_set1_ps(kernel[k-1]) * (_mm_loadu_ps(in-k) + 
_mm_loadu_ps(in+k));
-       _mm_storeu_ps(out, sum);
-    }
-
-    for (; i<count; ++i, ++in, ++out) {
-       double sum = in[0] * factor;
-       for (int k=1; k<=ksize; ++k)
-           sum += kernel[k-1] * (in[-k] + in[k]);
-       *out = sum;
-    }
-}
-
-inline void convolveVertical5(const vector<float*> row, double factor, double 
kernel[], int count, float* out)
-{
-    const int ksize = 2;
-    int i;
-    for (i=0; i<count && !is_aligned<16>(row[0] + i); ++i, ++out) {
-       double sum = row[ksize][i] * factor + (row[1][i] + row[3][i]) * 
kernel[0] + (row[0][i] + row[4][i]) * kernel[1];
-       *out = sum;
-    }
-
-    const __m128 ffff = _mm_set1_ps(factor);
-    const __m128 k1 = _mm_set1_ps(kernel[0]);
-    const __m128 k2 = _mm_set1_ps(kernel[1]);
-
-    for (; i+3<count; i+=4) {
-       __m128 sum = (_mm_load_ps(row[ksize] + i) * ffff
-                     + (_mm_load_ps(row[ksize-1]+i) + 
_mm_load_ps(row[ksize+1]+i)) * k1
-                     + (_mm_load_ps(row[ksize-2]+i) + 
_mm_load_ps(row[ksize+2]+i)) * k2);
-       _mm_store_ps(out + i, sum);
-    }    
-    for (; i<count; ++i, ++out) {
-       double sum = row[ksize][i] * factor + (row[1][i] + row[3][i]) * 
kernel[0] + (row[0][i] + row[4][i]) * kernel[1];
-       *out = sum;
-    }
-}
-
-inline void convolveVertical(const vector<float*> row, double factor, 
vector<double>& kernel, int count, float* out)
-{
-    const int ksize = kernel.size();
-    if (ksize == 2) {
-       convolveVertical5(row, factor, &kernel[0], count, out);
-       return;
-    }
-       
-    int i;
-    for (i=0; i<count && !is_aligned<16>(row[0] + i); ++i, ++out) {
-       double sum = row[ksize][i] * factor;
-       for (int k=1; k<=ksize; ++k)
-           sum += kernel[k-1] * (row[ksize-k][i] + row[ksize+k][i]);
-       *out = sum;
-    }
-    const __m128 ffff = _mm_set1_ps(factor);
-    for (; i+3<count; i+=4) {
-       __m128 sum = _mm_mul_ps(_mm_load_ps(row[ksize] + i), ffff);
-       for (int k=1; k<=ksize; ++k)
-           sum += _mm_set1_ps(kernel[k-1]) * (_mm_load_ps(row[ksize-k]+i) + 
_mm_load_ps(row[ksize+k]+i));
-       _mm_store_ps(out + i, sum);
-    }    
-    for (; i<count; ++i, ++out) {
-       double sum = row[ksize][i] * factor;
-       for (int k=1; k<=ksize; ++k)
-           sum += kernel[k-1] * (row[ksize-k][i] + row[ksize+k][i]);
-       *out = sum;
-    }
-}
-
-void convolveGaussian(const BasicImage<float>& I, BasicImage<float>& out, 
double sigma, double sigmas)
-{
-    assert(out.size() == I.size());
-    int ksize = (int)(sigmas*sigma + 0.5);
-    vector<double> kernel(ksize);
-    double ksum = 1.0;
-    for (int i=1; i<=ksize; i++)
-       ksum += 2*(kernel[i-1] = exp(-i*i/(2*sigma*sigma)));
-    double factor = 1.0/ksum;
-    for (int i=0; i<ksize; i++)
-       kernel[i] *= factor;
-    const int w = I.size().x;
-    const int h = I.size().y;
-    const int swin = 2*ksize;
-
-    AlignedMem<float,16> buffer(w*(swin+1));
-    vector<float*> rows(swin+1);
-
-    for (int k=0;k<swin+1;k++)
-       rows[k] = buffer.data() + k*w;
-
-    float* output = out.data();
-    for (int i=0; i<h; i++) {
-       float* next_row = rows[swin];
-       const float* input = I[i];
-       // beginning of row
-       for (int j=0; j<ksize; j++) {
-           double hsum = input[j] * factor;
-           for (int k=0; k<ksize; k++)
-               hsum += (input[abs(j-k-1)] + input[j+k+1]) * kernel[k];
-           next_row[j] = hsum;
-       }
-       // middle of row
-       input += ksize;
-       convolveMiddle(input, factor, kernel, w-swin, next_row+ksize);
-       input += w-swin;
-       // end of row
-       for (int j=w-ksize; j<w; j++, input++) {
-           double hsum = *input * factor;
-           const int room = w-j;
-           for (int k=0; k<ksize; k++) {
-               hsum += (input[-k-1] + (k+1 >= room ? input[2*room-k-2] : 
input[k+1])) * kernel[k];
-           }
-           next_row[j] = hsum;
-       }
-       // vertical
-       if (i >= swin) {
-           convolveVertical(rows, factor, kernel, w, output);
-           output += w;
-           if (i == h-1) {
-               for (int r=0; r<ksize; r++, output += w) {
-                   vector<float*> rrows(rows.size());
-                   rrows[ksize] = rows[ksize+r+1];
-                   for (int k=0; k<ksize; ++k) {
-                       rrows[ksize-k-1] = rows[ksize+r-k];
-                       int hi = ksize+r+k+2;
-                       rrows[ksize+k+1] = rows[hi > swin ? 2*swin - hi : hi];
-                   }
-                   convolveVertical(rrows, factor, kernel, w, output);
-               }
-           }
-       } else if (i == swin-1) {
-           for (int r=0; r<ksize; r++, output += w) {
-               vector<float*> rrows(rows.size());
-               rrows[ksize] = rows[r+1];
-               for (int k=0; k<ksize; ++k) {
-                   rrows[ksize-k-1] = rows[abs(r-k-1)+1];
-                   rrows[ksize+k+1] = rows[r+k+2];
-               }
-               convolveVertical(rrows, factor, kernel, w, output);
-           }
-       }
-    
-       float* tmp = rows[0];
-       for (int r=0;r<swin; r++)
-           rows[r] = rows[r+1];
-       rows[swin] = tmp;
-    }
-}
-#endif
-
 
 };
 

Index: cvd_src/image_io.cc
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/image_io.cc,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- cvd_src/image_io.cc 29 Sep 2006 21:40:27 -0000      1.23
+++ cvd_src/image_io.cc 28 Feb 2008 00:27:22 -0000      1.24
@@ -42,7 +42,7 @@
 
 Exceptions::Image_IO::OpenError::OpenError(const string& name, const string& 
why, int error)
 {
-       what = "Opening file: " + name+ " (" + why + "): " + strerror(errno);
+       what = "Opening file: " + name+ " (" + why + "): " + strerror(error);
 }
 
 Exceptions::Image_IO::MalformedImage::MalformedImage(const string& why)

Index: cvd_src/nonmax_suppression.cxx
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/nonmax_suppression.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- cvd_src/nonmax_suppression.cxx      22 Nov 2007 00:52:00 -0000      1.5
+++ cvd_src/nonmax_suppression.cxx      28 Feb 2008 00:27:22 -0000      1.6
@@ -47,9 +47,9 @@
        int point_above = 0;
        int point_below = 0;
        
-       const unsigned int sz = corners.size(); 
+       const int sz = corners.size(); 
        
-       for(unsigned int i=0; i < sz; i++)
+       for(int i=0; i < sz; i++)
        {
                Score score = scores[i];
                ImageRef pos = corners[i];
@@ -131,7 +131,7 @@
 // The two collectors which either return just the ImageRef or the 
<ImageRef,int> pair
 struct collect_pos
 {
-       static inline ImageRef collect(const ImageRef& pos, int score){return 
pos;}
+       static inline ImageRef collect(const ImageRef& pos, int ){return pos;}
 };
 
 struct collect_score

Index: cvd_src/yuv420.cpp
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/yuv420.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- cvd_src/yuv420.cpp  7 Dec 2005 14:45:20 -0000       1.1
+++ cvd_src/yuv420.cpp  28 Feb 2008 00:27:22 -0000      1.2
@@ -1,7 +1,7 @@
-#include <cvd/config.h>
-#include <cvd/colourspace.h>
-#include <cvd/utility.h>
-#include <cvd/internal/assembly.h>
+#include "cvd/config.h"
+#include "cvd/colourspace.h"
+#include "cvd/utility.h"
+#include "cvd/internal/assembly.h"
 
 namespace CVD {
   namespace ColourSpace {
@@ -42,11 +42,18 @@
       }
     }
 
+#if CVD_INTERNAL_HAVE_YUV420P_MMX
+    extern "C"{
+       void cvd_asm_yuv420p_to_rgb(const unsigned char*, unsigned char*, int);
+    }
+
+#endif
+
     void yuv420p_to_rgb(const unsigned char* y, const unsigned char* u, const 
unsigned char* v, unsigned char* rgb, unsigned int width, unsigned int height) {
-#if defined(CVD_HAVE_MMXEXT) && defined(CVD_HAVE_CPU_i686)
+#if CVD_INTERNAL_HAVE_YUV420P_MMX
       if (is_aligned<8>(y) && (u == y + width*height) && is_aligned<8>(u) && 
(v == u + width*height/4) && is_aligned<8>(v) &&
          is_aligned<8>(rgb) && ((width&4) == 0) && ((height&1)==0))
-       Internal::Assembly::yuv420p_to_rgb(y,rgb,width,height);
+       cvd_asm_yuv420p_to_rgb(y,rgb,width,height);
       else
        yuv420p_to_rgb_c(y, u, v, rgb, width, height);
 #else
@@ -54,7 +61,7 @@
 #endif
     }    
     
-    void yuv420p_to_grey(const unsigned char* y, const unsigned char* u, const 
unsigned char* v, 
+    void yuv420p_to_grey(const unsigned char* y, const unsigned char*, const 
unsigned char*, 
                         unsigned char* grey, unsigned int width, unsigned int 
height)
     {
       memcpy(grey, y, width*height);

Index: cvd_src/yuv422.cpp
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/yuv422.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- cvd_src/yuv422.cpp  27 Dec 2005 10:23:13 -0000      1.2
+++ cvd_src/yuv422.cpp  28 Feb 2008 00:27:22 -0000      1.3
@@ -1,12 +1,11 @@
-#include <cvd/config.h>
-#include <cvd/internal/assembly.h>
-#include <cvd/utility.h>
-#include <cvd/colourspace.h>
+#include "cvd/utility.h"
+#include "cvd/colourspace.h"
+#include "cvd_src/yuv422.h"
 
 namespace CVD {
   namespace ColourSpace {
     
-    inline void yuv422_to_rgb_c(const unsigned char* yuv, unsigned char* rgb, 
unsigned int total)
+       void yuv422_to_rgb_c(const unsigned char* yuv, unsigned char* rgb, 
unsigned int total)
     {
       int yy, uu, vv, ug_plus_vg, ub, vr;
       int r,g,b;
@@ -37,24 +36,7 @@
       }
     }
 
-    void yuv422_to_rgb(const unsigned char* yuv, unsigned char* rgb, unsigned 
int width, unsigned int height) {
-#if defined(CVD_HAVE_MMXEXT) && defined(CVD_HAVE_CPU_i686)
-      if (is_aligned<8>(yuv) && is_aligned<8>(rgb)) {
-       Internal::Assembly::yuv422_to_rgb(yuv,rgb,width*height);
-       int remaining = (width*height)&7;
-       if (remaining) {
-         int done = (width*height) & (~0x7);
-         yuv422_to_rgb_c(yuv+done*2, rgb+done*3, remaining);     
-       }         
-      }
-      else
-       yuv422_to_rgb_c(yuv, rgb, width*height);
-#else
-      yuv422_to_rgb_c(yuv, rgb, width*height);
-#endif
-    }    
-   
-    inline void yuv422_to_grey_c(const unsigned char* yuv, unsigned char* 
grey, unsigned int total)
+       void yuv422_to_grey_c(const unsigned char* yuv, unsigned char* grey, 
unsigned int total)
     {
       total/=2;
       while (total--) {
@@ -65,23 +47,6 @@
       }
     }
 
-    void yuv422_to_grey(const unsigned char* yuv, unsigned char* grey, 
unsigned int width, unsigned int height) {
-#if defined(CVD_HAVE_MMXEXT) && defined(CVD_HAVE_CPU_i686)
-      if (is_aligned<8>(yuv) && is_aligned<8>(grey)) {
-       Internal::Assembly::yuv422_to_grey(yuv,grey,width*height);
-       int remaining = (width*height)&7;
-       if (remaining) {
-         int done = (width*height) & (~0x7);
-         yuv422_to_grey_c(yuv+done*2, grey+done, remaining);
-       }         
-      }
-      else
-       yuv422_to_grey_c(yuv, grey, width*height);
-#else
-      yuv422_to_grey_c(yuv, grey, width*height);
-#endif
-    }    
-
        void vuy422_to_rgb(const unsigned char* yuv, unsigned char* rgb, 
unsigned int width, unsigned int height)
        {
                int yy, uu, vv, ug_plus_vg, ub, vr;

Index: cvd_src/i686/halfsample.s
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/i686/halfsample.s,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- cvd_src/i686/halfsample.s   31 May 2005 13:41:06 -0000      1.1
+++ cvd_src/i686/halfsample.s   28 Feb 2008 00:27:23 -0000      1.2
@@ -20,9 +20,9 @@
 */
 
        .text
-.globl halfsample
-       .type   halfsample, @function
-halfsample:
+.globl cvd_asm_halfsample_mmx
+       .type   cvd_asm_halfsample_mmx, @function
+cvd_asm_halfsample_mmx:
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %ebx
@@ -79,4 +79,4 @@
        popl    %ebx
        popl    %ebp
        ret
-       .size   halfsample, .-halfsample
+       .size   cvd_asm_halfsample_mmx, .-cvd_asm_halfsample_mmx

Index: cvd_src/i686/rgb_to_gray.s
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/i686/rgb_to_gray.s,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- cvd_src/i686/rgb_to_gray.s  12 Dec 2005 18:23:50 -0000      1.1
+++ cvd_src/i686/rgb_to_gray.s  28 Feb 2008 00:27:23 -0000      1.2
@@ -1,7 +1,7 @@
        .text
-.globl rgb_to_gray
-       .type   rgb_to_gray, @function
-rgb_to_gray:
+.globl cvd_asm_rgb_to_gray
+       .type   cvd_asm_rgb_to_gray, @function
+cvd_asm_rgb_to_gray:
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %eax
@@ -90,4 +90,4 @@
        popl    %eax
        popl    %ebp
        ret
-       .size   rgb_to_gray, .-rgb_to_gray
+       .size   cvd_asm_rgb_to_gray, .-cvd_asm_rgb_to_gray

Index: cvd_src/i686/yuv420p_to_rgb.s
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/i686/yuv420p_to_rgb.s,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- cvd_src/i686/yuv420p_to_rgb.s       7 Dec 2005 14:45:20 -0000       1.1
+++ cvd_src/i686/yuv420p_to_rgb.s       28 Feb 2008 00:27:23 -0000      1.2
@@ -1,9 +1,9 @@
        .section        .rodata
        .align 8
        .text
-.globl yuv420p_to_rgb
-       .type   yuv420p_to_rgb, @function
-yuv420p_to_rgb:
+.globl cvd_asm_yuv420p_to_rgb
+       .type   cvd_asm_yuv420p_to_rgb, @function
+cvd_asm_yuv420p_to_rgb:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $12, %esp
@@ -149,4 +149,4 @@
        addl    $12, %esp
        popl    %ebp
        ret
-       .size   yuv420p_to_rgb, .-yuv420p_to_rgb
+       .size   cvd_asm_yuv420p_to_rgb, .-cvd_asm_yuv420p_to_rgb

Index: cvd_src/i686/yuv422_to_grey.s
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/i686/yuv422_to_grey.s,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- cvd_src/i686/yuv422_to_grey.s       7 Dec 2005 14:45:20 -0000       1.1
+++ cvd_src/i686/yuv422_to_grey.s       28 Feb 2008 00:27:23 -0000      1.2
@@ -1,9 +1,9 @@
        .section        .rodata
        .align 8
        .text
-.globl yuv422_to_grey
-       .type   yuv422_to_grey, @function
-yuv422_to_grey:
+.globl cvd_asm_yuv422_to_grey
+       .type   cvd_asm_yuv422_to_grey, @function
+cvd_asm_yuv422_to_grey:
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %eax
@@ -48,4 +48,4 @@
        popl    %eax
        popl    %ebp
        ret
-       .size   yuv422_to_grey, .-yuv422_to_grey
+       .size   cvd_asm_yuv422_to_grey, .-cvd_asm_yuv422_to_grey

Index: cvd_src/i686/yuv422_to_rgb.s
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/i686/yuv422_to_rgb.s,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- cvd_src/i686/yuv422_to_rgb.s        7 Dec 2005 14:45:20 -0000       1.1
+++ cvd_src/i686/yuv422_to_rgb.s        28 Feb 2008 00:27:23 -0000      1.2
@@ -1,7 +1,7 @@
        .text
-.globl yuv422_to_rgb
-       .type   yuv422_to_rgb, @function
-yuv422_to_rgb: 
+.globl cvd_asm_yuv422_to_rgb
+       .type   cvd_asm_yuv422_to_rgb, @function
+cvd_asm_yuv422_to_rgb: 
        pushl   %ebp
        movl    %esp, %ebp
        subl    $16, %esp
@@ -137,4 +137,4 @@
        emms
        leave
        ret
-       .size   yuv422_to_rgb, .-yuv422_to_rgb
+       .size   cvd_asm_yuv422_to_rgb, .-cvd_asm_yuv422_to_rgb

Index: make/march_flags
===================================================================
RCS file: /cvsroot/libcvd/libcvd/make/march_flags,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- make/march_flags    28 Nov 2006 16:55:30 -0000      1.7
+++ make/march_flags    28 Feb 2008 00:27:24 -0000      1.8
@@ -9,4 +9,6 @@
 opteron_64 opteron k8 i686 
 athlon64_64 k8 i686
 athlon athlon i686
+i686 i686
 sparc ultrasparc3 ultrasparc
+

Index: cvd_src/half_sample.cc
===================================================================
RCS file: cvd_src/half_sample.cc
diff -N cvd_src/half_sample.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/half_sample.cc      28 Feb 2008 00:27:22 -0000      1.1
@@ -0,0 +1,78 @@
+#include "cvd/vision.h"
+#include "cvd/config.h"
+
+#ifdef CVD_INTERNAL_HAVE_HALFSAMPLE_SSE16
+#include <emmintrin.h>
+#endif
+
+
+namespace CVD
+{
+       namespace Internal{
+                               
+               #if CVD_INTERNAL_HAVE_HALFSAMPLE_MMX8
+                       extern "C" {
+                               void cvd_asm_halfsample_mmx(const unsigned 
char*, unsigned char*, int, int);
+                       }
+               #endif
+
+               #ifdef CVD_INTERNAL_HAVE_HALFSAMPLE_SSE16
+               void halfSampleSSE2(const byte* in, byte* out, int w, int h) 
+               {
+                       const unsigned long long mask[2] = 
{0x00FF00FF00FF00FFull, 0x00FF00FF00FF00FFull};
+                       //byte test[16];
+                       const byte* nextRow = in + w;
+                       __m128i m = _mm_loadu_si128((const __m128i*)mask);
+                       int sw = w >> 4;
+                       int sh = h >> 1;
+
+                       for (int i=0; i<sh; i++) 
+                       {
+                               for (int j=0; j<sw; j++) 
+                               {
+                                       __m128i here = _mm_load_si128((const 
__m128i*)in);
+                                       __m128i next = _mm_load_si128((const 
__m128i*)nextRow);
+                                       here = _mm_avg_epu8(here,next);
+                                       next = 
_mm_and_si128(_mm_srli_si128(here,1), m);
+                                       here = _mm_and_si128(here,m);
+                                       here = _mm_avg_epu16(here, next);
+                                       _mm_storel_epi64((__m128i*)out, 
_mm_packus_epi16(here,here));
+                                       in += 16;
+                                       nextRow += 16;
+                                       out += 8;
+                               }
+
+                               in += w;
+                               nextRow += w;
+                       }
+               }
+               #endif
+
+
+       }
+
+       void halfSample(const BasicImage<byte>& in, BasicImage<byte>& out)
+       {   
+               if( (in.size()/2) != out.size())
+                       throw 
Exceptions::Vision::IncompatibleImageSizes("halfSample");
+
+               #if CVD_INTERNAL_HAVE_HALFSAMPLE_SSE16
+                       if (is_aligned<16>(in.data()) && 
is_aligned<16>(out.data()) && ((in.size().x % 16) == 0))
+                       {
+                               Internal::halfSampleSSE2(in.data(), out.data(), 
in.size().x, in.size().y);
+                               return;
+                       }
+               #endif
+
+               #ifdef CVD_INTERNAL_HAVE_HALFSAMPLE_MMX8
+               if (is_aligned<8>(in.data()) && is_aligned<8>(out.data()) && 
(in.size().x % 8 == 0))
+               {
+                       Internal::cvd_asm_halfsample_mmx(in.data(), out.data(), 
in.size().x, in.size().y);
+                       return;
+               }
+
+               #endif
+
+               halfSample<byte>(in, out);
+       }
+}

Index: cvd_src/utility_helpers.h
===================================================================
RCS file: cvd_src/utility_helpers.h
diff -N cvd_src/utility_helpers.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/utility_helpers.h   28 Feb 2008 00:27:22 -0000      1.1
@@ -0,0 +1,178 @@
+#ifndef CVD_INCLUDE_UTILITY_HELPERS_H
+#define CVD_INCLUDE_UTILITY_HELPERS_H
+
+#include "cvd/utility.h"
+#include <xmmintrin.h>
+using namespace std;
+
+namespace CVD{
+    template <class F, class T1, class T2, int A, int M> inline void 
maybe_aligned_differences(const T1* a, const T1* b, T2* c, unsigned int count)
+    {
+       if (count < M*2) {
+           F::unaligned_differences(a,b,c,count);
+           return;
+       }
+       if (!is_aligned<A>(a)) {            
+           unsigned int steps = steps_to_align<A>(a);
+           F::unaligned_differences(a,b,c,steps);
+           count -= steps;
+           a += steps;
+           b += steps;
+           c += steps;
+       }
+       if (!is_aligned<A>(c) || count < M) {
+           F::unaligned_differences(a,b,c,count);
+           return;
+       }       
+       unsigned int block = (count/M)*M;
+       F::aligned_differences(a,b,c,block);
+       if (count > block) {
+           F::unaligned_differences(a+block,b+block,c+block,count-block);
+       }
+    }    
+    
+    template <class F, class T1, class T2, int A, int M> inline void 
maybe_aligned_add_mul_add(const T1* a, const T1* b, const T1& c, T2* out, 
unsigned int count)
+    {
+       if (count < M*2) {
+           F::unaligned_add_mul_add(a,b,c,out,count);
+           return;
+       }
+       if (!is_aligned<A>(a)) {      
+           unsigned int steps = steps_to_align<A>(a);
+           F::unaligned_add_mul_add(a,b,c,out,steps);
+           count -= steps;
+           a += steps;
+           b += steps;
+           out += steps;
+           if (count < M || !is_aligned<16>(out)) {
+               F::unaligned_add_mul_add(a,b,c,out,count);
+               return;
+           }
+       }
+       else if (count < M || !is_aligned<16>(out)) {
+           F::unaligned_add_mul_add(a,b,c,out,count);
+           return;
+       }
+       unsigned int block = (count/M)*M;
+       F::aligned_add_mul_add(a,b,c,out,block);
+       if (count > block)
+           F::unaligned_add_mul_add(a+block,b+block,c, out+block,count-block);
+    }    
+
+    template <class F, class T1, class T2, int A, int M> inline void 
maybe_aligned_assign_mul(const T1* a, const T1& c, T2* out, unsigned int count)
+    {
+       if (count < M*2) {
+           F::unaligned_assign_mul(a,c,out,count);
+           return;
+       }
+       if (!is_aligned<A>(a)) {      
+           unsigned int steps = steps_to_align<A>(a);
+           F::unaligned_assign_mul(a,c,out,steps);
+           count -= steps;
+           a += steps;
+           out += steps;
+           if (count < M) {
+               F::unaligned_assign_mul(a,c,out,count);
+               return;
+           }
+       }
+       unsigned int block = (count/M)*M;
+       F::aligned_assign_mul(a,c,out,block);
+       if (count > block) {
+           F::unaligned_assign_mul(a+block,c, out+block,count-block);
+       }
+    }    
+
+    template <class F, class R, class T1, int A, int M> inline R 
maybe_aligned_inner_product(const T1* a, const T1* b, unsigned int count)
+    {
+       if (count < M*2) {
+           return F::unaligned_inner_product(a,b,count);
+       }
+       R sum = 0;
+       if (!is_aligned<A>(a)) {      
+           unsigned int steps = steps_to_align<A>(a);
+           sum = F::unaligned_inner_product(a,b,steps);
+           count -= steps;
+           a += steps;
+           b += steps;
+           if (count < M) {
+               return sum + F::unaligned_inner_product(a,b,count);
+           }
+       }
+       unsigned int block = (count/M)*M;
+       sum += F::aligned_inner_product(a,b,block);
+       if (count > block)
+           sum += F::unaligned_inner_product(a+block,b+block,count-block);
+       return sum;
+    }    
+
+    template <class F, class R, class T1, int A, int M> inline R 
maybe_aligned_ssd(const T1* a, const T1* b, unsigned int count)
+    {
+       if (count < M*2) {
+           return F::unaligned_ssd(a,b,count);
+       }
+       R sum = 0;
+       if (!is_aligned<A>(a)) {      
+           unsigned int steps = steps_to_align<A>(a);
+           sum = F::unaligned_ssd(a,b,steps);
+           count -= steps;
+           a += steps;
+           b += steps;
+           if (count < M) {
+               return sum + F::unaligned_ssd(a,b,count);
+           }
+       }
+       unsigned int block = (count/M)*M;
+       sum += F::aligned_ssd(a,b,block);
+       if (count > block)
+           sum += F::unaligned_ssd(a+block,b+block,count-block);
+       return sum;
+    }    
+
+template <class F, class T1, class T2, int A, int M> inline void 
maybe_aligned_square(const T1* in, T2* out, size_t count)
+{
+    if (count < M*2) {
+       return F::unaligned_square(in,out,count);
+    }
+    if (!is_aligned<A>(in)) {
+       unsigned int steps = steps_to_align<A>(in);
+       F::unaligned_square(in,out,steps);
+       count -= steps;
+       in += steps;
+       out += steps;
+       if (count < M) {
+           F::unaligned_square(in,out,count);
+       }
+    }
+    size_t block = (count/M)*M;
+    F::aligned_square(in,out,block);
+    if (count > block)
+       F::unaligned_square(in+block,out+block,count-block);
+}    
+
+template <class F, class T1, class T2, int A, int M> inline void 
maybe_aligned_subtract_square(const T1* in, T2* out, size_t count)
+{
+    if (count < M*2) {
+       return F::unaligned_subtract_square(in,out,count);
+    }
+    if (!is_aligned<A>(in)) {
+       unsigned int steps = steps_to_align<A>(in);
+       F::unaligned_subtract_square(in,out,steps);
+       count -= steps;
+       in += steps;
+       out += steps;
+       if (count < M) {
+           F::unaligned_subtract_square(in,out,count);
+       }
+    }
+    size_t block = (count/M)*M;
+    F::aligned_subtract_square(in,out,block);
+    if (count > block)
+       F::unaligned_subtract_square(in+block,out+block,count-block);
+}    
+
+
+
+}
+
+#endif

Index: cvd_src/yuv422.h
===================================================================
RCS file: cvd_src/yuv422.h
diff -N cvd_src/yuv422.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/yuv422.h    28 Feb 2008 00:27:23 -0000      1.1
@@ -0,0 +1,14 @@
+#ifndef CVD_SRC_YUV_422_H
+#define CVD_SRC_YUV_422_H
+namespace CVD {
+namespace ColourSpace {
+    
+       void yuv422_to_grey(const unsigned char* yuv, unsigned char* grey, 
unsigned int width, unsigned int height);
+       void yuv422_to_rgb(const unsigned char* yuv, unsigned char* rgb, 
unsigned int width, unsigned int height);
+
+       void yuv422_to_rgb_c(const unsigned char* yuv, unsigned char* rgb, 
unsigned int n);
+       void yuv422_to_grey_c(const unsigned char* yuv, unsigned char* grey, 
unsigned int n);
+}
+}
+#endif
+

Index: cvd_src/i686/convert_rgb_to_y.cc
===================================================================
RCS file: cvd_src/i686/convert_rgb_to_y.cc
diff -N cvd_src/i686/convert_rgb_to_y.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/i686/convert_rgb_to_y.cc    28 Feb 2008 00:27:23 -0000      1.1
@@ -0,0 +1,36 @@
+#include "cvd/config.h"
+#include "cvd/image_convert.h"
+#include "cvd/utility.h"
+
+namespace CVD 
+{
+       namespace Internal
+       {
+               extern "C"{
+                       void cvd_asm_rgb_to_gray(const unsigned char* in, 
unsigned char* out, int size, int wr, int wg, int wb);
+               }
+       }
+
+    void ConvertImage<Rgb<byte>, byte, Pixel::CIE<Rgb<byte>, byte>, 
1>::convert(const BasicImage<Rgb<byte> >& from, BasicImage<byte>& to) 
+       {
+               const Rgb<byte>* rgb = from.data();
+               byte* gray = to.data();
+               int count=0;
+
+               while (!is_aligned<16>(rgb) || !is_aligned<16>(gray)) 
+               {
+                       Pixel::CIE<Rgb<byte>,byte>::convert(*rgb, *gray);
+                       rgb++;
+                       gray++;
+                       count++;
+               }
+
+               if (count < from.totalsize())
+                       Internal::cvd_asm_rgb_to_gray((const byte*)rgb, gray, 
(from.totalsize()-count)&3, 77, 150, 29);
+
+               count = (count + from.totalsize()) & 3;
+
+               for(;count < from.totalsize(); count ++)
+                       Pixel::CIE<Rgb<byte>,byte>::convert(from.data()[count], 
to.data()[count]);
+    }
+}

Index: cvd_src/i686/convolve_gaussian.cc
===================================================================
RCS file: cvd_src/i686/convolve_gaussian.cc
diff -N cvd_src/i686/convolve_gaussian.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/i686/convolve_gaussian.cc   28 Feb 2008 00:27:23 -0000      1.1
@@ -0,0 +1,187 @@
+#include <cvd/convolution.h>
+#include <xmmintrin.h>
+
+using namespace std;
+
+namespace CVD {
+
+inline void convolveMiddle5(const float* in, double factor, const double 
kernel[], int count, float* out)
+{
+    int i;
+    const __m128 ffff = _mm_set1_ps(factor);
+    const __m128 k1 = _mm_set1_ps(kernel[0]);
+    const __m128 k2 = _mm_set1_ps(kernel[1]);
+    for (i=0; i+3<count; i+=4, in += 4, out += 4) {
+       __m128 sum = (_mm_mul_ps(_mm_loadu_ps(in), ffff) + 
+                     _mm_mul_ps(k1, (_mm_loadu_ps(in-1) + _mm_loadu_ps(in+1))) 
+ 
+                     _mm_mul_ps(k2, (_mm_loadu_ps(in-2) + 
_mm_loadu_ps(in+2))));
+       _mm_storeu_ps(out, sum);
+    }
+
+    for (; i<count; ++i, ++in, ++out) {
+       double sum = in[0] * factor + kernel[0] * (in[-1] + in[1]) + kernel[1] 
* (in[-2] * in[2]);
+       *out = sum;
+    }
+}
+
+inline void convolveMiddle(const float* in, double factor, const 
vector<double>& kernel, int count, float* out)
+{
+    const int ksize = kernel.size();
+    if (ksize == 2) {
+       convolveMiddle5(in, factor, &kernel[0], count, out);
+       return;
+    }
+    int i;
+    const __m128 ffff = _mm_set1_ps(factor);
+    for (i=0; i+3<count; i+=4, in += 4, out += 4) {
+       __m128 sum = _mm_mul_ps(_mm_loadu_ps(in), ffff);
+       for (int k=1; k<=ksize; ++k)
+           sum += _mm_set1_ps(kernel[k-1]) * (_mm_loadu_ps(in-k) + 
_mm_loadu_ps(in+k));
+       _mm_storeu_ps(out, sum);
+    }
+
+    for (; i<count; ++i, ++in, ++out) {
+       double sum = in[0] * factor;
+       for (int k=1; k<=ksize; ++k)
+           sum += kernel[k-1] * (in[-k] + in[k]);
+       *out = sum;
+    }
+}
+
+inline void convolveVertical5(const vector<float*> row, double factor, double 
kernel[], int count, float* out)
+{
+    const int ksize = 2;
+    int i;
+    for (i=0; i<count && !is_aligned<16>(row[0] + i); ++i, ++out) {
+       double sum = row[ksize][i] * factor + (row[1][i] + row[3][i]) * 
kernel[0] + (row[0][i] + row[4][i]) * kernel[1];
+       *out = sum;
+    }
+
+    const __m128 ffff = _mm_set1_ps(factor);
+    const __m128 k1 = _mm_set1_ps(kernel[0]);
+    const __m128 k2 = _mm_set1_ps(kernel[1]);
+
+    for (; i+3<count; i+=4) {
+       __m128 sum = (_mm_load_ps(row[ksize] + i) * ffff
+                     + (_mm_load_ps(row[ksize-1]+i) + 
_mm_load_ps(row[ksize+1]+i)) * k1
+                     + (_mm_load_ps(row[ksize-2]+i) + 
_mm_load_ps(row[ksize+2]+i)) * k2);
+       _mm_store_ps(out + i, sum);
+    }    
+    for (; i<count; ++i, ++out) {
+       double sum = row[ksize][i] * factor + (row[1][i] + row[3][i]) * 
kernel[0] + (row[0][i] + row[4][i]) * kernel[1];
+       *out = sum;
+    }
+}
+
+inline void convolveVertical(const vector<float*> row, double factor, 
vector<double>& kernel, int count, float* out)
+{
+    const int ksize = kernel.size();
+    if (ksize == 2) {
+       convolveVertical5(row, factor, &kernel[0], count, out);
+       return;
+    }
+       
+    int i;
+    for (i=0; i<count && !is_aligned<16>(row[0] + i); ++i, ++out) {
+       double sum = row[ksize][i] * factor;
+       for (int k=1; k<=ksize; ++k)
+           sum += kernel[k-1] * (row[ksize-k][i] + row[ksize+k][i]);
+       *out = sum;
+    }
+    const __m128 ffff = _mm_set1_ps(factor);
+    for (; i+3<count; i+=4) {
+       __m128 sum = _mm_mul_ps(_mm_load_ps(row[ksize] + i), ffff);
+       for (int k=1; k<=ksize; ++k)
+           sum += _mm_set1_ps(kernel[k-1]) * (_mm_load_ps(row[ksize-k]+i) + 
_mm_load_ps(row[ksize+k]+i));
+       _mm_store_ps(out + i, sum);
+    }    
+    for (; i<count; ++i, ++out) {
+       double sum = row[ksize][i] * factor;
+       for (int k=1; k<=ksize; ++k)
+           sum += kernel[k-1] * (row[ksize-k][i] + row[ksize+k][i]);
+       *out = sum;
+    }
+}
+
+void convolveGaussian(const BasicImage<float>& I, BasicImage<float>& out, 
double sigma, double sigmas)
+{
+    assert(out.size() == I.size());
+    int ksize = (int)(sigmas*sigma + 0.5);
+    vector<double> kernel(ksize);
+    double ksum = 1.0;
+    for (int i=1; i<=ksize; i++)
+       ksum += 2*(kernel[i-1] = exp(-i*i/(2*sigma*sigma)));
+    double factor = 1.0/ksum;
+    for (int i=0; i<ksize; i++)
+       kernel[i] *= factor;
+    const int w = I.size().x;
+    const int h = I.size().y;
+    const int swin = 2*ksize;
+
+    AlignedMem<float,16> buffer(w*(swin+1));
+    vector<float*> rows(swin+1);
+
+    for (int k=0;k<swin+1;k++)
+       rows[k] = buffer.data() + k*w;
+
+    float* output = out.data();
+    for (int i=0; i<h; i++) {
+       float* next_row = rows[swin];
+       const float* input = I[i];
+       // beginning of row
+       for (int j=0; j<ksize; j++) {
+           double hsum = input[j] * factor;
+           for (int k=0; k<ksize; k++)
+               hsum += (input[abs(j-k-1)] + input[j+k+1]) * kernel[k];
+           next_row[j] = hsum;
+       }
+       // middle of row
+       input += ksize;
+       convolveMiddle(input, factor, kernel, w-swin, next_row+ksize);
+       input += w-swin;
+       // end of row
+       for (int j=w-ksize; j<w; j++, input++) {
+           double hsum = *input * factor;
+           const int room = w-j;
+           for (int k=0; k<ksize; k++) {
+               hsum += (input[-k-1] + (k+1 >= room ? input[2*room-k-2] : 
input[k+1])) * kernel[k];
+           }
+           next_row[j] = hsum;
+       }
+       // vertical
+       if (i >= swin) {
+           convolveVertical(rows, factor, kernel, w, output);
+           output += w;
+           if (i == h-1) {
+               for (int r=0; r<ksize; r++, output += w) {
+                   vector<float*> rrows(rows.size());
+                   rrows[ksize] = rows[ksize+r+1];
+                   for (int k=0; k<ksize; ++k) {
+                       rrows[ksize-k-1] = rows[ksize+r-k];
+                       int hi = ksize+r+k+2;
+                       rrows[ksize+k+1] = rows[hi > swin ? 2*swin - hi : hi];
+                   }
+                   convolveVertical(rrows, factor, kernel, w, output);
+               }
+           }
+       } else if (i == swin-1) {
+           for (int r=0; r<ksize; r++, output += w) {
+               vector<float*> rrows(rows.size());
+               rrows[ksize] = rows[r+1];
+               for (int k=0; k<ksize; ++k) {
+                   rrows[ksize-k-1] = rows[abs(r-k-1)+1];
+                   rrows[ksize+k+1] = rows[r+k+2];
+               }
+               convolveVertical(rrows, factor, kernel, w, output);
+           }
+       }
+    
+       float* tmp = rows[0];
+       for (int r=0;r<swin; r++)
+           rows[r] = rows[r+1];
+       rows[swin] = tmp;
+    }
+}
+
+};
+

Index: cvd_src/i686/gradient.cc
===================================================================
RCS file: cvd_src/i686/gradient.cc
diff -N cvd_src/i686/gradient.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/i686/gradient.cc    28 Feb 2008 00:27:23 -0000      1.1
@@ -0,0 +1,80 @@
+#include "cvd/vision.h"
+#include <emmintrin.h>
+
+using namespace std;
+
+namespace CVD {
+
+    // I have to use this because gcc 3.3 has an internal bug with 
_mm_slli_epi16
+#define shift_left_7(thing) asm ( "psllw $0x7, %0  \n\t" : : "x"(thing) : "%0" 
);
+    
+    void gradient(const byte* in, short (*out)[2], int w, int h)
+    {
+        const byte zeros[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+        const byte* curr = in + w;
+        out += w;
+        int total = (w*(h-2)) >> 4;
+        __m128i zero = _mm_loadu_si128((const __m128i*)zeros);
+        while (total--) {
+            __m128i up = _mm_load_si128((const __m128i*)(curr-w));
+            __m128i down = _mm_load_si128((const __m128i*)(curr+w));           
 
+            __m128i hor_left, hor_right;
+            {
+                __m128i hor = _mm_load_si128((const __m128i*)curr);
+                hor_left = _mm_slli_si128(hor, 1);
+                hor_right = _mm_srli_si128(hor, 1);
+            }
+            {
+                __m128i left = _mm_unpacklo_epi8(hor_right, zero);
+                __m128i right = _mm_unpacklo_epi8(hor_left, zero);
+                __m128i hdiff = _mm_insert_epi16(_mm_sub_epi16(right,left), 
short(curr[1]) - short(curr[-1]), 0);
+                __m128i vdiff = _mm_sub_epi16(_mm_unpacklo_epi8(down, zero), 
_mm_unpacklo_epi8(up, zero));
+                {
+                    __m128i part1 = _mm_unpacklo_epi16(hdiff, vdiff);
+                    shift_left_7(part1);
+                    _mm_stream_si128((__m128i*)out, part1);
+                }
+                {
+                    __m128i part2 = _mm_unpackhi_epi16(hdiff, vdiff);
+                    shift_left_7(part2);
+                    _mm_stream_si128((__m128i*)(out+4), part2);
+                }
+            }
+            {
+                __m128i left = _mm_unpackhi_epi8(hor_right, zero);
+                __m128i right = _mm_unpackhi_epi8(hor_left, zero);
+                __m128i hdiff = _mm_insert_epi16(_mm_sub_epi16(right,left), 
short(curr[16]) - short(curr[14]), 7);
+                __m128i vdiff = _mm_sub_epi16(_mm_unpackhi_epi8(down, 
zero),_mm_unpackhi_epi8(up, zero));
+                {
+                    __m128i part3 = _mm_unpacklo_epi16(hdiff, vdiff);
+                    shift_left_7(part3);
+                    _mm_stream_si128((__m128i*)(out+8), part3);
+                }
+                {
+                    __m128i part4 = _mm_unpackhi_epi16(hdiff, vdiff);
+                    shift_left_7(part4);
+                    _mm_stream_si128((__m128i*)(out+12), part4);
+                }
+            }
+            curr += 16;
+            out += 16;
+        }
+        _mm_empty();
+    }
+
+    inline void gradient(const BasicImage<byte>& im, BasicImage<short[2]>& out)
+    {
+               if( im.size() != out.size())
+                       throw 
Exceptions::Vision::IncompatibleImageSizes("gradient");
+
+               if (is_aligned<16>(im.data()) && is_aligned<16>(out.data()))
+               {
+                       zeroBorders(out);
+                       gradient(im.data(), out.data(), im.size().x, 
im.size().y);
+               }
+               else
+                       gradient<byte,short[2]>(im,out);
+
+    }
+
+};

Index: cvd_src/i686/median_3x3.cc
===================================================================
RCS file: cvd_src/i686/median_3x3.cc
diff -N cvd_src/i686/median_3x3.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/i686/median_3x3.cc  28 Feb 2008 00:27:23 -0000      1.1
@@ -0,0 +1,76 @@
+#include "cvd/vision.h"
+
+#include <emmintrin.h>
+
+using namespace std;
+
+namespace CVD {
+
+#define SORT2_SIMD_UB(a,b)                     \
+    {                                          \
+       const __m128i ta = a;                   \
+       a = _mm_min_epu8(a,b);                  \
+       b = _mm_max_epu8(ta,b);                 \
+    }
+    
+#define SORT3_SIMD_UB(a,b,c)                   \
+    {                                          \
+       SORT2_SIMD_UB(a,b);                     \
+       SORT2_SIMD_UB(b,c);                     \
+       SORT2_SIMD_UB(a,b);                     \
+    }
+    
+    namespace median {
+       inline __m128i median3(__m128i a, __m128i b, __m128i c) {
+           SORT2_SIMD_UB(a,b);
+           return _mm_max_epu8(a,_mm_min_epu8(b,c));
+       }
+       
+       __m128i median_3x3_simd(const byte* p, const int w)
+       {
+           __m128i a = _mm_loadu_si128((const __m128i*)(p-w-1));
+           __m128i b = _mm_loadu_si128((const __m128i*)(p-w));
+           __m128i c = _mm_loadu_si128((const __m128i*)(p-w+1));
+           SORT3_SIMD_UB(a,b,c);
+           __m128i d = _mm_loadu_si128((const __m128i*)(p-1));
+           __m128i e = _mm_loadu_si128((const __m128i*)(p));
+           __m128i f = _mm_loadu_si128((const __m128i*)(p+1));
+           SORT3_SIMD_UB(d,e,f);
+           __m128i g = _mm_loadu_si128((const __m128i*)(p+w-1));
+           __m128i h = _mm_loadu_si128((const __m128i*)(p+w));
+           __m128i i = _mm_loadu_si128((const __m128i*)(p+w+1));
+           SORT3_SIMD_UB(g,h,i);
+           e = median3(b,e,h);
+           g = _mm_max_epu8(_mm_max_epu8(a,d), g);
+           c = _mm_min_epu8(c, _mm_min_epu8(f,i));
+           return median3(c,e,g);
+       }
+       
+       void median_filter_3x3_simd(const byte* p, const int stride, const int 
n, byte* out)
+       {
+           int j = 0;
+           for (; j+15<n; j+=16, p+=16, out += 16) {
+               _mm_storeu_si128((__m128i*)out, median_3x3_simd(p,stride));
+           }
+           if (j < n) {
+               const int left = n - j;
+               if (n >= 16 && left > 8)
+                   _mm_storeu_si128((__m128i*)(out+left-16), 
median_3x3_simd(p+left-16,stride));
+               else
+                   median_filter_3x3(p, stride, left, out);
+           }
+       }
+       
+    }
+
+    void median_filter_3x3(const SubImage<byte>& I, SubImage<byte> out)
+    {
+       assert(out.size() == I.size());
+       const int s = I.row_stride();
+       const int n = I.size().x - 2;
+       for (int i=1; i+1<I.size().y; ++i)
+           median::median_filter_3x3_simd(I[i]+1, s, n, out[i]+1);
+    }
+    
+
+};

Index: cvd_src/i686/testconf
===================================================================
RCS file: cvd_src/i686/testconf
diff -N cvd_src/i686/testconf

Index: cvd_src/i686/utility_byte_differences.cc
===================================================================
RCS file: cvd_src/i686/utility_byte_differences.cc
diff -N cvd_src/i686/utility_byte_differences.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/i686/utility_byte_differences.cc    28 Feb 2008 00:27:23 -0000      
1.1
@@ -0,0 +1,58 @@
+#include "cvd/utility.h"
+#include "cvd_src/utility_helpers.h"
+#include <mmintrin.h>
+
+namespace CVD {
+
+    void byte_to_short_differences(const __m64* a, const __m64* b, __m64* 
diff, unsigned int count)
+    {
+       __m64 z = _mm_setzero_si64();
+       for (;count; --count, ++a, ++b, diff+=2) {
+           __m64 aq = *a;
+           __m64 bq = *b;
+           __m64 alo = _mm_unpacklo_pi8(aq,z);
+           __m64 ahi = _mm_unpackhi_pi8(aq,z);
+           __m64 blo = _mm_unpacklo_pi8(bq,z);
+           __m64 bhi = _mm_unpackhi_pi8(bq,z);
+           diff[0] = _mm_sub_pi16(alo,blo);
+           diff[1] = _mm_sub_pi16(ahi,bhi);
+       }
+       _mm_empty();
+    }
+
+    void short_differences(const __m64* a, const __m64* b, __m64* diff, 
unsigned int count)
+    {
+       while (count--) {
+           *(diff++) = _mm_sub_pi16(*(a++), *(b++));
+       }
+       _mm_empty();
+    }
+
+    
+    struct MMX_funcs {
+       template <class T1, class T2> static inline void 
unaligned_differences(const T1* a, const T1* b, T2* diff, size_t count) {
+           differences<T1,T2>(a,b,diff,count);
+       }
+       static inline void aligned_differences(const byte* a, const byte* b, 
short* diff, unsigned int count) {
+           if (is_aligned<8>(b))
+               byte_to_short_differences((const __m64*)a,(const __m64*)b, 
(__m64*)diff, count>>3);
+           else
+               unaligned_differences(a,b,diff,count);
+       }
+       
+       static inline void aligned_differences(const short* a, const short* b, 
short* diff, unsigned int count) {
+           if (is_aligned<8>(b))           
+               short_differences((const __m64*)a, (const __m64*)b, 
(__m64*)diff, count>>2);
+           else
+               unaligned_differences(a,b,diff,count);
+       }
+    };
+
+    void differences(const byte* a, const byte* b, short* diff, unsigned int 
count) {
+       maybe_aligned_differences<MMX_funcs, byte, short, 8, 8>(a,b,diff,count);
+    }
+    
+    void differences(const short* a, const short* b, short* diff, unsigned int 
count) {
+       maybe_aligned_differences<MMX_funcs, short, short, 8, 
4>(a,b,diff,count);
+    }
+}

Index: cvd_src/i686/utility_double_int.cc
===================================================================
RCS file: cvd_src/i686/utility_double_int.cc
diff -N cvd_src/i686/utility_double_int.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/i686/utility_double_int.cc  28 Feb 2008 00:27:23 -0000      1.1
@@ -0,0 +1,228 @@
+#include "cvd/utility.h"
+#include "cvd_src/utility_helpers.h"
+#include <emmintrin.h>
+
+namespace CVD {
+
+
+    static inline __m128i zero_si128() { __m128i x; asm ( "pxor %0, %0  \n\t" 
: "=x"(x) ); return x; }
+    template <bool Aligned> inline __m128i load_si128(const void* addr) { 
return _mm_loadu_si128((const __m128i*)addr); }
+    template <> inline __m128i load_si128<true>(const void* addr) { return 
_mm_load_si128((const __m128i*)addr); }
+    template <bool Aligned> inline __m128d load_pd(const void* addr) { return 
_mm_loadu_pd((const double*)addr); }
+    template <> inline __m128d load_pd<true>(const void* addr) { return 
_mm_load_pd((const double*)addr); }
+
+    template <bool Aligned> inline void store_pd(__m128d m, void* addr) { 
return _mm_storeu_pd((double*)addr, m); }
+    template <> inline void store_pd<true>(__m128d m, void* addr) { return 
_mm_store_pd((double*)addr, m); }
+
+    template <bool Aligned_b> void int_differences(const __m128i* a, const 
__m128i* b, __m128i* diff, unsigned int count)
+    {
+       while (count--) {
+           *(diff++) = _mm_sub_epi32(*(a++), load_si128<Aligned_b>(b++));
+       }
+    }
+    
+    template <bool Aligned_b> void double_differences(const __m128d* a, const 
__m128d* b, __m128d* diff, unsigned int count)
+    {
+       while (count--) {
+           *(diff++) = _mm_sub_pd(*(a++), load_pd<Aligned_b>(b++));
+       }
+    }
+
+    template <bool Aligned_b> void double_add_multiple_of_sum(const __m128d* 
a, const __m128d* b, const double& c, __m128d* out, unsigned int count)
+    {
+       __m128d cc = _mm_set1_pd(c);
+       while (count--) {
+           *out = _mm_add_pd(_mm_mul_pd(_mm_add_pd(*(a++), 
load_pd<Aligned_b>(b++)), cc), *out);
+           ++out;
+       }
+    }
+
+    template <bool Aligned_out> void double_assign_multiple(const __m128d* a, 
const double& c, __m128d* out, unsigned int count)
+    {
+       __m128d cc = _mm_set1_pd(c);
+       while (count--)
+           store_pd<Aligned_out>(_mm_mul_pd(*(a++), cc), out++);
+    }
+    template <bool Aligned_b> double double_inner_product(const __m128d* a, 
const __m128d* b, unsigned int count)
+    {
+       double sums_store[2];
+       const unsigned int BLOCK = 1<<16;
+       double dot = 0;
+       while (count) {
+           size_t pass = std::min(count, BLOCK);
+           count-=pass;
+           __m128d sums = _mm_setzero_pd();
+           while (pass--) {
+               __m128d prod = _mm_mul_pd(*(a++), load_pd<Aligned_b>(b++));
+               sums = _mm_add_pd(prod, sums);
+           }
+           _mm_storeu_pd(sums_store, sums);
+           dot += sums_store[0] + sums_store[1];
+       }
+       return dot;
+    }
+
+    template <bool Aligned_b> long long byte_sum_squared_differences(const 
__m128i* a, const __m128i* b, unsigned int count) {
+       unsigned long sums_store[4];    
+       const unsigned int BLOCK = 1<<15;
+       long long ssd = 0;
+       while (count) {
+           size_t pass = std::min(count, BLOCK);
+           count -= pass;
+           __m128i sums = _mm_setzero_si128();
+           while (pass--) {
+               __m128i lo_a = load_si128<true>(a++);
+               __m128i lo_b = load_si128<Aligned_b>(b++);
+               __m128i hi_a = _mm_unpackhi_epi8(lo_a, sums);
+               __m128i hi_b = _mm_unpackhi_epi8(lo_b, sums);
+               lo_a = _mm_unpacklo_epi8(lo_a, sums);
+               lo_b = _mm_unpacklo_epi8(lo_b, sums);
+               lo_a = _mm_sub_epi16(lo_a, lo_b);
+               hi_a = _mm_sub_epi16(hi_a, hi_b);
+               lo_a = _mm_madd_epi16(lo_a,lo_a);
+               hi_a = _mm_madd_epi16(hi_a,hi_a);
+               sums = _mm_add_epi32(_mm_add_epi32(lo_a, hi_a), sums);
+           }
+           _mm_storeu_si128((__m128i*)sums_store, sums);
+           ssd += sums_store[0] + sums_store[1] + sums_store[2] + 
sums_store[3];
+       }
+       return ssd;
+    }
+
+    template <bool Aligned_b> inline double 
double_sum_squared_differences(const __m128d* a, const __m128d* b, unsigned int 
count) 
+    {
+       double sums_store[2];
+       const unsigned int BLOCK = 1<<10;
+       double ssd = 0;
+       while (count) {
+           size_t pass = std::min(count, BLOCK);
+           count-=pass;
+           __m128d sums = _mm_setzero_pd();
+           while (pass--) {
+               __m128d diff = _mm_sub_pd(*(a++), load_pd<Aligned_b>(b++));
+               sums = _mm_add_pd(_mm_mul_pd(diff,diff), sums);
+           }
+           _mm_storeu_pd(sums_store, sums);
+           ssd += sums_store[0] + sums_store[1];
+       }
+       return ssd;
+    }
+
+    
+    struct SSE2_funcs {
+       template <class T1, class T2> static inline void 
unaligned_differences(const T1* a, const T1* b, T2* diff, size_t count) {
+           differences<T1,T2>(a,b,diff,count);
+       }
+
+       static inline void aligned_differences(const int32_t* a, const int32_t* 
b, int32_t* diff, unsigned int count) {
+           if (is_aligned<16>(b))
+               int_differences<true>((const __m128i*)a, (const __m128i*)b, 
(__m128i*)diff, count>>2);
+           else
+               int_differences<false>((const __m128i*)a, (const __m128i*)b, 
(__m128i*)diff, count>>2);
+       }
+
+       static inline void aligned_differences(const double* a, const double* 
b, double* diff, unsigned int count)
+       {
+           if (is_aligned<16>(b))
+               double_differences<true>((const __m128d*)a,(const 
__m128d*)b,(__m128d*)diff,count>>1);
+           else
+               double_differences<false>((const __m128d*)a,(const 
__m128d*)b,(__m128d*)diff,count>>1);
+       }
+
+       template <class T1, class T2> static inline void 
unaligned_add_mul_add(const T1* a, const T1* b, const T1& c, T2* out, size_t 
count) {
+           add_multiple_of_sum<T1,T2>(a,b,c,out,count);
+       }
+       
+       static inline void aligned_add_mul_add(const double* a, const double* 
b, const double& c, double* out, unsigned int count)
+       {
+           if (is_aligned<16>(b))
+               double_add_multiple_of_sum<true>((const __m128d*)a, (const 
__m128d*)b, c, (__m128d*)out, count>>1);
+           else
+               double_add_multiple_of_sum<false>((const __m128d*)a, (const 
__m128d*)b, c, (__m128d*)out, count>>1);
+       }
+       
+       template <class T1, class T2> static inline void 
unaligned_assign_mul(const T1* a, const T1& c, T2* out, size_t count) {
+           assign_multiple<T1,T2>(a,c,out,count);
+       }
+
+       static inline void aligned_assign_mul(const double* a, const double& c, 
double* out, unsigned int count)
+       {
+           if (is_aligned<16>(out))
+               double_assign_multiple<true>((const __m128d*)a, c, 
(__m128d*)out, count>>1);
+           else
+               double_assign_multiple<false>((const __m128d*)a, c, 
(__m128d*)out, count>>1);
+       }
+       
+       template <class T1> static inline double unaligned_inner_product(const 
T1* a, const T1* b, size_t count) {
+           return inner_product<T1>(a,b,count);
+       }
+       
+       static inline double aligned_inner_product(const double* a, const 
double* b, unsigned int count)
+       {
+           if (is_aligned<16>(b))
+               return double_inner_product<true>((const __m128d*) a, (const 
__m128d*) b, count>>1);
+           else
+               return double_inner_product<false>((const __m128d*) a, (const 
__m128d*) b, count>>1);
+       }
+
+       template <class T1> static inline double unaligned_ssd(const T1* a, 
const T1* b, size_t count) {
+           return sum_squared_differences<T1>(a,b,count);
+       }
+       
+       static inline long long unaligned_ssd(const byte* a, const byte* b, 
size_t count) {
+           return SumSquaredDifferences<long long, int, 
byte>::sum_squared_differences(a,b,count);
+       }
+
+       static inline double aligned_ssd(const double* a, const double* b, 
size_t count) 
+       {
+           if (is_aligned<16>(b))
+               return double_sum_squared_differences<true>((const __m128d*)a, 
(const __m128d*)b, count>>1);
+           else
+               return double_sum_squared_differences<false>((const __m128d*)a, 
(const __m128d*)b, count>>1);
+       }
+
+       static inline long long aligned_ssd(const byte* a, const byte* b, 
size_t count) 
+       {
+           if (is_aligned<16>(b)) 
+               return byte_sum_squared_differences<true>((const __m128i*)a, 
(const __m128i*)b, count>>4);
+           else
+               return byte_sum_squared_differences<false>((const __m128i*)a, 
(const __m128i*)b, count>>4);
+       }       
+    };
+
+    void differences(const int32_t* a, const int32_t* b, int32_t* diff, 
unsigned int size)
+    {
+       maybe_aligned_differences<SSE2_funcs, int32_t, int32_t, 16, 
4>(a,b,diff,size);
+    }
+
+    void differences(const double* a, const double* b, double* diff, unsigned 
int size)
+    {
+       maybe_aligned_differences<SSE2_funcs, double, double, 16, 
2>(a,b,diff,size);
+    }
+
+    void add_multiple_of_sum(const double* a, const double* b, const double& 
c,  double* out, unsigned int count)
+    {
+       maybe_aligned_add_mul_add<SSE2_funcs, double, double, 16, 
2>(a,b,c,out,count);
+    }
+
+    void assign_multiple(const double* a, const double& c,  double* out, 
unsigned int count)
+    {
+       maybe_aligned_assign_mul<SSE2_funcs, double, double, 16, 
2>(a,c,out,count);
+    }
+
+    double inner_product(const double* a, const double* b, unsigned int count)
+    {
+       return maybe_aligned_inner_product<SSE2_funcs, double, double, 16, 
2>(a,b,count);
+    }
+
+    double sum_squared_differences(const double* a, const double* b, size_t 
count)
+    {
+       return maybe_aligned_ssd<SSE2_funcs, double, double, 16, 2>(a,b,count);
+    }
+
+    long long sum_squared_differences(const byte* a, const byte* b, size_t 
count)
+    {
+       return maybe_aligned_ssd<SSE2_funcs, long long, byte, 16, 
16>(a,b,count); 
+    }
+    
+}

Index: cvd_src/i686/utility_float.cc
===================================================================
RCS file: cvd_src/i686/utility_float.cc
diff -N cvd_src/i686/utility_float.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/i686/utility_float.cc       28 Feb 2008 00:27:23 -0000      1.1
@@ -0,0 +1,220 @@
+#include "cvd/utility.h"
+#include "cvd_src/utility_helpers.h"
+
+
+#include <xmmintrin.h>
+
+
+using namespace std;
+
+namespace CVD {
+
+       //Some versions of gcc do not define _mm_load?_ps as taking a const 
float*
+       //Later versions always use the const.
+    template <bool Aligned> inline __m128 load_ps(const void* addr) { return 
_mm_loadu_ps(static_cast<float*>(const_cast<void*>(addr))); }
+    template <> inline __m128 load_ps<true>(const void* addr) { return 
_mm_load_ps(static_cast<float*>(const_cast<void*>(addr))); }
+
+    template <bool Aligned> inline void store_ps(__m128 m, void* addr) { 
return _mm_storeu_ps((float*)addr, m); }
+    template <> inline void store_ps<true>(__m128 m, void* addr) { return 
_mm_store_ps((float*)addr, m); }
+
+    template <bool Aligned_b> void float_differences(const __m128* a, const 
__m128* b, __m128* diff, unsigned int count)
+    {
+       while (count--) {
+           _mm_stream_ps((float*)diff, _mm_sub_ps(load_ps<true>(a), 
load_ps<Aligned_b>(b)));
+           ++diff;
+           ++a;
+           ++b;
+       }
+    }
+    
+    template <bool Aligned_b> void float_add_multiple_of_sum(const __m128* a, 
const __m128* b, const float& c, __m128* out, unsigned int count)
+    {
+       __m128 cccc = _mm_set1_ps(c);
+       while (count--) {
+           *out = _mm_add_ps(_mm_mul_ps(_mm_add_ps(load_ps<true>(a), 
load_ps<Aligned_b>(b)), cccc), *out);
+           ++out;
+           ++a;
+           ++b;
+       }
+    }
+
+    template <bool Aligned_out> inline void float_assign_multiple(const 
__m128* a, const float& c, __m128* out, unsigned int count)
+    {
+       const __m128 cccc = _mm_set1_ps(c);
+       while (count--)
+           store_ps<Aligned_out>(_mm_mul_ps(*(a++), cccc), out++);
+       
+    }
+    
+    template <bool Aligned_b> double float_inner_product(const __m128* a, 
const __m128* b, unsigned int count)
+    {
+       float sums_store[4];
+       const unsigned int BLOCK = 1<<10;
+       double dot = 0;
+       while (count) {
+           size_t pass = std::min(count, BLOCK);
+           count-=pass;
+           __m128 sums = _mm_setzero_ps();
+           while (pass--) {
+               __m128 prod = _mm_mul_ps(*(a++), load_ps<Aligned_b>(b++));
+               sums = _mm_add_ps(prod, sums);
+           }
+           _mm_storeu_ps(sums_store, sums);
+           dot += sums_store[0] + sums_store[1] + sums_store[2] + 
sums_store[3];
+       }
+       return dot;
+    }
+
+    template <bool Aligned_b> inline double 
float_sum_squared_differences(const __m128* a, const __m128* b, size_t count) 
+    {
+       float sums_store[4];
+       const size_t BLOCK = 1<<10;
+       double ssd = 0;
+       while (count) {
+           size_t pass = std::min(count, BLOCK);
+           count-=pass;
+           __m128 sums = _mm_setzero_ps();
+           while (pass--) {
+               __m128 diff = _mm_sub_ps(*(a++), load_ps<Aligned_b>(b++));
+               sums = _mm_add_ps(_mm_mul_ps(diff,diff), sums);
+           }
+           _mm_storeu_ps(sums_store, sums);
+           ssd += sums_store[0] + sums_store[1] + sums_store[2] + 
sums_store[3];
+       }
+       return ssd;
+    }
+    
+    template <bool Aligned_out> void float_square(const __m128* in, __m128* 
out, size_t count) {
+       while (count--) {
+           __m128 x = load_ps<true>(in);
+           store_ps<Aligned_out>(_mm_mul_ps(x, x), out);
+           ++in;
+           ++out;
+       }
+    }
+
+    template <bool Aligned_out> void float_subtract_square(const __m128* in, 
__m128* out, size_t count) {
+       while (count--) {
+           __m128 x = load_ps<true>(in);
+           __m128 y = load_ps<Aligned_out>(out);
+           store_ps<Aligned_out>(_mm_sub_ps(y, _mm_mul_ps(x, x)), out);
+           ++in;
+           ++out;
+       }
+    }
+
+    struct SSE_funcs {
+       template <class T1, class T2> static inline void 
unaligned_differences(const T1* a, const T1* b, T2* diff, size_t count) {
+           differences<T1,T2>(a,b,diff,count);
+       }
+       
+       static inline void aligned_differences(const float* a, const float* b, 
float* diff, unsigned int count) {
+           if (is_aligned<16>(b))
+               float_differences<true>((const __m128*)a, (const __m128*)b, 
(__m128*)diff, count>>2);
+           else
+               float_differences<false>((const __m128*)a, (const __m128*)b, 
(__m128*)diff, count>>2);
+       }
+
+       template <class T1, class T2> static inline void 
unaligned_add_mul_add(const T1* a, const T1* b, const T1& c, T2* out, size_t 
count) {
+           add_multiple_of_sum<T1,T2>(a,b,c,out,count);
+       }
+       static inline void aligned_add_mul_add(const float* a, const float* b, 
const float& c, float* out, size_t count) {
+           if (is_aligned<16>(b))
+               float_add_multiple_of_sum<true>((const __m128*)a, (const 
__m128*)b, c, (__m128*)out, count>>2);
+           else
+               float_add_multiple_of_sum<false>((const __m128*)a, (const 
__m128*)b, c, (__m128*)out, count>>2);
+       }       
+
+       template <class T1, class T2> static inline void 
unaligned_assign_mul(const T1* a, const T1& c, T2* out, size_t count) {
+           assign_multiple<T1,T2>(a,c,out,count);
+       }
+       static inline void aligned_assign_mul(const float* a, const float& c, 
float* out, size_t count) {
+           if (is_aligned<16>(out)) 
+               float_assign_multiple<false>((const __m128*)a, c, (__m128*)out, 
count>>2);
+           else                
+               float_assign_multiple<false>((const __m128*)a, c, (__m128*)out, 
count>>2);
+       }       
+
+       template <class T1> static inline double unaligned_inner_product(const 
T1* a, const T1* b, size_t count) {
+           return inner_product<T1>(a,b,count);
+       }
+       
+       static inline double aligned_inner_product(const float* a, const float* 
b, unsigned int count)
+       {
+           if (is_aligned<16>(b))
+               return float_inner_product<true>((const __m128*) a, (const 
__m128*) b, count>>2);
+           else
+               return float_inner_product<false>((const __m128*) a, (const 
__m128*) b, count>>2);
+       }       
+
+       template <class T1> static inline double unaligned_ssd(const T1* a, 
const T1* b, size_t count) {
+           return sum_squared_differences<T1>(a,b,count);
+       }
+       
+       static inline double aligned_ssd(const float* a, const float* b, 
unsigned int count)
+       {
+           if (is_aligned<16>(b))
+               return float_sum_squared_differences<true>((const __m128*) a, 
(const __m128*) b, count>>2);
+           else
+               return float_sum_squared_differences<false>((const __m128*) a, 
(const __m128*) b, count>>2);
+       }       
+       
+       template <class T1, class T2> static inline void unaligned_square(const 
T1* in, T2* out, size_t count) {
+           square<T1,T2>(in, out, count);
+       }
+
+       static inline void aligned_square(const float* in, float* out, size_t 
count) {
+           if (is_aligned<16>(out))
+               float_square<true>((const __m128*)in, (__m128*)out, count >> 2);
+           else
+               float_square<false>((const __m128*)in, (__m128*)out, count >> 
2);               
+       }
+       template <class T1, class T2> static inline void 
unaligned_subtract_square(const T1* in, T2* out, size_t count) {
+           subtract_square<T1,T2>(in, out, count);
+       }
+
+       static inline void aligned_subtract_square(const float* in, float* out, 
size_t count) {
+           if (is_aligned<16>(out))
+               float_subtract_square<true>((const __m128*)in, (__m128*)out, 
count >> 2);
+           else
+               float_subtract_square<false>((const __m128*)in, (__m128*)out, 
count >> 2);              
+       }
+    };
+    
+    void differences(const float* a, const float* b, float* diff, unsigned int 
size)
+    {
+       maybe_aligned_differences<SSE_funcs, float, float, 16, 
4>(a,b,diff,size);
+    }
+    
+    void add_multiple_of_sum(const float* a, const float* b, const float& c,  
float* out, unsigned int count)
+    {
+       maybe_aligned_add_mul_add<SSE_funcs,float,float,16,4>(a,b,c,out,count);
+    }
+    
+    void assign_multiple(const float* a, const float& c,  float* out, unsigned 
int count) 
+    {
+       maybe_aligned_assign_mul<SSE_funcs,float,float,16,4>(a,c,out,count);
+    }
+
+    
+    double inner_product(const float* a, const float* b, unsigned int count) 
+    {
+       return 
maybe_aligned_inner_product<SSE_funcs,double,float,16,4>(a,b,count);
+    }
+
+    double sum_squared_differences(const float* a, const float* b, size_t 
count)
+    {
+       return maybe_aligned_ssd<SSE_funcs,double,float,16,4>(a,b,count);
+    }
+    
+    void square(const float* in, float* out, size_t count) 
+    {
+       maybe_aligned_square<SSE_funcs,float,float,16,4>(in, out, count);
+    }
+
+    void subtract_square(const float* in, float* out, size_t count) 
+    {
+       maybe_aligned_subtract_square<SSE_funcs,float,float,16,4>(in, out, 
count);
+    }
+    
+}

Index: cvd_src/i686/yuv422_wrapper.cc
===================================================================
RCS file: cvd_src/i686/yuv422_wrapper.cc
diff -N cvd_src/i686/yuv422_wrapper.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/i686/yuv422_wrapper.cc      28 Feb 2008 00:27:23 -0000      1.1
@@ -0,0 +1,45 @@
+#include "cvd/utility.h"
+#include "cvd/colourspace.h"
+#include "cvd_src/yuv422.h"
+
+namespace CVD {
+namespace ColourSpace {
+       extern "C"
+       {
+               void cvd_asm_yuv422_to_rgb(const unsigned char* yuv, unsigned 
char* rgb, unsigned int width);
+               void cvd_asm_yuv422_to_grey(const unsigned char* grey, unsigned 
char* rgb, unsigned int width);
+       }
+
+       void yuv422_to_rgb(const unsigned char* yuv, unsigned char* rgb, 
unsigned int width, unsigned int height) 
+       {
+               if (is_aligned<8>(yuv) && is_aligned<8>(rgb)) 
+               {
+                       cvd_asm_yuv422_to_rgb(yuv,rgb,width*height);
+                       int remaining = (width*height)&7;
+                       if (remaining) 
+                       {
+                               int done = (width*height) & (~0x7);
+                               yuv422_to_rgb_c(yuv+done*2, rgb+done*3, 
remaining);       
+                       }         
+               }
+               else
+                       yuv422_to_rgb_c(yuv, rgb, width*height);
+       }    
+
+       void yuv422_to_grey(const unsigned char* yuv, unsigned char* grey, 
unsigned int width, unsigned int height)
+       {
+               if (is_aligned<8>(yuv) && is_aligned<8>(grey)) 
+               {
+                       cvd_asm_yuv422_to_grey(yuv,grey,width*height);
+                       int remaining = (width*height)&7;
+                       if (remaining) 
+                       {
+                               int done = (width*height) & (~0x7);
+                               yuv422_to_grey_c(yuv+done*2, grey+done, 
remaining);
+                       }         
+               }
+               else
+                       yuv422_to_grey_c(yuv, grey, width*height);
+       }    
+}
+}

Index: cvd_src/noarch/convert_rgb_to_y.cc
===================================================================
RCS file: cvd_src/noarch/convert_rgb_to_y.cc
diff -N cvd_src/noarch/convert_rgb_to_y.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/noarch/convert_rgb_to_y.cc  28 Feb 2008 00:27:23 -0000      1.1
@@ -0,0 +1,18 @@
+#include <cvd/config.h>
+#include <cvd/image_convert.h>
+#include <cvd/utility.h>
+namespace CVD {
+
+       void ConvertImage<Rgb<byte>, byte, Pixel::CIE<Rgb<byte>, byte>, 
1>::convert(const BasicImage<Rgb<byte> >& from, BasicImage<byte>& to) 
+       {
+               const Rgb<byte>* rgb = from.data();
+               byte* gray = to.data(), *gend = to.data() + to.totalsize();
+
+               while (gray < gend)
+               {
+                       Pixel::CIE<Rgb<byte>,byte>::convert(*rgb, *gray);
+                       rgb++;
+                       gray++;
+               }
+       }
+}

Index: cvd_src/noarch/convolve_gaussian.cc
===================================================================
RCS file: cvd_src/noarch/convolve_gaussian.cc
diff -N cvd_src/noarch/convolve_gaussian.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/noarch/convolve_gaussian.cc 28 Feb 2008 00:27:24 -0000      1.1
@@ -0,0 +1,9 @@
+#include "cvd/convolution.h"
+
+namespace CVD
+{
+       void convolveGaussian(const BasicImage<float>& I, BasicImage<float>& 
out, double sigma, double sigmas)
+       {
+               convolveGaussian<float>(I, out, sigma, sigmas);
+       }
+}

Index: cvd_src/noarch/gradient.cc
===================================================================
RCS file: cvd_src/noarch/gradient.cc
diff -N cvd_src/noarch/gradient.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/noarch/gradient.cc  28 Feb 2008 00:27:24 -0000      1.1
@@ -0,0 +1,13 @@
+#include "cvd/vision.h"
+
+using namespace std;
+
+namespace CVD {
+
+    inline void gradient(const BasicImage<byte>& im, BasicImage<short[2]>& out)
+    {
+               if( im.size() != out.size())
+                       throw 
Exceptions::Vision::IncompatibleImageSizes("gradient");
+               gradient<byte,short[2]>(im,out);
+    }
+};

Index: cvd_src/noarch/median_3x3.cc
===================================================================
RCS file: cvd_src/noarch/median_3x3.cc
diff -N cvd_src/noarch/median_3x3.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/noarch/median_3x3.cc        28 Feb 2008 00:27:24 -0000      1.1
@@ -0,0 +1,9 @@
+#include "cvd/vision.h"
+
+namespace CVD{
+    void median_filter_3x3(const SubImage<byte>& I, SubImage<byte> out)
+       {
+               median_filter_3x3<byte>(I, out);
+       }
+
+};

Index: cvd_src/noarch/utility_byte_differences.cc
===================================================================
RCS file: cvd_src/noarch/utility_byte_differences.cc
diff -N cvd_src/noarch/utility_byte_differences.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/noarch/utility_byte_differences.cc  28 Feb 2008 00:27:24 -0000      
1.1
@@ -0,0 +1,12 @@
+#include "cvd/utility.h"
+
+namespace CVD {
+
+    void differences(const byte* a, const byte* b, short* diff, unsigned int 
count) {
+               differences<byte, short>(a, b, diff, count);
+    }
+    
+    void differences(const short* a, const short* b, short* diff, unsigned int 
count) {
+               differences<short, short>(a, b, diff, count);
+    }
+}

Index: cvd_src/noarch/utility_double_int.cc
===================================================================
RCS file: cvd_src/noarch/utility_double_int.cc
diff -N cvd_src/noarch/utility_double_int.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/noarch/utility_double_int.cc        28 Feb 2008 00:27:24 -0000      
1.1
@@ -0,0 +1,40 @@
+#include "cvd/utility.h"
+
+namespace CVD {
+
+    void differences(const int32_t* a, const int32_t* b, int32_t* diff, 
unsigned int size)
+    {
+               differences<int32_t, int32_t>(a, b, diff, size);
+    }
+
+    void differences(const double* a, const double* b, double* diff, unsigned 
int size)
+    {
+               differences<double, double>(a, b, diff, size);
+    }
+
+    void add_multiple_of_sum(const double* a, const double* b, const double& 
c,  double* out, unsigned int count)
+    {
+               add_multiple_of_sum<double, double>(a, b, c, out, count);
+    }
+
+    void assign_multiple(const double* a, const double& c,  double* out, 
unsigned int count)
+    {
+               assign_multiple<double, double>(a, c, out, count);
+    }
+
+    double inner_product(const double* a, const double* b, unsigned int count)
+    {
+               return inner_product<double>(a, b, count);
+    }
+
+    double sum_squared_differences(const double* a, const double* b, size_t 
count)
+    {
+               return 
SumSquaredDifferences<double,double,double>::sum_squared_differences(a,b,count);
+    }
+
+    long long sum_squared_differences(const byte* a, const byte* b, size_t 
count)
+    {
+               return SumSquaredDifferences<long 
long,int,byte>::sum_squared_differences(a,b,count);
+    }
+    
+}

Index: cvd_src/noarch/utility_float.cc
===================================================================
RCS file: cvd_src/noarch/utility_float.cc
diff -N cvd_src/noarch/utility_float.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/noarch/utility_float.cc     28 Feb 2008 00:27:24 -0000      1.1
@@ -0,0 +1,40 @@
+#include "cvd/utility.h"
+
+namespace CVD
+{
+       void differences(const float* a, const float* b, float* diff, unsigned 
int size)
+       {
+               differences<float, float>(a, b, diff, size);
+       }
+
+       void add_multiple_of_sum(const float* a, const float* b, const float& 
c,  float* out, unsigned int count)
+       {
+               add_multiple_of_sum<float, float>(a, b, c, out, count);
+       }
+
+
+       void assign_multiple(const float* a, const float& c,  float* out, 
unsigned int count)
+       {
+               assign_multiple<float, float, float>(a, c, out, count);
+       }
+
+       double inner_product(const float* a, const float* b, unsigned int count)
+       {
+               inner_product<float>(a, b, count);
+       }
+
+       double sum_squared_differences(const float* a, const float* b, size_t 
count)
+       {
+      return SumSquaredDifferences<double, 
float,float>::sum_squared_differences(a,b,count);
+       }
+
+       void square(const float* in, float* out, size_t count)
+       {
+               square<float, float>(in, out, count);
+       }
+
+       void subtract_square(const float* in, float* out, size_t count)
+       {
+               subtract_square<float, float>(in, out, count);
+       }
+}

Index: cvd_src/noarch/yuv422_wrapper.cc
===================================================================
RCS file: cvd_src/noarch/yuv422_wrapper.cc
diff -N cvd_src/noarch/yuv422_wrapper.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cvd_src/noarch/yuv422_wrapper.cc    28 Feb 2008 00:27:24 -0000      1.1
@@ -0,0 +1,17 @@
+#include "cvd/utility.h"
+#include "cvd/colourspace.h"
+#include "cvd_src/yuv422.h"
+
+namespace CVD {
+namespace ColourSpace {
+    
+       void yuv422_to_rgb(const unsigned char* yuv, unsigned char* rgb, 
unsigned int width, unsigned int height) 
+       {
+               yuv422_to_rgb_c(yuv, rgb, width*height);
+       }    
+
+       void yuv422_to_grey(const unsigned char* yuv, unsigned char* grey, 
unsigned int width, unsigned int height)
+       {
+               yuv422_to_grey_c(yuv, grey, width*height);
+       }    
+}}

Index: make/compile_deps.awk
===================================================================
RCS file: make/compile_deps.awk
diff -N make/compile_deps.awk
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ make/compile_deps.awk       28 Feb 2008 00:27:24 -0000      1.1
@@ -0,0 +1,26 @@
+/^have/{
+       what=substr($1, 6)
+       have[what]= ($2 == "yes")
+       next
+}
+
+/^#/{next}
+NF==0{next}
+
+!selected{
+       
+       for(i=2; i <= NF; i++)
+               if($i != "END" && !have[$i])
+                       next
+
+       selected= ($NF != "END")
+
+       nd = split($1, dependees, ",")
+       
+       for(i=1; i <= nd; i++)
+               print dependees[i]
+}
+
+$NF=="END"{
+       selected=0
+}

Index: cvd_src/image_convert.cc
===================================================================
RCS file: cvd_src/image_convert.cc
diff -N cvd_src/image_convert.cc
--- cvd_src/image_convert.cc    9 Dec 2005 05:49:07 -0000       1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,22 +0,0 @@
-#include <cvd/config.h>
-#include <cvd/image_convert.h>
-#include <cvd/utility.h>
-#include <cvd/internal/assembly.h>
-namespace CVD {
-
-#if defined(CVD_HAVE_MMXEXT) && defined(CVD_HAVE_CPU_i686)
-    void ConvertImage<Rgb<byte>, byte, Pixel::CIE<Rgb<byte>, byte>, 
1>::convert(const BasicImage<Rgb<byte> >& from, BasicImage<byte>& to) {
-       const Rgb<byte>* rgb = from.data();
-       byte* gray = to.data();
-       int count=0;
-       while (!is_aligned<16>(rgb) || !is_aligned<16>(gray)) {
-           Pixel::CIE<Rgb<byte>,byte>::convert(*rgb, *gray);
-           rgb++;
-           gray++;
-           count++;
-         }
-       if (count < from.totalsize())
-           Internal::Assembly::rgb_to_gray((const byte*)rgb, gray, 
from.totalsize()-count, 77, 150, 29);
-    }
-#endif
-}

Index: cvd_src/utility.cc
===================================================================
RCS file: cvd_src/utility.cc
diff -N cvd_src/utility.cc
--- cvd_src/utility.cc  4 Sep 2007 23:33:08 -0000       1.8
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,683 +0,0 @@
-#include <cvd/config.h>
-#include <cvd/utility.h>
-// internal functions used by CVD vision algorithm implementations
-#include <cvd/internal/assembly.h>
-
-#if CVD_HAVE_MMINTRIN
-#    include <mmintrin.h>
-#endif
-
-#if CVD_HAVE_XMMINTRIN
-#    include <xmmintrin.h>
-#endif
-
-#if CVD_HAVE_EMMINTRIN
-#    include <emmintrin.h>
-#endif
-
-using namespace std;
-
-    using CVD::is_aligned;
-    using CVD::steps_to_align;
-    template <class F, class T1, class T2, int A, int M> inline void 
maybe_aligned_differences(const T1* a, const T1* b, T2* c, unsigned int count)
-    {
-       if (count < M*2) {
-           F::unaligned_differences(a,b,c,count);
-           return;
-       }
-       if (!is_aligned<A>(a)) {            
-           unsigned int steps = steps_to_align<A>(a);
-           F::unaligned_differences(a,b,c,steps);
-           count -= steps;
-           a += steps;
-           b += steps;
-           c += steps;
-       }
-       if (!is_aligned<A>(c) || count < M) {
-           F::unaligned_differences(a,b,c,count);
-           return;
-       }       
-       unsigned int block = (count/M)*M;
-       F::aligned_differences(a,b,c,block);
-       if (count > block) {
-           F::unaligned_differences(a+block,b+block,c+block,count-block);
-       }
-    }    
-    
-    template <class F, class T1, class T2, int A, int M> inline void 
maybe_aligned_add_mul_add(const T1* a, const T1* b, const T1& c, T2* out, 
unsigned int count)
-    {
-       if (count < M*2) {
-           F::unaligned_add_mul_add(a,b,c,out,count);
-           return;
-       }
-       if (!is_aligned<A>(a)) {      
-           unsigned int steps = steps_to_align<A>(a);
-           F::unaligned_add_mul_add(a,b,c,out,steps);
-           count -= steps;
-           a += steps;
-           b += steps;
-           out += steps;
-           if (count < M || !is_aligned<16>(out)) {
-               F::unaligned_add_mul_add(a,b,c,out,count);
-               return;
-           }
-       }
-       else if (count < M || !is_aligned<16>(out)) {
-           F::unaligned_add_mul_add(a,b,c,out,count);
-           return;
-       }
-       unsigned int block = (count/M)*M;
-       F::aligned_add_mul_add(a,b,c,out,block);
-       if (count > block)
-           F::unaligned_add_mul_add(a+block,b+block,c, out+block,count-block);
-    }    
-
-    template <class F, class T1, class T2, int A, int M> inline void 
maybe_aligned_assign_mul(const T1* a, const T1& c, T2* out, unsigned int count)
-    {
-       if (count < M*2) {
-           F::unaligned_assign_mul(a,c,out,count);
-           return;
-       }
-       if (!is_aligned<A>(a)) {      
-           unsigned int steps = steps_to_align<A>(a);
-           F::unaligned_assign_mul(a,c,out,steps);
-           count -= steps;
-           a += steps;
-           out += steps;
-           if (count < M) {
-               F::unaligned_assign_mul(a,c,out,count);
-               return;
-           }
-       }
-       unsigned int block = (count/M)*M;
-       F::aligned_assign_mul(a,c,out,block);
-       if (count > block) {
-           F::unaligned_assign_mul(a+block,c, out+block,count-block);
-       }
-    }    
-
-    template <class F, class R, class T1, int A, int M> inline R 
maybe_aligned_inner_product(const T1* a, const T1* b, unsigned int count)
-    {
-       if (count < M*2) {
-           return F::unaligned_inner_product(a,b,count);
-       }
-       R sum = 0;
-       if (!is_aligned<A>(a)) {      
-           unsigned int steps = steps_to_align<A>(a);
-           sum = F::unaligned_inner_product(a,b,steps);
-           count -= steps;
-           a += steps;
-           b += steps;
-           if (count < M) {
-               return sum + F::unaligned_inner_product(a,b,count);
-           }
-       }
-       unsigned int block = (count/M)*M;
-       sum += F::aligned_inner_product(a,b,block);
-       if (count > block)
-           sum += F::unaligned_inner_product(a+block,b+block,count-block);
-       return sum;
-    }    
-
-    template <class F, class R, class T1, int A, int M> inline R 
maybe_aligned_ssd(const T1* a, const T1* b, unsigned int count)
-    {
-       if (count < M*2) {
-           return F::unaligned_ssd(a,b,count);
-       }
-       R sum = 0;
-       if (!is_aligned<A>(a)) {      
-           unsigned int steps = steps_to_align<A>(a);
-           sum = F::unaligned_ssd(a,b,steps);
-           count -= steps;
-           a += steps;
-           b += steps;
-           if (count < M) {
-               return sum + F::unaligned_ssd(a,b,count);
-           }
-       }
-       unsigned int block = (count/M)*M;
-       sum += F::aligned_ssd(a,b,block);
-       if (count > block)
-           sum += F::unaligned_ssd(a+block,b+block,count-block);
-       return sum;
-    }    
-
-template <class F, class T1, class T2, int A, int M> inline void 
maybe_aligned_square(const T1* in, T2* out, size_t count)
-{
-    if (count < M*2) {
-       return F::unaligned_square(in,out,count);
-    }
-    if (!is_aligned<A>(in)) {
-       unsigned int steps = steps_to_align<A>(in);
-       F::unaligned_square(in,out,steps);
-       count -= steps;
-       in += steps;
-       out += steps;
-       if (count < M) {
-           F::unaligned_square(in,out,count);
-       }
-    }
-    size_t block = (count/M)*M;
-    F::aligned_square(in,out,block);
-    if (count > block)
-       F::unaligned_square(in+block,out+block,count-block);
-}    
-
-template <class F, class T1, class T2, int A, int M> inline void 
maybe_aligned_subtract_square(const T1* in, T2* out, size_t count)
-{
-    if (count < M*2) {
-       return F::unaligned_subtract_square(in,out,count);
-    }
-    if (!is_aligned<A>(in)) {
-       unsigned int steps = steps_to_align<A>(in);
-       F::unaligned_subtract_square(in,out,steps);
-       count -= steps;
-       in += steps;
-       out += steps;
-       if (count < M) {
-           F::unaligned_subtract_square(in,out,count);
-       }
-    }
-    size_t block = (count/M)*M;
-    F::aligned_subtract_square(in,out,block);
-    if (count > block)
-       F::unaligned_subtract_square(in+block,out+block,count-block);
-}    
-
-
-namespace CVD {
-
-#if defined(CVD_HAVE_MMXEXT) && defined(CVD_HAVE_MMINTRIN)
-
-
-    void byte_to_short_differences(const __m64* a, const __m64* b, __m64* 
diff, unsigned int count)
-    {
-       __m64 z = _mm_setzero_si64();
-       for (;count; --count, ++a, ++b, diff+=2) {
-           __m64 aq = *a;
-           __m64 bq = *b;
-           __m64 alo = _mm_unpacklo_pi8(aq,z);
-           __m64 ahi = _mm_unpackhi_pi8(aq,z);
-           __m64 blo = _mm_unpacklo_pi8(bq,z);
-           __m64 bhi = _mm_unpackhi_pi8(bq,z);
-           diff[0] = _mm_sub_pi16(alo,blo);
-           diff[1] = _mm_sub_pi16(ahi,bhi);
-       }
-       _mm_empty();
-    }
-
-    void short_differences(const __m64* a, const __m64* b, __m64* diff, 
unsigned int count)
-    {
-       while (count--) {
-           *(diff++) = _mm_sub_pi16(*(a++), *(b++));
-       }
-       _mm_empty();
-    }
-
-    
-    struct MMX_funcs {
-       template <class T1, class T2> static inline void 
unaligned_differences(const T1* a, const T1* b, T2* diff, size_t count) {
-           differences<T1,T2>(a,b,diff,count);
-       }
-       static inline void aligned_differences(const byte* a, const byte* b, 
short* diff, unsigned int count) {
-           if (is_aligned<8>(b))
-               byte_to_short_differences((const __m64*)a,(const __m64*)b, 
(__m64*)diff, count>>3);
-           else
-               unaligned_differences(a,b,diff,count);
-       }
-       
-       static inline void aligned_differences(const short* a, const short* b, 
short* diff, unsigned int count) {
-           if (is_aligned<8>(b))           
-               short_differences((const __m64*)a, (const __m64*)b, 
(__m64*)diff, count>>2);
-           else
-               unaligned_differences(a,b,diff,count);
-       }
-    };
-
-    void differences(const byte* a, const byte* b, short* diff, unsigned int 
count) {
-       maybe_aligned_differences<MMX_funcs, byte, short, 8, 8>(a,b,diff,count);
-    }
-    
-    void differences(const short* a, const short* b, short* diff, unsigned int 
count) {
-       maybe_aligned_differences<MMX_funcs, short, short, 8, 
4>(a,b,diff,count);
-    }
-#endif
-
-
-#if defined(CVD_HAVE_SSE) && defined(CVD_HAVE_XMMINTRIN)
-       
-       //Some versions of gcc do not define _mm_load?_ps as taking a const 
float*
-       //Later versions always use the const.
-    template <bool Aligned> inline __m128 load_ps(const void* addr) { return 
_mm_loadu_ps(static_cast<float*>(const_cast<void*>(addr))); }
-    template <> inline __m128 load_ps<true>(const void* addr) { return 
_mm_load_ps(static_cast<float*>(const_cast<void*>(addr))); }
-
-    template <bool Aligned> inline void store_ps(__m128 m, void* addr) { 
return _mm_storeu_ps((float*)addr, m); }
-    template <> inline void store_ps<true>(__m128 m, void* addr) { return 
_mm_store_ps((float*)addr, m); }
-
-    template <bool Aligned_b> void float_differences(const __m128* a, const 
__m128* b, __m128* diff, unsigned int count)
-    {
-       while (count--) {
-           _mm_stream_ps((float*)diff, _mm_sub_ps(load_ps<true>(a), 
load_ps<Aligned_b>(b)));
-           ++diff;
-           ++a;
-           ++b;
-       }
-    }
-    
-    template <bool Aligned_b> void float_add_multiple_of_sum(const __m128* a, 
const __m128* b, const float& c, __m128* out, unsigned int count)
-    {
-       __m128 cccc = _mm_set1_ps(c);
-       while (count--) {
-           *out = _mm_add_ps(_mm_mul_ps(_mm_add_ps(load_ps<true>(a), 
load_ps<Aligned_b>(b)), cccc), *out);
-           ++out;
-           ++a;
-           ++b;
-       }
-    }
-
-    template <bool Aligned_out> inline void float_assign_multiple(const 
__m128* a, const float& c, __m128* out, unsigned int count)
-    {
-       const __m128 cccc = _mm_set1_ps(c);
-       while (count--)
-           store_ps<Aligned_out>(_mm_mul_ps(*(a++), cccc), out++);
-       
-    }
-    
-    template <bool Aligned_b> double float_inner_product(const __m128* a, 
const __m128* b, unsigned int count)
-    {
-       float sums_store[4];
-       const unsigned int BLOCK = 1<<10;
-       double dot = 0;
-       while (count) {
-           size_t pass = std::min(count, BLOCK);
-           count-=pass;
-           __m128 sums = _mm_setzero_ps();
-           while (pass--) {
-               __m128 prod = _mm_mul_ps(*(a++), load_ps<Aligned_b>(b++));
-               sums = _mm_add_ps(prod, sums);
-           }
-           _mm_storeu_ps(sums_store, sums);
-           dot += sums_store[0] + sums_store[1] + sums_store[2] + 
sums_store[3];
-       }
-       return dot;
-    }
-
-    template <bool Aligned_b> inline double 
float_sum_squared_differences(const __m128* a, const __m128* b, size_t count) 
-    {
-       float sums_store[4];
-       const size_t BLOCK = 1<<10;
-       double ssd = 0;
-       while (count) {
-           size_t pass = std::min(count, BLOCK);
-           count-=pass;
-           __m128 sums = _mm_setzero_ps();
-           while (pass--) {
-               __m128 diff = _mm_sub_ps(*(a++), load_ps<Aligned_b>(b++));
-               sums = _mm_add_ps(_mm_mul_ps(diff,diff), sums);
-           }
-           _mm_storeu_ps(sums_store, sums);
-           ssd += sums_store[0] + sums_store[1] + sums_store[2] + 
sums_store[3];
-       }
-       return ssd;
-    }
-    
-    template <bool Aligned_out> void float_square(const __m128* in, __m128* 
out, size_t count) {
-       while (count--) {
-           __m128 x = load_ps<true>(in);
-           store_ps<Aligned_out>(_mm_mul_ps(x, x), out);
-           ++in;
-           ++out;
-       }
-    }
-
-    template <bool Aligned_out> void float_subtract_square(const __m128* in, 
__m128* out, size_t count) {
-       while (count--) {
-           __m128 x = load_ps<true>(in);
-           __m128 y = load_ps<Aligned_out>(out);
-           store_ps<Aligned_out>(_mm_sub_ps(y, _mm_mul_ps(x, x)), out);
-           ++in;
-           ++out;
-       }
-    }
-
-    struct SSE_funcs {
-       template <class T1, class T2> static inline void 
unaligned_differences(const T1* a, const T1* b, T2* diff, size_t count) {
-           differences<T1,T2>(a,b,diff,count);
-       }
-       
-       static inline void aligned_differences(const float* a, const float* b, 
float* diff, unsigned int count) {
-           if (is_aligned<16>(b))
-               float_differences<true>((const __m128*)a, (const __m128*)b, 
(__m128*)diff, count>>2);
-           else
-               float_differences<false>((const __m128*)a, (const __m128*)b, 
(__m128*)diff, count>>2);
-       }
-
-       template <class T1, class T2> static inline void 
unaligned_add_mul_add(const T1* a, const T1* b, const T1& c, T2* out, size_t 
count) {
-           add_multiple_of_sum<T1,T2>(a,b,c,out,count);
-       }
-       static inline void aligned_add_mul_add(const float* a, const float* b, 
const float& c, float* out, size_t count) {
-           if (is_aligned<16>(b))
-               float_add_multiple_of_sum<true>((const __m128*)a, (const 
__m128*)b, c, (__m128*)out, count>>2);
-           else
-               float_add_multiple_of_sum<false>((const __m128*)a, (const 
__m128*)b, c, (__m128*)out, count>>2);
-       }       
-
-       template <class T1, class T2> static inline void 
unaligned_assign_mul(const T1* a, const T1& c, T2* out, size_t count) {
-           assign_multiple<T1,T2>(a,c,out,count);
-       }
-       static inline void aligned_assign_mul(const float* a, const float& c, 
float* out, size_t count) {
-           if (is_aligned<16>(out)) 
-               float_assign_multiple<false>((const __m128*)a, c, (__m128*)out, 
count>>2);
-           else                
-               float_assign_multiple<false>((const __m128*)a, c, (__m128*)out, 
count>>2);
-       }       
-
-       template <class T1> static inline double unaligned_inner_product(const 
T1* a, const T1* b, size_t count) {
-           return inner_product<T1>(a,b,count);
-       }
-       
-       static inline double aligned_inner_product(const float* a, const float* 
b, unsigned int count)
-       {
-           if (is_aligned<16>(b))
-               return float_inner_product<true>((const __m128*) a, (const 
__m128*) b, count>>2);
-           else
-               return float_inner_product<false>((const __m128*) a, (const 
__m128*) b, count>>2);
-       }       
-
-       template <class T1> static inline double unaligned_ssd(const T1* a, 
const T1* b, size_t count) {
-           return sum_squared_differences<T1>(a,b,count);
-       }
-       
-       static inline double aligned_ssd(const float* a, const float* b, 
unsigned int count)
-       {
-           if (is_aligned<16>(b))
-               return float_sum_squared_differences<true>((const __m128*) a, 
(const __m128*) b, count>>2);
-           else
-               return float_sum_squared_differences<false>((const __m128*) a, 
(const __m128*) b, count>>2);
-       }       
-       
-       template <class T1, class T2> static inline void unaligned_square(const 
T1* in, T2* out, size_t count) {
-           square<T1,T2>(in, out, count);
-       }
-
-       static inline void aligned_square(const float* in, float* out, size_t 
count) {
-           if (is_aligned<16>(out))
-               float_square<true>((const __m128*)in, (__m128*)out, count >> 2);
-           else
-               float_square<false>((const __m128*)in, (__m128*)out, count >> 
2);               
-       }
-       template <class T1, class T2> static inline void 
unaligned_subtract_square(const T1* in, T2* out, size_t count) {
-           subtract_square<T1,T2>(in, out, count);
-       }
-
-       static inline void aligned_subtract_square(const float* in, float* out, 
size_t count) {
-           if (is_aligned<16>(out))
-               float_subtract_square<true>((const __m128*)in, (__m128*)out, 
count >> 2);
-           else
-               float_subtract_square<false>((const __m128*)in, (__m128*)out, 
count >> 2);              
-       }
-    };
-    
-    void differences(const float* a, const float* b, float* diff, unsigned int 
size)
-    {
-       maybe_aligned_differences<SSE_funcs, float, float, 16, 
4>(a,b,diff,size);
-    }
-    
-    void add_multiple_of_sum(const float* a, const float* b, const float& c,  
float* out, unsigned int count)
-    {
-       maybe_aligned_add_mul_add<SSE_funcs,float,float,16,4>(a,b,c,out,count);
-    }
-    
-    void assign_multiple(const float* a, const float& c,  float* out, unsigned 
int count) 
-    {
-       maybe_aligned_assign_mul<SSE_funcs,float,float,16,4>(a,c,out,count);
-    }
-
-    
-    double inner_product(const float* a, const float* b, unsigned int count) 
-    {
-       return 
maybe_aligned_inner_product<SSE_funcs,double,float,16,4>(a,b,count);
-    }
-
-    double sum_squared_differences(const float* a, const float* b, size_t 
count)
-    {
-       return maybe_aligned_ssd<SSE_funcs,double,float,16,4>(a,b,count);
-    }
-    
-    void square(const float* in, float* out, size_t count) 
-    {
-       maybe_aligned_square<SSE_funcs,float,float,16,4>(in, out, count);
-    }
-
-    void subtract_square(const float* in, float* out, size_t count) 
-    {
-       maybe_aligned_subtract_square<SSE_funcs,float,float,16,4>(in, out, 
count);
-    }
-
-#endif
-
-#if defined (CVD_HAVE_SSE2) && defined(CVD_HAVE_EMMINTRIN)
-
-
-    static inline __m128i zero_si128() { __m128i x; asm ( "pxor %0, %0  \n\t" 
: "=x"(x) ); return x; }
-    template <bool Aligned> inline __m128i load_si128(const void* addr) { 
return _mm_loadu_si128((const __m128i*)addr); }
-    template <> inline __m128i load_si128<true>(const void* addr) { return 
_mm_load_si128((const __m128i*)addr); }
-    template <bool Aligned> inline __m128d load_pd(const void* addr) { return 
_mm_loadu_pd((const double*)addr); }
-    template <> inline __m128d load_pd<true>(const void* addr) { return 
_mm_load_pd((const double*)addr); }
-
-    template <bool Aligned> inline void store_pd(__m128d m, void* addr) { 
return _mm_storeu_pd((double*)addr, m); }
-    template <> inline void store_pd<true>(__m128d m, void* addr) { return 
_mm_store_pd((double*)addr, m); }
-
-    template <bool Aligned_b> void int_differences(const __m128i* a, const 
__m128i* b, __m128i* diff, unsigned int count)
-    {
-       while (count--) {
-           *(diff++) = _mm_sub_epi32(*(a++), load_si128<Aligned_b>(b++));
-       }
-    }
-    
-    template <bool Aligned_b> void double_differences(const __m128d* a, const 
__m128d* b, __m128d* diff, unsigned int count)
-    {
-       while (count--) {
-           *(diff++) = _mm_sub_pd(*(a++), load_pd<Aligned_b>(b++));
-       }
-    }
-
-    template <bool Aligned_b> void double_add_multiple_of_sum(const __m128d* 
a, const __m128d* b, const double& c, __m128d* out, unsigned int count)
-    {
-       __m128d cc = _mm_set1_pd(c);
-       while (count--) {
-           *out = _mm_add_pd(_mm_mul_pd(_mm_add_pd(*(a++), 
load_pd<Aligned_b>(b++)), cc), *out);
-           ++out;
-       }
-    }
-
-    template <bool Aligned_out> void double_assign_multiple(const __m128d* a, 
const double& c, __m128d* out, unsigned int count)
-    {
-       __m128d cc = _mm_set1_pd(c);
-       while (count--)
-           store_pd<Aligned_out>(_mm_mul_pd(*(a++), cc), out++);
-    }
-    template <bool Aligned_b> double double_inner_product(const __m128d* a, 
const __m128d* b, unsigned int count)
-    {
-       double sums_store[2];
-       const unsigned int BLOCK = 1<<16;
-       double dot = 0;
-       while (count) {
-           size_t pass = std::min(count, BLOCK);
-           count-=pass;
-           __m128d sums = _mm_setzero_pd();
-           while (pass--) {
-               __m128d prod = _mm_mul_pd(*(a++), load_pd<Aligned_b>(b++));
-               sums = _mm_add_pd(prod, sums);
-           }
-           _mm_storeu_pd(sums_store, sums);
-           dot += sums_store[0] + sums_store[1];
-       }
-       return dot;
-    }
-
-    template <bool Aligned_b> long long byte_sum_squared_differences(const 
__m128i* a, const __m128i* b, unsigned int count) {
-       unsigned long sums_store[4];    
-       const unsigned int BLOCK = 1<<15;
-       long long ssd = 0;
-       while (count) {
-           size_t pass = std::min(count, BLOCK);
-           count -= pass;
-           __m128i sums = _mm_setzero_si128();
-           while (pass--) {
-               __m128i lo_a = load_si128<true>(a++);
-               __m128i lo_b = load_si128<Aligned_b>(b++);
-               __m128i hi_a = _mm_unpackhi_epi8(lo_a, sums);
-               __m128i hi_b = _mm_unpackhi_epi8(lo_b, sums);
-               lo_a = _mm_unpacklo_epi8(lo_a, sums);
-               lo_b = _mm_unpacklo_epi8(lo_b, sums);
-               lo_a = _mm_sub_epi16(lo_a, lo_b);
-               hi_a = _mm_sub_epi16(hi_a, hi_b);
-               lo_a = _mm_madd_epi16(lo_a,lo_a);
-               hi_a = _mm_madd_epi16(hi_a,hi_a);
-               sums = _mm_add_epi32(_mm_add_epi32(lo_a, hi_a), sums);
-           }
-           _mm_storeu_si128((__m128i*)sums_store, sums);
-           ssd += sums_store[0] + sums_store[1] + sums_store[2] + 
sums_store[3];
-       }
-       return ssd;
-    }
-
-    template <bool Aligned_b> inline double 
double_sum_squared_differences(const __m128d* a, const __m128d* b, unsigned int 
count) 
-    {
-       double sums_store[2];
-       const unsigned int BLOCK = 1<<10;
-       double ssd = 0;
-       while (count) {
-           size_t pass = std::min(count, BLOCK);
-           count-=pass;
-           __m128d sums = _mm_setzero_pd();
-           while (pass--) {
-               __m128d diff = _mm_sub_pd(*(a++), load_pd<Aligned_b>(b++));
-               sums = _mm_add_pd(_mm_mul_pd(diff,diff), sums);
-           }
-           _mm_storeu_pd(sums_store, sums);
-           ssd += sums_store[0] + sums_store[1];
-       }
-       return ssd;
-    }
-
-    
-    struct SSE2_funcs {
-       template <class T1, class T2> static inline void 
unaligned_differences(const T1* a, const T1* b, T2* diff, size_t count) {
-           differences<T1,T2>(a,b,diff,count);
-       }
-
-       static inline void aligned_differences(const int32_t* a, const int32_t* 
b, int32_t* diff, unsigned int count) {
-           if (is_aligned<16>(b))
-               int_differences<true>((const __m128i*)a, (const __m128i*)b, 
(__m128i*)diff, count>>2);
-           else
-               int_differences<false>((const __m128i*)a, (const __m128i*)b, 
(__m128i*)diff, count>>2);
-       }
-
-       static inline void aligned_differences(const double* a, const double* 
b, double* diff, unsigned int count)
-       {
-           if (is_aligned<16>(b))
-               double_differences<true>((const __m128d*)a,(const 
__m128d*)b,(__m128d*)diff,count>>1);
-           else
-               double_differences<false>((const __m128d*)a,(const 
__m128d*)b,(__m128d*)diff,count>>1);
-       }
-
-       template <class T1, class T2> static inline void 
unaligned_add_mul_add(const T1* a, const T1* b, const T1& c, T2* out, size_t 
count) {
-           add_multiple_of_sum<T1,T2>(a,b,c,out,count);
-       }
-       
-       static inline void aligned_add_mul_add(const double* a, const double* 
b, const double& c, double* out, unsigned int count)
-       {
-           if (is_aligned<16>(b))
-               double_add_multiple_of_sum<true>((const __m128d*)a, (const 
__m128d*)b, c, (__m128d*)out, count>>1);
-           else
-               double_add_multiple_of_sum<false>((const __m128d*)a, (const 
__m128d*)b, c, (__m128d*)out, count>>1);
-       }
-       
-       template <class T1, class T2> static inline void 
unaligned_assign_mul(const T1* a, const T1& c, T2* out, size_t count) {
-           assign_multiple<T1,T2>(a,c,out,count);
-       }
-
-       static inline void aligned_assign_mul(const double* a, const double& c, 
double* out, unsigned int count)
-       {
-           if (is_aligned<16>(out))
-               double_assign_multiple<true>((const __m128d*)a, c, 
(__m128d*)out, count>>1);
-           else
-               double_assign_multiple<false>((const __m128d*)a, c, 
(__m128d*)out, count>>1);
-       }
-       
-       template <class T1> static inline double unaligned_inner_product(const 
T1* a, const T1* b, size_t count) {
-           return inner_product<T1>(a,b,count);
-       }
-       
-       static inline double aligned_inner_product(const double* a, const 
double* b, unsigned int count)
-       {
-           if (is_aligned<16>(b))
-               return double_inner_product<true>((const __m128d*) a, (const 
__m128d*) b, count>>1);
-           else
-               return double_inner_product<false>((const __m128d*) a, (const 
__m128d*) b, count>>1);
-       }
-
-       template <class T1> static inline double unaligned_ssd(const T1* a, 
const T1* b, size_t count) {
-           return sum_squared_differences<T1>(a,b,count);
-       }
-       
-       static inline long long unaligned_ssd(const byte* a, const byte* b, 
size_t count) {
-           return SumSquaredDifferences<long long, int, 
byte>::sum_squared_differences(a,b,count);
-       }
-
-       static inline double aligned_ssd(const double* a, const double* b, 
size_t count) 
-       {
-           if (is_aligned<16>(b))
-               return double_sum_squared_differences<true>((const __m128d*)a, 
(const __m128d*)b, count>>1);
-           else
-               return double_sum_squared_differences<false>((const __m128d*)a, 
(const __m128d*)b, count>>1);
-       }
-
-       static inline long long aligned_ssd(const byte* a, const byte* b, 
size_t count) 
-       {
-           if (is_aligned<16>(b)) 
-               return byte_sum_squared_differences<true>((const __m128i*)a, 
(const __m128i*)b, count>>4);
-           else
-               return byte_sum_squared_differences<false>((const __m128i*)a, 
(const __m128i*)b, count>>4);
-       }       
-    };
-
-    void differences(const int32_t* a, const int32_t* b, int32_t* diff, 
unsigned int size)
-    {
-       maybe_aligned_differences<SSE2_funcs, int32_t, int32_t, 16, 
4>(a,b,diff,size);
-    }
-
-    void differences(const double* a, const double* b, double* diff, unsigned 
int size)
-    {
-       maybe_aligned_differences<SSE2_funcs, double, double, 16, 
2>(a,b,diff,size);
-    }
-
-    void add_multiple_of_sum(const double* a, const double* b, const double& 
c,  double* out, unsigned int count)
-    {
-       maybe_aligned_add_mul_add<SSE2_funcs, double, double, 16, 
2>(a,b,c,out,count);
-    }
-
-    void assign_multiple(const double* a, const double& c,  double* out, 
unsigned int count)
-    {
-       maybe_aligned_assign_mul<SSE2_funcs, double, double, 16, 
2>(a,c,out,count);
-    }
-
-    double inner_product(const double* a, const double* b, unsigned int count)
-    {
-       return maybe_aligned_inner_product<SSE2_funcs, double, double, 16, 
2>(a,b,count);
-    }
-
-    double sum_squared_differences(const double* a, const double* b, size_t 
count)
-    {
-       return maybe_aligned_ssd<SSE2_funcs, double, double, 16, 2>(a,b,count);
-    }
-
-    long long sum_squared_differences(const byte* a, const byte* b, size_t 
count)
-    {
-       return maybe_aligned_ssd<SSE2_funcs, long long, byte, 16, 
16>(a,b,count); 
-    }
-#endif
-    
-}

Index: cvd_src/vision.cc
===================================================================
RCS file: cvd_src/vision.cc
diff -N cvd_src/vision.cc
--- cvd_src/vision.cc   28 Sep 2007 13:27:05 -0000      1.8
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,192 +0,0 @@
-#include <cvd/vision.h>
-#include <cvd/config.h>
-// internal functions used by CVD vision algorithm implementations
-#include <cvd/internal/assembly.h>
-
-#if defined( __GNUC__) && defined(CVD_HAVE_SSE2)
-#include <emmintrin.h>
-#endif
-
-using namespace std;
-
-namespace CVD {
-
-#if defined(CVD_HAVE_MMXEXT) && defined(CVD_HAVE_CPU_i686)
-    
-#if defined( __GNUC__) && defined(CVD_HAVE_SSE2)
-
-    // I have to use this because gcc 3.3 has an internal bug with 
_mm_slli_epi16
-#define shift_left_7(thing) asm ( "psllw $0x7, %0  \n\t" : : "x"(thing) : "%0" 
);
-    
-    void gradient(const byte* in, short (*out)[2], int w, int h)
-    {
-       const byte zeros[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-       const byte* curr = in + w;
-       out += w;
-       int total = (w*(h-2)) >> 4;
-       __m128i zero = _mm_loadu_si128((const __m128i*)zeros);
-       while (total--) {
-           __m128i up = _mm_load_si128((const __m128i*)(curr-w));
-           __m128i down = _mm_load_si128((const __m128i*)(curr+w));        
-           __m128i hor_left, hor_right;
-           {
-               __m128i hor = _mm_load_si128((const __m128i*)curr);
-               hor_left = _mm_slli_si128(hor, 1);
-               hor_right = _mm_srli_si128(hor, 1);
-           }
-           {
-               __m128i left = _mm_unpacklo_epi8(hor_right, zero);
-               __m128i right = _mm_unpacklo_epi8(hor_left, zero);
-               __m128i hdiff = _mm_insert_epi16(_mm_sub_epi16(right,left), 
short(curr[1]) - short(curr[-1]), 0);
-               __m128i vdiff = _mm_sub_epi16(_mm_unpacklo_epi8(down, zero), 
_mm_unpacklo_epi8(up, zero));
-               {
-                   __m128i part1 = _mm_unpacklo_epi16(hdiff, vdiff);
-                   shift_left_7(part1);
-                   _mm_stream_si128((__m128i*)out, part1);
-               }
-               {
-                   __m128i part2 = _mm_unpackhi_epi16(hdiff, vdiff);
-                   shift_left_7(part2);
-                   _mm_stream_si128((__m128i*)(out+4), part2);
-               }
-           }
-           {
-               __m128i left = _mm_unpackhi_epi8(hor_right, zero);
-               __m128i right = _mm_unpackhi_epi8(hor_left, zero);
-               __m128i hdiff = _mm_insert_epi16(_mm_sub_epi16(right,left), 
short(curr[16]) - short(curr[14]), 7);
-               __m128i vdiff = _mm_sub_epi16(_mm_unpackhi_epi8(down, 
zero),_mm_unpackhi_epi8(up, zero));
-               {
-                   __m128i part3 = _mm_unpacklo_epi16(hdiff, vdiff);
-                   shift_left_7(part3);
-                   _mm_stream_si128((__m128i*)(out+8), part3);
-               }
-               {
-                   __m128i part4 = _mm_unpackhi_epi16(hdiff, vdiff);
-                   shift_left_7(part4);
-                   _mm_stream_si128((__m128i*)(out+12), part4);
-               }
-           }
-           curr += 16;
-           out += 16;
-       }
-       _mm_empty();
-    }
-
-    void halfSampleSSE2(const byte* in, byte* out, int w, int h) 
-    {
-       const unsigned long long mask[2] = {0x00FF00FF00FF00FFull, 
0x00FF00FF00FF00FFull};
-       byte test[16];
-       const byte* nextRow = in + w;
-       __m128i m = _mm_loadu_si128((const __m128i*)mask);
-       int sw = w >> 4;
-       int sh = h >> 1;
-       for (int i=0; i<sh; i++) {
-           for (int j=0; j<sw; j++) {
-               __m128i here = _mm_load_si128((const __m128i*)in);
-               __m128i next = _mm_load_si128((const __m128i*)nextRow);
-               here = _mm_avg_epu8(here,next);
-               next = _mm_and_si128(_mm_srli_si128(here,1), m);
-               here = _mm_and_si128(here,m);
-               here = _mm_avg_epu16(here, next);
-               _mm_storel_epi64((__m128i*)out, _mm_packus_epi16(here,here));
-               in += 16;
-               nextRow += 16;
-               out += 8;
-           }
-           in += w;
-           nextRow += w;
-       }
-    }
-#endif
-
-    void halfSample(const BasicImage<byte>& in, BasicImage<byte>& out)
-    {   
-       if( (in.size()/2) != out.size())
-           throw Exceptions::Vision::IncompatibleImageSizes("halfSample");
-
-#if defined( __GNUC__) && defined(CVD_HAVE_SSE2)
-       if (is_aligned<16>(in.data()) && is_aligned<16>(out.data()) && 
((in.size().x % 16) == 0)) {
-           halfSampleSSE2(in.data(), out.data(), in.size().x, in.size().y);
-           return;
-       }
-#endif
-    
-       if (!is_aligned<8>(in.data()) || !is_aligned<8>(out.data()) || 
(in.size().x % 8 != 0))
-           halfSample<byte>(in, out);
-       else
-           Internal::Assembly::halfsample(in.data(), out.data(), in.size().x, 
in.size().y);
-    }
-#endif
-
-
-#if (CVD_HAVE_EMMINTRIN && CVD_HAVE_SSE2)
-    
-#define SORT2_SIMD_UB(a,b)                     \
-    {                                          \
-       const __m128i ta = a;                   \
-       a = _mm_min_epu8(a,b);                  \
-       b = _mm_max_epu8(ta,b);                 \
-    }
-    
-#define SORT3_SIMD_UB(a,b,c)                   \
-    {                                          \
-       SORT2_SIMD_UB(a,b);                     \
-       SORT2_SIMD_UB(b,c);                     \
-       SORT2_SIMD_UB(a,b);                     \
-    }
-    
-    namespace median {
-       inline __m128i median3(__m128i a, __m128i b, __m128i c) {
-           SORT2_SIMD_UB(a,b);
-           return _mm_max_epu8(a,_mm_min_epu8(b,c));
-       }
-       
-       __m128i median_3x3_simd(const byte* p, const int w)
-       {
-           __m128i a = _mm_loadu_si128((const __m128i*)(p-w-1));
-           __m128i b = _mm_loadu_si128((const __m128i*)(p-w));
-           __m128i c = _mm_loadu_si128((const __m128i*)(p-w+1));
-           SORT3_SIMD_UB(a,b,c);
-           __m128i d = _mm_loadu_si128((const __m128i*)(p-1));
-           __m128i e = _mm_loadu_si128((const __m128i*)(p));
-           __m128i f = _mm_loadu_si128((const __m128i*)(p+1));
-           SORT3_SIMD_UB(d,e,f);
-           __m128i g = _mm_loadu_si128((const __m128i*)(p+w-1));
-           __m128i h = _mm_loadu_si128((const __m128i*)(p+w));
-           __m128i i = _mm_loadu_si128((const __m128i*)(p+w+1));
-           SORT3_SIMD_UB(g,h,i);
-           e = median3(b,e,h);
-           g = _mm_max_epu8(_mm_max_epu8(a,d), g);
-           c = _mm_min_epu8(c, _mm_min_epu8(f,i));
-           return median3(c,e,g);
-       }
-       
-       void median_filter_3x3_simd(const byte* p, const int stride, const int 
n, byte* out)
-       {
-           int j = 0;
-           for (; j+15<n; j+=16, p+=16, out += 16) {
-               _mm_storeu_si128((__m128i*)out, median_3x3_simd(p,stride));
-           }
-           if (j < n) {
-               const int left = n - j;
-               if (n >= 16 && left > 8)
-                   _mm_storeu_si128((__m128i*)(out+left-16), 
median_3x3_simd(p+left-16,stride));
-               else
-                   median_filter_3x3(p, stride, left, out);
-           }
-       }
-       
-    }
-
-    void median_filter_3x3(const SubImage<byte>& I, SubImage<byte> out)
-    {
-       assert(out.size() == I.size());
-       const int s = I.row_stride();
-       const int n = I.size().x - 2;
-       for (int i=1; i+1<I.size().y; ++i)
-           median::median_filter_3x3_simd(I[i]+1, s, n, out[i]+1);
-    }
-#endif
-    
-
-};

Index: make/prog_dependencies.awk
===================================================================
RCS file: make/prog_dependencies.awk
diff -N make/prog_dependencies.awk
--- make/prog_dependencies.awk  3 May 2005 12:23:08 -0000       1.6
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,25 +0,0 @@
-BEGIN{
-       RS=" "
-       ORS=" "
-       a = -1
-}
-
-$0~stub{
-       print prev
-       prev=$1
-       next
-}
-
-!prev{
-       opts[$1]=1
-       next
-}
-
-!($1 in opts){prev=" "}
-
-END{
-       print prev
-}
-
-
-




reply via email to

[Prev in Thread] Current Thread [Next in Thread]