s/libopenjpeg.pc/libopenjpeg1.pc/
[openjpeg.git] / configure.ac
index 55ab6498f010d91e5dfe35397677bd7bbd440ee9..e554fce97490cac0fdb04ad59e885486e846d17e 100644 (file)
@@ -38,7 +38,6 @@ AC_SUBST(JP3D_BUILD_NR)
 # Checks for programs.
 AC_PROG_CC
 AC_PROG_CXX
-AC_PROG_RANLIB
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_SED
@@ -54,18 +53,18 @@ AC_OBJEXT
 #
 # Configure libtool
 AC_ENABLE_SHARED
-AC_ENABLE_STATIC
 AC_LIBTOOL_WIN32_DLL
 AC_LIBTOOL_SETUP
 AC_PROG_LIBTOOL
 #
 AC_C_BIGENDIAN
 #
-LDLIBS=""
-#
 LIB_MATH=""
 AC_CHECK_LIB(m,sqrt,LIB_MATH="-lm",,)
-LDLIBS=""
+LIB_Z=""
+AC_CHECK_LIB(z,inflate,LIB_Z="-lz",,)
+#
+LIBS="$LIBS $LIB_MATH $LIB_Z"
 #
 AC_PATH_PROG([PKGCONFIG], [pkg-config])
 #
@@ -95,10 +94,15 @@ if test "x$with_libpng" = xyes ; then
   else
    if test -n "$PKGCONFIG" ; then
      pngincludes="`$PKGCONFIG --variable=includedir libpng`"
-   fi
-   if test -n "$pngincludes" ; then
-    pngheader="$pngincludes"
-    pngincludes="-I$pngincludes"
+     if test -n "$pngincludes" ; then
+      pngheader="$pngincludes"
+      pngincludes="-I$pngincludes"
+     fi
+   else
+     if test -n "$LIBPNG_CONFIG" ; then
+      pngincludes="`$LIBPNG_CONFIG --I_opts`"
+      pngheader="`$LIBPNG_CONFIG --I_opts | $SED 's/-I//'`"
+     fi
    fi
   fi
   if test -n "$pngheader" ; then
@@ -106,34 +110,33 @@ if test "x$with_libpng" = xyes ; then
   else
    pngheader="png.h"
   fi
+#
   AC_CHECK_HEADER($pngheader,png_header_found="yes",,)
-#last resort
-  if test "$png_header_found" = "no" ; then
-   pngincludes=""
-   pngheader=""
-   if test -n "$LIBPNG_CONFIG" ; then
-     pngincludes="`$LIBPNG_CONFIG --I_opts`"
-     pngheader="`$LIBPNG_CONFIG --I_opts | $SED 's/-I//'`"
-   fi
-   if test -n "$pngheader" ; then
-    pngheader="$pngheader/png.h"
-    AC_CHECK_HEADER($pngheader,png_header_found="yes",,)
-   fi
-  fi
 #
   AC_ARG_WITH(png_libraries,
  [  --with-png-libraries=DIR        PNG library in nonstandard DIR])
   if [[ -n "$with_png_libraries" ]] ; then
-   pnglibs="-L$with_png_libraries -lpng -lz $LIB_MATH"
+   pnglibs="-L$with_png_libraries -lpng"
   else
     if test -n "$LIBPNG_CONFIG" ; then
-     pnglibs="`$LIBPNG_CONFIG --ldflags` -lz $LIB_MATH"
+     pnglibs="`$LIBPNG_CONFIG --ldflags`"
+    else
+      if test -n "$PKGCONFIG" ; then
+        pnglibs="`$PKGCONFIG --libs libpng`"
+      fi
     fi
   fi
+  savedLIBS="$LIBS"
+  LIBS="$pnglibs $LIB_Z $LIB_MATH"
+#
+  AC_CHECK_LIB(png,png_create_read_struct,,pnglibs="",)
+#
+  LIBS="$savedLIBS"
   if test -n "$pnglibs" ; then
     if test -n "$pngincludes" ; then
       with_libpng="yes"
       png_header_found="yes"
+      LIBS="$LIBS $pnglibs"
       AC_DEFINE(HAVE_LIBPNG, [1], [define to 1 if you have libpng])
     fi
   fi
@@ -141,7 +144,6 @@ fi
 #
 AC_MSG_RESULT(png is usable:$with_libpng)
 AM_CONDITIONAL([with_libpng], [test x$with_libpng = xyes])
-LDLIBS="$LDLIBS $pnglibs"
 AC_SUBST(pngincludes)
 AC_SUBST(pnglibs)
 # -------------------------------
@@ -158,14 +160,24 @@ AC_ARG_ENABLE(tiff,
 test "$enable_tiff" = "no"  && with_libtiff="no")
 #
 if test "x$with_libtiff" = xyes ; then
+#TIFF compiled with JPEG and JBIG support?
+ libjpeg=""
+ AC_CHECK_LIB(jpeg,jpeg_read_header,libjpeg=-ljpeg,,)
+ libjbig=""
+ AC_CHECK_LIB(jbig,jbg_enc_init,libjbig=-ljbig,,)
+ libjbig85=""
+ AC_CHECK_LIB(jbig85,jbg85_enc_init,libjbig85=-ljbig85,,)
 #standard path
  with_libtiff="no"
+ savedLIBS="$LIBS"
+ LIBS="-ltiff $libjpeg $libjbig $libjbig85 $LIB_Z $LIB_MATH"
  AC_CHECK_LIB(tiff, TIFFOpen, tifflibs=-ltiff)
+ LIBS="$savedLIBS"
  if test -n "$tifflibs" ; then
   AC_CHECK_HEADER(tiff.h,tiff_header_found="yes",,)
   if test "$tiff_header_found" = "yes" ; then 
    with_libtiff="yes"
-   LIBS="$LIBS -ltiff $LIB_MATH"
+   LIBS="$LIBS -ltiff $libjpeg $libjbig $libjbig85"
    AC_DEFINE(HAVE_LIBTIFF, [1], [define to 1 if you have libtiff])
   fi
  fi
@@ -186,12 +198,12 @@ if test "x$with_libtiff" = xyes ; then
   if test -n "$with_tiff_libraries" ; then
    tifflibs="-L$with_tiff_libraries"
   fi
-  tifflibs="$tifflibs -ltiff $LIB_MATH"
+  tifflibs="$tifflibs -ltiff"
   savedLIBS="$LIBS"
-  LIBS="$tifflibs"
+  LIBS="$tifflibs $libjpeg $libjbig $libjbig85 $LIB_Z $LIB_MATH"
   with_libtiff="no"
 #
-  AC_CHECK_FUNC(TIFFOpen, true, tifflibs="")
+  AC_CHECK_LIB(tiff, TIFFOpen, , tifflibs="",)
 #
   if test -n "$tifflibs" ; then
    if test "$tiff_header_found" = "yes" ; then
@@ -199,13 +211,12 @@ if test "x$with_libtiff" = xyes ; then
     AC_DEFINE(HAVE_LIBTIFF, [1], [define to 1 if you have libtiff])
    fi
   fi
-  LIBS="$savedLIBS $tifflibs"
+  LIBS="$savedLIBS $tifflibs $libjpeg $libjbig $libjbig85"
  fi
 fi
 #
 AC_MSG_RESULT(tiff is usable:$with_libtiff)
 AM_CONDITIONAL([with_libtiff], [test x$with_libtiff = xyes])
-LDLIBS="$tifflibs $LDLIBS"
 AC_SUBST(tiffincludes)
 AC_SUBST(tifflibs)
 # -------------------------------
@@ -262,13 +273,13 @@ if test "x$with_liblcms2" = xyes ; then
    if test -z "$lcms2libs" ; then
     lcms2libs="-llcms2"
    fi
-   lcms2libs="$lcms2libs $LIB_MATH"
+   lcms2libs="$lcms2libs"
   fi
   savedLIBS="$LIBS"
-  LIBS="$lcms2libs"
+  LIBS="$lcms2libs $LIB_MATH"
   with_liblcms2="no"
 #
-  AC_CHECK_FUNC(cmsOpenProfileFromFile, true, lcms2libs="")
+  AC_CHECK_LIB(lcms2, cmsOpenProfileFromFile, ,lcms2libs="",)
 #
   if test -n "$lcms2libs" ; then
    if test "$lcms2_header_found" = "yes" ; then
@@ -288,8 +299,7 @@ if test "x$with_liblcms2" = xyes ; then
 fi
 #
 AC_MSG_RESULT(lcms2 is usable:$with_liblcms2)
-AM_CONDITIONAL([with_liblcms2], [test x$with_liblmcs2 = xyes])
-LDLIBS="$lcms2libs $LDLIBS"
+AM_CONDITIONAL([with_liblcms2], [test x$with_liblcms2 = xyes])
 AC_SUBST(lcms2includes)
 AC_SUBST(lcms2libs)
 AC_MSG_RESULT(lcms2libs:$lcms2libs)
@@ -337,13 +347,13 @@ if [[ -z "$lcms2libs" ]] ; then
     if test -z "$lcms1libs" ; then
      lcms1libs="-llcms"
     fi
-    lcms1libs="$lcms1libs $LIB_MATH"
+    lcms1libs="$lcms1libs"
    fi
    savedLIBS="$LIBS"
-   LIBS="$lcms1libs"
+   LIBS="$lcms1libs $LIB_MATH"
    with_liblcms1="no"
 #
-   AC_CHECK_FUNC(cmsOpenProfileFromFile, true, lcms1libs="")
+   AC_CHECK_LIB(lcms, cmsOpenProfileFromFile, ,lcms1libs="",)
 #
    if test -n "$lcms1libs" ; then
     if test "$lcms1_header_found" = "yes" ; then
@@ -365,7 +375,6 @@ AC_MSG_RESULT(lcms is usable:$with_liblcms1)
 fi
 #
 AM_CONDITIONAL([with_liblcms1], [test x$with_liblcms1 = xyes])
-LDLIBS="$lcms1libs $LDLIBS"
 AC_SUBST(lcms1includes)
 AC_SUBST(lcms1libs)
 #
@@ -388,16 +397,41 @@ AC_SUBST(jpwl_dir)
 #
 # -------------------------------
 # Test for creating SHARED LIBS
+# wanted result: shared xor static
 # -------------------------------
-with_sharedlibs="no"
+with_sharedlibs="yes"
 AC_MSG_CHECKING(whether to build shared libraries)
 AC_ARG_ENABLE(shared,
- [  --enable-shared[=[yes|no]]       Build shared libs [ [default=no] ]],
- test "$enable_shared" = "yes" && with_sharedlibs="yes")
+[  --enable-shared[=[yes|no]]       Build shared libs [ [default=yes] ]],
+test "$enable_shared" = "no" && with_sharedlibs="no")
 #
 AC_MSG_RESULT($with_sharedlibs)
 AM_CONDITIONAL([with_sharedlibs], [test x$with_sharedlibs = xyes])
 #
+#
+build_so="no"
+build_dll="no"
+build_dylib="no"
+case "${host_os}" in
+    *cygwin*)
+        build_dll="yes"
+        ;;
+    *mingw*)
+        build_dll="yes"
+        ;;
+    *darwin*)
+        build_dylib="yes"
+        ;;
+       *)
+               build_so="yes"
+               ;;
+esac
+#
+AM_CONDITIONAL([build_dll], [test x$build_dll = xyes])
+AM_CONDITIONAL([build_dylib], [test x$build_dylib = xyes])
+AM_CONDITIONAL([build_so], [test x$build_so = xyes])
+#
+
 # -------------------------------
 # Test for creating JP3D
 # -------------------------------
@@ -414,16 +448,11 @@ if test "$with_jp3d" = "yes" ; then
 fi
 AC_SUBST(jp3d_dir)
 #
-AC_SUBST(LDLIBS)
-#
 AC_CHECK_PROG(with_doxygen, doxygen, [yes],[no],,)
-doxy_dir=""
-if test "$with_doxygen" = "yes" ; then
- dox_dir="doc"
-fi
-AC_SUBST(doxy_dir)
+AM_CONDITIONAL([with_doxygen], [test x$with_doxygen = xyes])
 #
 AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([libopenjpeg1.pc])
 AC_CONFIG_FILES([libopenjpeg/Makefile])
 AC_CONFIG_FILES([jpwl/Makefile])
 AC_CONFIG_FILES([codec/Makefile])
@@ -447,6 +476,7 @@ echo "lcms2 version       : $have_lcms2_version"
 echo "--enable-lcms1      : $with_liblcms1"
 echo "lcms1 header        : $lcms1_header_found"
 echo "lcms1 version       : $have_lcms1_version"
-echo "jpwl support        : $with_libjpwl"
+echo "--enable-jpwl       : $with_libjpwl"
 echo "--enable-jp3d       : $with_jp3d"
+echo "--enable-shared     : $with_sharedlibs"
 echo "----------------------------------------------"