help-make
[Top][All Lists]
Advanced

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

Re: dependencies in other folders


From: Eduardo Suárez
Subject: Re: dependencies in other folders
Date: Sat, 30 Aug 2008 09:26:20 +0100
User-agent: Thunderbird 2.0.0.16 (X11/20080724)

Philip Guenther wrote:
Right.  Let's look at the error message:
  make: stat: ../ab/../ab/../ab/../ab/../<elided>/ab/../ab/../ab/foo.c:
File name too long
...
So, the problem is that the pattern rules results in a prerequisite
that matches the same rule again *and* refers to the same file.  The
other pattern rule doesn't have that problem with 'bar.c' because the
prerequisite is at a different directory level, so when the rule tries
to match again it fails because the prereq doesn't exist.
I thought that being in other directory, it wouldn't match the target. Sorry for bothering that.
The first consideration in solving this is whether you can remove
these rules and instead just use the VPATH variable or the vpath
directive.  You should read chapter 4.5 "Searching Directories for
Prerequisites" in the info pages for the details.  That's probably the
simplest and cleanest way to solve this.
Let's say target and prerequisite have the same extension (e.g. think of an 'sed' processing):
################# START HERE
mkdir test_make test_make/a test_make/b
touch test_make/b/foo.c
cat<<EOF | tr "!" "\t" > test_make/a/Makefile
VPATH=../b
%.c: %.c
!cp \$< \$@
EOF
cd test_make/a
make foo.c
################# END HERE

Then I get:
make: Circular foo.c <- foo.c dependency dropped.
make: `../b/foo.c' is up to date.

Is it possible to solve it using VPATH?
If there's some insurmountable blocker to using VPATH or vpath, then I
would consider changing the pattern rules to have two colons.  This
makes them 'terminal' rules, so that make will only apply them if the
prerequisite file exists and make won't try to build that prerequisite
file from something else.  If the source files (../ab/foo.c and
../../b/bar.c) need to themselves be built as part of the run, then
this won't work.
With double colon it seems to work pretty fine.

Thanks a lot for your answer,
-Eduardo




reply via email to

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