acinclude/esd.m4
changeset 3342 3da232c5980a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/acinclude/esd.m4	Sun Oct 04 20:44:04 2009 +0000
     1.3 @@ -0,0 +1,168 @@
     1.4 +##############################################################################
     1.5 +#
     1.6 +# --- esd.m4 ---
     1.7 +#
     1.8 +# Configure paths for ESD
     1.9 +# Manish Singh    98-9-30
    1.10 +# stolen back from Frank Belew
    1.11 +# stolen from Manish Singh
    1.12 +# Shamelessly stolen from Owen Taylor
    1.13 +
    1.14 +dnl AM_PATH_ESD([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
    1.15 +dnl Test for ESD, and define ESD_CFLAGS and ESD_LIBS
    1.16 +dnl
    1.17 +AC_DEFUN([AM_PATH_ESD],
    1.18 +[dnl 
    1.19 +dnl Get the cflags and libraries from the esd-config script
    1.20 +dnl
    1.21 +AC_ARG_WITH(esd-prefix,[  --with-esd-prefix=PFX   Prefix where ESD is installed (optional)],
    1.22 +            esd_prefix="$withval", esd_prefix="")
    1.23 +AC_ARG_WITH(esd-exec-prefix,[  --with-esd-exec-prefix=PFX Exec prefix where ESD is installed (optional)],
    1.24 +            esd_exec_prefix="$withval", esd_exec_prefix="")
    1.25 +AC_ARG_ENABLE(esdtest, [  --disable-esdtest       Do not try to compile and run a test ESD program],
    1.26 +		    , enable_esdtest=yes)
    1.27 +
    1.28 +  if test x$esd_exec_prefix != x ; then
    1.29 +     esd_args="$esd_args --exec-prefix=$esd_exec_prefix"
    1.30 +     if test x${ESD_CONFIG+set} != xset ; then
    1.31 +        ESD_CONFIG=$esd_exec_prefix/bin/esd-config
    1.32 +     fi
    1.33 +  fi
    1.34 +  if test x$esd_prefix != x ; then
    1.35 +     esd_args="$esd_args --prefix=$esd_prefix"
    1.36 +     if test x${ESD_CONFIG+set} != xset ; then
    1.37 +        ESD_CONFIG=$esd_prefix/bin/esd-config
    1.38 +     fi
    1.39 +  fi
    1.40 +
    1.41 +  AC_PATH_PROG(ESD_CONFIG, esd-config, no)
    1.42 +  min_esd_version=ifelse([$1], ,0.2.7,$1)
    1.43 +  AC_MSG_CHECKING(for ESD - version >= $min_esd_version)
    1.44 +  no_esd=""
    1.45 +  if test "$ESD_CONFIG" = "no" ; then
    1.46 +    no_esd=yes
    1.47 +  else
    1.48 +    ESD_CFLAGS=`$ESD_CONFIG $esdconf_args --cflags`
    1.49 +    ESD_LIBS=`$ESD_CONFIG $esdconf_args --libs`
    1.50 +
    1.51 +    esd_major_version=`$ESD_CONFIG $esd_args --version | \
    1.52 +           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
    1.53 +    esd_minor_version=`$ESD_CONFIG $esd_args --version | \
    1.54 +           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
    1.55 +    esd_micro_version=`$ESD_CONFIG $esd_config_args --version | \
    1.56 +           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
    1.57 +    if test "x$enable_esdtest" = "xyes" ; then
    1.58 +      ac_save_CFLAGS="$CFLAGS"
    1.59 +      ac_save_LIBS="$LIBS"
    1.60 +      CFLAGS="$CFLAGS $ESD_CFLAGS"
    1.61 +      LIBS="$LIBS $ESD_LIBS"
    1.62 +dnl
    1.63 +dnl Now check if the installed ESD is sufficiently new. (Also sanity
    1.64 +dnl checks the results of esd-config to some extent
    1.65 +dnl
    1.66 +      rm -f conf.esdtest
    1.67 +      AC_TRY_RUN([
    1.68 +#include <stdio.h>
    1.69 +#include <stdlib.h>
    1.70 +#include <string.h>
    1.71 +#include <esd.h>
    1.72 +
    1.73 +char*
    1.74 +my_strdup (char *str)
    1.75 +{
    1.76 +  char *new_str;
    1.77 +  
    1.78 +  if (str)
    1.79 +    {
    1.80 +      new_str = malloc ((strlen (str) + 1) * sizeof(char));
    1.81 +      strcpy (new_str, str);
    1.82 +    }
    1.83 +  else
    1.84 +    new_str = NULL;
    1.85 +  
    1.86 +  return new_str;
    1.87 +}
    1.88 +
    1.89 +int main ()
    1.90 +{
    1.91 +  int major, minor, micro;
    1.92 +  char *tmp_version;
    1.93 +
    1.94 +  system ("touch conf.esdtest");
    1.95 +
    1.96 +  /* HP/UX 9 (%@#!) writes to sscanf strings */
    1.97 +  tmp_version = my_strdup("$min_esd_version");
    1.98 +  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
    1.99 +     printf("%s, bad version string\n", "$min_esd_version");
   1.100 +     exit(1);
   1.101 +   }
   1.102 +
   1.103 +   if (($esd_major_version > major) ||
   1.104 +      (($esd_major_version == major) && ($esd_minor_version > minor)) ||
   1.105 +      (($esd_major_version == major) && ($esd_minor_version == minor) && ($esd_micro_version >= micro)))
   1.106 +    {
   1.107 +      return 0;
   1.108 +    }
   1.109 +  else
   1.110 +    {
   1.111 +      printf("\n*** 'esd-config --version' returned %d.%d.%d, but the minimum version\n", $esd_major_version, $esd_minor_version, $esd_micro_version);
   1.112 +      printf("*** of ESD required is %d.%d.%d. If esd-config is correct, then it is\n", major, minor, micro);
   1.113 +      printf("*** best to upgrade to the required version.\n");
   1.114 +      printf("*** If esd-config was wrong, set the environment variable ESD_CONFIG\n");
   1.115 +      printf("*** to point to the correct copy of esd-config, and remove the file\n");
   1.116 +      printf("*** config.cache before re-running configure\n");
   1.117 +      return 1;
   1.118 +    }
   1.119 +}
   1.120 +
   1.121 +],, no_esd=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
   1.122 +       CFLAGS="$ac_save_CFLAGS"
   1.123 +       LIBS="$ac_save_LIBS"
   1.124 +     fi
   1.125 +  fi
   1.126 +  if test "x$no_esd" = x ; then
   1.127 +     AC_MSG_RESULT(yes)
   1.128 +     ifelse([$2], , :, [$2])     
   1.129 +  else
   1.130 +     AC_MSG_RESULT(no)
   1.131 +     if test "$ESD_CONFIG" = "no" ; then
   1.132 +       echo "*** The esd-config script installed by ESD could not be found"
   1.133 +       echo "*** If ESD was installed in PREFIX, make sure PREFIX/bin is in"
   1.134 +       echo "*** your path, or set the ESD_CONFIG environment variable to the"
   1.135 +       echo "*** full path to esd-config."
   1.136 +     else
   1.137 +       if test -f conf.esdtest ; then
   1.138 +        :
   1.139 +       else
   1.140 +          echo "*** Could not run ESD test program, checking why..."
   1.141 +          CFLAGS="$CFLAGS $ESD_CFLAGS"
   1.142 +          LIBS="$LIBS $ESD_LIBS"
   1.143 +          AC_TRY_LINK([
   1.144 +#include <stdio.h>
   1.145 +#include <esd.h>
   1.146 +],      [ return 0; ],
   1.147 +        [ echo "*** The test program compiled, but did not run. This usually means"
   1.148 +          echo "*** that the run-time linker is not finding ESD or finding the wrong"
   1.149 +          echo "*** version of ESD. If it is not finding ESD, you'll need to set your"
   1.150 +          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
   1.151 +          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
   1.152 +          echo "*** is required on your system"
   1.153 +	  echo "***"
   1.154 +          echo "*** If you have an old version installed, it is best to remove it, although"
   1.155 +          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
   1.156 +        [ echo "*** The test program failed to compile or link. See the file config.log for the"
   1.157 +          echo "*** exact error that occured. This usually means ESD was incorrectly installed"
   1.158 +          echo "*** or that you have moved ESD since it was installed. In the latter case, you"
   1.159 +          echo "*** may want to edit the esd-config script: $ESD_CONFIG" ])
   1.160 +          CFLAGS="$ac_save_CFLAGS"
   1.161 +          LIBS="$ac_save_LIBS"
   1.162 +       fi
   1.163 +     fi
   1.164 +     ESD_CFLAGS=""
   1.165 +     ESD_LIBS=""
   1.166 +     ifelse([$3], , :, [$3])
   1.167 +  fi
   1.168 +  AC_SUBST(ESD_CFLAGS)
   1.169 +  AC_SUBST(ESD_LIBS)
   1.170 +  rm -f conf.esdtest
   1.171 +])