help-make
[Top][All Lists]
Advanced

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

Problems with vpath directive in v3.81 (w/ minimal example)


From: Martin Willers
Subject: Problems with vpath directive in v3.81 (w/ minimal example)
Date: Sat, 7 Jul 2007 00:43:49 +0200
User-agent: KMail/1.9.1

Hi!

Well, since nobody answered my posting from a few days ago, I digged a little 
deeper into this issue and was able to create minimal example Makefiles.
This is with make v3.81 on GNU Linux:

$ make -v
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for i686-pc-linux-gnu


A short recap:

My project consists of a top-level Makefile and a number of subdirs,
each of which contains its own Makefile that gets called by the
top-level one and that creates a static library which then gets added
to the top-level-target linker line:

####################################################
SUBDIRS  := foo1 foo2 foo3 foo4 foo5 foo6 foo7 foo8
TARGET   := app
OBJFILES := toplevel.o
LIBDIRS  := $(patsubst %,-L%,$(SUBDIRS))
LIBS     := $(patsubst %,-l%,$(SUBDIRS))

vpath %.h include
vpath %.a lib $(SUBDIRS)

all: subdirs $(TARGET)

clean: subdirs
        -rm -f $(TARGET) core *.o *~

subdirs:
        @(for module in $(SUBDIRS); \
                do \
                        $(MAKE) -w -C $$module -f Makefile $(MAKECMDGOALS); \
                done)

$(TARGET): $(OBJFILES) $(LIBS)
        $(CC) -o $@ $(OBJFILES) $(LIBDIRS) $(LIBS)
####################################################

Every subdir contains this Makefile:


LIBNAME := $(shell basename `pwd`)
LIBFILENAME := lib$(LIBNAME).a
LIBTARGET := $(LIBFILENAME)

all: $(LIBTARGET)

$(LIBTARGET):
        touch $@

clean distclean:
        -rm -f $(LIBFILENAME) core *.o *~


Now, as long as MODULES contains up to 7 directory names, everything
is working fine. However, as soon as I add the 8th directory ("foo8" above),
make starts complaining:

$ make
make[1]: Entering directory `/home/luna/tmp/testmake3/foo1'
touch libfoo1.a
make[1]: Leaving directory `/home/luna/tmp/testmake3/foo1'
make[1]: Entering directory `/home/luna/tmp/testmake3/foo2'
touch libfoo2.a
make[1]: Leaving directory `/home/luna/tmp/testmake3/foo2'
make[1]: Entering directory `/home/luna/tmp/testmake3/foo3'
touch libfoo3.a
make[1]: Leaving directory `/home/luna/tmp/testmake3/foo3'
make[1]: Entering directory `/home/luna/tmp/testmake3/foo4'
touch libfoo4.a
make[1]: Leaving directory `/home/luna/tmp/testmake3/foo4'
make[1]: Entering directory `/home/luna/tmp/testmake3/foo5'
touch libfoo5.a
make[1]: Leaving directory `/home/luna/tmp/testmake3/foo5'
make[1]: Entering directory `/home/luna/tmp/testmake3/foo6'
touch libfoo6.a
make[1]: Leaving directory `/home/luna/tmp/testmake3/foo6'
make[1]: Entering directory `/home/luna/tmp/testmake3/foo7'
touch libfoo7.a
make[1]: Leaving directory `/home/luna/tmp/testmake3/foo7'
make[1]: Entering directory `/home/luna/tmp/testmake3/foo8'
touch libfoo8.a
make[1]: Leaving directory `/home/luna/tmp/testmake3/foo8'
cc    -c -o toplevel.o toplevel.c
make: *** No rule to make target `-lfoo8', needed by `app'.  Stop.


Another run of "make" then builds the target without problems; this error
only happens on a clean run of "make".
The Makefile in foo8 is exactly the same as in all the other subdirs, and the 
file foo8/libfoo8.a really DOES exist!
If I put any of the other dirs instead of foo8 as last entry of 
MODULES, then make complains about that one, and foo8 is ok - it's
always the last subdir that make complains about.


And now: If I remove the line with "vpath %.h include" - it works again!
Same if I put "vpath %.h..." BELOW "vpath %.a...".
And it also works if I put the first entry of "vpath %.a", namely "lib", 
+behind+ $(SUBDIRS).

What is going on here?

-- 
 Martin




reply via email to

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