help-make
[Top][All Lists]
Advanced

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

vpath-using makefile can build a target when steps are invoked individua


From: Britton Kerin
Subject: vpath-using makefile can build a target when steps are invoked individually, but can't chain them
Date: Wed, 19 May 2021 14:25:45 -0800

Maybe the below makes sense for some reason I don't understand but it
sure seems weird.
Seems like $< ends up with a different value depending on where the
request for the target comes from:

$ ls
Makefile
$ cat Makefile
OBJS = foo.o

FC = cp # Fake Compile
FL = cp # Fake Link

vpath %.o objdir

%.o: %.c
        $(FC) $< objdir/$@

foo: foo.o
        $(FL) $< $@

clean:
        rm -f *.o
        rm -f objdir/*.o
        rm foo
$ mkdir objdir
$ touch foo.c
$ make foo.o
cp  foo.c objdir/foo.o
$ make foo
cp  objdir/foo.o foo
$ make clean
rm -f *.o
rm -f objdir/*.o
rm foo
$ make foo
cp  foo.c objdir/foo.o
cp  foo.o foo
cp: cannot stat 'foo.o': No such file or directory
make: *** [Makefile:12: foo] Error 1
2 $



reply via email to

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