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