help-make
[Top][All Lists]
Advanced

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

Copied sourcefiles, automatic dependencies


From: Torsten Mohr
Subject: Copied sourcefiles, automatic dependencies
Date: Tue, 31 Jul 2007 19:09:25 +0200
User-agent: KMail/1.9.1

Hi,

> I treat my dependency files exactly the same as my object files, so I
> keep them in a separate tree. If you prefer to keep your object files in
> the source tree I'd just put my dependency files in the source tree too.
>
> I don't have a separate step to create the dependency info either.
> Have a look at
> http://www.cmcrossroads.com/option,com_smf/Itemid,180/topic,69672.0.html
> The final solution is actually quite easy to use and write (Once you know
> how it works of course).

thanks for the explanation and the link.  The principles in that article
are known to me.  Everything in that article works fine when you have the
sources organised as described in that article (all sources in one directory).


I think i was a bit unclear in describing the problem that i see, please let
me describe in more detail:


In a large project we have the sources organised in several subdirectories,
for example:

SRC := some/where/main.c a/directory/gui.c some/where/else/stuff.c

VPATH := some/where a/directoy some/where/else

BASENAMES := $(patsubst %.c,%,$(foreach f,$(notdir $f),$(SRC)))

I store all dependency files in dep_dir and all objects in obj_dir:

DEPENDS := $(patsubst %,dep_dir/%.d,$(BASENAMES))
OBJECTS := $(patsubst %,obj_dir/%.o,$(BASENAMES))

That way the dependency file for some/where/main.c becomes dep_dir/main.d .

The dependency file contains something like:

obj_dir/main.o dep_dir/main.d : some/where/main.c other.h

If a developer now COPIES main.c from some/where to a/directory and also
changes SRC to contain a/directoy/main.c then dep_dir/main.d andobj_dir/main.o
DO NOT get remade when a/directoy/main.c changes.

But the developer would expect that.  I can understand that, they do not want
to care about make's internals.  Also, i'd like to make this safe, so nothing
can go wrong.

As mentioned in an email before, i thought about creating a deep directory
structure underneath dep_dir, so the dependency file for some/where/main.c
would be dep_dir/some/where/main.d or creating other filenames like
dep_dir/some_where_main.d .  But i think that would lead to other problems,
for example:

%.d : %.c
        @ makedepend ...

I think this could not be written like this any more because the dependency
files can't be simply found any more.

Or is my thought wrong?


Thanks for any hints,
Torsten.




reply via email to

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