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