Hello automake,


      I've run into couple of problems while trying to build mutually
dependent libraries (i.e. ones which import symbols from one another).
It first seemed to me that automake simply do not have support for
them. However, I was able to solve them in quite acceptable for me
way. Below is README's which I wrote for the libtool demos
demonstrating how to do that. I'd appreciate comments, maybe I've gone
wrong track. One question I still have is whether libtool supports
building of mutually-interdependent libraries, i.e. can it break
the loop by building one lib without other yet built? does it pay
attention to not go cycle when collecting dependencies? Maybe someone
can answer me before I'll be able to test it on linux.

---
This is mutualdepdemo-flat, an example package that uses GNU libtool
with an Automake-generated environment to build set of two simple
mutually-dependent libraries and a program which use them.

This shows how to achieve that trick in simple, flat package layout.
More precisely, no automake/libtool magick required in this case:
you just list one library as LDADD for another, and vice-versa. For
the rest, pray make to take care.

In case of GNU make, it will break cycle by dropping *one* (consider
randomly-selected) dependency. This means that changing *one* of the
library will not lead to rebuilding another. Now you may think whether
you at all want all the libraries rebuilt when only one has been changed:
after all, most changes touch only internal mechanisms and don't change
interface. So, if your answer is 'no', look at mutualdepdemo-subdirs
how to allow mutally-dependent libraries to be built portably, while
get rid of unnecessary remakes.
---
This is mutualdepdemo-subdirs, an example package that uses GNU libtool
with an Automake-generated environment to build set of two simple
mutually-dependent libraries and a program which use them.

Unlike mutualdepdemo-flat, this is more realistic example, when
interdepndent libraries live in each own dir. The basic idea is still
the same: in each subdir's Makefile.am, in LDADD for library, we specify
another one. However, such layout brings serious problems, which cannot
be solved automagically by make as in mutualdepdemo-flat:

- First problem is bootstrapping the build: when the first library
is built, it already requires second, and vice versa. In current case,
make even do not know how to build the other library. Even if it did,
it won't help much: since it wouldn't have global picture, it wouldn't
recognize there's recursion and just would gone cycled.

- Other problem is maintaining build procedure covergent. Since one
library depends on another and vice versa, whatever library you build,
other becomes outdated ;-) This means that executing make once will
build everyting, but immediate running make again will run the show again
even though nothing really changed.

Solution to both problems would be either making automake much smarter
(it should detect inter-subdirectory dependency loops, touch all libs
except "first" for the bootstrap, and make make set mutually-dependent
libs' time to the same value when set of them has been built) or -
magick - inhibit build dependencies for libs. Summing up: structural
mutual-dependency (libtool's part) should stay, procedural one
(make's part) should go. Explicit resetting libs' DEPENDENCIES does
the trick. In general, it is recommended way, even for flat layout.
---


Best regards,
 Paul                          mailto:[EMAIL PROTECTED]


Reply via email to