Hi,

Here is a small patch for the Erlang support.
It defines a substitution variable containing the Erlang runtime system (ERTS) 
version. That's very useful for substituting in Erlang release resource files, 
which are commonly used in Erlang.

I have updated the doc, putting an emphasis on not using the version numbers 
for testing for features.

I have added Ruslan Babayev into THANKS, as this code is originally from him.

BR,
--
Romain Lenglet
diff --git a/AUTHORS b/AUTHORS
index 9c07a86..aac3f00 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -83,7 +83,7 @@ Gregorio Guidi              [email protected]                   2005-03-03
 Bruno Haible                [email protected]                     2005-06-12
 Toby Oliver Hilary White    [email protected]                     2005-10-18
 Eric Benjamin Blake         [email protected]                        2006-01-18
-Romain Lenglet              [email protected]  2006-02-10
+Romain Lenglet              [email protected]          2006-02-10
 Markus Duft                 [email protected]              2006-08-03
 Robert Schiele              [email protected]                  2006-09-12
 Joel Edward Denny           [email protected]                  2006-09-15
diff --git a/THANKS b/THANKS
index 8bf999a..00cf98d 100644
--- a/THANKS
+++ b/THANKS
@@ -311,8 +311,9 @@ Roger Leigh                 [email protected]
 Roland McGrath              [email protected]
 Rolf Ebert                  [email protected]
 Rolf Vandevaart             [email protected]
-Romain Lenglet              [email protected]
+Romain Lenglet              [email protected]
 Ruediger Kuhlmann           [email protected]
+Ruslan Babayev              ?
 Russ Allbery                [email protected]
 Russ Boylan                 [email protected]
 Ryuji Abe                   [email protected]
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index a26b1b7..891044b 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -7770,6 +7770,20 @@ presence of certain Erlang libraries.  All those macros require the
 configuration of an Erlang interpreter and an Erlang compiler
 (@pxref{Erlang Compiler and Interpreter}).
 
+...@defmac AC_ERLANG_SUBST_ERTS_VER
+...@acindex{erlang_subst_erts_ver}
+...@ovindex ERLANG_ERTS_VER
+
+Set the output variable @code{ERLANG_ERTS_VER} to the version of the
+Erlang runtime system (as returned by Erlang's
+...@code{erlang:system_info(version)} function).  The result of this test
+is cached if caching is enabled when running @command{configure}.  The
+...@code{erlang_erts_ver} variable is not intended to be used for testing
+for features of specific ERTS versions, but to be used for substituting
+the ERTS version in Erlang/OTP release resource files (@code{.rel}
+files), as shown below.
+...@end defmac
+
 @defmac AC_ERLANG_SUBST_ROOT_DIR
 @acindex{ERLANG_SUBST_ROOT_DIR}
 @ovindex ERLANG_ROOT_DIR
@@ -7820,6 +7834,35 @@ AC_ERLANG_CHECK_LIB([stdlib],
    echo "is installed in \"$ERLANG_LIB_DIR_stdlib\""],
   [AC_MSG_ERROR([stdlib was not found!])])
 @end example
+
+The @samp{erlang_lib_v...@var{library}} variables (set by
+...@code{ac_erlang_check_lib}) and the @code{ERLANG_ERTS_VER} variable (set
+by @code{AC_ERLANG_SUBST_ERTS_VER}) are not intended to be used for
+testing for features of specific versions of libraries or of the Erlang
+runtime system.  Those variables are intended to be substituted in
+Erlang release resource files (@code{.rel} files).  For instance, to
+generate a @code{example.rel} file for an application depending on the
+...@code{stdlib} library, an @code{configure.ac} file should contain for
+instance:
+
+...@example
+AC_ERLANG_SUBST_ERTS_VER
+AC_ERLANG_CHECK_LIB([stdlib],
+  [],
+  [AC_MSG_ERROR([stdlib was not found!])])
+AC_CONFIG_FILES([example.rel])
+...@end example
+
+And the @code{example.rel.in} file used to generate @code{example.rel}
+should contain:
+
+...@example
+{release,
+    {"@PACKAGE@", "@VERSION@"},
+    {erts, "@ERLANG_ERTS_VER@"},
+    [{stdlib, "@ERLANG_LIB_VER_stdlib@"},
+     {...@package@, "@VERSION@"}]}.
+...@end example
 @end defmac
 
 In addition to the above macros, which test installed Erlang libraries, the
diff --git a/lib/autoconf/erlang.m4 b/lib/autoconf/erlang.m4
index 7f6d92d..619bc4d 100644
--- a/lib/autoconf/erlang.m4
+++ b/lib/autoconf/erlang.m4
@@ -1,6 +1,6 @@
 # This file is part of Autoconf.                       -*- Autoconf -*-
 # Erlang/OTP language support.
-# Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2006, 2008, 2009 Free Software Foundation, Inc.
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -161,6 +161,7 @@ $2
 # AC_LANG_PREPROC(Erlang)
 # -----------------------
 # Find the Erlang preprocessor.  Must be AC_DEFUN'd to be AC_REQUIRE'able.
+#
 AC_DEFUN([AC_LANG_PREPROC(Erlang)],
 [m4_warn([syntax],
          [$0: No preprocessor defined for ]_AC_LANG)])
@@ -168,6 +169,7 @@ AC_DEFUN([AC_LANG_PREPROC(Erlang)],
 # AC_LANG_COMPILER(Erlang)
 # ------------------------
 # Find the Erlang compiler.  Must be AC_DEFUN'd to be AC_REQUIRE'able.
+#
 AC_DEFUN([AC_LANG_COMPILER(Erlang)],
 [AC_REQUIRE([AC_ERLANG_PATH_ERLC])])
 
@@ -262,7 +264,6 @@ AC_SUBST([ERLANG_LIB_DIR], [$erlang_cv_lib_dir])
 
 # AC_ERLANG_SUBST_INSTALL_LIB_DIR
 # -------------------------------
-#
 # Directories for installing Erlang/OTP packages are separated from the
 # directories determined by running the Erlang/OTP installation that is used
 # for building.
@@ -294,3 +295,27 @@ else
     AC_MSG_RESULT([$ERLANG_INSTALL_LIB_DIR/$1-$2])
 fi
 ])# AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR
+
+
+# AC_ERLANG_SUBST_ERTS_VER
+# ------------------------
+# Determines the Erlang runtime system version
+#
+AC_DEFUN([AC_ERLANG_SUBST_ERTS_VER],
+[AC_REQUIRE([AC_ERLANG_NEED_ERLC])[]dnl
+AC_REQUIRE([AC_ERLANG_NEED_ERL])[]dnl
+AC_CACHE_CHECK([for Erlang/OTP ERTS version],
+    [erlang_cv_erts_ver],
+    [AC_LANG_PUSH(Erlang)[]dnl
+     AC_RUN_IFELSE(
+        [AC_LANG_PROGRAM([], [dnl
+            Version = erlang:system_info(version),
+            file:write_file("conftest.out", Version),
+            ReturnValue = 0,
+            halt(ReturnValue)])],
+        [erlang_cv_erts_ver=`cat conftest.out`],
+        [AC_MSG_FAILURE([test Erlang program execution failed])])
+     AC_LANG_POP(Erlang)[]dnl
+    ])
+AC_SUBST([ERLANG_ERTS_VER], [$erlang_cv_erts_ver])
+])# AC_ERLANG_SUBST_ERTS_VER

Reply via email to