🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.misc.discuss
Article #63432

Re: Gnu make question

#63432
From: David R. Hunt
Date: Tue, 07 Feb 1995 03:20
28 lines
1360 bytes
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:

ODIR=O
LDIR=../L
VPATH=.;$(ODIR)

c.o:
	$(CC) -c $(CFLAGS) -o $(ODIR)/$*.o $<

OBJS =	this.o \
	that.o \
	theother.o

$(LDIR)/libthis.a:	$(OBJS)
	ar r $(LDIR)/libdos.a $(ODIR)/*.o

Hope this helps!
Dave Hunt
Technical Details
Message-ID: <3h6f09$2ff8@tequesta.gate.net>
Path: arc1-ca.pugleaf.net!swrinde!howland.reston.ans.net!news.sprintlink.net!tequesta.gate.net!orfl-21
References: <3guabp$bti@netline-fddi.jpl.nasa.gov>

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-06 16:40:32 PST
Path: arc1-ca.pugleaf.net!swrinde!howland.reston.ans.net!news.sprintlink.net!tequesta.gate.net!orfl-21
From: dhunt@gate.net (David R. Hunt)
Newsgroups: gnu.misc.discuss
Subject: Re: Gnu make question
Date: Tue, 07 Feb 95 03:20:03 GMT
Lines: 29
Distribution: world
Message-ID: <3h6f09$2ff8@tequesta.gate.net>
References: <3guabp$bti@netline-fddi.jpl.nasa.gov>
NNTP-Posting-Host: orfl-21.gate.net
X-Newsreader: News Xpress Version 1.0 Beta #2.1