Using autoconf in configure.ac I need to append to an output variable.
Specifically I want to append to the LIBS variable differently for each of my programs (myprogram1 and myprogram2 in the Makefile.am). Lets imagine myprogram1 requires a -lboost_python and myprogram2 requires -losg.
Essentially some programs require certain libs while others do not. Here is an example of what I am doing. Of course AC_SUBST does an assignment (= vs +=) from what I understand so that doesn’t work.
AC_CHECK_LIB([boost_python], [main], [AC_SUBST([myprogram1_LIBS], ["-lboost_python"])
AC_DEFINE([HAVE_LIBBOOST_PYTHON], [1], [Define if you have libboost_python])],
[AC_MSG_FAILURE([boost_python library not found])])
AC_CHECK_LIB([osg], [main], [AC_SUBST([myprogram2_LIBS], ["-losg"])
AC_DEFINE([HAVE_LIBOSG], [1], [Define if you have libosg])],
[AC_MSG_FAILURE([osg library not found])])
What I need is for the myprogram1_SOURCES to be built with the first lib and the myprogram2_SOURCES to be built with the second lib.
Is there an AC_APPEND_SUBST type macro I can use? And/or is there a better way for me to do what I need to do to build different programs with different libraries being linked?
I assume that your
AC_CHECK_LIBcalls and such do the right thing (if they don’t, have you tried using the macros from the autoconf archive (specificallyAX_BOOST_PYTHON))? I can’t believe that both boost python and osg providemain.Anyway, to answer the question as asked, you don’t have to provide the contents of an
AC_SUBST‘d variable all at once, so you can do stuff like this:P.S. the variable to add libraries to a program is
LDADDormyprogram1_LDADD.