From ea0316b80fbcac721db077e285a7a8e27b6accfc Mon Sep 17 00:00:00 2001 From: Andrew Thompson Date: Thu, 12 Mar 2009 19:54:20 +0000 Subject: [PATCH] FSBUILD-142 (with approval from MikeJ) git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12587 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- acinclude.m4 | 1 + build/config/erlang.m4 | 96 ++++++++++++++++++++++++++++++++++++++++++ build/modules.conf.in | 1 + configure.in | 3 ++ 4 files changed, 101 insertions(+) create mode 100644 build/config/erlang.m4 diff --git a/acinclude.m4 b/acinclude.m4 index e245a6aec0..e74bf468a9 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -6,6 +6,7 @@ m4_include([build/config/ac_gcc_archflag.m4]) m4_include([build/config/ac_gcc_x86_cpuid.m4]) m4_include([build/config/ax_lib_mysql.m4]) m4_include([build/config/ax_check_java.m4]) +m4_include([build/config/erlang.m4]) m4_include([build/config/odbc.m4]) m4_include([libs/apr/build/apr_common.m4]) m4_include([build/config/libcurl.m4]) diff --git a/build/config/erlang.m4 b/build/config/erlang.m4 new file mode 100644 index 0000000000..6fc8378006 --- /dev/null +++ b/build/config/erlang.m4 @@ -0,0 +1,96 @@ +AC_DEFUN([CHECK_ERLANG], [ +# +# Erlang checks for mod_erlang_event +# +AC_ARG_WITH( + [erlang], + [AS_HELP_STRING([--with-erlang], [Use system provided version of erlang (default: try)])], + [with_erlang="$withval"], + [with_erlang="try"] +) + +if test "$with_erlang" != "no" +then + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + + if test "$with_erlang" != "yes" -a "$with_erlang" != "try" ; then + AC_MSG_CHECKING([for erlang]) + if test ! -x "$with_erlang" ; then + AC_MSG_ERROR([Specified erlang does not exist or is not executable: $with_erlang]) + fi + AC_MSG_RESULT([$with_erlang]) + AC_SUBST([ERLANG], ["$with_erlang"]) + else + AC_PATH_PROG([ERLANG], ["erl"], ["no"], ["$PATH:/usr/bin:/usr/local/bin"]) + fi + + if test "$ERLANG" != "no" ; then + AC_MSG_CHECKING([erlang version]) + ERLANG_VER="`$ERLANG -version 2>&1 | cut -d' ' -f6`" + + if test -z "$ERLANG_VER" ; then + AC_MSG_ERROR([Unable to detect erlang version]) + fi + AC_MSG_RESULT([$ERLANG_VER]) + + ERLANG_LIBDIR=`$ERLANG -noshell -eval 'io:format("~s/lib~n", [[code:lib_dir("erl_interface")]]).' -s erlang halt` + AC_MSG_CHECKING([erlang libdir]) + if test -z "`echo $ERLANG_LIBDIR`" ; then + AC_MSG_ERROR([failed]) + else + ERLANG_LDFLAGS="-L$ERLANG_LIBDIR $ERLANG_LDFLAGS" + LIBS="-L$ERLANG_LIBDIR $LIBS" + fi + AC_MSG_RESULT([$ERLANG_LIBDIR]) + + ERLANG_INCDIR=`$ERLANG -noshell -eval 'io:format("~s/include~n", [[code:lib_dir("erl_interface")]]).' -s erlang halt` + AC_MSG_CHECKING([erlang incdir]) + if test -z "`echo $ERLANG_INCDIR`" ; then + AC_MSG_ERROR([failed]) + else + ERLANG_CFLAGS="-I$ERLANG_INCDIR $ERLANG_CFLAGS" + CFLAGS="-I$ERLANG_INCDIR $CFLAGS" + fi + AC_MSG_RESULT([$ERLANG_INCDIR]) + + AC_CHECK_HEADERS([ei.h], [has_ei_h="yes"], [has_ei_h="no"]) + + ERLANG_LIB="ei" + + # check liei + AC_CHECK_LIB([$ERLANG_LIB], [ei_encode_version], [has_libei="yes"], [has_libei="no"]) + # maybe someday ei will actually expose this? + AC_CHECK_LIB([$ERLANG_LIB], [ei_link_unlink], [ERLANG_CFLAGS="$ERLANG_CFLAGS -DEI_LINK_UNLINK"]) + + if test "$has_libei" = "no" ; then + AS_IF([test "$with_erlang" = "try"], + [AC_MSG_WARN([$ERLANG_LIB is unusable])], + [AC_MSG_ERROR([$ERLANG_LIB is unusable])] + ) + elif test "$has_ei_h" = "no"; then + AS_IF([test "$with_erlang" = "try"], + [AC_MSG_WARN([ei.h is unusable - are the erlang development headers installed?])], + [AC_MSG_ERROR([ei.h is unusable - are the erlang development headers installed?])] + ) + else + ERLANG_LDFLAGS="$ERLANG_LDFLAGS -lei" + AC_MSG_NOTICE([Your erlang seems OK, do not forget to enable mod_erlang_event in modules.conf]) + AC_SUBST([ERLANG_CFLAGS], [$ERLANG_CFLAGS]) + AC_SUBST([ERLANG_LDFLAGS], [$ERLANG_LDFLAGS]) + fi + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + else + AS_IF([test "$with_erlang" = "try"], + [AC_MSG_WARN([Could not find erlang, mod_erlang_event will not build, use --with-erlang to specify the location])], + [AC_MSG_ERROR([Could not find erlang, use --with-erlang to specify the location])] + ) + fi +else + AC_MSG_WARN([erlang support disabled, building mod_erlang_event will fail!]) +fi + +]) diff --git a/build/modules.conf.in b/build/modules.conf.in index ac4be8cc31..ae422041dd 100644 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -50,6 +50,7 @@ endpoints/mod_loopback event_handlers/mod_event_socket event_handlers/mod_cdr_csv #event_handlers/mod_radius_cdr +#event_handlers/mod_erlang_event formats/mod_native_file formats/mod_sndfile #formats/mod_shout diff --git a/configure.in b/configure.in index 1810a1136b..aaf641eb8f 100644 --- a/configure.in +++ b/configure.in @@ -692,6 +692,8 @@ else AC_MSG_WARN([python support disabled, building mod_python will fail!]) fi +CHECK_ERLANG + AC_CONFIG_FILES([Makefile src/Makefile src/mod/Makefile @@ -699,6 +701,7 @@ AC_CONFIG_FILES([Makefile src/mod/event_handlers/mod_radius_cdr/Makefile src/mod/languages/mod_java/Makefile src/mod/languages/mod_python/Makefile + src/mod/event_handlers/mod_erlang_event/Makefile src/include/switch_am_config.h build/getsounds.sh build/getlib.sh