29ee0bfa7688da3fa85351bfc28ec8494f26a04e
[openjpeg.git] / configure.ac
1 #AC_PREREQ([2.65])
2 define([OPJ_MAJOR], [1])
3 define([OPJ_MINOR], [4])
4 define([OPJ_BUILD], [0])
5 #
6 define([JP3D_MAJOR], [1])
7 define([JP3D_MINOR], [3])
8 define([JP3D_BUILD], [0])
9 #
10 #
11 #AC_INIT (PACKAGE, VERSION, [BUG-REPORT], [TARNAME], [URL])
12 AC_INIT(OpenJPEG,
13 OPJ_MAJOR.OPJ_MINOR.OPJ_BUILD,
14 http://code.google.com/p/openjpeg/,
15 openjpeg-OPJ_MAJOR.OPJ_MINOR.OPJ_BUILD,
16 http://www.openjpeg.org/)
17 AC_CONFIG_SRCDIR([libopenjpeg/openjpeg.c])
18 AC_CONFIG_HEADERS(opj_config.h)
19 #
20 AC_CANONICAL_SYSTEM
21 #foreign:package will not follow the GNU Standards
22 AM_INIT_AUTOMAKE(foreign)
23 #
24 MAJOR_NR=OPJ_MAJOR
25 MINOR_NR=OPJ_MINOR
26 BUILD_NR=OPJ_BUILD
27 AC_SUBST(MAJOR_NR)
28 AC_SUBST(MINOR_NR)
29 AC_SUBST(BUILD_NR)
30 #
31 JP3D_MAJOR_NR=JP3D_MAJOR
32 JP3D_MINOR_NR=JP3D_MINOR
33 JP3D_BUILD_NR=JP3D_BUILD
34 AC_SUBST(JP3D_MAJOR_NR)
35 AC_SUBST(JP3D_MINOR_NR)
36 AC_SUBST(JP3D_BUILD_NR)
37 #
38 # Checks for programs.
39 AC_PROG_CC
40 AC_PROG_CXX
41 AC_PROG_INSTALL
42 AC_PROG_LN_S
43 AC_PROG_SED
44 AC_SYS_LARGEFILE
45 AC_FUNC_FSEEKO
46 AC_PROG_MAKE_SET
47 #AC_HEADER_DIRENT
48 #
49 # Tests for Windows
50 #
51 AC_EXEEXT
52 AC_OBJEXT
53 #
54 # Configure libtool
55 AC_ENABLE_SHARED
56 AC_ENABLE_STATIC
57 AC_LIBTOOL_WIN32_DLL
58 AC_LIBTOOL_SETUP
59 AC_PROG_LIBTOOL
60 #
61 AC_C_BIGENDIAN
62 #
63 LIB_MATH=""
64 AC_CHECK_LIB(m,sqrt,LIB_MATH="-lm",,)
65 LIB_Z=""
66 AC_CHECK_LIB(z,inflate,LIB_Z="-lz",,)
67 #
68 AC_PATH_PROG([PKGCONFIG], [pkg-config])
69 #
70 # ------------------------------
71 # Test for PNG
72 # ------------------------------
73 AC_MSG_CHECKING(whether to build with PNG support)
74 pngincludes=""
75 pnglibs=""
76 png_header_found="no"
77 with_libpng="yes"
78 #
79 AC_ARG_ENABLE(png,
80 [  --enable-png[=[yes|no]]          Build with PNG support [ [default=yes] ]],
81 test "$enable_png" = "no"  && with_libpng="no")
82 #
83 if test "x$with_libpng" = xyes ; then
84   with_libpng="no"
85   AC_PATH_PROG([LIBPNG_CONFIG], [libpng-config])
86 #
87   pngheader=""
88   AC_ARG_WITH(png_includes,
89  [  --with-png-includes=DIR         PNG includes in nonstandard DIR])
90   if test -n "$with_png_includes" ; then
91    pngheader="$with_png_includes"
92    pngincludes="-I$with_png_includes"
93   else
94    if test -n "$PKGCONFIG" ; then
95      pngincludes="`$PKGCONFIG --variable=includedir libpng`"
96      if test -n "$pngincludes" ; then
97       pngheader="$pngincludes"
98       pngincludes="-I$pngincludes"
99      fi
100    else
101      if test -n "$LIBPNG_CONFIG" ; then
102       pngincludes="`$LIBPNG_CONFIG --I_opts`"
103       pngheader="`$LIBPNG_CONFIG --I_opts | $SED 's/-I//'`"
104      fi
105    fi
106   fi
107   if test -n "$pngheader" ; then
108    pngheader="$pngheader/png.h"
109   else
110    pngheader="png.h"
111   fi
112 #
113   AC_CHECK_HEADER($pngheader,png_header_found="yes",,)
114 #
115   AC_ARG_WITH(png_libraries,
116  [  --with-png-libraries=DIR        PNG library in nonstandard DIR])
117   if [[ -n "$with_png_libraries" ]] ; then
118    pnglibs="-L$with_png_libraries -lpng $LIB_Z $LIB_MATH"
119   else
120     if test -n "$LIBPNG_CONFIG" ; then
121      pnglibs="`$LIBPNG_CONFIG --ldflags` $LIB_Z $LIB_MATH"
122     else
123       if test -n "$PKGCONFIG" ; then
124         pnglibs="`$PKGCONFIG --libs libpng` $LIB_Z $LIB_MATH"
125       fi
126     fi
127   fi
128   savedLIBS="$LIBS"
129   LIBS="$pnglibs"
130 #
131   AC_CHECK_LIB(png,png_read_png,,pnglibs="",)
132 #
133   LIBS="$savedLIBS"
134   if test -n "$pnglibs" ; then
135     if test -n "$pngincludes" ; then
136       with_libpng="yes"
137       png_header_found="yes"
138       LIBS="$LIBS $pnglibs"
139       AC_DEFINE(HAVE_LIBPNG, [1], [define to 1 if you have libpng])
140     fi
141   fi
142 fi
143 #
144 AC_MSG_RESULT(png is usable:$with_libpng)
145 AM_CONDITIONAL([with_libpng], [test x$with_libpng = xyes])
146 AC_SUBST(pngincludes)
147 AC_SUBST(pnglibs)
148 # -------------------------------
149 # Test for TIFF
150 # -------------------------------
151 AC_MSG_CHECKING(whether to build with TIFF support)
152 tifflibs=""
153 tiffincludes=""
154 with_libtiff="yes"
155 tiff_header_found="no"
156 #
157 AC_ARG_ENABLE(tiff,
158 [  --enable-tiff[=[yes|no]]         Build with TIFF support [ [default=yes] ]],
159 test "$enable_tiff" = "no"  && with_libtiff="no")
160 #
161 if test "x$with_libtiff" = xyes ; then
162 #TIFF compiled with JPEG and JBIG support?
163  libjpeg=""
164  AC_CHECK_LIB(jpeg,jpeg_read_header,libjpeg=-ljpeg,,)
165  libjbig=""
166  AC_CHECK_LIB(jbig,jbg_enc_init,libjbig=-ljbig,,)
167  libjbig85=""
168  AC_CHECK_LIB(jbig85,jbg85_enc_init,libjbig85=-ljbig85,,)
169 #standard path
170  with_libtiff="no"
171  savedLIBS="$LIBS"
172  LIBS="-ltiff $libjpeg $libjbig $libjbig85 $LIB_Z $LIB_MATH"
173  AC_CHECK_LIB(tiff, TIFFOpen, tifflibs=-ltiff)
174  LIBS="$savedLIBS"
175  if test -n "$tifflibs" ; then
176   AC_CHECK_HEADER(tiff.h,tiff_header_found="yes",,)
177   if test "$tiff_header_found" = "yes" ; then 
178    with_libtiff="yes"
179    LIBS="$LIBS -ltiff $libjpeg $libjbig $libjbig85 $LIB_Z $LIB_MATH"
180    AC_DEFINE(HAVE_LIBTIFF, [1], [define to 1 if you have libtiff])
181   fi
182  fi
183 #
184  if test "x$with_libtiff" = xno ; then
185 #non-standard path
186   AC_ARG_WITH(tiff_includes,
187   [  --with-tiff-includes=DIR        TIFF includes in nonstandard DIR])
188   if test -n "$with_tiff_includes" ; then
189    tiffheader="$with_tiff_includes/tiff.h"
190    AC_CHECK_HEADER($tiffheader,tiff_header_found="yes",,)
191    if test "$tiff_header_found" = "yes" ; then
192      tiffincludes="-I$with_tiff_includes"
193    fi
194   fi
195   AC_ARG_WITH(tiff_libraries,
196   [  --with-tiff-libraries=DIR       TIFF library in nonstandard DIR])
197   if test -n "$with_tiff_libraries" ; then
198    tifflibs="-L$with_tiff_libraries"
199   fi
200   tifflibs="$tifflibs -ltiff $LIB_MATH"
201   savedLIBS="$LIBS"
202   LIBS="$tifflibs"
203   with_libtiff="no"
204 #
205   AC_CHECK_LIB(tiff, TIFFOpen, , tifflibs="",)
206 #
207   if test -n "$tifflibs" ; then
208    if test "$tiff_header_found" = "yes" ; then
209     with_libtiff="yes"
210     AC_DEFINE(HAVE_LIBTIFF, [1], [define to 1 if you have libtiff])
211    fi
212   fi
213   LIBS="$savedLIBS $tifflibs"
214  fi
215 fi
216 #
217 AC_MSG_RESULT(tiff is usable:$with_libtiff)
218 AM_CONDITIONAL([with_libtiff], [test x$with_libtiff = xyes])
219 AC_SUBST(tiffincludes)
220 AC_SUBST(tifflibs)
221 # -------------------------------
222 # Test for LCMS version 2.x 
223 # -------------------------------
224 AC_MSG_CHECKING(whether to build with LCMS support)
225 lcms1includes=""
226 lcms1libs=""
227 lcms2includes=""
228 lcms2libs=""
229 with_liblcms1="no"
230 lcms1_header_found="no"
231 lcms2_header_found="no"
232 have_lcms1_version=""
233 have_lcms2_version=""
234 with_liblcms2="yes"
235 #
236 AC_ARG_ENABLE(lcms2,
237 [  --enable-lcms2[=[yes|no]]        Build with LCMS-2 support [ [default=yes] ]],
238 test "$enable_lcms2" = "no"  && with_liblcms2="no")
239 #
240 if test "x$with_liblcms2" = xyes ; then
241   with_liblcms2="no"
242   lcms2header=""
243   AC_ARG_WITH(lcms2_includes,
244  [  --with-lcms2-includes=DIR       LCMS-2 includes in nonstandard DIR])
245   if test -n "$with_lcms2_includes" ; then
246    lcms2header="$with_lcms2_includes"
247    lcms2includes="-I$with_lcms2_includes"
248   else
249    if test -n "$PKGCONFIG" ; then
250      lcms2includes="`$PKGCONFIG --variable=prefix lcms2`"
251    fi
252    if test -n "$lcms2includes" ; then
253     lcms2header="$lcms2_includes"
254     lcms2includes="-I$lcms2includes/include"
255    fi
256   fi
257   if test -n "$lcms2header" ; then
258    lcms2header="$lcms2header/lcms2.h"
259   else
260    lcms2header="lcms2.h"
261   fi
262   AC_CHECK_HEADER($lcms2header,lcms2_header_found="yes",,)
263 #
264   AC_ARG_WITH(lcms2_libraries,
265  [  --with-lcms2-libraries=DIR      LCMS-2 library in nonstandard DIR])
266   if test -n "$with_lcms2_libraries" ; then
267    lcms2libs="-L$with_lcms2_libraries -llcms2"
268   else
269    if test -n "$PKGCONFIG" ; then
270      lcms2libs="`$PKGCONFIG --libs lcms2`"
271    fi
272    if test -z "$lcms2libs" ; then
273     lcms2libs="-llcms2"
274    fi
275    lcms2libs="$lcms2libs $LIB_MATH"
276   fi
277   savedLIBS="$LIBS"
278   LIBS="$lcms2libs"
279   with_liblcms2="no"
280 #
281   AC_CHECK_LIB(lcms2, cmsOpenProfileFromFile, ,lcms2libs="",)
282 #
283   if test -n "$lcms2libs" ; then
284    if test "$lcms2_header_found" = "yes" ; then
285     with_liblcms2="yes"
286     AC_DEFINE(HAVE_LIBLCMS2, [1], [define to 1 if you have lcms version 2.x])
287     if test -n "$PKGCONFIG" ; then
288       have_lcms2_version="`$PKGCONFIG --modversion lcms2`"
289     fi
290    fi
291   fi
292   if test "$with_liblcms2" = "no" ; then
293     lcms2libs=""
294     lcms2includes=""
295     lcms2libs=""
296   fi
297   LIBS="$savedLIBS $lcms2libs"
298 fi
299 #
300 AC_MSG_RESULT(lcms2 is usable:$with_liblcms2)
301 AM_CONDITIONAL([with_liblcms2], [test x$with_liblmcs2 = xyes])
302 AC_SUBST(lcms2includes)
303 AC_SUBST(lcms2libs)
304 AC_MSG_RESULT(lcms2libs:$lcms2libs)
305 # ----------------------------
306 # Test for LCMS version 1.x
307 # ----------------------------
308 if [[ -z "$lcms2libs" ]] ; then
309  with_liblcms1="yes"
310  AC_ARG_ENABLE(lcms1,
311  [  --enable-lcms1[=[yes|no]]        Build with LCMS-1 support [ [default=yes] ]],
312  test "$enable_lcms1" = "no"  && with_liblcms1="no")
313 #
314  if test "x$with_liblcms1" = xyes ; then
315    with_liblcms1="no"
316    lcms1header=""
317    AC_ARG_WITH(lcms1_includes,
318   [  --with-lcms1-includes=DIR       LCMS-1 includes in nonstandard DIR])
319    if test -n "$with_lcms1_includes" ; then
320     lcms1header="$with_lcms1_includes"
321     lcms1includes="-I$with_lcms1_includes"
322    else
323     if test -n "$PKGCONFIG" ; then
324       lcms1includes="`$PKGCONFIG --variable=includedir lcms`"
325     fi
326     if test -n "$lcms1includes" ; then
327      lcms1header="$lcms1includes"
328      lcms1includes="-I$lcms1includes"
329     fi
330    fi
331    if test -n "$lcms1header" ; then
332     lcms1header="$lcms1header/lcms.h"
333    else
334     lcms1header="lcms.h"
335    fi
336    AC_CHECK_HEADER($lcms1header,lcms1_header_found="yes",,)
337 #
338    AC_ARG_WITH(lcms1_libraries,
339   [  --with-lcms1-libraries=DIR      LCMS-1 library in nonstandard DIR])
340    if test -n "$with_lcms1_libraries" ; then
341     lcms1libs="-L$with_lcms1_libraries -llcms"
342    else
343     if test -n "$PKGCONFIG" ; then
344       lcms1libs="`$PKGCONFIG --libs lcms`"
345     fi
346     if test -z "$lcms1libs" ; then
347      lcms1libs="-llcms"
348     fi
349     lcms1libs="$lcms1libs $LIB_MATH"
350    fi
351    savedLIBS="$LIBS"
352    LIBS="$lcms1libs"
353    with_liblcms1="no"
354 #
355    AC_CHECK_LIB(lcms, cmsOpenProfileFromFile, ,lcms1libs="",)
356 #
357    if test -n "$lcms1libs" ; then
358     if test "$lcms1_header_found" = "yes" ; then
359      with_liblcms1="yes"
360      AC_DEFINE(HAVE_LIBLCMS1, [1], [define to 1 if you have lcms version 1.x])
361      if test -n "$PKGCONFIG" ; then
362        have_lcms1_version="`$PKGCONFIG --modversion lcms`"
363      fi
364     fi
365    fi
366    if test "$with_liblcms1" = "no" ; then
367      lcms1libs=""
368      lcms1includes=""
369      lcms1libs=""
370    fi
371    LIBS="$savedLIBS $lcms1libs"
372  fi
373 AC_MSG_RESULT(lcms is usable:$with_liblcms1)
374 fi
375 #
376 AM_CONDITIONAL([with_liblcms1], [test x$with_liblcms1 = xyes])
377 AC_SUBST(lcms1includes)
378 AC_SUBST(lcms1libs)
379 #
380 # -------------------------------
381 # Test for USE_JPWL
382 # -------------------------------
383 AC_MSG_CHECKING(whether to build with JPWL support)
384 with_libjpwl="no"
385 jpwl_dir=""
386 AC_ARG_ENABLE(jpwl,
387  [  --enable-jpwl[=[yes|no]]         Build with JPWL support [ [default=no] ]],
388  test "$enable_jpwl" = "yes" && with_libjpwl="yes")
389 #
390 AC_MSG_RESULT($with_libjpwl)
391 AM_CONDITIONAL([with_libjpwl], [test x$with_libjpwl = xyes])
392 if test "$with_libjpwl" = "yes" ; then
393  jpwl_dir="jpwl"
394 fi
395 AC_SUBST(jpwl_dir)
396 #
397 # -------------------------------
398 # Test for creating SHARED LIBS
399 # -------------------------------
400 with_sharedlibs="yes"
401 AC_MSG_CHECKING(whether to build shared libraries)
402 AC_ARG_ENABLE(shared,
403  [  --enable-shared[=[yes|no]]       Build shared libs [ [default=yes] ]],
404  test "$enable_shared" = "no" && with_sharedlibs="no")
405 #
406 AC_MSG_RESULT($with_sharedlibs)
407 AM_CONDITIONAL([with_sharedlibs], [test x$with_sharedlibs = xyes])
408 #
409 # -------------------------------
410 # Test for creating JP3D
411 # -------------------------------
412 with_jp3d="no"
413 jp3d_dir=""
414 AC_MSG_CHECKING(whether to build the JP3D library)
415 AC_ARG_ENABLE(jp3d,
416  [  --enable-jp3d[=[yes|no]]         Build jp3d libs [ [default=no] ]],
417  test "$enable_jp3d" = "yes" && with_jp3d="yes")
418 #
419 AC_MSG_RESULT($with_jp3d)
420 if test "$with_jp3d" = "yes" ; then
421  jp3d_dir="jp3d"
422 fi
423 AC_SUBST(jp3d_dir)
424 #
425 AC_CHECK_PROG(with_doxygen, doxygen, [yes],[no],,)
426 AM_CONDITIONAL([with_doxygen], [test x$with_doxygen = xyes])
427 #
428 AC_CONFIG_FILES([Makefile])
429 AC_CONFIG_FILES([libopenjpeg.pc])
430 AC_CONFIG_FILES([libopenjpeg/Makefile])
431 AC_CONFIG_FILES([jpwl/Makefile])
432 AC_CONFIG_FILES([codec/Makefile])
433 AC_CONFIG_FILES([mj2/Makefile])
434 AC_CONFIG_FILES([doc/Makefile])
435 AC_CONFIG_FILES([jp3d/Makefile])
436 AC_CONFIG_FILES([jp3d/libjp3dvm/Makefile])
437 AC_CONFIG_FILES([jp3d/codec/Makefile])
438 AC_OUTPUT
439 #
440 echo "----------------------------------------------"
441 echo "           your configuration"
442 echo ""
443 echo "--with-png-libraries: $with_libpng"
444 echo "libpng header       : $png_header_found"
445 echo "--enable-tiff       : $with_libtiff"
446 echo "libtiff header      : $tiff_header_found"
447 echo "--enable-lcms2      : $with_liblcms2"
448 echo "lcms2 header        : $lcms2_header_found"
449 echo "lcms2 version       : $have_lcms2_version"
450 echo "--enable-lcms1      : $with_liblcms1"
451 echo "lcms1 header        : $lcms1_header_found"
452 echo "lcms1 version       : $have_lcms1_version"
453 echo "--enable-jpwl       : $with_libjpwl"
454 echo "--enable-jp3d       : $with_jp3d"
455 echo "--enable-shared     : $with_sharedlibs"
456 echo "----------------------------------------------"