0
votes

I need to check for Erlang libraries on my configure.ac but the list of erlang apps is on a separate file, and I have to run a program to extract that list.

Normally, I can do this:

AC_ERLANG_CHECK_LIB([app1])
AC_ERLANG_CHECK_LIB([app2])

However, since the actual apps are on a separate file (and I don't want to repeat them on configure.ac, I was thinking on doing somewhere along the lines of:

DEPS=`some command that gets app1, app2`
# DEPS=app1 app2

m4_foreach_w(dep, "$DEPS", [AC_ERLANG_CHECK_LIB([dep])])

I know that "$DEPS" is the wrong argument here, since it needs the actual value for that - something like [app1 app2]. I also know that the evaluation of the DEPS variable isn't done untile ./configure is called, while m4_foreach_w requires the value of DEPS prior.

Any idea how to solve this?

2

2 Answers

1
votes

You could try:

m4_foreach_w(dep, m4_esyscmd([some command that generates list]),
       [AC_ERLANG_CHECK_LIB(dep)])

I suspect that this is a bad idea, but am unable to give more details on potential pitfalls. If it were me, I would prefer to hard code the dependencies or generate the configure.ac with a script.

0
votes

This approach might be total overkill for you but I'll just describe it.

When you run your program to get the list, munge the output into GNU Autogen .def file format:

elib.def

autogen definitions elib;

elib = { name="app1"; };
elib = { name="app2"; };

then invoke autogen with a template file like this:

gen.tpl

[+ autogen5 template 
m4=%s.m4
(setenv "SHELL" "/bin/sh") +]#
[+ (dne "# " "# ") +]
# whatever comment for the macro
AC_DEFUN([CHECK_MY_ELIBS],
[
[+
FOR elib "\n" +]AC_ERLANG_CHECK_LIB([[+name+]])[+ENDFOR+]
])

which'll output a macro elib.m4:

...
# whatever comment for the macro
AC_DEFUN([CHECK_MY_ELIBS],
[
AC_ERLANG_CHECK_LIB([app1])
AC_ERLANG_CHECK_LIB([app2])
])

You then invoke CHECK_MY_ELIBS in configure.ac after installing elib.m4 in AC_CONFIG_MACRO_DIR.

You could of course generate elib.m4 by some other means (e.g. perl, python), but this is not too hard.