help-make
[Top][All Lists]
Advanced

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

Implicitly specifying target directories


From: EXT-Pennington, Dale K
Subject: Implicitly specifying target directories
Date: Mon, 20 Mar 2006 10:45:02 -0600

We are in the process of splitting our source and object directories.
The new structure will be on the order of :


Base -------- src----subproj1
            |           +-subproj2
            |
            -----obj-----subproj1
                       +subproj2

Currently each subproj builds in its source directory and have make
files with object lists of

OBJS = obj1.o obj2.o ,,, objn.o

That server as dependencies for the final exe, and targets for pattern
based build rules.

Not we can modify the OBJS to be 

OBJDIR = ../../obj/subproj1
OBJS =  $(OBJDIR)/obj1.o $(OBJDIR)/obj2.o .... $(OBJDIR)/objn.o

But it would be better if we could just tell make that all .o are in
$(OBJDIR) even if they do not currently exist

I tried the vpath directory, but that only works if the .o already
exists. If it does not, they make the .o in the src directory, which is
not desired.

One other alternative I could see is to monkey the implicit rule to
always build the .o in the OBJDIR directory something like

%.o : %.c
        cc -o $(OBJDIR)/$(@F) -c $^

But it would be nice if there was a simple way to just tell gmake "all
.o's are to be in directory OBJDIR"

Update : 

I tried the pattern modification rule, and it directs the objects into
the correct directory, but the directory path is listed as the base
(src) directory,
so the rule :

exe : $(OBJS)
        cc -o $@ $^ 

Only lists the .o names without the actual paths (OBJS in the case is
the first version above, without the path names). I did look in the
manual where it discussed keeping the directory search results, but did
not see a good way to force the discard.


Thanks 
Dale Pennington





reply via email to

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