diff options
author | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2013-04-08 11:12:54 +0200 |
---|---|---|
committer | Christophe Romain <christophe.romain@process-one.net> | 2013-06-13 11:11:02 +0200 |
commit | 4d8f7706240a1603468968f47fc7b150b788d62f (patch) | |
tree | 92d55d789cc7ac979b3c9e161ffb7f908eba043a /m4 | |
parent | Fix Guide: ejabberd_service expects a shaper_rule, not a shaper (diff) |
Switch to rebar build tool
Use dynamic Rebar configuration
Make iconv dependency optional
Disable transient_supervisors compile option
Add hipe compilation support
Only compile ibrowse and lhttpc when needed
Make it possible to generate an OTP application release
Add --enable-debug compile option
Add --enable-all compiler option
Add --enable-tools configure option
Add --with-erlang configure option.
Add --enable-erlang-version-check configure option.
Add lager support
Improve the test suite
Diffstat (limited to 'm4')
-rw-r--r-- | m4/erlang-extra.m4 | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/m4/erlang-extra.m4 b/m4/erlang-extra.m4 new file mode 100644 index 000000000..c0716323e --- /dev/null +++ b/m4/erlang-extra.m4 @@ -0,0 +1,82 @@ +dnl erlang-extra.m4 + +AC_DEFUN([ERLANG_SUBST_LIB_VER], +[AC_ERLANG_CHECK_LIB([$1]) +ERLANG_LIB_VER_SUBST="$ERLANG_LIB_VER_SUBST -e 's,[@]ERLANG_LIB_VER_$1[@],\$(ERLANG_LIB_VER_$1),g'" +AC_SUBST([ERLANG_LIB_VER_SUBST]) +]) # ERLANG_SUBST_LIB_VER + +AC_DEFUN([ERLANG_VERSION_CHECK], +[ AC_MSG_CHECKING([Erlang/OTP version]) + cat > conftest.erl <<EOF +-module(conftest). +-export([[start/0]]). + +start() -> + ERTS = erlang:system_info(version), + RequiredMin = "$1", + RequiredMax = "$2", + Status = + case {string:tokens(RequiredMin, " "), + string:tokens(RequiredMax, " ")} of + {[[MinStr | _]], [[MaxStr | _]]} -> + case check(ERTS, {MinStr, MaxStr}) of + less -> + list_to_binary([[ERTS, " found, ", RequiredMin, " required"]]); + greater -> + list_to_binary([[ERTS, " found, ", RequiredMax, " or earlier required"]]); + ok -> + <<"ok">> + end; + _ -> + list_to_binary([[ERTS, " found, ", RequiredMin, " required"]]) + end, + file:write_file("conftest.out", Status), + halt(). + +check(CurStr, {MinStr, MaxStr}) -> + Cur = parse(CurStr), + Min = parse(MinStr), + Max = parse(MaxStr), + case {less_or_equal(Min, Cur), less_or_equal(Cur, Max)} of + {false, true} -> less; + {true, true} -> ok; + {true, false} -> greater + end. + +parse(Version) -> + lists:map(fun(A) -> {Int,[[]]} = string:to_integer(A), Int end, + string:tokens(Version, ".")). + +less_or_equal([[]], [[]]) -> + true; +less_or_equal([[Left| Rl]], [[Right| Rr]]) -> + case {Left < Right, Left == Right} of + {true, _} -> + true; + {false, false} -> + false; + {false, true} -> + less_or_equal(Rl, Rr) + end. + +EOF + + $ERLC conftest.erl || AC_MSG_ERROR(["Could not compile Erlang/OTP version check program using '$ERLC'"]) + + if ! $ERL -s conftest -noshell -o ! -f conftest.out ; then + AC_MSG_ERROR(["Could not run Erlang/OTP version check program using '$ERL'"]) + fi + + if test "x`cat conftest.out`" != "xok"; then + AC_MSG_RESULT([failed]) + X="`cat conftest.out`" + if test "[$3]" == "warn"; then + AC_MSG_WARN([$X]) + else + AC_MSG_FAILURE([$X]) + fi + else + AC_MSG_RESULT([ok]) + fi +]) dnl ERLANG_VERSION_CHECK |