[Top][All Lists]

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

Re: library dependencies SUBDIR problem automake

From: Michiel Soede
Subject: Re: library dependencies SUBDIR problem automake
Date: Tue, 4 Aug 2009 20:09:08 +0200

Hi John,

Thanks for the fast reply (my mailtool messed up the line-feeds I guess, sorry about that). You were right about the wrong order in SUBDIRS = apps comps (that was a type).

Your answers raised some new questions to me:

- non-recursive make, is that the same as just making one big make file that will always build everything? So I would loose the ability to build (for example) only one application, or library?

- isn't there any other way to modify the of an application so that it will execute the
 makefile's of it's dependend library (components)?

- making a hack so that an application will go BACK into the directories of the dependend components by adding SUBDIRS = ../comps/comp1 is probably not the way to go (and can
 cause infinity recursion loops).

best regards,

From: "John Calcote" <address@hidden>
Sent: Tuesday, August 04, 2009 6:54 PM
To: "Michiel Soede" <address@hidden>
Cc: <address@hidden>
Subject: Re: library dependencies SUBDIR problem automake

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/ comp1/ 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 = $(top_builddir)/comps/comp1/libcomp1.a
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]