source: trunk/third/gnome-media/acinclude.m4 @ 18682

Revision 18682, 6.5 KB checked in by ghudson, 21 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18681, which included commits to RCS files with non-trunk default branches.
Line 
1# Configure paths for ESD
2# Manish Singh    98-9-30
3# stolen back from Frank Belew
4# stolen from Manish Singh
5# Shamelessly stolen from Owen Taylor
6
7dnl AM_PATH_ESD([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
8dnl Test for ESD, and define ESD_CFLAGS and ESD_LIBS
9dnl
10AC_DEFUN(AM_PATH_ESD,
11[dnl
12dnl Get the cflags and libraries from the esd-config script
13dnl
14AC_ARG_WITH(esd-prefix,[  --with-esd-prefix=PFX   Prefix where ESD is installed (optional)],
15            esd_prefix="$withval", esd_prefix="")
16AC_ARG_WITH(esd-exec-prefix,[  --with-esd-exec-prefix=PFX Exec prefix where ESD is installed (optional)],
17            esd_exec_prefix="$withval", esd_exec_prefix="")
18AC_ARG_ENABLE(esdtest, [  --disable-esdtest       Do not try to compile and run a test ESD program],
19                    , enable_esdtest=yes)
20
21  if test x$esd_exec_prefix != x ; then
22     esd_args="$esd_args --exec-prefix=$esd_exec_prefix"
23     if test x${ESD_CONFIG+set} != xset ; then
24        ESD_CONFIG=$esd_exec_prefix/bin/esd-config
25     fi
26  fi
27  if test x$esd_prefix != x ; then
28     esd_args="$esd_args --prefix=$esd_prefix"
29     if test x${ESD_CONFIG+set} != xset ; then
30        ESD_CONFIG=$esd_prefix/bin/esd-config
31     fi
32  fi
33
34  AC_PATH_PROG(ESD_CONFIG, esd-config, no)
35  min_esd_version=ifelse([$1], ,0.2.7,$1)
36  AC_MSG_CHECKING(for ESD - version >= $min_esd_version)
37  no_esd=""
38  if test "$ESD_CONFIG" = "no" ; then
39    no_esd=yes
40  else
41    ESD_CFLAGS=`$ESD_CONFIG $esdconf_args --cflags`
42    ESD_LIBS=`$ESD_CONFIG $esdconf_args --libs`
43
44    esd_major_version=`$ESD_CONFIG $esd_args --version | \
45           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
46    esd_minor_version=`$ESD_CONFIG $esd_args --version | \
47           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
48    esd_micro_version=`$ESD_CONFIG $esd_config_args --version | \
49           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
50    if test "x$enable_esdtest" = "xyes" ; then
51      ac_save_CFLAGS="$CFLAGS"
52      ac_save_LIBS="$LIBS"
53      CFLAGS="$CFLAGS $ESD_CFLAGS"
54      LIBS="$LIBS $ESD_LIBS"
55dnl
56dnl Now check if the installed ESD is sufficiently new. (Also sanity
57dnl checks the results of esd-config to some extent
58dnl
59      rm -f conf.esdtest
60      AC_TRY_RUN([
61#include <stdio.h>
62#include <stdlib.h>
63#include <string.h>
64#include <esd.h>
65
66char*
67my_strdup (char *str)
68{
69  char *new_str;
70 
71  if (str)
72    {
73      new_str = malloc ((strlen (str) + 1) * sizeof(char));
74      strcpy (new_str, str);
75    }
76  else
77    new_str = NULL;
78 
79  return new_str;
80}
81
82int main ()
83{
84  int major, minor, micro;
85  char *tmp_version;
86
87  system ("touch conf.esdtest");
88
89  /* HP/UX 9 (%@#!) writes to sscanf strings */
90  tmp_version = my_strdup("$min_esd_version");
91  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
92     printf("%s, bad version string\n", "$min_esd_version");
93     exit(1);
94   }
95
96   if (($esd_major_version > major) ||
97      (($esd_major_version == major) && ($esd_minor_version > minor)) ||
98      (($esd_major_version == major) && ($esd_minor_version == minor) && ($esd_micro_version >= micro)))
99    {
100      return 0;
101    }
102  else
103    {
104      printf("\n*** 'esd-config --version' returned %d.%d.%d, but the minimum version\n", $esd_major_version, $esd_minor_version, $esd_micro_version);
105      printf("*** of ESD required is %d.%d.%d. If esd-config is correct, then it is\n", major, minor, micro);
106      printf("*** best to upgrade to the required version.\n");
107      printf("*** If esd-config was wrong, set the environment variable ESD_CONFIG\n");
108      printf("*** to point to the correct copy of esd-config, and remove the file\n");
109      printf("*** config.cache before re-running configure\n");
110      return 1;
111    }
112}
113
114],, no_esd=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
115       CFLAGS="$ac_save_CFLAGS"
116       LIBS="$ac_save_LIBS"
117     fi
118  fi
119  if test "x$no_esd" = x ; then
120     AC_MSG_RESULT(yes)
121     ifelse([$2], , :, [$2])     
122  else
123     AC_MSG_RESULT(no)
124     if test "$ESD_CONFIG" = "no" ; then
125       echo "*** The esd-config script installed by ESD could not be found"
126       echo "*** If ESD was installed in PREFIX, make sure PREFIX/bin is in"
127       echo "*** your path, or set the ESD_CONFIG environment variable to the"
128       echo "*** full path to esd-config."
129     else
130       if test -f conf.esdtest ; then
131        :
132       else
133          echo "*** Could not run ESD test program, checking why..."
134          CFLAGS="$CFLAGS $ESD_CFLAGS"
135          LIBS="$LIBS $ESD_LIBS"
136          AC_TRY_LINK([
137#include <stdio.h>
138#include <esd.h>
139],      [ return 0; ],
140        [ echo "*** The test program compiled, but did not run. This usually means"
141          echo "*** that the run-time linker is not finding ESD or finding the wrong"
142          echo "*** version of ESD. If it is not finding ESD, you'll need to set your"
143          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
144          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
145          echo "*** is required on your system"
146          echo "***"
147          echo "*** If you have an old version installed, it is best to remove it, although"
148          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
149        [ echo "*** The test program failed to compile or link. See the file config.log for the"
150          echo "*** exact error that occured. This usually means ESD was incorrectly installed"
151          echo "*** or that you have moved ESD since it was installed. In the latter case, you"
152          echo "*** may want to edit the esd-config script: $ESD_CONFIG" ])
153          CFLAGS="$ac_save_CFLAGS"
154          LIBS="$ac_save_LIBS"
155       fi
156     fi
157     ESD_CFLAGS=""
158     ESD_LIBS=""
159     ifelse([$3], , :, [$3])
160  fi
161  AC_SUBST(ESD_CFLAGS)
162  AC_SUBST(ESD_LIBS)
163  rm -f conf.esdtest
164])
165
166dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
167dnl example
168dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
169dnl will set SYSCONFDIR to /usr/local/etc
170
171AC_DEFUN(AS_AC_EXPAND,
172[
173  EXP_VAR=[$1]
174  FROM_VAR=[$2]
175
176  dnl first expand prefix and exec_prefix if necessary
177  prefix_save=$prefix
178  if test "x$prefix" = "xNONE"; then
179    prefix=/usr/local
180  fi
181  exec_prefix_save=$exec_prefix
182  if test "x$exec_prefix" = "xNONE"; then
183    exec_prefix=/usr/local
184  fi
185
186  full_var="$FROM_VAR"
187  dnl loop until it doesn't change anymore
188  while true; do
189    new_full_var="`eval echo $full_var`"
190    if test "x$new_full_var"="x$full_var"; then break; fi
191    full_var=$new_full_var
192  done
193
194  dnl clean up
195  full_var=$new_full_var
196  AC_SUBST([$1], "$full_var")
197  prefix=$prefix_save
198  exec_prefix=$exec_prefix_save
199])
Note: See TracBrowser for help on using the repository browser.