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