]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FSBUILD-142 (with approval from MikeJ)
authorAndrew Thompson <andrew@hijacked.us>
Thu, 12 Mar 2009 19:54:20 +0000 (19:54 +0000)
committerAndrew Thompson <andrew@hijacked.us>
Thu, 12 Mar 2009 19:54:20 +0000 (19:54 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12587 d0543943-73ff-0310-b7d9-9358b9ac24b2

acinclude.m4
build/config/erlang.m4 [new file with mode: 0644]
build/modules.conf.in
configure.in

index e245a6aec0de69cf0d9cb39511821f38b3860c24..e74bf468a917c9fdaf33bb8041e478043af3491b 100644 (file)
@@ -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 (file)
index 0000000..6fc8378
--- /dev/null
@@ -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
+
+])
index ac4be8cc316e00e6aba00896aab0a75ffc54721a..ae422041ddc6b65c1588186c2464c29e9c921786 100644 (file)
@@ -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
index 1810a1136b291b2318a8d614f7a95067379c4f98..aaf641eb8f9e80e32301171c934d73e2fead2fa2 100644 (file)
@@ -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