--- autoconf/ChangeLog 2006-03-10 16:00:51.669437120 +0900 +++ autoconf-patched/ChangeLog 2006-03-10 20:35:22.142544616 +0900 @@ -1,3 +1,8 @@ +2006-03-10 Romain Lenglet + + * doc/autoconf.texi (several sections): Add documentation for macros + in erlang.m4. + 2006-03-08 Ralf Wildenhues * tests/c.at (AC_PROG_CPP without warnings, AC_PROG_CPP via CC): --- autoconf/doc/autoconf.texi 2006-03-10 16:00:52.311339536 +0900 +++ autoconf-patched/doc/autoconf.texi 2006-03-10 20:33:56.175613576 +0900 @@ -336,6 +336,7 @@ * Compilers and Preprocessors:: Checking for compiling programs * System Services:: Operating system services * Posix Variants:: Special kludges for specific Posix variants +* Erlang Libraries:: Checking for the existence of Erlang libraries Common Behavior @@ -381,6 +382,7 @@ * C Compiler:: Checking its characteristics * C++ Compiler:: Likewise * Fortran Compiler:: Likewise +* Erlang Compiler and Interpreter:: Likewise Writing Tests @@ -2211,6 +2213,14 @@ want to use it. @end defvar address@hidden ERLCFLAGS address@hidden ERLCFLAGS +Debugging and optimization options for the Erlang compiler. If it is not set +in the environment when @command{configure} runs, the default value is empty. address@hidden uses this variable when compiling programs to test for +Erlang features. address@hidden defvar + @defvar FCFLAGS @ovindex FCFLAGS Debugging and optimization options for the Fortran compiler. If it @@ -2530,6 +2540,26 @@ otherwise the package won't support separated builds. @end table +For the more specific installation of Erlang libraries, the following variables +are defined: + address@hidden ERLANG_INSTALL_LIB_DIR address@hidden ERLANG_INSTALL_LIB_DIR +The common parent directory of Erlang library installation directories. +This variable is set by calling the @code{AC_ERLANG_SUBST_INSTALL_LIB_DIR} +macro in @file{configure.ac}. address@hidden defvar + address@hidden address@hidden address@hidden address@hidden +The installation directory for Erlang library @var{library}. +This variable is set by calling the address@hidden(@var{library}, @var{version}} +macro in @file{configure.ac}. address@hidden defvar + address@hidden Libraries}, for details. + @node Build Directories @subsection Build Directories @@ -3211,6 +3241,7 @@ * Compilers and Preprocessors:: Checking for compiling programs * System Services:: Operating system services * Posix Variants:: Special kludges for specific Posix variants +* Erlang Libraries:: Checking for the existence of Erlang libraries @end menu @node Common Behavior @@ -5601,6 +5632,7 @@ * C Compiler:: Checking its characteristics * C++ Compiler:: Likewise * Fortran Compiler:: Likewise +* Erlang Compiler and Interpreter:: Likewise @end menu @node Specific Compiler Characteristics @@ -6449,6 +6481,67 @@ message). @end defmac address@hidden Erlang Compiler and Interpreter address@hidden Erlang Compiler and Interpreter Characteristics address@hidden Erlang + +Autoconf defines the following macros for determining paths to the essential +Erlang/OTP programs: + address@hidden AC_ERLANG_PATH_ERLC (@ovar{value-if-not-found}, @ovar{path}) address@hidden address@hidden ERLC address@hidden ERLCFLAGS +Determine an Erlang compiler to use. If @code{ERLC} is not already set in the +environment, check for @command{erlc}. Set output variable @code{ERLC} to the +complete path of the compiler command found. + +The optional two arguments have the same meaning as the two last arguments of +macro @code{AC_PROG_PATH} for looking for the @command{erlc} program. For +example, to look for @command{erlc} only in the @file{/usr/lib/erlang/bin} +directory: + address@hidden +AC_ERLANG_PATH_ERLC([not found], [/usr/lib/erlang/bin]) address@hidden example address@hidden defmac + address@hidden AC_ERLANG_NEED_ERLC (@ovar{path}) address@hidden address@hidden AC_ERLANG_PATH_ERLC address@hidden ERLC address@hidden ERLCFLAGS +A simplified variant of the @code{AC_ERLANG_PATH_ERLC} macro, that prints an +error message and exits the @command{configure} script if the @command{erlc} +program is not found. address@hidden defmac + address@hidden AC_ERLANG_PATH_ERL (@ovar{value-if-not-found}, @ovar{path}) address@hidden address@hidden ERL +Determine an Erlang interpreter to use. If @code{ERL} is not already set in the +environment, check for @command{erl}. Set output variable @code{ERL} to the +complete path of the interpreter command found. + +The optional two arguments have the same meaning as the two last arguments of +macro @code{AC_PROG_PATH} for looking for the @command{erl} program. For +example, to look for @command{erl} only in the @file{/usr/lib/erlang/bin} +directory: + address@hidden +AC_ERLANG_PATH_ERL([not found], [/usr/lib/erlang/bin]) address@hidden example address@hidden defmac + address@hidden AC_ERLANG_NEED_ERL (@ovar{path}) address@hidden address@hidden AC_ERLANG_PATH_ERL address@hidden ERL +A simplified variant of the @code{AC_ERLANG_PATH_ERL} macro, that prints an +error message and exits the @command{configure} script if the @command{erl} +program is not found. address@hidden defmac + @node System Services @section System Services @@ -6598,6 +6691,86 @@ @end defmac address@hidden Erlang Libraries address@hidden Erlang Libraries address@hidden Erlang, Library, checking + +The following macros check for an installation of Erlang/OTP, and for the +presence of certain Erlang libraries. All those macros require the +configuration of an Erlang interpreter and an Erlang compiler +(@pxref{Erlang Compiler and Interpreter}). + address@hidden AC_ERLANG_SUBST_ROOT_DIR address@hidden address@hidden ERLANG_ROOT_DIR + +Set the output variable @code{ERLANG_ROOT_DIR} to the path of the root +directory of Erlang/OTP (as returned by Erlang's @code{code:root_dir/0} +function), which is the directory where it is installed. The result of this +test is cached if caching is enabled when running @code{configure}. address@hidden defmac + address@hidden AC_ERLANG_SUBST_LIB_DIR address@hidden address@hidden ERLANG_LIB_DIR + +Set the output variable @code{ERLANG_LIB_DIR} to the path of the library +directory of Erlang/OTP (as returned by Erlang's address@hidden:lib_dir/0} function}, which subdirectories each contain an installed +Erlang/OTP library. The result of this test is cached if caching is enabled +when running @code{configure}. address@hidden defmac + address@hidden AC_ERLANG_CHECK_LIB (@var{library}, @ovar(action-if-found}, @ovar{action-if-not-found}) address@hidden address@hidden ERLANG_LIB_DIR_library + +Test whether the Erlang/OTP library @var{library} is installed by calling +Erlang's @code{code:lib_dir/1} function. The result of this test is cached if +caching is enabled when running @code{configure}. @var{action-if-found} is a +list of shell commands to run if the library is installed; address@hidden is a list of shell commands to run if it is not. +Additionally, if the library is installed, the output variable address@hidden@var{library}} is set to the path to the library +installation directory. For example, to check if the @code{stdlib} library is +installed: + address@hidden +AC_ERLANG_CHECK_LIB([stdlib], + [echo "stdlib is installed in $ERLANG_LIB_DIR_stdlib"], + [AC_MSG_ERROR([stdlib was not found!])]) address@hidden example address@hidden defmac + +In addition to the above macros, which test installed Erlang libraries, the +following macros determine paths to built libraries installation directories: + address@hidden AC_ERLANG_SUBST_INSTALL_LIB_DIR address@hidden address@hidden ERLANG_INSTALL_LIB_DIR + +Set the @code{ERLANG_INSTALL_LIB_DIR} output variable to the directory into +which every built Erlang library should be installed in a separate subdirectory. +If this variable is not set in the environment when @command{configure} runs, +its default value is @code{$ERLANG_LIB_DIR}, as determined by the address@hidden macro. address@hidden defmac + address@hidden AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR (@var{library}, @var{version}) address@hidden address@hidden address@hidden + +Set the @address@hidden output variable to the +directory into which the built Erlang library @var{library} version address@hidden should be installed. If this variable is not set in the +environment when @command{configure} runs, its default value is address@hidden/@address@hidden, the address@hidden variable being set by the address@hidden macro. address@hidden defmac + + + @c ========================================================= Writing Tests @@ -6678,6 +6851,10 @@ Do compilation tests using @code{FC} and use extension @file{.f} (or whatever has been set by @code{AC_FC_SRCEXT}) for test programs. Use compilation flags: @code{FCFLAGS}. + address@hidden Erlang +Compile and execute tests using @code{ERLC} and @code{ERL} and use extension address@hidden for test Erlang modules. Use compilation flags: @code{ERLCFLAGS}. @end table @end defmac @@ -6869,6 +7046,7 @@ AC_INIT([Hello], [1.0], [bug-hello@@example.org]) AC_DEFINE([HELLO_WORLD], ["Hello, World\n"], [Greetings string.]) +AC_LANG(C) AC_LANG_CONFTEST( [AC_LANG_SOURCE([[const char hw[] = "Hello, World\n";]])]) gcc -E -dD -o - conftest.c @@ -6891,6 +7069,9 @@ const char hw[] = "Hello, World\n"; @end example +When the test language is Fortran or Erlang, the @code{AC_DEFINE} definitions +are not automatically translated as constants in the source code by this macro. + @defmac AC_LANG_PROGRAM (@var{prologue}, @var{body}) @acindex{LANG_PROGRAM} Expands into a source file which consists of the @var{prologue}, and @@ -6935,6 +7116,35 @@ @} @end example +In Erlang tests, the created @file{conftest.erl} source file is that of an +Erlang module called @code{conftest}. This module defines and exports one address@hidden/0} function, which is called to perform the test. The address@hidden is optional code that is inserted between the module header +and the @code{start/0} function definition. @var{body} is the body of the address@hidden/0} function (without the final period). + +For instance: + address@hidden +AC_INIT([Hello], [1.0], [bug-hello@@example.org]) +AC_LANG(Erlang) +AC_LANG_CONFTEST( +[AC_LANG_PROGRAM([[-define(HELLO_WORLD, "Hello, world!").]], + [[io:format("~s~n", [?HELLO_WORLD])]])]) +cat conftest.erl address@hidden example + address@hidden +results in: + address@hidden +-module(conftest). +-export([start/0]). +-define(HELLO_WORLD, "Hello, world!"). +start() -> +io:format("~s~n", [?HELLO_WORLD]) +. address@hidden example @defmac AC_LANG_CALL (@var{prologue}, @var{function}) @acindex{LANG_CALL} @@ -6946,8 +7156,9 @@ This function will probably be replaced in the future by a version which would enable specifying the arguments. The use of this macro is not encouraged, as it violates strongly the typing system. address@hidden defmac +This macro cannot be used for Erlang tests. address@hidden defmac @defmac AC_LANG_FUNC_LINK_TRY (@var{function}) @acindex{LANG_FUNC_LINK_TRY} @@ -6959,6 +7170,8 @@ It is considered to be severely broken, and in the future will be removed in favor of actual function calls (with properly typed arguments). + +This macro cannot be used for Erlang tests. @end defmac @node Running the Preprocessor @@ -6973,6 +7186,9 @@ Nevertheless, if you need to run the preprocessor, then use @code{AC_PREPROC_IFELSE}. +Note that the Fortan and Erlang languages have no preprocessor, hence the +macros described in this section cannot be used for tests in those languages. + @defmac AC_PREPROC_IFELSE (@var{input}, @ovar{action-if-true}, @ovar{action-if-false}) @acindex{PREPROC_IFELSE} Run the preprocessor of the current language (@pxref{Language Choice}) @@ -7067,6 +7283,12 @@ Linker}). @end defmac +When setting Erlang as the test language, the @var{input} must be the source +code of a module named @code{conftest}. @code{AC_COMPILE_IFELSE} generates a address@hidden file that can be interpreted by the Erlang virtual +machine. Using @code{AC_LANG_PROGRAM} to specify the test program ensures that +the Erlang module has the right name. + @node Running the Linker @section Running the Linker @@ -7105,6 +7327,8 @@ use @code{AC_RUN_IFELSE} if you need to do that (@pxref{Run Time}). @end defmac +Erlang being an interpreted language, Erlang programs do not need linking, +hence @code{AC_LINK_IFELSE} cannot be used with Erlang tests. @node Run Time @@ -7173,6 +7397,29 @@ @samp{yes}, and then use an alternate method to get the results instead of calling the macros. +Erlang tests must exit themselves the Erlang VM by calling the @code{halt/1} +function: the given status code is used to determine the success of the test +(status is @code{0}) or its failure (status is different than @code{0}), as +explained above. If a test must output configuration information, since +halting the VM may truncate data output into the standard output, it is +recommended to output data into the @file{conftest.out} file, using the +function of module @code{file}. That file is automatically deleted by address@hidden + +For instance, a simplified implementation of Autoconf's address@hidden macro is: + address@hidden +AC_INIT([LibdirTest], [1.0], [bug-libdirtest@@example.org]) +AC_ERLANG_NEED_ERL +AC_LANG(Erlang) +AC_RUN_IFELSE( + [AC_LANG_PROGRAM([], [dnl + file:write_file("conftest.out", code:lib_dir()), + halt(0)])], + [echo "code:lib_dir() returned: `cat conftest.out`"], + [AC_MSG_FAILURE([test Erlang program execution failed])]) address@hidden example @node Systemology @section Systemology