help-make
[Top][All Lists]
Advanced

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

(un)expected make behavior while using VPATH


From: adrian ilarion Ciobanu
Subject: (un)expected make behavior while using VPATH
Date: Tue, 13 Nov 2012 18:01:45 +0200

Hello subscribers,

this is my Makefile:

    CC=cc
    INC=-I.
    CFLAGS=-g  -DDEBUG -std=gnu99 -DSFHASH -DDOMAIN
    LDFLAGS=-ldl
    OBJS=*.o
    OBJDIR=.obj
    BINDIR=.obj
    LIBDIR=.obj

    %.o: %.c
            $(CC) $(INC) $(CFLAGS) -DSFHASH -o $(OBJDIR)/$@ -c $<


    VPATH = .obj
    #vpath %.o $(OBJDIR)

    hashtest: hashfuncs.o hast.o scanners.o parseargs.o
            $(CC) -rdynamic -o $(BINDIR)/$@ $^ $(LDFLAGS)

    clean:
            @rm -f $(OBJDIR)/$(OBJS) $(BINDIR)/hashtest



using it for the first time: make does not rewrite gcc's input file paths:

    @delphi# make clean
    @delphi# make
    cc -I. -g  -DDEBUG -std=gnu99 -DSFHASH -DDOMAIN -DSFHASH -o
.obj/hashfuncs.o -c hashfuncs.c
    cc -I. -g  -DDEBUG -std=gnu99 -DSFHASH -DDOMAIN -DSFHASH -o
.obj/hast.o -c hast.c
    cc -I. -g  -DDEBUG -std=gnu99 -DSFHASH -DDOMAIN -DSFHASH -o
.obj/scanners.o -c scanners.c
    cc -I. -g  -DDEBUG -std=gnu99 -DSFHASH -DDOMAIN -DSFHASH -o
.obj/parseargs.o -c parseargs.c
    cc -rdynamic -o .obj/hashtest hashfuncs.o hast.o scanners.o parseargs.o -ldl
    cc: error: hashfuncs.o: No such file or directory
    cc: error: hast.o: No such file or directory
    cc: error: scanners.o: No such file or directory
    cc: error: parseargs.o: No such file or directory
    make: *** [hashtest] Error 1


using it second time in a row, it does:


    @delphi# make
    cc -rdynamic -o .obj/hashtest .obj/hashfuncs.o .obj/hast.o
.obj/scanners.o .obj/parseargs.o -ldl
    @delphi#


GNU Make manual says:

 The value of the make variable VPATH specifies a list of directories
 that make should search. Most often, the directories are expected to
 contain prerequisite files that are not in the current directory;
 however, **make uses VPATH as a search list for both prerequisites and**
 **targets of rules**.


I was expecting either to work for the first time or not work for the
second time.

The target's dependencies generated at runtime are found aok, why
isn't $^ properly expanded?


Thank you,
Adrian



reply via email to

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