[Top][All Lists]

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

Re: library dependencies SUBDIR problem automake

From: John Calcote
Subject: Re: library dependencies SUBDIR problem automake
Date: Tue, 04 Aug 2009 10:54:05 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Gecko/20090715 Thunderbird/3.0b3

Hi Michiel,

On 8/4/2009 10:01 AM, Michiel Soede wrote:
I have a problem with dependencies to libraries in my build structure.the 
directory structure in my project is as follows (roughly):

configure.acmakefile.amapps/         app1/                  comps/         
the component makefile generates a library:noinst_LIBRARIES = 
libcomp1.alibcomp1a_a_SOURCES =
I recurse in all subdirectories, using SUBDIRS:SUBDIRS = apps comps
in the comps:SUBDIRS = comp1
same for the apps directory.
the app1 uses LDADD to link the app with
bin_PROGRAMS = app1app1_SOURCES = main.ccapp1_LDADD = 
Now when I call make at the root, everything is build correctly.
But when I cd into apps/app1/ and call make, I have problems with:
- if comp1 was not made before (e.g. from the root), make will fail  (no rule 
to make libcomp1.a)
- if I did make the library at the root, it is not recompiled automatically 
when  I modify
.. any ideas on these problems?
The lack of proper text wrapping on your message made it a bit difficult to see your directory structure, but I think I've sorted it out, based on your other comments:

According to your makefiles, app1 is dependent on comp1 (app1_LDADD = .../libcomp1.a), but comp1 is not built as a sub-component (sub-directory) of app1. Thus, (I believe you are saying) when you build from the project root, everything is fine, but when you build from the app1 directory, comp1 doesn't get built, and thus the app1 build fails. Is this correct?

A recursive build system must be designed to build component dependencies first before building the components. Thus, one limitation of a recursive build system is that it rather defines (or at least constrains) the directory structure that you must use. To get comps to be built before apps from within the app1 directory, you must build the comps directory structure from within the app1 directory.

I recognize that applications 2-n may also use components 1-n, so you have a problem here, and the only way around it is to use a non-recursive build system. That is, you can place all of your build logic in the top-level file using relative paths, and then the makefile dependencies will be properly structured for you by Automake:
= = = = = = = = = = =
bin_PROGRAMS = app1 app2 app3 ...
app1_SOURCES = apps/app1/
app2_SOURCES = apps/app2/...

noinst_LIBRARIES = libcomp1.a libcomp2.a libcomp3.a ...
libcomp1_a_SOURCES = comps/comp1/
libcomp2_a_SOURCES = comps/comp2/...

app1_LDADD = libcomp1.a
= = = = = = = = = = =

I also noted that you had

SUBDIRS = apps comps

in your top-level file. This is wrong - the comps hierarchy should be built before the apps hierarchy, or else there will still be no libraries in the comps hierarchy for the apps to link against, unless you've manually built the comps directory first, and then attempted to build from root.


reply via email to

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