autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't detect OpenEXR


From: Robin Rowe
Subject: Re: Can't detect OpenEXR
Date: Fri, 31 Dec 2004 10:55:10 -0800

Making progress!

Here's what I've got now:

############## OpenEXR
AC_MSG_CHECKING(for openexr support)
AC_LANG(C++)
AC_CHECK_HEADER(OpenEXR/half.h,,AC_MSG_ERROR([*** openexr dev header half.h
not found ***]))
AC_LANG(C)
# AM_PATH_OPENEXR(have_openexr=yes OPENEXR='openexr', have_openexr=no
OPENEXR= )
OPENEXR_INCLUDES="-I/usr/include/OpenEXR"
AC_SUBST(OPENEXR_INCLUDES)
# end OpenEXR

This works, barely. I tried using $prefix and $ac_default_prefix in
OPENEXR_INCLUDES, but those gave NONE and /usr/local/include respectively.
How do I get the hard path to /usr out of OPENEXR_INCLUDES?

For OPENEXR_LIBS I have that set in Makefile.am. OpenEXR is a plug-in,
should not link to the main program.

I didn't change AC_MSG_CHECKING as Stepan suggested because I'm not clear
what I should do instead or why.

There's an old AM_PATH_OPENEXR macro somebody had created in our
acinclude.m4, but it reports no OpenEXR unless used with flags on the line
with ./configure. This was from before OpenEXR was packaged, when we had to
use optional args to add OpenEXR. Suggestions?

AC_DEFUN(AM_PATH_OPENEXR,
[dnl
dnl Get the cflags and libraries
dnl
AC_ARG_WITH(openexr-prefix,[  --with-openexr-prefix=PFX   Prefix where
libopenexr is installed (optional)], openexr_prefix="$withval",
openexr_prefix="")
AC_ARG_ENABLE(openexrtest, [  --disable-openexrtest       Do not try to
compile and run a test Openexr program],, enable_openexrtest=yes)

  if test "x$openexr_prefix" != "xNONE" ; then
    openexr_args="$openexr_args --prefix=$openexr_prefix"
    OPENEXR_INCLUDES="-I$openexr_prefix/include/OpenEXR"
    OPENEXR_LIBS="-L$openexr_prefix/lib"
  elif test "$prefix" != ""; then
    openexr_args="$openexr_args --prefix=$prefix"
    OPENEXR_INCLUDES="-I$prefix/include/OpenEXR"
    OPENEXR_LIBS="-L$prefix/lib"
  fi

  OPENEXR_LIBS="$X_LIBS $OPENEXR_LIBS -lIlmImf -lImath -lIex -lHalf -lz"

  AC_MSG_CHECKING(for OpenEXR)
  no_openexr=""


  if test "x$enable_openexrtest" = "xyes" ; then
    ac_save_CXXFLAGS="$CXXFLAGS"
    ac_save_LIBS="$LIBS"
    CXXFLAGS="$CXXFLAGS $OPENEXR_CXXFLAGS $OPENEXR_INCLUDES $OPENEXR_LIBS"
    LIBS="$LIBS $OPENEXR_LIBS"
      rm -f conf.openexrtest
      AC_LANG_SAVE
      AC_LANG_CPLUSPLUS
      AC_TRY_RUN([
#include <stdlib.h>
#include <ImfRgbaFile.h>
#include <stdio.h>

int main ()
{ printf("running openexrtest program... ");
  try
  {
    Imf::RgbaInputFile exr ("");
  }
  catch (...)
  {
  }
  system("touch conf.openexrtest");
  return 0;
}

],, no_openexr=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
       AC_LANG_RESTORE
       CXXFLAGS="$ac_save_CXXFLAGS"
       LIBS="$ac_save_LIBS"
  fi

  if test "x$no_openexr" = "x" ; then
     AC_MSG_RESULT(yes)
     ifelse([$1], , :, [$1])
  else
     AC_MSG_RESULT(no)
     if test -f conf.openexrtest ; then
       :
     else
       echo "*** Could not run OpenEXR test program, checking why..."
       CXXFLAGS="$CXXFLAGS $OPENEXR_CXXFLAGS $OPENEXR_INCLUDES
$OPENEXR_LIBS"
       LIBS="$LIBS $OPENEXR_LIBS"
       AC_LANG_SAVE
       AC_LANG_CPLUSPLUS
       AC_TRY_LINK([
#include <stdio.h>
#include <ImfRgbaFile.h>
],     [ Imf::RgbaInputFile exr ("");return 0; ],
       [ echo "*** The test program compiled, but did not run. This usually
means"
       echo "*** that the run-time linker is not finding OpenEXR or finding
the wrong"
       echo "*** version of OpenEXR. If it is not finding OpenEXR, you'll
need to set your"
       echo "*** LD_LIBRARY_PATH environment variable, or edit
/etc/ld.so.conf to point"
       echo "*** to the installed location  Also, make sure you have run
ldconfig if that"
       echo "*** is required on your system"
 echo "*** LD_LIBRARY_PATH = "
 printenv LD_LIBRARY_PATH
 echo "*** OPENEXR_LIBS = $OPENEXR_LIBS"
 echo "*** OPENEXR_INCLUDES = $OPENEXR_INCLUDES"
       echo "***"])
       AC_LANG_RESTORE
       CXXFLAGS="$ac_save_CXXFLAGS"
       LIBS="$ac_save_LIBS"
     fi
     OPENEXR_INCLUDES=""
     OPENEXR_LIBS=""
     ifelse([$2], , :, [$2])
  fi
  AC_SUBST(OPENEXR_INCLUDES)
  AC_SUBST(OPENEXR_LIBS)
  rm -f conf.openexrtest
])

Thanks,

Robin





reply via email to

[Prev in Thread] Current Thread [Next in Thread]