esd.m4 6.7 KB

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