* Juliano Ravasi Ferraz wrote on Sat, Jan 10, 2004 at 11:22:16PM CET:
> 
> I've added AC_CONFIG_LIBOBJ_DIR([lib]) to configure.ac, and added the 
> needed files to lib/. Automake found them and added all to distribution 
> except for some needed header files that I had to list under noinst_HEADERS.
> 
> The problem is that when I add @LIBOBJS@ to _LIBADD and _LDADD rules in 
> the Makefile.am's of src/ and util/ directories, automake fails with 
> missing files in those directories, the same files that are in the lib/ 
> directory (automake bug?).

A setup I know to work with current autotools is the following
(assuming existing files lib/getopt.c and src/foo.c):

$ cat configure.ac
AC_INIT([foo], [0.1], [EMAIL PROTECTED])
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_LIBOBJ_DIR([lib])
AC_PROG_CC
AC_PROG_RANLIB
dnl Next line is just an example
AC_LIBOBJ([getopt])
AC_CONFIG_FILES([Makefile src/Makefile lib/Makefile])
AC_OUTPUT
$ cat Makefile.am
SUBDIRS = lib src
$ cat lib/Makefile.am
noinst_LIBRARIES = libreplace.a
libreplace_a_SOURCES =
libreplace_a_LIBADD = $(LIBOBJS)
$ cat src/Makefile.am
bin_PROGRAMS = foo
LDADD = ../lib/libreplace.a
$

A few remarks:
- You might get spurious errors because the src/Makefile does not know
how to rebuild ../lib/libreplace.a (esp. if you change the order in
SUBDIRS).  The following line in src/Makefile.am should fix this (I'm
unsure if automake can be brought to cope with this on its own):

../lib/libreplace.a:
        @cd ../lib && $(MAKE) libreplace.a

- Empty libraries cause an error with ar on some systems (unicosmk is
an example).  Might have to add a dummy.c to libreplace_a_SOURCES.

More comments on this welcome.  Would an example like this be accepted
for automake documentation (given it'd be in form of a complete patch)?
This question has come up several times, I think.

Regards,
Ralf


Reply via email to