[Top][All Lists]

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

Re: Crossing directories for target and source

From: Philip Guenther
Subject: Re: Crossing directories for target and source
Date: Thu, 7 Oct 2010 12:00:25 -0700

On Thu, Oct 7, 2010 at 11:29 AM, Erik Rull <address@hidden> wrote:
> I'm planning to restructure my projects source tree.
> Is it possible to write a rule that does the following:
> src/*.c compiles all files to build/*.o
> AND is capable to find out that one of the *.c ind the src/ has been
> modified.


build/%.o: src/%.c
        $(COMPILE.c) $(OUTPUT_OPTION) $<

> My plan is to run the makefile in the parent directory of both src and build.
> I'm asking that before starting restructuring because I've heard that make
> seems to have some difficulties crossing directories.

The design of the VPATH feature (which predates GNU make, btw) makes
it basically useless for such setups where you're generating files
into a directory other than the current directory.  c.f. for details.

Similarly, the default rules are all about generating files in the
current directory, so if you don't put the files there, you'll
basically have to write all the rules you need yourself.  That's not
necessarily a bad thing, as you don't really need all those rules, but
it's something to take into account.

Otherwise, I would call "difficulties crossing directories" FUD.

Philip Guenther

reply via email to

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