various AC_HELP_STRING changes
[platform/upstream/gst-plugins-good.git] / m4 / esd.m4
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
7 dnl AM_PATH_ESD([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
8 dnl Test for ESD, and define ESD_CFLAGS and ESD_LIBS
9 dnl
10 AC_DEFUN(AM_PATH_ESD,
11 [dnl 
12 dnl Get the cflags and libraries from the esd-config script
13 dnl
14 AC_ARG_WITH(esd-prefix,
15   AC_HELP_STRING([--with-esd-prefix=PFX],
16                  [prefix where ESD is installed (optional)]),
17   esd_prefix="$withval", esd_prefix="")
18
19 AC_ARG_WITH(esd-exec-prefix,
20   AC_HELP_STRING([--with-esd-exec-prefix=PFX],
21                  [exec prefix where ESD is installed (optional)]),
22   esd_exec_prefix="$withval", esd_exec_prefix="")
23
24 AC_ARG_ENABLE(esdtest,
25   AC_HELP_STRING([--disable-esdtest],
26                  [do not try to compile and run a test ESD program]),
27   , enable_esdtest=yes)
28
29   if test x$esd_exec_prefix != x ; then
30      esd_args="$esd_args --exec-prefix=$esd_exec_prefix"
31      if test x${ESD_CONFIG+set} != xset ; then
32         ESD_CONFIG=$esd_exec_prefix/bin/esd-config
33      fi
34   fi
35   if test x$esd_prefix != x ; then
36      esd_args="$esd_args --prefix=$esd_prefix"
37      if test x${ESD_CONFIG+set} != xset ; then
38         ESD_CONFIG=$esd_prefix/bin/esd-config
39      fi
40   fi
41
42   AC_PATH_PROG(ESD_CONFIG, esd-config, no)
43   min_esd_version=ifelse([$1], ,0.2.7,$1)
44   AC_MSG_CHECKING(for ESD - version >= $min_esd_version)
45   no_esd=""
46   if test "$ESD_CONFIG" = "no" ; then
47     no_esd=yes
48   else
49     ESD_CFLAGS=`$ESD_CONFIG $esdconf_args --cflags`
50     ESD_LIBS=`$ESD_CONFIG $esdconf_args --libs`
51
52     esd_major_version=`$ESD_CONFIG $esd_args --version | \
53            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
54     esd_minor_version=`$ESD_CONFIG $esd_args --version | \
55            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
56     esd_micro_version=`$ESD_CONFIG $esd_config_args --version | \
57            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
58     if test "x$enable_esdtest" = "xyes" ; then
59       ac_save_CFLAGS="$CFLAGS"
60       ac_save_LIBS="$LIBS"
61       CFLAGS="$CFLAGS $ESD_CFLAGS"
62       LIBS="$LIBS $ESD_LIBS"
63 dnl
64 dnl Now check if the installed ESD is sufficiently new. (Also sanity
65 dnl checks the results of esd-config to some extent
66 dnl
67       rm -f conf.esdtest
68       AC_TRY_RUN([
69 #include <stdio.h>
70 #include <stdlib.h>
71 #include <string.h>
72 #include <esd.h>
73
74 char*
75 my_strdup (char *str)
76 {
77   char *new_str;
78   
79   if (str)
80     {
81       new_str = malloc ((strlen (str) + 1) * sizeof(char));
82       strcpy (new_str, str);
83     }
84   else
85     new_str = NULL;
86   
87   return new_str;
88 }
89
90 int main ()
91 {
92   int major, minor, micro;
93   char *tmp_version;
94
95   system ("touch conf.esdtest");
96
97   /* HP/UX 9 (%@#!) writes to sscanf strings */
98   tmp_version = my_strdup("$min_esd_version");
99   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
100      printf("%s, bad version string\n", "$min_esd_version");
101      exit(1);
102    }
103
104    if (($esd_major_version > major) ||
105       (($esd_major_version == major) && ($esd_minor_version > minor)) ||
106       (($esd_major_version == major) && ($esd_minor_version == minor) && ($esd_micro_version >= micro)))
107     {
108       return 0;
109     }
110   else
111     {
112       printf("\n*** 'esd-config --version' returned %d.%d.%d, but the minimum version\n", $esd_major_version, $esd_minor_version, $esd_micro_version);
113       printf("*** of ESD required is %d.%d.%d. If esd-config is correct, then it is\n", major, minor, micro);
114       printf("*** best to upgrade to the required version.\n");
115       printf("*** If esd-config was wrong, set the environment variable ESD_CONFIG\n");
116       printf("*** to point to the correct copy of esd-config, and remove the file\n");
117       printf("*** config.cache before re-running configure\n");
118       return 1;
119     }
120 }
121
122 ],, no_esd=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
123        CFLAGS="$ac_save_CFLAGS"
124        LIBS="$ac_save_LIBS"
125      fi
126   fi
127   if test "x$no_esd" = x ; then
128      AC_MSG_RESULT(yes)
129      ifelse([$2], , :, [$2])     
130   else
131      AC_MSG_RESULT(no)
132      if test "$ESD_CONFIG" = "no" ; then
133        echo "*** The esd-config script installed by ESD could not be found"
134        echo "*** If ESD was installed in PREFIX, make sure PREFIX/bin is in"
135        echo "*** your path, or set the ESD_CONFIG environment variable to the"
136        echo "*** full path to esd-config."
137      else
138        if test -f conf.esdtest ; then
139         :
140        else
141           echo "*** Could not run ESD test program, checking why..."
142           CFLAGS="$CFLAGS $ESD_CFLAGS"
143           LIBS="$LIBS $ESD_LIBS"
144           AC_TRY_LINK([
145 #include <stdio.h>
146 #include <esd.h>
147 ],      [ return 0; ],
148         [ echo "*** The test program compiled, but did not run. This usually means"
149           echo "*** that the run-time linker is not finding ESD or finding the wrong"
150           echo "*** version of ESD. If it is not finding ESD, you'll need to set your"
151           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
152           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
153           echo "*** is required on your system"
154           echo "***"
155           echo "*** If you have an old version installed, it is best to remove it, although"
156           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
157         [ echo "*** The test program failed to compile or link. See the file config.log for the"
158           echo "*** exact error that occured. This usually means ESD was incorrectly installed"
159           echo "*** or that you have moved ESD since it was installed. In the latter case, you"
160           echo "*** may want to edit the esd-config script: $ESD_CONFIG" ])
161           CFLAGS="$ac_save_CFLAGS"
162           LIBS="$ac_save_LIBS"
163        fi
164      fi
165      ESD_CFLAGS=""
166      ESD_LIBS=""
167      ifelse([$3], , :, [$3])
168   fi
169   AC_SUBST(ESD_CFLAGS)
170   AC_SUBST(ESD_LIBS)
171   rm -f conf.esdtest
172 ])
173
174 dnl AM_ESD_SUPPORTS_MULTIPLE_RECORD([ACTION-IF-SUPPORTS [, ACTION-IF-NOT-SUPPORTS]])
175 dnl Test, whether esd supports multiple recording clients (version >=0.2.21)
176 dnl
177 AC_DEFUN(AM_ESD_SUPPORTS_MULTIPLE_RECORD,
178 [dnl
179   AC_MSG_NOTICE([whether installed esd version supports multiple recording clients])
180   ac_save_ESD_CFLAGS="$ESD_CFLAGS"
181   ac_save_ESD_LIBS="$ESD_LIBS"
182   AM_PATH_ESD(0.2.21,
183     ifelse([$1], , [
184       AM_CONDITIONAL(ESD_SUPPORTS_MULTIPLE_RECORD, true)
185       AC_DEFINE(ESD_SUPPORTS_MULTIPLE_RECORD, 1,
186         [Define if you have esound with support of multiple recording clients.])],
187     [$1]),
188     ifelse([$2], , [AM_CONDITIONAL(ESD_SUPPORTS_MULTIPLE_RECORD, false)], [$2])
189     if test "x$ac_save_ESD_CFLAGS" != x ; then
190        ESD_CFLAGS="$ac_save_ESD_CFLAGS"
191     fi
192     if test "x$ac_save_ESD_LIBS" != x ; then
193        ESD_LIBS="$ac_save_ESD_LIBS"
194     fi
195   )
196 ])