Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!genrad!decvax!decwrl!hplabs!hp-pcd!uoregon!omepd!intelisc!littlei!ogcvax!schaefer From: schaefer@ogcvax.UUCP (Barton E. Schaefer) Newsgroups: comp.unix.questions Subject: Re: Using subdirectories from make Message-ID: <1433@ogcvax.UUCP> Date: Sat, 26-Sep-87 16:08:21 EDT Article-I.D.: ogcvax.1433 Posted: Sat Sep 26 16:08:21 1987 Date-Received: Wed, 30-Sep-87 00:56:29 EDT References: <831@ektools.UUCP> <204@tut.cis.ohio-state.edu> Reply-To: schaefer@ogcvax.UUCP (Barton E. Schaefer) Organization: Oregon Graduate Center, Beaverton, OR Lines: 43 In article snafu@ihlpm.ATT.COM (Wallis) writes: }In article <204@tut.cis.ohio-state.edu>, mdf@tut.cis.ohio-state.edu (Mark D. Freeman) writes: }>In <831@ektools.UUCP> jim@ektools.UUCP (James Hugh Moore) writes: }>>... a way of keeping source in one directory and objects in another and }>>using one makefile. }> }> I am in need of similar advice. }> }On UNIX, the following should work. I'll base the example on the following }directory structure ... }---- }SOURCE_DIR = $(BASE)/src }INC_DIR = $(BASE)/include }OBJ_DIR = $(BASE)/obj } [...] }$(OBJ_DIR)/foo.o: $(SRC_DIR)/foo.c $(INC_DIR)/hdr.h } $(CC) $(CFLAGS) $(SRC_DIR)/foo.c This works OK, but what if there are several dozen source files and corresponding objects? Do you really want to specify every single one of those dependencies and compilation commands, where the only thing that changes from line to line is the basename of the file? The VPATH variable (found in 4.3BSD make, among others) helps a little, but can't specify different object directories and leaves something to be desired even in terms of local objects depending on "remote" sources. For example, given the dependency foo : foo.o $(CC) $(CFLAGS) foo.o -o foo where foo.c is in a VPATH-specified directory, the "right " thing happens if you say "make foo". But if you type "make foo.o" (which works under the default ".c.o:" dependency if foo.c is in the same directory) simply does nothing -- doesn't even complain that it can't make foo.c. Is there any way to handle this? -- Bart Schaefer CSNET: schaefer@Oregon-Grad UUCP: ...{tektronix,verdix}!ogcvax!schaefer "This area is like heaven, and they want to turn it into California." -- Joseph Cook, Amish farmer, protesting highway construction