I have just submitted a patch to Autoconf, on the Autoconf patches mailing-list, which allows to easily:
- auto-configure paths to Erlang/OTP tools (
- determine the paths of the installed Erlang/OTP environment and of installed libraries;
- determine paths for installing built Erlang modules;
- use Erlang as an Autoconf test language (and it is actually used in my patch to determine the Erlang root path and libraries paths).
That patch is a set of M4 macros that can be used in
configure.ac Autoconf files, to automatically configure any Erlang project. My macros are very configurable: many options can be set through environment variables and options to the generated
configure scripts, configuration caching is fully supported, etc. I have used those macros personally in my projects for a few month now, and they work fine.
If you want to use that macro file, you must copy my
erlang.m4 file (from my patch) directly into the directory of standard Autoconf’s macro files (
/usr/share/autoconf/autoconf on Debian), then list it into Autoconf’s main macro file (
autoconf.m4) and update Autoconf’s macro cache file with the following commands (as
> cd /usr/share/autoconf/autoconf/ > echo 'm4_include([autoconf/erlang.m4])' >> autoconf.m4 > autom4te --language=autoconf --freeze --output=autoconf.m4f
To have an idea of how to use those macros in your own
configure.ac, take a look at the dummy
Makefile.am files that I sent along with my patch.
It must be noted that my
erlang.m4 cannot be correctly parsed by Automake’s
aclocalprogram. The reason is that it incorrectly parses macro definitions which names contain round brackets, such as
AC_LANG_COMPILER(Erlang) in that definition taken from my
aclocal considers that such a definition is incorrect, although it is actually correct and even mandatory as of Autoconf’s test language support framework (one must use round brackets in those macro names, there is no other way!). As a consequence, one cannot include those macros in a project’s
acinclude.m4 file, or in a
m4/ subdirectory of a project along with a
ACLOCAL_AMFLAGS = -I m4 line in the main
Makefile.am file, or even as a share
erlang.m4 file in
/usr/share/aclocal-1.9: in all those cases, the macros are parsed (incorrectly!) by
aclocal. The only solution is therefore to directly include my
erlang.m4 file directly into the Autoconf project, which was my motivation to submit that patch.
aclocal is meant to disappear in the future, which is a Good Thing.
Perspectives to this work would be to add support of Erlang in Automake, but that is a lot more difficult and is less interesting to me…