[Freeswitch-svn] [commit] r12587 - in freeswitch/trunk: . build build/config

FreeSWITCH SVN andrew at freeswitch.org
Thu Mar 12 12:54:20 PDT 2009


Author: andrew
Date: Thu Mar 12 14:54:20 2009
New Revision: 12587

Log:
FSBUILD-142 (with approval from MikeJ)


Added:
   freeswitch/trunk/build/config/erlang.m4
Modified:
   freeswitch/trunk/acinclude.m4
   freeswitch/trunk/build/modules.conf.in
   freeswitch/trunk/configure.in

Modified: freeswitch/trunk/acinclude.m4
==============================================================================
--- freeswitch/trunk/acinclude.m4	(original)
+++ freeswitch/trunk/acinclude.m4	Thu Mar 12 14:54:20 2009
@@ -6,6 +6,7 @@
 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])

Added: freeswitch/trunk/build/config/erlang.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/build/config/erlang.m4	Thu Mar 12 14:54:20 2009
@@ -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
+
+])

Modified: freeswitch/trunk/build/modules.conf.in
==============================================================================
--- freeswitch/trunk/build/modules.conf.in	(original)
+++ freeswitch/trunk/build/modules.conf.in	Thu Mar 12 14:54:20 2009
@@ -50,6 +50,7 @@
 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

Modified: freeswitch/trunk/configure.in
==============================================================================
--- freeswitch/trunk/configure.in	(original)
+++ freeswitch/trunk/configure.in	Thu Mar 12 14:54:20 2009
@@ -692,6 +692,8 @@
 	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 @@
                 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



More information about the Freeswitch-svn mailing list