erlang.m4 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. AC_DEFUN([CHECK_ERLANG], [
  2. #
  3. # Erlang checks for mod_erlang_event
  4. #
  5. AC_ARG_WITH(
  6. [erlang],
  7. [AS_HELP_STRING([--with-erlang], [Use system provided version of erlang (default: try)])],
  8. [with_erlang="$withval"],
  9. [with_erlang="try"]
  10. )
  11. AM_CONDITIONAL([HAVE_ERLANG],[false])
  12. if test "$with_erlang" != "no"
  13. then
  14. save_CFLAGS="$CFLAGS"
  15. save_LIBS="$LIBS"
  16. if test "$with_erlang" != "yes" -a "$with_erlang" != "try" ; then
  17. AC_MSG_CHECKING([for erlang])
  18. if test ! -x "$with_erlang" ; then
  19. AC_MSG_ERROR([Specified erlang does not exist or is not executable: $with_erlang])
  20. fi
  21. AC_MSG_RESULT([$with_erlang])
  22. AC_SUBST([ERLANG], ["$with_erlang"])
  23. else
  24. AC_PATH_PROG([ERLANG], ["erl"], ["no"], ["$PATH:/usr/bin:/usr/local/bin"])
  25. fi
  26. if test "$ERLANG" != "no" ; then
  27. AC_MSG_CHECKING([erlang version])
  28. ERLANG_VER="`$ERLANG -version 2>&1 | cut -d' ' -f6`"
  29. if test -z "$ERLANG_VER" ; then
  30. AC_MSG_ERROR([Unable to detect erlang version])
  31. fi
  32. AC_MSG_RESULT([$ERLANG_VER])
  33. ERLANG_LIBDIR=`$ERLANG -noshell -eval 'io:format("~n~s/lib~n", [[code:lib_dir("erl_interface")]]).' -s erlang halt | tail -n 1`
  34. AC_MSG_CHECKING([erlang libdir])
  35. if test -z "`echo $ERLANG_LIBDIR`" ; then
  36. AC_MSG_ERROR([failed])
  37. else
  38. ERLANG_LDFLAGS="-L$ERLANG_LIBDIR $ERLANG_LDFLAGS"
  39. LIBS="-L$ERLANG_LIBDIR $LIBS"
  40. fi
  41. AC_MSG_RESULT([$ERLANG_LIBDIR])
  42. ERLANG_INCDIR=`$ERLANG -noshell -eval 'io:format("~n~s/include~n", [[code:lib_dir("erl_interface")]]).' -s erlang halt | tail -n 1`
  43. AC_MSG_CHECKING([erlang incdir])
  44. if test -z "`echo $ERLANG_INCDIR`" ; then
  45. AC_MSG_ERROR([failed])
  46. else
  47. ERLANG_CFLAGS="-I$ERLANG_INCDIR $ERLANG_CFLAGS"
  48. CFLAGS="-I$ERLANG_INCDIR $CFLAGS"
  49. fi
  50. AC_MSG_RESULT([$ERLANG_INCDIR])
  51. AC_CHECK_HEADERS([ei.h], [has_ei_h="yes"], [has_ei_h="no"])
  52. ERLANG_LIB="ei"
  53. # check liei
  54. AC_CHECK_LIB([$ERLANG_LIB], [ei_encode_version], [has_libei="yes"], [has_libei="no"])
  55. # maybe someday ei will actually expose this?
  56. AC_CHECK_LIB([$ERLANG_LIB], [ei_link_unlink], [ERLANG_CFLAGS="$ERLANG_CFLAGS -DEI_LINK_UNLINK"])
  57. if test "$has_libei" = "no" ; then
  58. AS_IF([test "$with_erlang" = "try"],
  59. [AC_MSG_WARN([$ERLANG_LIB is unusable])],
  60. [AC_MSG_ERROR([$ERLANG_LIB is unusable])]
  61. )
  62. elif test "$has_ei_h" = "no"; then
  63. AS_IF([test "$with_erlang" = "try"],
  64. [AC_MSG_WARN([ei.h is unusable - are the erlang development headers installed?])],
  65. [AC_MSG_ERROR([ei.h is unusable - are the erlang development headers installed?])]
  66. )
  67. else
  68. ERLANG_MAJOR="`echo "$ERLANG_VER" | sed 's/\([[^.]][[^.]]*\).*/\1/'`"
  69. ERLANG_MINOR="`echo "$ERLANG_VER" | sed 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'`"
  70. ERLANG_LDFLAGS="$ERLANG_LDFLAGS -lei"
  71. AC_MSG_NOTICE([Your erlang seems OK, do not forget to enable mod_erlang_event in modules.conf])
  72. AC_SUBST([ERLANG_CFLAGS], [$ERLANG_CFLAGS])
  73. AC_SUBST([ERLANG_LDFLAGS], [$ERLANG_LDFLAGS])
  74. AC_SUBST([ERLANG_VERSION], [$ERLANG_VER])
  75. AC_SUBST([ERLANG_MAJOR], [$ERLANG_MAJOR])
  76. AC_SUBST([ERLANG_MINOR], [$ERLANG_MINOR])
  77. AM_CONDITIONAL([HAVE_ERLANG],[true])
  78. fi
  79. LIBS="$save_LIBS"
  80. CFLAGS="$save_CFLAGS"
  81. else
  82. AS_IF([test "$with_erlang" = "try"],
  83. [AC_MSG_WARN([Could not find erlang, mod_erlang_event will not build, use --with-erlang to specify the location])],
  84. [AC_MSG_ERROR([Could not find erlang, use --with-erlang to specify the location])]
  85. )
  86. fi
  87. else
  88. AC_MSG_WARN([erlang support disabled, building mod_erlang_event will fail!])
  89. fi
  90. ])