esd.m4 5.7 KB

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