automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

library dependency


From: John Wohlbier
Subject: library dependency
Date: Tue, 3 Mar 2009 21:27:18 -0700

Forgive me if this has been worked over (and over and over) but I could not
find anything in the archives to answer my question.

I have two libraries sitting next to each other in the source tree, and I'd
like one to depend on the other. In particular, lib1 depends on lib2. Under
normal operation lib2 is built first and then lib1 due to their ordering in
the top level Makefile.am. But I'm wondering if there is the possibility to
have lib2 built in the case when it isn't already built, by building lib1.

Here is my test case to demonstrate what I'm trying to achieve.
[testam]$ls -R
COPYING        Makefile.in    config.guess    configure    install-sh
ltmain.sh
INSTALL        aclocal.m4    config.log    configure.ac    lib1
missing
Makefile    autom4te.cache    config.status    configure.scan    lib2
Makefile.am    autoscan.log    config.sub    depcomp        libtool

./lib1:
Makefile    Makefile.am    Makefile.in    lib1src.c

./lib2:
Makefile    Makefile.am    Makefile.in    lib2src.c

where
[testam]$cat Makefile.am
SUBDIRS = lib2 lib1

[testam]$cat lib2/Makefile.am
lib_LTLIBRARIES = liblib2.la
liblib2_la_SOURCES = lib2src.c

[testam]$cat lib2/lib2src.c
#include <stdio.h>

void lib2fn(void) {
  printf("hello from lib2\n");
}

[testam]$cat lib1/Makefile.am
lib_LTLIBRARIES = liblib1.la
liblib1_la_SOURCES = lib1src.c
liblib1_la_LIBADD = ${top_builddir}/lib2/liblib2.la

[testam]$cat lib1/lib1src.c
#include <stdio.h>

void lib1fn(void) {
  printf("hello from lib1\n");
}

>From the top level this builds fine. But if I switch into lib1 when lib2
hasn't already been built, then I get
[testam/lib1]$make
/bin/sh ../libtool --tag=CC   --mode=compile gcc -DPACKAGE_NAME=\"dummy\"
-DPACKAGE_TARNAME=\"dummy\" -DPACKAGE_VERSION=\"0\"
-DPACKAGE_STRING=\"dummy\ 0\" -DPACKAGE_BUGREPORT=\"joeblow\"
-DPACKAGE=\"dummy\" -DVERSION=\"0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1
-DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1
-DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1
-DHAVE_DLFCN_H=1 -I.     -g -O2 -MT lib1src.lo -MD -MP -MF .deps/lib1src.Tpo
-c -o lib1src.lo lib1src.c
mkdir .libs
 gcc -DPACKAGE_NAME=\"dummy\" -DPACKAGE_TARNAME=\"dummy\"
-DPACKAGE_VERSION=\"0\" "-DPACKAGE_STRING=\"dummy 0\""
-DPACKAGE_BUGREPORT=\"joeblow\" -DPACKAGE=\"dummy\" -DVERSION=\"0\"
-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1
-DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
-DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -I. -g -O2 -MT
lib1src.lo -MD -MP -MF .deps/lib1src.Tpo -c lib1src.c  -fno-common -DPIC -o
.libs/lib1src.o
 gcc -DPACKAGE_NAME=\"dummy\" -DPACKAGE_TARNAME=\"dummy\"
-DPACKAGE_VERSION=\"0\" "-DPACKAGE_STRING=\"dummy 0\""
-DPACKAGE_BUGREPORT=\"joeblow\" -DPACKAGE=\"dummy\" -DVERSION=\"0\"
-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1
-DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
-DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -I. -g -O2 -MT
lib1src.lo -MD -MP -MF .deps/lib1src.Tpo -c lib1src.c -o lib1src.o
>/dev/null 2>&1
mv -f .deps/lib1src.Tpo .deps/lib1src.Plo
make: *** No rule to make target `../lib2/liblib2.la', needed by `liblib1.la'.
Stop.


Does automake allow for automatically building lib2 when make is typed
within lib1? If so, how is it done? If not, is this an unreasonable thing to
expect the dependencies to handle?

Thanks much.

jgw



-- 
John G. Wohlbier


reply via email to

[Prev in Thread] Current Thread [Next in Thread]