fixed a bug in autotools files that prevented libfcgi to be correctly found in some...
authorAntonin Descampe <antonin@gmail.com>
Mon, 15 Aug 2011 13:22:46 +0000 (13:22 +0000)
committerAntonin Descampe <antonin@gmail.com>
Mon, 15 Aug 2011 13:22:46 +0000 (13:22 +0000)
CHANGES
applications/jpip/opj_client/opj_dec_server/Makefile.am
applications/jpip/tools/jpip_to_j2k.c
applications/jpip/tools/jpip_to_jp2.c
configure.ac
m4/opj_check_lib.m4

diff --git a/CHANGES b/CHANGES
index 48526ed7b5f3c8094021f4faa0020521c07dad34..fab0970a711ca21d9c55039209a3c30a95ddcb77 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,9 @@ What's New for OpenJPEG
 ! : changed
 + : added
 
+August 15, 2011
+* [antonin] fixed a bug in autotools files that prevented libfcgi to be correctly found in some cases (patch from V.Torri).
+
 August 12, 2011
 + [antonin] added cmake support to openjpip
 
index 4286a53deeeb815eb00228bcb6e32d2ff3904ddb..96c10ebe4990a5cd798eb08aea08bda55cbe8b76 100644 (file)
@@ -8,6 +8,8 @@ opj_dec_server_CPPFLAGS = \
 -I$(top_builddir)/applications/jpip/opj_server \
 -I$(top_srcdir)/applications/jpip/libopenjpip \
 -I$(top_builddir)/applications/jpip/libopenjpip \
+-I$(top_srcdir)/libopenjpeg \
+-I$(top_builddir)/libopenjpeg \
 @FCGI_CFLAGS@ \
 -DSERVER
 opj_dec_server_CFLAGS = 
index df84354c2d5d8e9efac6c686805fd08d2beb5a42..a3403f6527ebfe5b00e90292997048e0b5ff4faa 100644 (file)
@@ -94,8 +94,11 @@ int main(int argc,char *argv[])
   delete_msgqueue( &msgqueue);
   free( jpipstream);
 
-
+#ifdef _WIN32
+  if(( outfd = open( argv[2], O_WRONLY|O_CREAT, _S_IREAD | _S_IWRITE)) == -1){
+#else
   if(( outfd = open( argv[2], O_WRONLY|O_CREAT, S_IRWXU|S_IRWXG)) == -1){
+#endif
     fprintf( stderr, "file %s open error\n", argv[2]);
     return -1;
   }
index 979ddaf90502fbcbdd3e327ff9e111c664d83fc3..1bd08d4483165290bb40fa0f42c804fda297bad9 100644 (file)
@@ -101,8 +101,12 @@ int main(int argc,char *argv[])
   printf("NC: %d, bpc: %d\n", ihdrbox->nc, ihdrbox->bpc);
   
   jp2stream = recons_jp2( msgqueue, jpipstream, msgqueue->first->csn, &jp2len);
-    
+
+#ifdef _WIN32
+  if(( outfd = open( argv[2], O_WRONLY|O_CREAT, _S_IREAD | _S_IWRITE)) == -1){
+#else    
   if(( outfd = open( argv[2], O_WRONLY|O_CREAT, S_IRWXU|S_IRWXG)) == -1){
+#endif
     fprintf( stderr, "file %s open error\n", argv[2]);
     return -1;
   }
index dd4dd2e5dff834d2210be453a6a8f55b6fa33799..326e56fa0a9d839e2df2a4f67006dded140c35eb 100644 (file)
@@ -138,41 +138,6 @@ AC_ARG_ENABLE([jpip],
 AC_MSG_CHECKING([whether to build the JPIP library])
 AC_MSG_RESULT([${want_jpip}])
 
-if test "x${want_jpip}" = "xyes" ; then
-   AC_DEFINE(USE_JPIP, [1], [define to 1 if you use jpip])
-fi
-
-# libfcgi
-
-if test "x${want_jpip}" = "xyes" ; then
-   OPJ_CHECK_LIB([/usr],
-      [fcgi_stdio.h],
-      [fcgi],
-      [FCGI_printf],
-      [want_jpip="yes"],
-      [want_jpip="no"])
-fi
-
-if test "x${want_jpip}" = "xno" ; then
-   OPJ_CHECK_LIB([/usr/local],
-      [fcgi_stdio.h],
-      [fcgi],
-      [FCGI_printf],
-      [want_jpip="yes"],
-      [want_jpip="no"])
-fi
-
-if test "x${want_jpip}" = "xno" ; then
-   OPJ_CHECK_LIB([/opt],
-      [fcgi_stdio.h],
-      [fcgi],
-      [FCGI_printf],
-      [want_jpip="yes"],
-      [want_jpip="no"])
-fi
-
-AM_CONDITIONAL([WANT_JPIP], [test "x${want_jpip}" = "xyes"])
-
 
 ### Checks for programs
 
@@ -239,26 +204,7 @@ if test "x${want_png}" = "xyes" ; then
       ])
 
    if ! test "x${have_libpng}" = "xyes" ; then
-      OPJ_CHECK_LIB([/usr],
-         [png.h],
-         [png],
-         [png_create_write_struct],
-         [have_libpng="yes"],
-         [have_libpng="no"])
-   fi
-
-   if ! test "x${have_libpng}" = "xyes" ; then
-      OPJ_CHECK_LIB([/usr/local],
-         [png.h],
-         [png],
-         [png_create_write_struct],
-         [have_libpng="yes"],
-         [have_libpng="no"])
-   fi
-
-   if ! test "x${have_libpng}" = "xyes" ; then
-      OPJ_CHECK_LIB([/opt],
-         [png.h],
+      OPJ_CHECK_LIB([png.h],
          [png],
          [png_create_write_struct],
          [have_libpng="yes"],
@@ -300,31 +246,13 @@ AC_MSG_RESULT([${want_tiff}])
 
 if test "x${want_tiff}" = "xyes" ; then
 
-   OPJ_CHECK_LIB([/usr],
+   OPJ_CHECK_LIB(
       [tiff.h],
       [tiff],
       [TIFFOpen],
       [have_libtiff="yes"],
       [have_libtiff="no"])
 
-   if ! test "x${have_libtiff}" = "xyes" ; then
-      OPJ_CHECK_LIB([/usr/local],
-         [tiff.h],
-         [tiff],
-         [TIFFOpen],
-         [have_libtiff="yes"],
-         [have_libtiff="no"])
-   fi
-
-   if ! test "x${have_libtiff}" = "xyes" ; then
-      OPJ_CHECK_LIB([/opt],
-         [tiff.h],
-         [tiff],
-         [TIFFOpen],
-         [have_libtiff="yes"],
-         [have_libtiff="no"])
-   fi
-
    if test "x${have_libtiff}" = "xno" ; then
       AC_MSG_WARN([Can not find a usuable TIFF library. Make sure that CPPFLAGS and LDFLAGS are correctly set.])
    fi
@@ -339,11 +267,6 @@ fi
 
 AM_CONDITIONAL([with_libtiff], [test "x${have_libtiff}" = "xyes"])
 
-AC_ARG_VAR([TIFF_CFLAGS], [preprocessor flags for libtiff])
-AC_SUBST(TIFF_CFLAGS)
-AC_ARG_VAR([TIFF_LIBS], [linker flags for libtiff])
-AC_SUBST(TIFF_LIBS)
-
 # libcms2
 
 lcms_output="no"
@@ -422,6 +345,31 @@ if test "x${have_lcms2}" = "xno" ; then
 
 fi
 
+# libfcgi
+
+if test "x${want_jpip}" = "xyes" ; then
+
+   have_fcgi="no"
+   OPJ_CHECK_LIB(
+      [fcgi_stdio.h],
+      [fcgi],
+      [FCGI_Accept],
+      [have_fcgi="yes"],
+      [have_fcgi="no"])
+
+   if ! test "x${have_fcgi}" = "xyes" ; then
+      AC_MSG_WARN([FastCGI library not found. OpenJPIP will not be compiled.])
+      want_jpip="no"
+   fi
+
+fi
+
+if test "x${want_jpip}" = "xyes" ; then
+   AC_DEFINE(USE_JPIP, [1], [define to 1 if you use jpip])
+fi
+
+AM_CONDITIONAL([WANT_JPIP], [test "x${want_jpip}" = "xyes"])
+
 ### Checks for header files
 
 ## FIXME: declarations must be fixed in source code. See autoconf manual
index e401f8e11b4b37a66df0b234ec881f55e9a27042..a92d2622fdd8705d895a39d05c9f1a7e14ecab41 100644 (file)
@@ -3,12 +3,12 @@ dnl That code is public domain and can be freely used or copied.
 
 dnl Macro that check if a library is in a specified directory.
 
-dnl Usage: OPJ_CHECK_LIB(prefix, header, lib, func [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+dnl Usage: OPJ_CHECK_LIB_WITH_PREFIX(prefix, header, lib, func [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
 dnl Call AC_SUBST(THELIB_CFLAGS)
 dnl Call AC_SUBST(THELIB_LIBS)
 dnl where THELIB is the uppercase value of 'lib'
 
-AC_DEFUN([OPJ_CHECK_LIB],
+AC_DEFUN([OPJ_CHECK_LIB_WITH_PREFIX],
 [
 
 m4_pushdef([UP], m4_toupper([$3]))
@@ -21,36 +21,108 @@ __opj_func=$4
 __opj_have_dep="no"
 
 save_CPPFLAGS=${CPPFLAGS}
-CPPFLAGS="${CPPFLAGS} -I${__opj_prefix}/include"
-AC_CHECK_HEADER([${__opj_header}], [__opj_have_dep="yes"], [__opj_have_dep="no"])
-CPPFLAGS=${save_CPPFLAGS}
+save_LDFLAGS=${LDFLAGS}
+save_LIBS=${LIBS}
 
-if test "x${__opj_have_dep}" = "xyes" ; then
-   save_LDFLAGS=${LDFLAGS}
+if test "x${__opj_prefix}" = "x" ; then
+   CPPFLAGS="${CPPFLAGS} $UP[_CFLAGS]"
+   LDFLAGS="${LDFLAGS} $UP[_LIBS]"
+else
+   CPPFLAGS="${CPPFLAGS} -I${__opj_prefix}/include"
    LDFLAGS="${LDFLAGS} -L${__opj_prefix}/lib"
-   AC_CHECK_LIB([${__opj_lib}],
-      [${__opj_func}],
-      [__opj_have_dep="yes"],
-      [__opj_have_dep="no"])
-   LDFLAGS=${save_LDFLAGS}
+   LIBS="${LIBS} -l${__opj_lib}"
+fi
+
+AC_LINK_IFELSE(
+   [AC_LANG_PROGRAM(
+       [[
+#include <${__opj_header}>
+       ]],
+       [[
+${__opj_func}();
+       ]])],
+       [__opj_have_dep="yes"],
+       [__opj_have_dep="no"])
+
+CPPFLAGS=${save_CPPFLAGS}
+LDFLAGS=${save_LDFLAGS}
+LIBS=${save_LIBS}
+
+if test "x${__opj_prefix}" = "x" ; then
+   AC_MSG_CHECKING([whether ]UP[ library is available in standard or predefined directories])
+else
+   AC_MSG_CHECKING([whether ]UP[ library is available in ${__opj_prefix}])
 fi
+AC_MSG_RESULT([${__opj_have_dep}])
 
-if test "x${__opj_have_dep}" = "xyes" ; then
-   if ! test "x$1" = "x/usr" ; then
+if test "x${__opj_have_dep}" = "xyes" && ! test "x${__opj_prefix}" = "x"; then
+   if test "x${UP[]_CFLAGS}" = "x" ; then
       UP[]_CFLAGS="-I${__opj_prefix}/include"
-      UP[]_LIBS="-L${__opj_prefix}/lib"
    fi
-   UP[]_LIBS="${UP[]_LIBS} -l${__opj_lib}"
+   if test "x${UP[]_LIBS}" = "x" ; then
+      UP[]_LIBS="-L${__opj_prefix}/lib -l${__opj_lib}"
+   fi
+fi
+
+AS_IF([test "x${__opj_have_dep}" = "xyes"], [$5], [$6])
+
+m4_popdef([UP])
+m4_popdef([DOWN])
+
+])
+
+dnl Macro that check if a library is in a set of directories.
+
+dnl Usage: OPJ_CHECK_LIB(header, lib, func [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+
+AC_DEFUN([OPJ_CHECK_LIB],
+[
+
+m4_pushdef([UP], m4_toupper([$2]))
+
+__opj_have_dep="no"
+
+OPJ_CHECK_LIB_WITH_PREFIX([],
+   [$1],
+   [$2],
+   [$3],
+   [__opj_have_dep="yes"],
+   [__opj_have_dep="no"])
+
+if ! test "x${__opj_have_dep}" = "xyes" ; then
+   OPJ_CHECK_LIB_WITH_PREFIX([/usr],
+      [$1],
+      [$2],
+      [$3],
+      [__opj_have_dep="yes"],
+      [__opj_have_dep="no"])
 fi
 
-AC_ARG_VAR(UP[_CFLAGS], [preprocessor flags for lib$3])
+if ! test "x${__opj_have_dep}" = "xyes" ; then
+   OPJ_CHECK_LIB_WITH_PREFIX([/usr/local],
+      [$1],
+      [$2],
+      [$3],
+      [__opj_have_dep="yes"],
+      [__opj_have_dep="no"])
+fi
+
+if ! test "x${__opj_have_dep}" = "xyes" ; then
+   OPJ_CHECK_LIB_WITH_PREFIX([/opt/local],
+      [$1],
+      [$2],
+      [$3],
+      [__opj_have_dep="yes"],
+      [__opj_have_dep="no"])
+fi
+
+AC_ARG_VAR(UP[_CFLAGS], [preprocessor flags for lib$2])
 AC_SUBST(UP[_CFLAGS])
-AC_ARG_VAR(UP[_LIBS], [linker flags for lib$3])
+AC_ARG_VAR(UP[_LIBS], [linker flags for lib$2])
 AC_SUBST(UP[_LIBS])
 
-AS_IF([test "x${__opj_have_dep}" = "xyes"], [$5], [$6])
+AS_IF([test "x${__opj_have_dep}" = "xyes"], [$4], [$5])
 
 m4_popdef([UP])
-m4_popdef([DOWN])
 
 ])