39be9321f6140abded3f16899584af7faa2eed47
[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.46 $)
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 OpenCV to use xine video libraries?
117 AC_ARG_WITH([xine],
118             [AS_HELP_STRING([--with-xine],[use xine libraries (see LICENSE) [no]])],
119             [with_xine=$withval],
120             [with_xine=no])
121
122 # does the user want OpenCV to use ffmpeg video libraries?
123 AC_ARG_WITH([ffmpeg],
124             [AS_HELP_STRING([--with-ffmpeg],[use ffmpeg libraries (see LICENSE) [automatic]])],
125             [with_ffmpeg=$withval],
126             [with_ffmpeg=auto])
127
128 # does the user want OpenCV to use libraw1394/libdc1394 for video input?
129 AC_ARG_WITH([1394libs],
130             [AS_HELP_STRING([--with-1394libs],[use libraw1394/libdc1394 [automatic]])],
131             [with_1394libs=$withval],
132             [with_1394libs=auto])
133
134 # does the user want OpenCV to use the video4linux kernel module?
135 AC_ARG_WITH([v4l],
136             [AS_HELP_STRING([--with-v4l],[use video4linux [automatic]])],
137             [with_v4l=$withval],
138             [with_v4l=auto])
139
140 # does the user want OpenCV to use image libraries from OS X 10.4?
141 AC_ARG_WITH([imageio],
142             [AS_HELP_STRING([--with-imageio],[use ImageIO libraries [automatic]])],
143             [with_imageio=$withval],
144             [with_imageio=yes])
145
146 # does the user want OpenCV to use QuickTime video libraries?
147 AC_ARG_WITH([quicktime],
148             [AS_HELP_STRING([--with-quicktime],[use QuickTime libraries [automatic]])],
149             [with_quicktime=$withval],
150             [with_quicktime=yes])
151
152 # does the user want OpenCV to use the Carbon GUI of Mac OS X?
153 AC_ARG_WITH([carbon],
154             [AS_HELP_STRING([--with-carbon],[use Carbon windows [automatic]])],
155             [with_carbon=$withval],
156             [with_carbon=yes])
157
158 # does the user want OpenCV to use GTK+ 2.0 for the GUI?
159 AC_ARG_WITH([gtk],
160             [AS_HELP_STRING([--with-gtk],[use gtk+ 2.0 windows [automatic]])],
161             [with_gtk=$withval],
162             [with_gtk=auto])
163
164 # does the user want OpenCV to use gthread for GTK+ threaded HighGUI?
165 AC_ARG_WITH([gthread],
166             [AS_HELP_STRING([--with-gthread],[use gthread in addition to gtk+ [automatic]])],
167             [with_gthread=$withval],
168             [with_gthread=auto])
169
170
171 ######################################################################
172 # getting the code to compile
173
174 # cure annoying default arguments for CFLAGS and CXXFLAGS
175 # that autoconf automatically sets in GNU environments if
176 # no CFLAGS or CXXFLAGS were manually given
177 if test x"$CFLAGS" = "x-g -O2" ; then
178     CFLAGS=""
179 fi
180 if test x"$CXXFLAGS" = "x-g -O2" ; then
181     CXXFLAGS=""
182 fi
183
184
185 # see if the user wants aggressive optimizations of the code,
186 # check whether to include debugging code
187 AC_MSG_CHECKING([whether to build debug version (no optimization)])
188 if test x"$debug" = "xyes"; then
189     AC_MSG_RESULT([yes])
190     if test x"$ac_cv_c_compiler_gnu" = "xyes"; then
191         CPPFLAGS="-DDEBUG -D_DEBUG $CPPFLAGS"
192         CXXFLAGS="-ggdb -O0 $CXXFLAGS"
193     fi
194 else
195     AC_MSG_RESULT([no])
196     AC_MSG_NOTICE( TARGET=$target )
197     case $target in
198     i*86-apple-*)
199         if test x"$ac_cv_c_compiler_gnu" = "xyes"; then
200             # apples g++ fails with '-march=i686' and there are no apple machines older than prescott/core anyway
201             CXXFLAGS="-g -march=prescott -ffast-math -fomit-frame-pointer $CXXFLAGS"
202         fi
203         ;;
204     i686-*-*)
205         if test x"$ac_cv_c_compiler_gnu" = "xyes"; then
206           # default to i686/pentiumpro -- people can override this
207           CXXFLAGS="-g -march=i686 -ffast-math -fomit-frame-pointer $CXXFLAGS"
208         fi
209         ;;
210     powerpc-*-*)
211         if test x"$ac_cv_c_compiler_gnu" = "xyes"; then
212             # default to G3 processors -- people can override this
213             CXXFLAGS="-g -mcpu=G3 -mtune=G5 -fomit-frame-pointer $CXXFLAGS"
214         fi
215         ;;
216     *-*-*)
217         if test x"$ac_cv_c_compiler_gnu" = "xyes"; then
218             CXXFLAGS="-fomit-frame-pointer $CXXFLAGS"
219         fi
220         ;;
221     esac
222     
223     CPPFLAGS="-DNDEBUG $CPPFLAGS"
224     CXXFLAGS="-O3 $CXXFLAGS"
225 fi
226
227 if test x"$ac_cv_c_compiler_gnu" = "xyes"; then
228     PY_CXXFLAGS="-Wall -pipe $CXXFLAGS"
229     CXXFLAGS="-Wall -fno-rtti -pipe $CXXFLAGS"
230 else
231     PY_CXXFLAGS="$CXXFLAGS"
232 fi
233 AC_SUBST(PY_CXXFLAGS)
234
235 # add libm because it is used by several libraries and OpenCV itself 
236 AC_CHECK_LIB(m,pow)
237 AC_CHECK_LIB(dl,dlopen)
238 AC_CHECK_LIB(pthread,pthread_create)
239
240 # check endianness
241 AC_C_BIGENDIAN
242
243 # check for specific functions that might be missing from
244 # certain standard library implementations
245 AC_FUNC_ALLOCA
246 AC_CHECK_HEADERS([malloc.h])
247 AC_CHECK_HEADERS([assert.h])
248 AC_CHECK_FUNCS(lrint)
249
250
251 ######################################################################
252 # HighGUI dependencies for windowing system
253
254 # honor user selection, 
255 # if no selection given check for Carbon first
256 CARBON_CFLAGS=""
257 CARBON_LIBS=""
258 if test x"$with_carbon" = "xyes"; then
259
260     # header presence and usability seem to be enough
261     AC_CHECK_HEADER([Carbon/Carbon.h],
262                     [
263                       AC_DEFINE(HAVE_CARBON,,[Carbon windowing environment])
264                       CARBON_LIBS="-Xlinker -framework -Xlinker Carbon"
265                       have_carbon=yes
266                     ],
267                     [
268                       have_carbon=no 
269                       with_carbon=no
270                     ])
271
272     # sanity checks
273     if test x"$have_carbon" = "xyes"; then
274     
275         # if we asked for gtk, this is not ok
276         if test x"$with_gtk" = "xyes"; then
277             AC_MSG_ERROR([You cannot specify --with-carbon and --with-gtk at the same time])
278         fi
279
280         # don't check alternatives if carbon was found
281         if test x"$with_gtk" = "xauto"; then
282             with_gtk=no
283         fi
284     fi
285 else
286     have_carbon=no
287     if test ! x"$with_carbon" = "xno"; then
288         AC_MSG_WARN([unexpected arguments for option --with-carbon, continuing assuming 'no'])
289     fi
290 fi
291 AC_SUBST(CARBON_CFLAGS)
292 AC_SUBST(CARBON_LIBS)
293 AM_CONDITIONAL([BUILD_CARBON], [test x"$have_carbon" = "xyes"])
294
295 # use GTK+ 2.x (or later) for windowing 
296 # if carbon not present or not wanted (--without-carbon)
297 GTK_CFLAGS=""
298 GTK_LIBS=""
299 GTHREAD_CFLAGS=""
300 GTHREAD_LIBS=""
301 if test x"$with_gtk" = "xno"; then
302     have_gtk=no
303 else
304
305     # check if ./configure arguments are valid
306     if test x"$with_gtk" = "xauto"; then
307        with_gtk=yes
308     fi
309     if test x"$with_gtk" = "xyes"; then
310     
311         # pkg-config is needed for GTK+
312         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
313         if test x"$PKG_CONFIG" == "xno"; then
314             AC_MSG_ERROR([You have to install pkg-config to compile OpenCV with GTK+])
315         fi
316     
317         PKG_CHECK_MODULES(GTK, "gtk+-2.0 gdk-pixbuf-2.0", 
318                           [
319                             have_gtk=yes 
320                             AC_DEFINE(HAVE_GTK,,[GTK+ 2.x toolkit])
321                           ],
322                           [ have_gtk=no ])
323
324     else
325         # if we get here then --with-gtk was not called with 'yes','no' or 'auto'
326         AC_MSG_WARN([unexpected arguments for option --with-gtk, continuing assuming 'no'])
327         have_gtk=no
328     fi
329 fi
330 if test x"$with_gthread" = "xno"; then
331     have_gthread=no
332 else
333     if test x"$have_gtk" = "xyes"; then
334         if test x"$with_gthread" = "xauto"; then
335             with_gthread=yes
336         fi
337
338         if test x"$with_gthread" = "xyes"; then
339             PKG_CHECK_MODULES(GTHREAD, "gthread-2.0",
340                               [
341                                 have_gthread=yes
342                                 AC_DEFINE(HAVE_GTHREAD,,[GTK+ 2.0 Thread support])
343                               ],
344                               [ have_gthread=no ])
345         else
346             # if we get here then --with-gthread was not called with 'yes','no' or 'auto'
347             AC_MSG_WARN([unexpected arguments for option --with-gthread, continuing assuming 'no'])
348             have_gthread=no
349         fi
350     else
351         # if no gtk+ was detected, looking for gthread does not make any sense
352         have_gthread=no
353     fi
354 fi
355 AC_SUBST(GTK_CFLAGS)
356 AC_SUBST(GTK_LIBS)
357 AC_SUBST(GTHREAD_CFLAGS)
358 AC_SUBST(GTHREAD_LIBS)
359 AM_CONDITIONAL([BUILD_GTK], [test x"$have_gtk" = "xyes"])
360
361
362 ######################################################################
363 # HighGUI dependencies for video I/O
364
365 # if QuickTime is present, it will override everything else,
366 # (unless '--without-quicktime' was given)
367 if test x"$with_quicktime" = "xyes"; then
368
369     # check other ./configure flags
370     if test x"$with_ffmpeg" = "xyes"; then
371         AC_MSG_ERROR([You cannot specify --with-quicktime and --with-ffmpeg at the same time])
372     fi
373     if test x"$with_xine" = "xyes"; then
374         AC_MSG_ERROR([You cannot specify --with-quicktime and --with-xine at the same time])
375     fi
376     if test x"$with_1394libs" = "xyes"; then
377         AC_MSG_ERROR([You cannot specify --with-quicktime and --with-1394libs at the same time])
378     fi
379     if test x"$with_v4l" = "xyes"; then
380         AC_MSG_ERROR([You cannot specify --with-quicktime and --with-v4l at the same time])
381     fi
382     
383     # header presence and usability seem to be enough
384     AC_CHECK_HEADER([QuickTime/QuickTime.h],
385                     [
386                       AC_DEFINE(HAVE_QUICKTIME,,[QuickTime video libraries])
387                       have_quicktime=yes
388                     ],
389                     [ have_quicktime=no ])
390     
391     # specify quicktime libraries
392     if test x"$have_quicktime" = "xyes"; then
393         QUICKTIME_LIBS="-Xlinker -framework -Xlinker QuickTime -Xlinker -framework -Xlinker QuartzCore"
394  
395         # don't check alternatives if quicktime was found
396         if test x"$with_ffmpeg" = "xauto"; then
397             with_ffmpeg=no
398         fi
399         if test x"$with_xine" = "xauto"; then
400             with_xine=no
401         fi
402         if test x"$with_1394libs" = "xauto"; then
403             with_1394libs=no
404         fi
405         if test x"$with_v4l" = "xauto"; then
406             with_v4l=no
407         fi
408     fi
409 else
410     # check if ./configure arguments are valid
411     have_quicktime=no
412     if test ! x"$with_quicktime" = "xno"; then
413         AC_MSG_WARN([unexpected arguments for option --with-quicktime, continuing assuming 'no'])
414     fi
415 fi
416 AC_SUBST(QUICKTIME_CFLAGS)
417 AC_SUBST(QUICKTIME_LIBS)
418 AM_CONDITIONAL([BUILD_QUICKTIME], [test x"$have_quicktime" = "xyes"])
419
420 # prefer XINE over FFMPEG for video reading because it is quick, has a cleaner API
421 # and allows for easy seeking with some formats
422 if test x"$with_xine" = "xno"; then
423     have_xine=no
424     # XINE_LIBS=""
425 else
426
427     # check if ./configure arguments are valid
428     if test x"$with_xine" = "xauto"; then
429        with_xine=yes
430     fi
431     if test x"$with_xine" = "xyes"; then
432         AC_CHECK_HEADER(xine.h,
433                         AC_CHECK_LIB(xine, xine_init,
434                                     [
435                                       have_xine=yes
436                                       AC_DEFINE(HAVE_XINE,,[Xine video library])
437                                       XINE_LIBS="-lxine"
438                                     ],
439                                     [ have_xine=no ]),
440                         [ have_xine=no ])
441     else
442         # if we get here then --with-xine was not called with 'yes','no' or 'auto'
443         AC_MSG_WARN([unexpected arguments for option --with-xine, continuing assuming 'no'])
444         have_xine=no
445     fi
446 fi
447 AC_SUBST(XINE_LIBS)
448 AM_CONDITIONAL([BUILD_XINE], [test x"$have_xine" = "xyes"])
449
450 # unfortunately, xine does not feature video writing,
451 # so we have to resort to FFMPEG here
452 if test x"$with_ffmpeg" = "xno"; then
453     have_ffmpeg=no
454     # FFMPEGLIBS=""
455 else
456
457     # check if ./configure arguments are valid
458     if test x"$with_ffmpeg" = "xauto"; then
459        with_ffmpeg=yes
460     fi
461     if test x"$with_ffmpeg" = "xyes"; then
462         AC_CHECK_HEADER(ffmpeg/avcodec.h,
463                         AC_SEARCH_LIBS([avcodec_decode_video],[avcodec_pic avcodec],                                      [
464                                        AC_SEARCH_LIBS([av_open_input_file], [avformat_pic avformat],
465                                                     [
466                                                       have_ffmpeg=yes
467                                                       AC_DEFINE(HAVE_FFMPEG,,[FFMpeg video library])
468                                                       FFMPEGLIBS="-lavcodec -lavformat"
469                                                     ],
470                                                     [ have_ffmpeg=no ],
471                                                     [-lavcodec])
472                                      ],
473                                      [ have_ffmpeg=no ]),
474                         [ have_ffmpeg=no ])
475     else
476         # if we get here then --with-ffmpeg was not called with 'yes','no' or 'auto'
477         AC_MSG_WARN([unexpected arguments for option --with-ffmpeg, continuing assuming 'no'])
478         have_ffmpeg=no
479     fi
480 fi
481 AC_SUBST(FFMPEGLIBS)
482 AM_CONDITIONAL([BUILD_FFMPEG], [test x"$have_ffmpeg" = "xyes"])
483
484 # IEEE1394 / FireWire video video i/o with libdc1394, libraw1394
485 # (can be managed by QuickTime as well)
486 if test x"$with_1394libs" = "xno"; then
487     have_raw1394=no
488     have_dc1394=no
489     # IEEE1394LIBS=""
490 else
491
492     # check if ./configure arguments are valid
493     if test x"$with_1394libs" = "xauto"; then
494        with_1394libs=yes
495     fi
496     if test x"$with_1394libs" = "xyes"; then
497     
498         SAVELIBS="$LIBS"
499         have_raw1394=no
500         have_dc1394=no
501         
502         AC_CHECK_HEADER(libraw1394/raw1394.h,
503                         AC_CHECK_LIB(raw1394, raw1394_new_handle, 
504                                      [
505                                        have_raw1394=yes
506                                        LIBS="-lm -lraw1394 $LIBS"
507                                      ]))
508         
509         if test x"$have_raw1394" = "xyes"; then
510             AC_CHECK_HEADER(libdc1394/dc1394_control.h,
511                             AC_CHECK_LIB(dc1394_control, dc1394_camera_on, 
512                                          [
513                                            have_dc1394=yes
514                                            AC_DEFINE(HAVE_DC1394,,[IEEE1394 capturing support])
515                                            AC_EGREP_HEADER(do_extra_buffering, libdc1394/dc1394_control.h,
516                                                            [AC_DEFINE(HAVE_DC1394_095,,[libdc1394 0.9.4 or 0.9.5])])
517                                            IEEE1394LIBS="-lm -lraw1394 -ldc1394_control"
518                                          ]))
519         fi
520         
521         LIBS="$SAVELIBS"
522     else
523         # if we get here then --with-1394libs was not called with 'yes','no' or 'auto'
524         AC_MSG_WARN([unexpected arguments for option --with-1394libs, continuing assuming 'no'])
525         have_dc1394=no
526     fi
527 fi
528 AC_SUBST(IEEE1394LIBS)
529 AM_CONDITIONAL([BUILD_DC1394], [test x"$have_dc1394" = "xyes"])
530
531 # Video for Linux (V4L) 
532 # we support version 1 and 2 currently
533 if test x"$with_v4l" = "xno"; then
534     have_v4l=no
535     have_v4l2=no
536     have_v4l1or2=no
537 else
538     # check if ./configure arguments are valid
539     if test x"$with_v4l" = "xauto"; then
540        with_v4l=yes
541     fi
542     if test x"$with_v4l" = "xyes"; then
543         AC_CHECK_HEADER([linux/videodev.h],
544                         [
545                           AC_DEFINE(HAVE_CAMV4L,,[V4L capturing support])
546                           have_v4l=yes
547                           have_v4l1or2=yes
548                         ],
549                         [ 
550                           have_v4l=no
551                           have_v4l1or2=no
552                         ])
553         AC_CHECK_HEADER([linux/videodev2.h],
554                         [
555                           AC_DEFINE(HAVE_CAMV4L2,,[V4L2 capturing support])
556                           have_v4l2=yes
557                           have_v4l1or2=yes
558                         ],
559                         [ have_v4l2=no ],
560                 [[
561                 #include <asm/types.h>
562                 #include <sys/time.h>
563                 ]])
564     else
565         # if we get here then --with-v4l was not called with 'yes','no' or 'auto'
566         AC_MSG_WARN([unexpected arguments for option --with-v4l, continuing assuming 'no'])
567         have_v4l=no
568         have_v4l2=no
569         have_v4l1or2=no
570     fi
571
572 fi
573 AM_CONDITIONAL([BUILD_V4L], [test x"$have_v4l1or2" = "xyes"])
574
575
576 ######################################################################
577 # HighGUI dependencies for image I/O
578
579 SAVELIBS="$LIBS"
580 IMAGELIBS=""
581
582 AC_SUBST(IMAGELIBS)
583
584 have_imageio=no
585 if test x"$with_imageio" = "xauto"; then
586     with_imageio=yes
587 fi
588 if test x"$with_imageio" = "xyes"; then
589     AC_CHECK_HEADER([ApplicationServices/ApplicationServices.h],
590                     [
591                       have_imageio=yes
592                       AC_DEFINE(HAVE_IMAGEIO,,[Apple ImageIO Framework])
593                       IMAGELIBS="$IMAGELIBS -framework ApplicationServices"
594                       LIBS="$LIBS -framework ApplicationServices"
595                     ],
596                     [ have_imageio=no ])
597 fi
598 AM_CONDITIONAL([BUILD_IMAGEIO], [test x"$have_imageio" = "xyes"])
599
600
601 have_jpeg=no
602 have_zlib=no
603 have_png=no
604 have_tiff=no
605
606 # there are problems with dependencies of ImageIO to libtiff, etc.
607 # that we avoid by not linking them ourselves
608 if test x"$have_imageio" = "xno" ; then
609
610   AC_CHECK_HEADER(jpeglib.h,
611                   AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
612                                [
613                                  have_jpeg=yes
614                                  AC_DEFINE(HAVE_JPEG,,[IJG JPEG codec])
615                                  IMAGELIBS="$IMAGELIBS -ljpeg"
616                                ]))
617
618   AC_CHECK_HEADER(zlib.h,
619                   AC_CHECK_LIB(z, gzopen,
620                                [
621                                  have_zlib=yes
622                                  AC_DEFINE(HAVE_ZLIB,,[LZ77 compression/decompression library (used for PNG)])
623                                  IMAGELIBS="$IMAGELIBS -lz -lm"
624                                  LIBS="$LIBS -lz -lm"
625                                ]))
626
627   AC_CHECK_HEADER(png.h, 
628                   [
629                     AC_DEFINE(HAVE_PNG_H,,[png.h needs to be included])
630                     have_png=yes
631                   ])
632   AC_CHECK_HEADER([libpng/png.h], 
633                   [
634                     AC_DEFINE(HAVE_LIBPNG_PNG_H,,[libpng/png.h needs to be included])
635                     have_png=yes
636                   ])
637   
638   if test x"$have_png" = "xyes"; then
639     AC_CHECK_LIB(png12, png_read_image,
640                  [
641                    have_png=yes
642                    AC_DEFINE(HAVE_PNG,,[PNG codec])
643                    IMAGELIBS="-lpng12 $IMAGELIBS"
644                    LIBS="-lpng12 $LIBS"
645                    AC_CHECK_FUNCS(png_get_valid png_set_tRNS_to_alpha)
646                  ],
647                  [ have_png=no ])
648   fi
649
650   AC_CHECK_HEADER(tiff.h,
651                   AC_CHECK_LIB(tiff, TIFFReadRGBAStrip,
652                                [
653                                  have_tiff=yes
654                                  AC_DEFINE(HAVE_TIFF,,[TIFF codec])
655                                  IMAGELIBS="$IMAGELIBS -ltiff"
656                                  LIBS="$LIBS -ltiff"
657                                ]))
658 fi
659
660 have_jasper=no
661 AC_CHECK_HEADER(jasper/jasper.h,
662                 AC_CHECK_LIB(jasper, jas_image_readcmpt,
663                              [
664                                have_jasper=yes
665                                AC_DEFINE(HAVE_JASPER,,[JPEG-2000 codec])
666                                IMAGELIBS="$IMAGELIBS -ljasper"
667                                LIBS="$LIBS -ljasper"
668                              ]))
669
670 have_ilmimf=no
671 AC_CHECK_HEADER(ImfCRgbaFile.h,
672                 AC_CHECK_LIB(IlmImf, ImfInputReadPixels,
673                              [
674                                have_ilmimf=yes
675                                AC_DEFINE(HAVE_ILMIMF,,[OpenEXR codec])
676                                IMAGELIBS="$IMAGELIBS -lIlmImf -lIex -lHalf"
677                                LIBS="$LIBS -lIlmImf -lIex -lHalf"
678                              ],,
679                              [ -lIex -lHalf ]))
680
681 # Restore original LIBS settings...
682 LIBS="$SAVELIBS"
683 AC_SUBST(IMAGELIBS)
684
685
686 ######################################################################
687 # SWIG wrappers
688
689 # currently there is only python.
690 # If additional wrapper languages / SWIG modules
691 # get available for OpenCV, we will have a --with-LANGUAGE switch
692 # for every wrapper language
693 if test x"$with_python" = "xyes"; then
694     AC_MSG_NOTICE([Checking for necessary tools to build python wrappers])
695
696     # we need Python now
697     AM_PATH_PYTHON()
698
699     # get some info on how to compile and link python modules
700     AZ_PYTHON_CSPEC()
701     AZ_PYTHON_LSPEC()
702
703     # if not explicitly forbidden, check for swig also
704     if test x"$with_swig" = "xauto"; then
705         with_swig=yes
706     fi
707     
708     ### almost ok... just need to check if we have the Python headers ###
709
710     # first, save the CPPFLAGS
711     OLD_CPPFLAGS=$CPPFLAGS
712
713     # then add the PYTHON path founded previously
714     CPPFLAGS="$CPPFLAGS $PYTHON_CSPEC"
715
716     # now, we can check
717     AC_CHECK_HEADER(Python.h,
718         [have_python=yes],
719         [
720           AC_MSG_WARN([Python headers not found, disabling python wrappers])
721           have_python=no
722         ])
723
724     # restore the old CPPFLAGS
725     CPPFLAGS=$OLD_CPPFLAGS
726
727 else
728     # check if ./configure arguments are valid
729     if test x"$with_python" = "xno"; then
730         have_python=no
731     else
732         # if we get here then --with-python was not called with 'yes','no' or 'auto'
733         AC_MSG_WARN([unexpected arguments for option --with-python, continuing assuming 'no'])
734         have_python=no
735     fi
736 fi
737 AM_CONDITIONAL([BUILD_PYTHON_WRAPPERS], [test x"$have_python" = "xyes"])
738
739 # check for swig itself
740 SWIG=""
741 if test x"$with_swig" = "xyes"; then
742     AC_MSG_NOTICE([Checking for SWIG])
743
744         # Python 2.5 requires SWIG >= 1.3.30
745         AM_PYTHON_CHECK_VERSION( [2.5], have_python25=yes, have_python25=no )
746         if test x"$have_python25" = "xyes" ; then
747                 AC_PATH_SWIG([1.3.30])
748         else
749                 AC_PATH_SWIG([1.2.24])
750         fi
751
752     if test -n "$SWIG"; then
753         SWIG_ENABLE_CXX()
754         SWIG_MULTI_MODULE_SUPPORT()
755
756         # check for swig python library
757         SWIG_PYTHON()
758         have_swig=yes
759     else
760                 if test x"$have_python25" = "xyes"; then
761                         AC_MSG_WARN([Python Version >= 2.5 requires SWIG >= 1.3.30])
762                 fi
763                 have_swig=no
764     fi
765 else
766     if test x"$with_swig" = "xno"; then
767         have_swig=no
768     else
769         if test x"$with_swig" = "xauto"; then
770             # no (python) wrapper will be generated
771             # we don't need to check for SWIG
772             have_swig=no
773         else
774             # if we get here then --with-swig was not called with 'yes','no' or 'auto'
775             AC_MSG_WARN([unexpected arguments for option --with-swig, continuing assuming 'no'])
776             have_swig=no
777         fi
778     fi
779 fi
780 AM_CONDITIONAL([UPDATE_SWIG_WRAPPERS], [test x"$have_swig" = "xyes"])
781
782
783 ######################################################################
784 # Parallelization
785 #
786 #CXXOPENMP="no"
787 #
788 #AC_ARG_WITH(openmp, dnl
789 #  [--with-openmp=COMPILER  use OpenMP supporting compiler [default=no] ],
790 #    [CXXOPENMP="$withval"],[CXXOPENMP="no"])
791 #if test "$CXXOPENMP" = "no"; then
792 #    CXXOPENMP="$CXX"
793 #fi
794 #
795 #AC_SUBST(CXXOPENMP)
796
797 AC_SUBST(DEBUG)
798
799 AC_CONFIG_FILES([Makefile
800 opencv.pc
801 opencv.spec
802 docs/Makefile
803 data/Makefile
804 cxcore/Makefile
805 cxcore/include/Makefile
806 cxcore/src/Makefile
807 cv/Makefile
808 cv/include/Makefile
809 cv/src/Makefile
810 cvaux/Makefile
811 cvaux/include/Makefile
812 cvaux/src/Makefile
813 ml/Makefile
814 ml/include/Makefile
815 ml/src/Makefile
816 otherlibs/Makefile
817 otherlibs/highgui/Makefile
818 apps/Makefile
819 apps/haartraining/Makefile
820 apps/haartraining/include/Makefile
821 apps/haartraining/src/Makefile
822 interfaces/Makefile
823 interfaces/swig/Makefile
824 interfaces/swig/filtered/Makefile
825 interfaces/swig/general/Makefile
826 interfaces/swig/python/Makefile
827 tests/Makefile
828 tests/python/Makefile
829 tests/cv/Makefile
830 tests/cv/src/Makefile
831 tests/cxts/Makefile
832 tests/cxcore/Makefile
833 tests/cxcore/src/Makefile
834 utils/Makefile
835 samples/Makefile
836 samples/c/Makefile
837 samples/python/Makefile
838 ])
839
840 AC_OUTPUT
841
842 AC_MSG_RESULT([
843 General configuration ================================================
844     Compiler:                 ${CXX} 
845     CXXFLAGS:                 ${CXXFLAGS}
846     
847     Install path:             ${prefix}
848     
849 HighGUI configuration ================================================
850
851     Windowing system --------------
852     Use Carbon / Mac OS X:    ${have_carbon}
853     Use gtk+ 2.x:             ${have_gtk}
854     Use gthread:              ${have_gthread}
855     
856     Image I/O ---------------------
857     Use ImageIO / Mac OS X:   ${have_imageio}
858     Use libjpeg:              ${have_jpeg}
859     Use zlib:                 ${have_zlib}
860     Use libpng:               ${have_png}
861     Use libtiff:              ${have_tiff}
862     Use libjasper:            ${have_jasper}
863     Use libIlmImf:            ${have_ilmimf}
864     
865     Video I/O ---------------------
866     Use QuickTime / Mac OS X: ${have_quicktime}
867     Use xine:                 ${have_xine}
868     Use ffmpeg:               ${have_ffmpeg}
869     Use dc1394 & raw1394:     ${have_dc1394}
870     Use v4l:                  ${have_v4l}
871     Use v4l2:                 ${have_v4l2}
872     
873 Wrappers for other languages =========================================
874     SWIG                      ${SWIG}
875     Python                    ${have_python}
876
877 Additional build settings ============================================
878     Build demo apps           ${enable_apps}
879
880 Now run make ...
881 ])
882
883 if test x"$have_xine" = "xyes"; then
884     AC_MSG_NOTICE([
885 ATTENTION: highgui will be built with xine support,
886            thus it will be a subject to GNU Public License])
887 fi