2
votes

I have two autotools projects that work fine on their own:

p1 does not build any libs nor use C++, and is meant to be compiled by the user. So I don't libtoolize nor LT_INIT here.

p2 creates a tiny C++ library that is used only in development, here I have LT_INIT and call libtoolize.

But when I put the p2 directory inside p1, running automake inside the p2 directory will notice that it's in a subdirectory of an autotools project, and I get the error

configure.ac:31: required file `../ltmain.sh' not found

I tried adding

AC_CONFIG_AUX_DIR([.])

to the configure.ac of p2, but then the ac_aux_dir variable in configure gets empty, and I get the error

configure: error: cannot run /bin/sh /config.sub

(the line in configure tries to run $ax_aux_dir/config.sub)

Is there a clean way to have an unrelated autotools project inside an autotools project, or should I just give up?

2

2 Answers

3
votes

I figured it out two minutes after asking, how typical. Apparently, configure.ac has to have:

AC_INIT(…)
AC_CONFIG_AUX_DIR([.])
AM_INIT_AUTOMAKE(…)

and not:

AC_CONFIG_AUX_DIR([.])
AC_INIT(…)
AM_INIT_AUTOMAKE(…)

like I had (it gives an error message if AUX_DIR is after AM_INIT_AUTOMAKE, which led me to believe it had to be after AC_INIT too).

Anyway, this works :)

2
votes

In configure.ac of p1 you can write:

AC_CONFIG_SUBDIRS(p2)

This call to AC_CONFIG_SUBDIRS will cause p2 to be treated as a sub project of p1, with its own configure.ac etc., with everything "just working automatically" (hopefully). There's also a complete small example in the autoconf manual