[Top][All Lists]

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

[bug #16286] VPATH and directory cache

From: anonymous
Subject: [bug #16286] VPATH and directory cache
Date: Thu, 6 Apr 2006 18:15:55 +0000
User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)


                 Summary: VPATH and directory cache
                 Project: make
            Submitted by: None
            Submitted on: Donnerstag 06.04.2006 um 18:15 UTC
                Severity: 3 - Normal
              Item Group: Bug
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
       Component Version: 3.79.1
        Operating System: Any
           Fixed Release: None



Normally, all prerequisites are searched in ./ and in all directories found
If found, the $^ variable holds the prerequisites with the actual path where
they are found.

Unfortunately this utterly fails if the prerequisite was the target of a
previously executed rule.

Following the manual, make assumes that a rule creates its target. But what
if the target is created in a different directory than then ./ ? make adds
the file to its directory cache - without noticing that it was created
somewhere else.
As soon as the former target appears as prerequisite, make does no longer
search in VPATH but simply assumes that the file is in the current directory.
And of course the rule fails to build its target then.

When running make a second time, it skips building the object files (of
course), finds them through vpath and works as expected.

VPATH = $(INCSRC):obj:bin
SRCS =  foo1.c foo2.c foo3.c foo4.c foo5.c foo6.c
OBJS =  $(SRCS:.c=.o)
TARG =  $foo.elf 

all: $(OBJS) $(TARG)
        avr-objcopy -O binary -I ihex $(PROJ).hex $(PROJ).bin

%o : %c
        @$(CC) -c $(CPFLAGS) $(INCFIRST) -I$(INCDIR) $(INCLAST) $< -o obj/$@

%elf: $(OBJS)
        @$(CC) $^ $(LDFLAGS) $(LIBS) -o bin/$@


make compiles all c files properly, the object files placed in the obj
subfolder. but then the linking of the object files fails.
 While all compiled .o files are in obj/*.o , make constructs a $^ variable
which contains some prerequisites with and some without the obj/ prefix.

A debug output reveals that whils considering targets and rules for the
prerequisites in the %elf rule, make has pruned some files form the search
(apparently because of their -wrong- appearance in the directory cache) while
others are searched for and found by the VPATH mechanism.
Which ones are found and which are simply (and wrongly) assumed depends on
the number of source files and seems to be influenced by cosmic x-rays too.
The only fix to this problem was to change the rule like this:

%elf: $(OBJS)
        @$(CC) $(addprefix obj/,$(notdir $^)) $(LDFLAGS) $(LIBS) -o bin/$@

which renders the vpath mechanism almost useless, only working properly for
files that aren't made by make itself.


Reply to this item at:


  Nachricht geschickt von/durch Savannah

reply via email to

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