**** make file in another dir -- help !! ****

Siping Liu siping at cathedral.cerc.wvu.wvnet.edu
Sat Sep 1 04:00:47 AEST 1990


Thanks to the rapid replies -- it didn't take much longer
than turn around to ask my fellow workers here.

******************************************************************

>From filipski at cs.Buffalo.EDU Fri Aug 31 12:53:16 1990
Return-Path: <filipski at cs.Buffalo.EDU>
Received: from sybil.cs.Buffalo.EDU by cerc.wvu.wvnet.edu (4.1/SMI-4.0:RAL-041790)
	id AA03288; Fri, 31 Aug 90 12:53:14 EDT
Received: by sybil.cs.Buffalo.EDU (4.0/1.01)
	id AA23193; Fri, 31 Aug 90 12:48:39 EDT
Date: Fri, 31 Aug 90 12:48:39 EDT
From: filipski at cs.Buffalo.EDU (Paul Filipski)
Message-Id: <9008311648.AA23193 at sybil.cs.Buffalo.EDU>
To: siping
Subject: Re: **** make file in another dir -- help !! ****
Newsgroups: comp.unix.questions
In-Reply-To: <730 at babcock.cerc.wvu.wvnet.edu>
Organization: State University of New York at Buffalo/Comp Sci
Cc: 
Status: R

In article <730 at babcock.cerc.wvu.wvnet.edu> you write:
>I'd like to run my make file in one directory (also generate the object
>files and executable file in this directory) but the source files are
>stored in another directory. I do not know how to specify this situation
>in my makefile. I tried to put the path with every file names in the
>makefile but it didn't work. The guy who works with me said make can
>not handle this.

After extensive searching, I've yet to find anything that make can't
handle.  It's extremely robust.  Some things get awfully tricky,
though.

>Can you help me to solve this or confirm that it is impossible?

Depending on your version of make, you should have the
'%'-matching-mechanism (for lack of a better name).

This would allow you to write a new default rule in the following way.
Assume that you want objects and executables in the ~/obj directory,
and C sources are in ~/src.  Also, you're Makefile would be in ~/obj.

%.o : ~/src/%.c
	cc -c -o $@ $(CFLAGS) $<

Which make interprets (roughly) as :
	If I want foo.o and I've got ~/src/foo.c then
	I can cc ~/src/foo.c and put my output here!

You'll probably want to check the man page for more information.

>Thanks a lot.
You're welcome.

>siping at cerc.wvu.wvnet.edu

Enjoy,
Paul

-- 
Paul Filipski			State University of New York at Buffalo
filipski at cs.buffalo.edu		Dept of Computer Science
UUCP: ...!{watmath,boulder,decvax,rutgers}!sunybcs!filipski
			M-52 M-x yow

>From preston at src.umd.edu Fri Aug 31 13:47:32 1990
Return-Path: <preston at src.umd.edu>
Received: from src9.src.umd.edu by cerc.wvu.wvnet.edu (4.1/SMI-4.0:RAL-041790)
	id AA03526; Fri, 31 Aug 90 13:47:30 EDT
Received: from gauss.src.umd.edu 
	by src9.src.umd.edu (4.1/UMDENG-0.1/02-20-90)
	id AA08730; Fri, 31 Aug 90 13:42:51 EDT
Message-Id: <9008311742.AA08730 at src9.src.umd.edu>
Date: Fri, 31 Aug 90 13:42:30 EDT
From: preston at src.umd.edu (James Preston)
To: siping at cerc.wvu.wvnet.edu
Status: R

makefile in another dir

	Set the variable VPATH in the makefile to the path to the .c files

 
i.e VPATH = ../../other_dir/sources:.



More information about the Comp.unix.questions mailing list