Article View: gnu.misc.discuss
Article #63321Re: Gnu make question
From: Jim Karpinski
Date: Fri, 10 Feb 1995 05:00
Date: Fri, 10 Feb 1995 05:00
75 lines
3368 bytes
3368 bytes
In article <3h6f09$2ff8@tequesta.gate.net>, dhunt@gate.net (David R. Hunt) wrote: > vsnyder@math.jpl.nasa.gov (Van Snyder) wrote: > >I have a simple makefile that compiles all the .c files in a directory and > >makes a library. I want to make two libraries, one with debugging, and one > >with optimization. The natural way (for me) to do that is to have two > >subdirectories of the source directory, in which I put the .o files compiled > >with different options (e.g. -g and -O). > > > > ... > > Try using the VPATH or vpath directives (see section 4.3 of the GNU Make manual) > in combination with an implicit rule: > I've had the same desire to put object files in different directories. I've tried using VPATH and vpath and I couldn't get them to work the way I wanted. It seems that VPATH and vpath always look in the current directory first. This is not what I wanted. I wanted it to work like the PATH directive from Polymake. With Polymake you could set a path for each file extension. Ex. .PATH.OBJ=./OBJ;./DBOBJ Polymake would look for a target .OBJ file in each directory in the corresponding PATH.OBJ and if it wasn't found, it would be built in the first directory in the .PATH.OBJ This is a fragment of a makefile that I've been using to locate object files into different directories using GNU make. I've edited out all the extraneous stuff. Hopefully, I left all the good stuff. (I've been using GNU make from djgpp running on MS-DOG) # start of makefile # Jim Karpinski # 02/09/95 # The macro CC is set in the environment to be either GCC or XGCC # The goal of this is to put the object files for the # gcc compiler in ./gcc # xgcc compiler in ./xgcc ODIR=$(CC) $(ODIR)/%.o : %.c $(CC) $(CFLAGS) $(CDEBUG) -o $@ $< >>ccer $(ODIR)/%.o : %.s $(CC) $(CFLAGS) $(CDEBUG) -o $@ $< >>ccer ALLSRCS=$(wildcard *.c) ALLOBJS=$(addprefix $(ODIR)/, $(ALLSRCS:.c=.o) ) DOALL: $(ODIR) $(ALLOBJS) ld -s -stats -Map g32.map D:/djgpp/lib/crt0.o $(ODIR)/*.o D:/djgpp/lib/libc.a $(ODIR) : -mkdir $(ODIR) $(ODIR)/src1.o : inc1.h $(ODIR)/src2.o : inc2.h $(ODIR)/src3.o : inc3.h # end of makefile I hope this helps. I spent alot of time trying to get VPATH or vpath to work. I just don't understand how they should be used. They don't seem useful to me. Jim Karpinski jk55@cornell.edu
Technical Details
Message-ID:
<jk55-1002950006360001@132.236.236.86>Path:
arc1-ca.pugleaf.net!nntp.gmd.de!stern.fokus.gmd.de!gmdtub!cs.tu-berlin.de!fauern!news.th-darmstadt.de!terra.wiwi.uni-frankfurt.de!zeus.rbi.informatik.uni-frankfurt.de!news.dfn.de!news.dkrz.de!news.rrz.uni-hamburg.de!unibwh.unibw-hamburg.de!Germany.EU.net!EU.net!uunet!cs.utexas.edu!howland.reston.ans.net!news.cac.psu.edu!news.tc.cornell.edu!travelers.mail.cornell.edu!newsstand.cit.cornell.edu!NewsWatcher!userReferences:
<3guabp$bti@netline-fddi.jpl.nasa.gov> <3h6f09$2ff8@tequesta.gate.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1025b4,dc36dc913ab9ebab X-Google-Attributes: gid1025b4,public X-Google-ArrivalTime: 1995-02-09 21:00:39 PST Path: arc1-ca.pugleaf.net!nntp.gmd.de!stern.fokus.gmd.de!gmdtub!cs.tu-berlin.de!fauern!news.th-darmstadt.de!terra.wiwi.uni-frankfurt.de!zeus.rbi.informatik.uni-frankfurt.de!news.dfn.de!news.dkrz.de!news.rrz.uni-hamburg.de!unibwh.unibw-hamburg.de!Germany.EU.net!EU.net!uunet!cs.utexas.edu!howland.reston.ans.net!news.cac.psu.edu!news.tc.cornell.edu!travelers.mail.cornell.edu!newsstand.cit.cornell.edu!NewsWatcher!user From: jk55@cornell.edu (Jim Karpinski ) Newsgroups: gnu.misc.discuss Subject: Re: Gnu make question Message-ID: <jk55-1002950006360001@132.236.236.86> Date: 10 Feb 95 05:00:39 GMT References: <3guabp$bti@netline-fddi.jpl.nasa.gov> <3h6f09$2ff8@tequesta.gate.net> Sender: jk55@cornell.edu (Verified) Organization: Cornell University Lines: 75 NNTP-Posting-Host: cu-dialup-0312.cit.cornell.edu