aclocal.m4 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. AC_DEFUN([AC_PATH_GENERIC],
  2. [dnl
  3. dnl we're going to need uppercase, lowercase and user-friendly versions of the
  4. dnl string `LIBRARY'
  5. pushdef([UP], translit([$1], [a-z], [A-Z]))dnl
  6. pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl
  7. dnl
  8. dnl Get the cflags and libraries from the LIBRARY-config script
  9. dnl
  10. AC_ARG_WITH(DOWN-prefix,[ --with-]DOWN[-prefix=PFX Prefix where $1 is installed (optional)],
  11. DOWN[]_config_prefix="$withval", DOWN[]_config_prefix="")
  12. AC_ARG_WITH(DOWN-exec-prefix,[ --with-]DOWN[-exec-prefix=PFX Exec prefix where $1 is installed (optional)],
  13. DOWN[]_config_exec_prefix="$withval", DOWN[]_config_exec_prefix="")
  14. if test x$DOWN[]_config_exec_prefix != x ; then
  15. DOWN[]_config_args="$DOWN[]_config_args --exec-prefix=$DOWN[]_config_exec_prefix"
  16. if test x${UP[]_CONFIG+set} != xset ; then
  17. UP[]_CONFIG=$DOWN[]_config_exec_prefix/bin/DOWN-config
  18. fi
  19. fi
  20. if test x$DOWN[]_config_prefix != x ; then
  21. DOWN[]_config_args="$DOWN[]_config_args --prefix=$DOWN[]_config_prefix"
  22. if test x${UP[]_CONFIG+set} != xset ; then
  23. UP[]_CONFIG=$DOWN[]_config_prefix/bin/DOWN-config
  24. fi
  25. fi
  26. AC_PATH_PROG(UP[]_CONFIG, DOWN-config, no)
  27. ifelse([$2], ,
  28. AC_MSG_CHECKING(for $1),
  29. AC_MSG_CHECKING(for $1 - version >= $2)
  30. )
  31. no_[]DOWN=""
  32. if test "$UP[]_CONFIG" = "no" ; then
  33. no_[]DOWN=yes
  34. else
  35. UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args --cflags`"
  36. UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args --libs`"
  37. ifelse([$2], , ,[
  38. DOWN[]_config_major_version=`$UP[]_CONFIG $DOWN[]_config_args \
  39. --version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  40. DOWN[]_config_minor_version=`$UP[]_CONFIG $DOWN[]_config_args \
  41. --version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  42. DOWN[]_config_micro_version=`$UP[]_CONFIG $DOWN[]_config_args \
  43. --version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  44. DOWN[]_wanted_major_version="regexp($2, [\<\([0-9]*\)], [\1])"
  45. DOWN[]_wanted_minor_version="regexp($2, [\<\([0-9]*\)\.\([0-9]*\)], [\2])"
  46. DOWN[]_wanted_micro_version="regexp($2, [\<\([0-9]*\).\([0-9]*\).\([0-9]*\)], [\3])"
  47. # Compare wanted version to what config script returned.
  48. # If I knew what library was being run, i'd probably also compile
  49. # a test program at this point (which also extracted and tested
  50. # the version in some library-specific way)
  51. if test "$DOWN[]_config_major_version" -lt \
  52. "$DOWN[]_wanted_major_version" \
  53. -o \( "$DOWN[]_config_major_version" -eq \
  54. "$DOWN[]_wanted_major_version" \
  55. -a "$DOWN[]_config_minor_version" -lt \
  56. "$DOWN[]_wanted_minor_version" \) \
  57. -o \( "$DOWN[]_config_major_version" -eq \
  58. "$DOWN[]_wanted_major_version" \
  59. -a "$DOWN[]_config_minor_version" -eq \
  60. "$DOWN[]_wanted_minor_version" \
  61. -a "$DOWN[]_config_micro_version" -lt \
  62. "$DOWN[]_wanted_micro_version" \) ; then
  63. # older version found
  64. no_[]DOWN=yes
  65. echo -n "*** An old version of $1 "
  66. echo -n "($DOWN[]_config_major_version"
  67. echo -n ".$DOWN[]_config_minor_version"
  68. echo ".$DOWN[]_config_micro_version) was found."
  69. echo -n "*** You need a version of $1 newer than "
  70. echo -n "$DOWN[]_wanted_major_version"
  71. echo -n ".$DOWN[]_wanted_minor_version"
  72. echo ".$DOWN[]_wanted_micro_version."
  73. echo "***"
  74. echo "*** If you have already installed a sufficiently new version, this error"
  75. echo "*** probably means that the wrong copy of the DOWN-config shell script is"
  76. echo "*** being found. The easiest way to fix this is to remove the old version"
  77. echo "*** of $1, but you can also set the UP[]_CONFIG environment to point to the"
  78. echo "*** correct copy of DOWN-config. (In this case, you will have to"
  79. echo "*** modify your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf"
  80. echo "*** so that the correct libraries are found at run-time)"
  81. fi
  82. ])
  83. fi
  84. if test "x$no_[]DOWN" = x ; then
  85. AC_MSG_RESULT(yes)
  86. ifelse([$3], , :, [$3])
  87. else
  88. AC_MSG_RESULT(no)
  89. if test "$UP[]_CONFIG" = "no" ; then
  90. echo "*** The DOWN-config script installed by $1 could not be found"
  91. echo "*** If $1 was installed in PREFIX, make sure PREFIX/bin is in"
  92. echo "*** your path, or set the UP[]_CONFIG environment variable to the"
  93. echo "*** full path to DOWN-config."
  94. fi
  95. UP[]_CFLAGS=""
  96. UP[]_LIBS=""
  97. ifelse([$4], , :, [$4])
  98. fi
  99. AC_SUBST(UP[]_CFLAGS)
  100. AC_SUBST(UP[]_LIBS)
  101. popdef([UP])
  102. popdef([DOWN])
  103. ])