Update to 2.0.0 tree from current Fremantle build
[opencv] / configure.in
1 # Process this file with autoconf to produce a configure script.
2
3 # Set various version strings
4 m4_define([opencv_major_version],    [2])
5 m4_define([opencv_minor_version],    [0])
6 m4_define([opencv_subminor_version], [0])
7 m4_define([opencv_version],          [opencv_major_version.opencv_minor_version.opencv_subminor_version])
8
9 # Before making a release, the LT_VERSION string should be modified.
10 # See: http://www.gnu.org/software/libtool/manual.html#Versioning
11 #
12 # The string is of the form Current:Revision:Age.
13 #
14 # The following lines are taken from the GNU Libtool Manual:
15 # Here are a set of rules to help you update your library version information:
16 #
17 # Start with version information of 0:0:0 for each libtool library.
18 # Update the version information only immediately before a public release of your software.
19 # More frequent updates are unnecessary, and only guarantee that the current interface number
20 # gets larger faster.
21 #
22 # 1) If the library source code has changed at all since the last update,
23 #    then increment revision (c:r:a becomes c:r+1:a).
24 # 2) If any interfaces have been added, removed, or changed since the last update,
25 #    increment current, and set revision to 0.
26 # 3) If any interfaces have been added since the last public release, then increment age.
27 # 4) If any interfaces have been removed since the last public release, then set age to 0.
28 #
29 # Never try to set the interface numbers so that they correspond to the release number of your package.
30 # This is an abuse that only fosters misunderstanding of the purpose of library versions. Instead,
31 # use the -release flag (see Release numbers), but be warned that every release of your package will
32 # not be binary compatible with any other release.
33 m4_define([opencv_lt_version], [4:0:0])
34
35 # init autotools
36 # we need autoconf >= 2.62 beause of several macros in there
37 AC_PREREQ(2.63)
38 AC_INIT([opencv],[opencv_version],[opencvlibrary-devel@lists.sourceforge.net])
39 AC_CONFIG_SRCDIR([opencv.pc.in])
40 AC_CONFIG_AUX_DIR([autotools])
41 AC_CONFIG_MACRO_DIR([autotools/aclocal])
42
43 # put CVS revision of this configure.in into the resulting configure script
44 AC_REVISION($Revision: 1.60 $)
45
46 # Detect the canonical host and target build environment
47 AC_CANONICAL_HOST
48 AC_CANONICAL_TARGET
49
50 # setup automake - we need >= 1.6 because of python and aclocal support
51 #                  we updated to 1.9 because of cross-platform issues
52 AC_CONFIG_HEADERS([cvconfig.h])
53 AM_INIT_AUTOMAKE([1.9])
54 AC_PROG_MAKE_SET
55
56 # use ugly maintainer-mode flag to help CVS users that do not want to
57 # help developing OpenCV but just need to compile the latest version
58 # AM_MAINTAINER_MODE
59
60 # substitute versionnumbers
61 AC_SUBST(MMAJOR,     [opencv_major_version])
62 AC_SUBST(MMINOR,     [opencv_minor_version])
63 AC_SUBST(MSUBMINOR,  [opencv_subminor_version])
64 AC_SUBST(VERSION,    [opencv_version])
65 AC_SUBST(LT_VERSION, [opencv_lt_version])
66
67 # disable building static libraries,
68 # allow Cygwin to build DLLs
69 AC_DISABLE_STATIC
70 AC_LIBTOOL_WIN32_DLL
71
72 # Do compilation tests using CXX and CXXCPP and use extension .C for test programs. 
73 # Use compilation flags: CPPFLAGS with CXXCPP, and both CPPFLAGS and CXXFLAGS with CXX. 
74 AC_LANG(C++)
75
76 # checks for programs.
77 AC_PROG_CXXCPP
78 AC_PROG_CXX
79 AC_PROG_LIBTOOL
80
81
82 ######################################################################
83 # the following interpret 'with' and 'enable' switches.
84 # some of these switches trigger checks that can be found further
85 # below in this configure script
86
87 # does the user want aggressive optimization?
88 AC_ARG_ENABLE([debug],
89               [AS_HELP_STRING([--enable-debug],[build debug version without optimization [no]])],
90               [enable_debug=$enableval],
91               [enable_debug=no])
92
93 # does the user want to have automatic guess of suitable optimization options
94 AC_ARG_ENABLE([optimization],
95               [AS_HELP_STRING([--enable-optimization],[automatic guess of suitable optimization options [yes]])],
96               [enable_optimization=$enableval],
97               [enable_optimization=yes])
98
99 # does the user want to have SSE / SSE2 / SSE3 specified?
100 AC_ARG_ENABLE([sse],
101               [AS_HELP_STRING([--enable-sse],[enable SSE(2) intrinsics [automatic]])],
102               [enable_sse=$enableval],
103               [enable_sse=auto])
104
105 # does the user want to build demo applications?
106 AC_ARG_ENABLE([apps],
107               [AS_HELP_STRING([--enable-apps],[build demo applications [yes]])],
108               [enable_apps=$enableval],
109               [enable_apps="yes"])
110 AM_CONDITIONAL([BUILD_APPS], [test x"$enable_apps" = x"yes"])
111
112
113 # the following checks reflect the dependencies of OpenCV on other
114 # libraries that do the actual work for video I/O or windowing
115 # subsystem. On some platforms there are ambiguities that a user
116 # can influence. There is also additional logic to be found in code
117 # later code lines that tries to do sensible decisions on what to use
118
119 # does the user want to compile python modules as well?
120 AC_ARG_WITH([native-lapack],
121             [AS_HELP_STRING([--with-native-lapack],[use platform native BLAS and LAPACK [no]])],
122             [with_native_lapack=$withval],
123             [with_native_lapack=no])
124
125 # compile and link against OpenMP
126 # because of this: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28482
127 # we disable OpenMP by default. But one may enable it explicitly with --with-openmp
128 #AC_ARG_WITH([openmp],
129 #            [AS_HELP_STRING([--with-openmp],[use OpenMP threading [no]])],
130 #            [with_openmp=$withval],
131 #            [with_openmp=no])
132
133 # does the user want to compile python modules as well?
134 AC_ARG_WITH([swig],
135             [AS_HELP_STRING([--with-swig],[use swig wrapper generator [no]])],
136             [with_swig=$withval],
137             [with_swig=no])
138
139 # does the user want to compile python modules as well?
140 AC_ARG_WITH([python],
141             [AS_HELP_STRING([--with-python],[use python for wrapping [yes]])],
142             [with_python=$withval],
143             [with_python=yes])
144
145 # does the user want to compile octave modules as well?
146 AC_ARG_WITH([octave],
147             [AS_HELP_STRING([--with-octave],[use octave for wrapping [no]])],
148             [with_octave=$withval],
149             [with_octave=no])
150
151 # does the user want OpenCV to use xine video libraries?
152 AC_ARG_WITH([xine],
153             [AS_HELP_STRING([--with-xine],[use xine libraries (see LICENSE) [no]])],
154             [with_xine=$withval],
155             [with_xine=no])
156
157 # does the user want OpenCV to use the gstreamer multimedia framework?
158 AC_ARG_WITH([gstreamer],
159             [AS_HELP_STRING([--with-gstreamer],[use gstreamer multimedia framework (see LICENSE) [no]])],
160             [with_gstreamer=$withval],
161             [with_gstreamer=no])
162
163 # does the user want OpenCV to use ffmpeg video libraries?
164 AC_ARG_WITH([ffmpeg],
165             [AS_HELP_STRING([--with-ffmpeg],[use ffmpeg libraries (see LICENSE) [automatic]])],
166             [with_ffmpeg=$withval],
167             [with_ffmpeg=auto])
168
169 # does the user want OpenCV to use libraw1394/libdc1394 for video input?
170 AC_ARG_WITH([1394libs],
171             [AS_HELP_STRING([--with-1394libs],[use libraw1394/libdc1394 [automatic]])],
172             [with_1394libs=$withval],
173             [with_1394libs=auto])
174
175 # does the user want OpenCV to use the video4linux kernel module?
176 AC_ARG_WITH([v4l],
177             [AS_HELP_STRING([--with-v4l],[use video4linux [automatic]])],
178             [with_v4l=$withval],
179             [with_v4l=auto])
180
181 # does the user want OpenCV to use the unicap library?
182 AC_ARG_WITH([unicap],
183             [AS_HELP_STRING([--with-unicap],[use unicap (see LICENSE) [no]])],
184             [with_unicap=$withval],
185             [with_unicap=no])
186
187 # does the user want OpenCV to use image libraries from OS X 10.4?
188 AC_ARG_WITH([imageio],
189             [AS_HELP_STRING([--with-imageio],[use ImageIO libraries [automatic]])],
190             [with_imageio=$withval],
191             [with_imageio=yes])
192
193 # does the user want OpenCV to use QuickTime video libraries?
194 AC_ARG_WITH([quicktime],
195             [AS_HELP_STRING([--with-quicktime],[use QuickTime libraries [automatic]])],
196             [with_quicktime=$withval],
197             [with_quicktime=yes])
198
199 # does the user want OpenCV to use the Carbon GUI of Mac OS X?
200 AC_ARG_WITH([carbon],
201             [AS_HELP_STRING([--with-carbon],[use Carbon windows [automatic]])],
202             [with_carbon=$withval],
203             [with_carbon=yes])
204
205 # does the user want OpenCV to use GTK+ 2.0 for the GUI?
206 AC_ARG_WITH([gtk],
207             [AS_HELP_STRING([--with-gtk],[use gtk+ 2.0 windows [automatic]])],
208             [with_gtk=$withval],
209             [with_gtk=auto])
210
211 # does the user want OpenCV to use gthread for GTK+ threaded HighGUI?
212 AC_ARG_WITH([gthread],
213             [AS_HELP_STRING([--with-gthread],[use gthread in addition to gtk+ [automatic]])],
214             [with_gthread=$withval],
215             [with_gthread=auto])
216
217
218 ######################################################################
219 # Compiler options
220
221 # OpenMP support
222 # macro calls AC_SUBST(OPENMP_CXXFLAGS)
223 # and brings its own enable/disable switch ("--disable-openmp")
224 # AC_OPENMP
225
226 # SSE/SSE2/SSE3 support
227 if test x"$enable_sse" = "xauto"; then
228   # This macro calls:
229   #   AC_SUBST(SIMD_FLAGS)
230   # And defines:
231   #   HAVE_MMX / HAVE_SSE / HAVE_SSE2 / HAVE_SSE3 / HAVE_SSSE3
232   AX_EXT
233 else
234   if test x"$enable_sse" = "xyes"; then
235     AC_DEFINE(HAVE_MMX,,[Support mmx instructions])
236     AC_DEFINE(HAVE_SSE,,[Support SSE (Streaming SIMD Extensions) instructions])
237     AC_DEFINE(HAVE_SSE2,,[Support SSE2 (Streaming SIMD Extensions 2) instructions])
238     #AC_DEFINE(HAVE_SSE3,,[Support SSE3 (Streaming SIMD Extensions 3) instructions])
239     #AC_DEFINE(HAVE_SSSE3,,[Support SSSE3 (Supplemental Streaming SIMD Extensions 3) instructions])
240     
241     SIMD_FLAGS=" -mmmx -msse -msse2"
242     AC_SUBST(SIMD_FLAGS)
243   fi
244 fi
245
246
247 ## check whether to include debugging compiler flags
248 AC_MSG_CHECKING([whether to build debug version])
249 DEBUG_CPPFLAGS=""
250 DEBUG_CXXFLAGS=""
251 if test x"$enable_debug" = "xyes"; then
252   AC_MSG_RESULT([yes])
253   
254   if test x"$ac_cv_c_compiler_gnu" = "xyes"; then
255     DEBUG_CXXFLAGS="-ggdb"
256   fi
257   
258   DEBUG_CPPFLAGS="-DDEBUG -D_DEBUG"
259 else
260   AC_MSG_RESULT([no])
261 fi
262 AC_SUBST(DEBUG_CPPFLAGS)
263 AC_SUBST(DEBUG_CXXFLAGS)
264
265
266 ## see if the user wants aggressive optimizations of the code
267 AC_MSG_CHECKING([whether to enable aggressive optimization flags])
268 OPTIMIZATION_CPPFLAGS=""
269 OPTIMIZATION_CXXFLAGS=""
270 FLOAT_STORE_CFLAGS=""
271 if test x"$enable_optimization" = "xyes"; then
272   AC_MSG_RESULT([yes])
273   
274   # cure annoying default arguments for CFLAGS and CXXFLAGS
275   # that autoconf automatically sets in GNU environments if
276   # no CFLAGS or CXXFLAGS were manually given
277   #
278   # this is a more or less a hack ...
279   if test x"$CFLAGS" = x"-g -O2" ; then
280     CFLAGS=""
281   fi
282   if test x"$CXXFLAGS" = x"-g -O2" ; then
283     CXXFLAGS=""
284   fi
285   
286   if test x"$ac_cv_c_compiler_gnu" = "xyes"; then
287     
288     # special flag for gcc to work around excess precision bug in cLapack
289     FLOAT_STORE_CFLAGS="-ffloat-store"
290
291     # Due to a misconception, until SVN revision r1713, the case statement
292     # used the value of '--target', not of '--host'
293     case $host in
294     i386-apple-*)
295       # all intel macs have at least prescott instruction set
296       OPTIMIZATION_CXXFLAGS="-fast -g"
297       ;;
298     x86_64-apple-*)
299       # all 64bit intel macs have at least nocona instruction set
300       OPTIMIZATION_CXXFLAGS="-fast -g -march=nocona"
301       ;;
302     i?86-*-*)
303       # okay, we use this default together with the specification of the target architecture
304       # let us just assume, a Pentium 4 would be the minimum platform for OpenCV,
305       # then SSE2 instruction set is available also
306       OPTIMIZATION_CXXFLAGS="-O3 -g -march=pentium4 -ffast-math -fomit-frame-pointer"
307       ;;
308     amd64-*-* | x86_64-*-*)
309       OPTIMIZATION_CXXFLAGS="-O3 -g -march=x86-64 -ffast-math -fomit-frame-pointer"
310       ;;
311     powerpc-apple-*)
312       # Mac OS X 10.4 runs on CPUs >= G4 only
313       OPTIMIZATION_CXXFLAGS="-O3 -falign-loops-max-skip=15 -falign-jumps-max-skip=15 -falign-loops=16 -falign-jumps=16 -falign-functions=16 -ffast-math -fstrict-aliasing -funroll-loops -ftree-loop-linear -ftree-loop-memset -mcpu=G4 -mpowerpc-gpopt -mtune=G5 -fsched-interblock -fgcse-sm -g"
314       ;;
315     powerpc64-apple-*)
316       # There are no 64bit Macs with a CPU that's not a G5
317       OPTIMIZATION_CXXFLAGS="-O3 -falign-loops-max-skip=15 -falign-jumps-max-skip=15 -falign-loops=16 -falign-jumps=16 -falign-functions=16 -ffast-math -fstrict-aliasing -funroll-loops -ftree-loop-linear -ftree-loop-memset -mcpu=G5 -mpowerpc-gpopt -fsched-interblock -fgcse-sm -m64 -g"
318       ;;
319     powerpc-*-*)
320       # generic PowerPCs don't have Apple's 'fast' or 'fastf' switch
321       OPTIMIZATION_CXXFLAGS="-O3 -g -mcpu=G3 -mtune=G4 -fomit-frame-pointer"
322       ;;
323     *-*-*)
324       OPTIMIZATION_CXXFLAGS="-O2 -fomit-frame-pointer"
325       ;;
326     esac
327   fi
328   
329   OPTIMIZATION_CPPFLAGS="-DNDEBUG"
330 else
331   AC_MSG_RESULT([no])
332 fi
333 AC_SUBST(OPTIMIZATION_CPPFLAGS)
334 AC_SUBST(OPTIMIZATION_CXXFLAGS)
335 AC_SUBST(FLOAT_STORE_CFLAGS)
336
337 # basic libraries needed by OpenCV
338 AC_CHECK_LIB(m,pow)
339 AC_CHECK_LIB(dl,dlopen)
340 AC_CHECK_LIB(pthread,pthread_create)
341 AC_CHECK_LIB(z,gzputs)
342
343 # check endianness
344 AC_C_BIGENDIAN
345
346 # check for specific functions that might be missing from
347 # certain standard library implementations
348 AC_FUNC_ALLOCA
349 AC_CHECK_HEADERS([malloc.h])
350 AC_CHECK_HEADERS([assert.h])
351 AC_CHECK_FUNCS(lrint)
352 AC_SEARCH_LIBS([clock_gettime],[rt])
353
354 ######################################################################
355 # BLAS and LAPACK
356
357 LAPACK_LIBS=""
358 have_native_lapack=no
359 if test x"$with_native_lapack" = "xyes"; then
360   # check for Accellerate framework on Mac OS X
361   # 
362   # As of Mac OS X 10.5 blas and lapack exist as standard shared 
363   # libraries, so this check could be replaced by separate checks for
364   # those two libraries as it may be helpful for Linux/Unix variants
365   # as well.
366   AC_CHECK_HEADER([vecLib/clapack.h],
367                 [
368                   AC_DEFINE(HAVE_VECLIB,,[BLAS and LAPACK from Accelerate/vecLib framework])
369                   LAPACK_LIBS="-Xlinker -framework -Xlinker vecLib"
370                   have_native_lapack=yes
371                 ],
372                 [
373                   have_native_lapack=no
374                 ])
375 fi
376
377 AC_SUBST(LAPACK_LIBS)
378 AM_CONDITIONAL([NATIVE_LAPACK], [test x"$have_native_lapack" = "xyes"])
379
380
381 ######################################################################
382 # HighGUI dependencies for windowing system
383
384 # honor user selection,
385 # if no selection given check for Carbon first
386 CARBON_CFLAGS=""
387 CARBON_LIBS=""
388 if test x"$with_carbon" = "xyes"; then
389
390     # header presence and usability seem to be enough
391     AC_CHECK_HEADER([Carbon/Carbon.h],
392                     [
393                       AC_DEFINE(HAVE_CARBON,,[Carbon windowing environment])
394                       CARBON_LIBS="-Xlinker -framework -Xlinker Carbon"
395                       have_carbon=yes
396                     ],
397                     [
398                       have_carbon=no
399                       with_carbon=no
400                     ])
401
402     # sanity checks
403     if test x"$have_carbon" = "xyes"; then
404
405         # if we asked for gtk, this is not ok
406         if test x"$with_gtk" = "xyes"; then
407             AC_MSG_ERROR([You cannot specify --with-carbon and --with-gtk at the same time])
408         fi
409
410         # don't check alternatives if carbon was found
411         if test x"$with_gtk" = "xauto"; then
412             with_gtk=no
413         fi
414     fi
415 else
416     have_carbon=no
417     if test ! x"$with_carbon" = "xno"; then
418         AC_MSG_WARN([unexpected arguments for option --with-carbon, continuing assuming 'no'])
419     fi
420 fi
421 AC_SUBST(CARBON_CFLAGS)
422 AC_SUBST(CARBON_LIBS)
423 AM_CONDITIONAL([BUILD_CARBON], [test x"$have_carbon" = "xyes"])
424
425 # use GTK+ 2.x (or later) for windowing
426 # if carbon not present or not wanted (--without-carbon)
427 GTK_CFLAGS=""
428 GTK_LIBS=""
429 GTHREAD_CFLAGS=""
430 GTHREAD_LIBS=""
431 if test x"$with_gtk" = "xno"; then
432     have_gtk=no
433 else
434
435     # check if ./configure arguments are valid
436     if test x"$with_gtk" = "xauto"; then
437        with_gtk=yes
438     fi
439     if test x"$with_gtk" = "xyes"; then
440
441         # pkg-config is needed for GTK+
442         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
443         if test x"$PKG_CONFIG" = x"no"; then
444             AC_MSG_WARN([You have to install pkg-config to compile OpenCV with GTK+])
445         else
446             PKG_CHECK_MODULES(GTK, "gtk+-2.0 gdk-pixbuf-2.0",
447                               [
448                                 have_gtk=yes
449                                 AC_DEFINE(HAVE_GTK,,[GTK+ 2.x toolkit])
450                               ],
451                               [ have_gtk=no ])
452         fi
453     else
454         # if we get here then --with-gtk was not called with 'yes','no' or 'auto'
455         AC_MSG_WARN([unexpected arguments for option --with-gtk, continuing assuming 'no'])
456         have_gtk=no
457     fi
458 fi
459 if test x"$with_gthread" = "xno"; then
460     have_gthread=no
461 else
462     if test x"$have_gtk" = "xyes"; then
463         if test x"$with_gthread" = "xauto"; then
464             with_gthread=yes
465         fi
466
467         if test x"$with_gthread" = "xyes"; then
468             PKG_CHECK_MODULES(GTHREAD, "gthread-2.0",
469                               [
470                                 have_gthread=yes
471                                 AC_DEFINE(HAVE_GTHREAD,,[GTK+ 2.0 Thread support])
472                               ],
473                               [ have_gthread=no ])
474         else
475             # if we get here then --with-gthread was not called with 'yes','no' or 'auto'
476             AC_MSG_WARN([unexpected arguments for option --with-gthread, continuing assuming 'no'])
477             have_gthread=no
478         fi
479     else
480         # if no gtk+ was detected, looking for gthread does not make any sense
481         have_gthread=no
482     fi
483 fi
484 AC_SUBST(GTK_CFLAGS)
485 AC_SUBST(GTK_LIBS)
486 AC_SUBST(GTHREAD_CFLAGS)
487 AC_SUBST(GTHREAD_LIBS)
488 AM_CONDITIONAL([BUILD_GTK], [test x"$have_gtk" = "xyes"])
489
490
491 ######################################################################
492 # HighGUI dependencies for video I/O
493
494 # if QuickTime is present, it will override everything else,
495 # (unless '--without-quicktime' was given)
496 if test x"$with_quicktime" = "xyes"; then
497
498     # check other ./configure flags
499     if test x"$with_ffmpeg" = "xyes"; then
500         AC_MSG_ERROR([You cannot specify --with-quicktime and --with-ffmpeg at the same time])
501     fi
502     if test x"$with_xine" = "xyes"; then
503         AC_MSG_ERROR([You cannot specify --with-quicktime and --with-xine at the same time])
504     fi
505     if test x"$with_1394libs" = "xyes"; then
506         AC_MSG_ERROR([You cannot specify --with-quicktime and --with-1394libs at the same time])
507     fi
508     if test x"$with_v4l" = "xyes"; then
509         AC_MSG_ERROR([You cannot specify --with-quicktime and --with-v4l at the same time])
510     fi
511
512     # header presence and usability seem to be enough
513     AC_CHECK_HEADER([QuickTime/QuickTime.h],
514                     [
515                       AC_DEFINE(HAVE_QUICKTIME,,[QuickTime video libraries])
516                       have_quicktime=yes
517                     ],
518                     [ have_quicktime=no ])
519
520     # specify quicktime libraries
521     if test x"$have_quicktime" = "xyes"; then
522         QUICKTIME_LIBS="-Xlinker -framework -Xlinker QuickTime -Xlinker -framework -Xlinker QuartzCore"
523
524         # don't check alternatives if quicktime was found
525         if test x"$with_ffmpeg" = "xauto"; then
526             with_ffmpeg=no
527         fi
528         if test x"$with_xine" = "xauto"; then
529             with_xine=no
530         fi
531         if test x"$with_1394libs" = "xauto"; then
532             with_1394libs=no
533         fi
534         if test x"$with_v4l" = "xauto"; then
535             with_v4l=no
536         fi
537     fi
538 else
539     # check if ./configure arguments are valid
540     have_quicktime=no
541     if test ! x"$with_quicktime" = "xno"; then
542         AC_MSG_WARN([unexpected arguments for option --with-quicktime, continuing assuming 'no'])
543     fi
544 fi
545 AC_SUBST(QUICKTIME_CFLAGS)
546 AC_SUBST(QUICKTIME_LIBS)
547 AM_CONDITIONAL([BUILD_QUICKTIME], [test x"$have_quicktime" = "xyes"])
548
549 # GStreamer seems to be a nice solution for both reading and writing
550 # and even supports some cameras
551 GSTREAMER_CFLAGS=""
552 GSTREAMER_LIBS=""
553 if test x"$with_gstreamer" = "xno"; then
554     have_gstreamer=no
555 else
556
557     if test x"$with_ffmpeg" = "xyes"; then
558         AC_MSG_ERROR([You cannot specify --with-gstreamer and --with-ffmpeg at the same time])
559     fi
560
561     # check if ./configure arguments are valid
562     if test x"$with_gstreamer" = "xauto"; then
563        with_gstreamer=yes
564     fi
565     if test x"$with_gstreamer" = "xyes"; then
566
567         # pkg-config is needed for GTK+
568         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
569         if test x"$PKG_CONFIG" == "xno"; then
570             AC_MSG_ERROR([You have to install pkg-config to compile OpenCV with GStreamer])
571         fi
572
573         PKG_CHECK_MODULES(GSTREAMER, "gstreamer-0.10",
574                           [
575                             have_gstreamer=yes
576                             AC_DEFINE(HAVE_GSTREAMER,,[GStreamer multimedia framework])
577                           ],
578                           [ have_gstreamer=no ])
579
580         if test x"$have_gstreamer" = "xyes"; then
581             GSTREAMER_LIBS="$GSTREAMER_LIBS -lgstbase-0.10"
582             with_ffmpeg=no
583         fi
584     else
585         # if we get here then --with-gstreamer was not called with 'yes','no' or 'auto'
586         AC_MSG_WARN([unexpected arguments for option --with-gstreamer, continuing assuming 'no'])
587         have_gstreamer=no
588     fi
589 fi
590 AC_SUBST(GSTREAMER_CFLAGS)
591 AC_SUBST(GSTREAMER_LIBS)
592 AM_CONDITIONAL([BUILD_GSTREAMER], [test x"$have_gstreamer" = "xyes"])
593
594 # Check for the unicap library
595 UNICAP_PACKAGE_LIBS=""
596 UNICAP_PACKAGE_CFLAGS=""
597 UCIL_PACKAGE_LIBS=""
598 UCIL_PACKAGE_CFLAGS=""
599 if test x"$with_unicap" = "xno"; then
600     have_unicap=no
601 else
602         PKG_CHECK_MODULES(UNICAP_PACKAGE,libunicap)
603         PKG_CHECK_MODULES(UCIL_PACKAGE,libucil)
604         have_unicap=yes
605         AC_DEFINE(HAVE_UNICAP,,[Unicap video capture library])
606 fi
607 AM_CONDITIONAL([BUILD_UNICAP], [test x"$have_unicap" = "xyes"])
608 AC_SUBST(UNICAP_PACKAGE_LIBS)
609 AC_SUBST(UNICAP_PACKAGE_CFLAGS)
610 AC_SUBST(UCIL_PACKAGE_LIBS)
611 AC_SUBST(UCIL_PACKAGE_CFLAGS)
612
613 # prefer XINE over FFMPEG for video reading because it is quick, has a cleaner API
614 # and allows for easy seeking with some formats
615 if test x"$with_xine" = "xno"; then
616     have_xine=no
617     # XINE_LIBS=""
618 else
619
620     # check if ./configure arguments are valid
621     if test x"$with_xine" = "xauto"; then
622        with_xine=yes
623     fi
624     if test x"$with_xine" = "xyes"; then
625         AC_CHECK_HEADER(xine.h,
626                         AC_CHECK_LIB(xine, xine_init,
627                                     [
628                                       have_xine=yes
629                                       AC_DEFINE(HAVE_XINE,,[Xine video library])
630                                       XINE_LIBS="-lxine"
631                                     ],
632                                     [ have_xine=no ]),
633                         [ have_xine=no ])
634     else
635         # if we get here then --with-xine was not called with 'yes','no' or 'auto'
636         AC_MSG_WARN([unexpected arguments for option --with-xine, continuing assuming 'no'])
637         have_xine=no
638     fi
639 fi
640 AC_SUBST(XINE_LIBS)
641 AM_CONDITIONAL([BUILD_XINE], [test x"$have_xine" = "xyes"])
642
643 # unfortunately, xine does not feature video writing,
644 # so we have to resort to FFMPEG here
645 if test x"$with_ffmpeg" = "xno"; then
646     have_ffmpeg=no
647     # FFMPEGLIBS=""
648 else
649     
650     have_ffmpeg=no
651     have_avcodec=no
652     have_avformat=no
653     
654     # check if ./configure arguments are valid
655     if test x"$with_ffmpeg" = "xauto"; then
656        with_ffmpeg=yes
657     fi
658     
659     if test x"$with_ffmpeg" = "xyes"; then
660         AC_CHECK_HEADERS([ffmpeg/avcodec.h libavcodec/avcodec.h],[have_avcodec=yes])
661         AC_CHECK_HEADERS([ffmpeg/avformat.h libavformat/avformat.h],[have_avformat=yes])
662         
663         if test x"$have_avcodec"x"$have_avformat" = "xyesxyes" ; then
664             AC_SEARCH_LIBS([avcodec_decode_video],[avcodec_pic avcodec],[
665                 AC_SEARCH_LIBS([av_open_input_file], [avformat_pic avformat],[have_ffmpeg=yes],[],[-lavcodec])])
666         fi
667         
668         if test x"$have_ffmpeg" = "xyes" ; then
669             # libswscale is not always necessary, but if it is there, we want to use it
670             AC_CHECK_HEADERS([ffmpeg/swscale.h libswscale/swscale.h],[
671                 AC_CHECK_LIB([swscale],[sws_getContext],[FFMPEG_SWSCALE_LIBS="-lswscale"
672                     AC_DEFINE(HAVE_FFMPEG_SWSCALE,,[FFMPEG helper library])])])
673             
674             AC_DEFINE(HAVE_FFMPEG,,[FFMPEG video library])
675             FFMPEGLIBS="-lavcodec -lavformat $FFMPEG_SWSCALE_LIBS"
676         fi
677     else
678         # if we get here then --with-ffmpeg was not called with 'yes','no' or 'auto'
679         AC_MSG_WARN([unexpected arguments for option --with-ffmpeg, continuing assuming 'no'])
680         have_ffmpeg=no
681     fi
682 fi
683 AC_SUBST(FFMPEGLIBS)
684 AM_CONDITIONAL([BUILD_FFMPEG], [test x"$have_ffmpeg" = "xyes"])
685
686 # IEEE1394 / FireWire video video i/o with libdc1394, libraw1394
687 # (can be managed by QuickTime as well)
688 if test x"$with_1394libs" = "xno"; then
689     have_raw1394=no
690     have_dc1394=no
691     have_dc1394_2=no
692     # IEEE1394LIBS=""
693 else
694
695     # check if ./configure arguments are valid
696     if test x"$with_1394libs" = "xauto"; then
697        with_1394libs=yes
698     fi
699     if test x"$with_1394libs" = "xyes"; then
700
701         SAVELIBS="$LIBS"
702         have_raw1394=no
703         have_dc1394=no
704         have_dc1394_2=no
705
706         AC_CHECK_HEADER(libraw1394/raw1394.h,
707                         AC_CHECK_LIB(raw1394, raw1394_new_handle,
708                                      [
709                                        have_raw1394=yes
710                                        LIBS="-lraw1394 $LIBS"
711                                      ]))
712
713         if test x"$have_raw1394" = "xyes"; then
714             AC_CHECK_HEADER(dc1394/dc1394.h,
715                             AC_CHECK_LIB(dc1394, dc1394_camera_enumerate,
716                                          [
717                                            have_dc1394_2=yes
718                                            AC_DEFINE(HAVE_DC1394_2,,[IEEE1394 capturing support])
719                                            IEEE1394LIBS="-lraw1394 -ldc1394"
720                                          ]))
721             
722             if test x"$have_dc1394_2" = "xno"; then
723                 AC_CHECK_HEADER(libdc1394/dc1394_control.h,
724                                 AC_CHECK_LIB(dc1394_control, dc1394_camera_on,
725                                              [
726                                                have_dc1394=yes
727                                                AC_DEFINE(HAVE_DC1394,,[IEEE1394 capturing support])
728                                                AC_EGREP_HEADER(do_extra_buffering, libdc1394/dc1394_control.h,
729                                                                [AC_DEFINE(HAVE_DC1394_095,,[libdc1394 0.9.4 or 0.9.5])])
730                                                IEEE1394LIBS="-lraw1394 -ldc1394_control"
731                                              ]))
732             fi
733         fi
734
735         LIBS="$SAVELIBS"
736     else
737         # if we get here then --with-1394libs was not called with 'yes','no' or 'auto'
738         AC_MSG_WARN([unexpected arguments for option --with-1394libs, continuing assuming 'no'])
739         have_dc1394=no
740     fi
741 fi
742 AC_SUBST(IEEE1394LIBS)
743 AM_CONDITIONAL([BUILD_DC1394], [test x"$have_dc1394" = "xyes"])
744 AM_CONDITIONAL([BUILD_DC1394_2], [test x"$have_dc1394_2" = "xyes"])
745
746 # Video for Linux (V4L)
747 # we support version 1 and 2 currently
748 if test x"$with_v4l" = "xno"; then
749     have_v4l=no
750     have_v4l2=no
751     have_v4l1or2=no
752 else
753     # check if ./configure arguments are valid
754     if test x"$with_v4l" = "xauto"; then
755        with_v4l=yes
756     fi
757     if test x"$with_v4l" = "xyes"; then
758         AC_CHECK_HEADER([linux/videodev.h],
759                         [
760                           AC_DEFINE(HAVE_CAMV4L,,[V4L capturing support])
761                           have_v4l=yes
762                           have_v4l1or2=yes
763                         ],
764                         [
765                           have_v4l=no
766                           have_v4l1or2=no
767                         ])
768         AC_CHECK_HEADER([linux/videodev2.h],
769                         [
770                           AC_DEFINE(HAVE_CAMV4L2,,[V4L2 capturing support])
771                           have_v4l2=yes
772                           have_v4l1or2=yes
773                         ],
774                         [ have_v4l2=no ],
775                 [[
776                 #include <asm/types.h>
777                 #include <sys/time.h>
778                 ]])
779     else
780         # if we get here then --with-v4l was not called with 'yes','no' or 'auto'
781         AC_MSG_WARN([unexpected arguments for option --with-v4l, continuing assuming 'no'])
782         have_v4l=no
783         have_v4l2=no
784         have_v4l1or2=no
785     fi
786
787 fi
788 AM_CONDITIONAL([BUILD_V4L], [test x"$have_v4l1or2" = "xyes"])
789
790
791 ######################################################################
792 # HighGUI dependencies for image I/O
793
794 SAVELIBS="$LIBS"
795 IMAGELIBS=""
796
797 AC_SUBST(IMAGELIBS)
798
799 have_imageio=no
800 if test x"$with_imageio" = "xauto"; then
801     with_imageio=yes
802 fi
803 if test x"$with_imageio" = "xyes"; then
804     AC_CHECK_HEADER([ApplicationServices/ApplicationServices.h],
805                     [
806                       have_imageio=yes
807                       AC_DEFINE(HAVE_IMAGEIO,,[Apple ImageIO Framework])
808                       IMAGELIBS="$IMAGELIBS -framework ApplicationServices"
809                       LIBS="$LIBS -framework ApplicationServices"
810                     ],
811                     [ have_imageio=no ])
812 fi
813 AM_CONDITIONAL([BUILD_IMAGEIO], [test x"$have_imageio" = "xyes"])
814
815
816 have_jpeg=no
817 have_zlib=no
818 have_png=no
819 have_tiff=no
820
821 # there are problems with dependencies of ImageIO to libtiff, etc.
822 # that we avoid by not linking them ourselves
823 if test x"$have_imageio" = "xno" ; then
824
825   AC_CHECK_HEADER(jpeglib.h,
826                   AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
827                                [
828                                  have_jpeg=yes
829                                  AC_DEFINE(HAVE_JPEG,,[IJG JPEG codec])
830                                  IMAGELIBS="$IMAGELIBS -ljpeg"
831                                ]))
832
833   AC_CHECK_HEADER(zlib.h,
834                   AC_CHECK_LIB(z, gzopen,
835                                [
836                                  have_zlib=yes
837                                  AC_DEFINE(HAVE_ZLIB,,[LZ77 compression/decompression library (used for PNG)])
838                                  IMAGELIBS="$IMAGELIBS -lz"
839                                  LIBS="$LIBS -lz"
840                                ]))
841
842   AC_CHECK_HEADER(png.h,
843                   [
844                     AC_DEFINE(HAVE_PNG_H,,[png.h needs to be included])
845                     have_png=yes
846                   ])
847   AC_CHECK_HEADER([libpng/png.h],
848                   [
849                     AC_DEFINE(HAVE_LIBPNG_PNG_H,,[libpng/png.h needs to be included])
850                     have_png=yes
851                   ])
852
853   if test x"$have_png" = "xyes"; then
854     AC_CHECK_LIB(png12, png_read_image,
855                  [
856                    have_png=yes
857                    AC_DEFINE(HAVE_PNG,,[PNG codec])
858                    IMAGELIBS="-lpng12 $IMAGELIBS"
859                    LIBS="-lpng12 $LIBS"
860                    AC_CHECK_FUNCS(png_get_valid png_set_tRNS_to_alpha)
861                  ],
862                  [ have_png=no ])
863   fi
864
865   AC_CHECK_HEADER(tiff.h,
866                   AC_CHECK_LIB(tiff, TIFFReadRGBAStrip,
867                                [
868                                  have_tiff=yes
869                                  AC_DEFINE(HAVE_TIFF,,[TIFF codec])
870                                  IMAGELIBS="$IMAGELIBS -ltiff"
871                                  LIBS="$LIBS -ltiff"
872                                ]))
873 fi
874
875 have_jasper=no
876 AC_CHECK_HEADER(jasper/jasper.h,
877                 AC_CHECK_LIB(jasper, jas_image_readcmpt,
878                              [
879                                have_jasper=yes
880                                AC_DEFINE(HAVE_JASPER,,[JPEG-2000 codec])
881                                IMAGELIBS="$IMAGELIBS -ljasper"
882                                LIBS="$LIBS -ljasper"
883                              ]))
884
885 have_ilmimf=no
886 AC_CHECK_HEADER(ImfCRgbaFile.h,
887                 AC_CHECK_LIB(IlmImf, ImfInputReadPixels,
888                              [
889                                have_ilmimf=yes
890                                AC_DEFINE(HAVE_ILMIMF,,[OpenEXR codec])
891                                IMAGELIBS="$IMAGELIBS -lIlmImf -lIex -lHalf"
892                                LIBS="$LIBS -lIlmImf -lIex -lHalf"
893                              ],,
894                              [ -lIex -lHalf ]))
895
896 # Restore original LIBS settings...
897 LIBS="$SAVELIBS"
898 AC_SUBST(IMAGELIBS)
899
900
901 ######################################################################
902 # SWIG wrappers
903
904 # each language should have --with-LANGUAGE switch
905
906 # check for python
907 if test x"$with_python" = "xyes"; then
908     AC_MSG_NOTICE([Checking for necessary tools to build python wrappers])
909
910     # we need Python now
911     AM_PATH_PYTHON()
912
913     # get some info on how to compile and link python modules
914     AZ_PYTHON_CSPEC()
915     AZ_PYTHON_LSPEC()
916
917     # if not explicitly forbidden, check for swig also
918     if test x"$with_swig" = "xauto"; then
919         with_swig=yes
920     fi
921
922     ### almost ok... just need to check if we have the Python headers ###
923
924     # first, save the CPPFLAGS
925     OLD_CPPFLAGS=$CPPFLAGS
926
927     # then add the PYTHON path founded previously
928     CPPFLAGS="$CPPFLAGS $PYTHON_CSPEC"
929
930     # now, we can check
931     AC_CHECK_HEADER(Python.h,
932         [have_python=yes],
933         [
934           AC_MSG_WARN([Python headers not found, disabling python wrappers])
935           have_python=no
936         ])
937
938     # restore the old CPPFLAGS
939     CPPFLAGS=$OLD_CPPFLAGS
940
941 else
942     # check if ./configure arguments are valid
943     if test x"$with_python" = "xno"; then
944         have_python=no
945     else
946         # if we get here then --with-python was not called with 'yes','no' or 'auto'
947         AC_MSG_WARN([unexpected arguments for option --with-python, continuing assuming 'no'])
948         have_python=no
949     fi
950 fi
951 AM_CONDITIONAL([BUILD_PYTHON_WRAPPERS], [test x"$have_python" = "xyes"])
952
953 # check for octave
954 if test x"$with_octave" = "xyes"; then
955     AC_MSG_NOTICE([Checking for necessary tools to build octave wrappers])
956
957     # find octave and mkoctfile
958     AC_PATH_PROG(OCTAVE,octave)
959     AC_PATH_PROG(MKOCTFILE,mkoctfile)
960
961     if test -z "$OCTAVE"; then
962        AC_MSG_WARN([octave not found, disabling octave wrappers])
963        with_octave=no
964     fi
965     if test -z "$MKOCTFILE"; then
966        AC_MSG_WARN([mkoctfile not found, disabling octave wrappers])
967        with_octave=no
968     fi
969     OCTAVE_INCFLAGS=`$MKOCTFILE -p INCFLAGS`
970     AC_SUBST(OCTAVE_INCFLAGS,[$OCTAVE_INCFLAGS])
971 fi
972 if test x"$with_octave" = "xyes"; then
973     # check that octave version is at least 2.9.12
974     cat > conftest.m <<'EOF'
975 [[a,b,c]]=sscanf([[version()," "]],"%i.%i.%i","C");
976 exit(sum([[a,b,c]].*[[1e5,1e3,1]])<209012)
977 EOF
978     $OCTAVE --no-init-file conftest.m >& /dev/null || with_octave="no";
979     rm -f conftest.m
980
981     if test x"$with_octave" = "xno"; then
982        AC_MSG_WARN([Octave version < 2.9.12, disabling octave wrappers])
983     fi
984 fi
985 if test x"$with_octave" = "xyes"; then
986     # if not explicitly forbidden, check for swig also
987     if test x"$with_swig" = "xauto"; then
988         with_swig=yes
989     fi
990
991     # check that we have octave headers
992     OLD_CPPFLAGS=$CPPFLAGS
993     CPPFLAGS="$CPPFLAGS -x c++ $OCTAVE_INCFLAGS"
994     AC_CHECK_HEADER(octave/oct.h,
995         [have_octave=yes],
996         [
997           AC_MSG_WARN([Octave headers not found, disabling octave wrappers])
998           have_octave=no
999         ])
1000     
1001     # restore the old CPPFLAGS
1002     CPPFLAGS=$OLD_CPPFLAGS
1003
1004     # find Octave arch
1005     AC_MSG_CHECKING([for Octave arch])
1006     OCTAVE_ARCH=`$OCTAVE -q --eval 'strcat(octave_config_info("canonical_host_type"), "-", octave_config_info("api_version"))'|sed -e 's/ans = //'`
1007     AC_MSG_RESULT([$OCTAVE_ARCH])
1008     AC_SUBST(OCTAVE_ARCH,[$OCTAVE_ARCH])
1009
1010 else
1011     # check if ./configure arguments are valid
1012     if test x"$with_octave" = "xno"; then
1013         have_octave=no
1014     else
1015         # if we get here then --with-octave was not called with 'yes','no' or 'auto'
1016         AC_MSG_WARN([unexpected arguments for option --with-octave, continuing assuming 'no'])
1017         have_octave=no
1018     fi
1019 fi
1020 AM_CONDITIONAL([BUILD_OCTAVE_WRAPPERS], [test x"$have_octave" = "xyes"])
1021
1022 # check for swig itself
1023 SWIG=""
1024 if test x"$with_swig" = "xyes"; then
1025     AC_MSG_NOTICE([Checking for SWIG])
1026
1027         # Python 2.5 requires SWIG >= 1.3.30
1028         AM_PYTHON_CHECK_VERSION( [2.5], have_python25=yes, have_python25=no )
1029         if test x"$have_python25" = "xyes" ; then
1030                 AC_PATH_SWIG([1.3.30])
1031         else
1032                 AC_PATH_SWIG([1.2.24])
1033         fi
1034
1035
1036     if test -n "$SWIG"; then
1037         SWIG_ENABLE_CXX()
1038         SWIG_MULTI_MODULE_SUPPORT()
1039
1040         # if octave wrappers are enabled, check that swig supports octave
1041         if test x"$with_octave" = "xyes"; then
1042            AC_MSG_CHECKING([if SWIG supports Octave])
1043 cat > conftest.i <<EOF
1044 %module conftest
1045 EOF
1046            $SWIG -c++ -octave conftest.i || AC_MSG_ERROR(SWIG doesn't support Octave modules)
1047            AC_MSG_RESULT([yes])
1048            rm -f conftest.*
1049
1050         # specify the flags for swig
1051         AC_SUBST([SWIG_OCTAVE_OPT], "-octave")
1052
1053         fi
1054
1055         # check for swig python library
1056         SWIG_PYTHON()
1057         have_swig=yes
1058     else
1059                 if test x"$have_python25" = "xyes"; then
1060                         AC_MSG_WARN([Python Version >= 2.5 requires SWIG >= 1.3.30])
1061                 fi
1062                 have_swig=no
1063     fi
1064 else
1065     if test x"$with_swig" = "xno"; then
1066         have_swig=no
1067     else
1068         if test x"$with_swig" = "xauto"; then
1069             # no (python) wrapper will be generated
1070             # we don't need to check for SWIG
1071             have_swig=no
1072         else
1073             # if we get here then --with-swig was not called with 'yes','no' or 'auto'
1074             AC_MSG_WARN([unexpected arguments for option --with-swig, continuing assuming 'no'])
1075             have_swig=no
1076         fi
1077     fi
1078 fi
1079 AM_CONDITIONAL([UPDATE_SWIG_WRAPPERS], [test x"$have_swig" = "xyes"])
1080
1081 AC_SUBST(DEBUG)
1082
1083 AC_CONFIG_FILES([Makefile
1084 opencv.pc
1085 opencv.spec
1086 data/Makefile
1087 include/Makefile
1088 3rdparty/Makefile
1089 src/Makefile
1090 apps/Makefile
1091 interfaces/Makefile
1092 interfaces/swig/Makefile
1093 interfaces/swig/filtered/Makefile
1094 interfaces/swig/general/Makefile
1095 interfaces/swig/python/Makefile
1096 interfaces/swig/octave/Makefile
1097 tests/Makefile
1098 utils/Makefile
1099 samples/Makefile
1100 ])
1101
1102 AC_OUTPUT
1103
1104 AC_MSG_RESULT([
1105 General configuration ================================================
1106
1107     CXX:                      ${CXX}
1108     CXXCPP:                   ${CXXCPP}
1109     CPPFLAGS:                 ${CPPFLAGS}
1110     CXXFLAGS:                 ${CXXFLAGS}
1111     LDFLAGS:                  ${LDFLAGS}
1112
1113     Install path:             ${prefix}
1114
1115     Debug flags               ${DEBUG_CPPFLAGS} ${DEBUG_CXXFLAGS}
1116     Optimization flags        ${OPTIMIZATION_CPPFLAGS} ${OPTIMIZATION_CXXFLAGS}
1117     MMX/SSE/SSE2/SSE3:        ${SIMD_FLAGS}
1118     OpenMP support:           ${OPENMP_CXXFLAGS}
1119     External BLAS & LAPACK:   ${have_native_lapack}
1120
1121 HighGUI configuration ================================================
1122
1123     Windowing system --------------
1124     Use Carbon / Mac OS X:    ${have_carbon}
1125     Use gtk+ 2.x:             ${have_gtk}
1126     Use gthread:              ${have_gthread}
1127
1128     Image I/O ---------------------
1129     Use ImageIO / Mac OS X:   ${have_imageio}
1130     Use libjpeg:              ${have_jpeg}
1131     Use zlib:                 ${have_zlib}
1132     Use libpng:               ${have_png}
1133     Use libtiff:              ${have_tiff}
1134     Use libjasper:            ${have_jasper}
1135     Use libIlmImf/OpenEXR:    ${have_ilmimf}
1136
1137     Video I/O ---------------------
1138     Use QuickTime / Mac OS X: ${have_quicktime}
1139     Use xine:                 ${have_xine}
1140     Use gstreamer:            ${have_gstreamer}
1141     Use ffmpeg:               ${have_ffmpeg}
1142     Use dc1394 & raw1394:     ${have_dc1394}
1143     Use dc1394_v2 & raw1394:  ${have_dc1394_2}
1144     Use v4l:                  ${have_v4l}
1145     Use v4l2:                 ${have_v4l2}
1146     Use unicap:               ${have_unicap}
1147
1148 Wrappers for other languages =========================================
1149
1150     SWIG                      ${SWIG}
1151     Python                    ${have_python}
1152     Octave                    ${have_octave}
1153
1154 Additional build settings ============================================
1155
1156     Build demo apps           ${enable_apps}
1157
1158 Now run make ...
1159 ])
1160
1161 if test x"$have_xine" = "xyes"; then
1162     AC_MSG_NOTICE([
1163 ATTENTION: highgui will be built with xine support,
1164            thus it will be a subject to GNU Public License])
1165 fi