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

coolbean nieters at copernicus.crd.ge.com
Sat Sep 1 03:22:01 AEST 1990



Hi

We do what you are talking about.  There is a project/src directory and 
we make files in a project/debug directory that depend on files in ../src.
Here's an example of the 'important' parts of the Makefile to achieve this:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

To make a target in debug called "foo" which depends on foo.c in
debug and bar.c in ../src

# some definitions

# standard message about linking
LINK_MSG = @echo Linking $@
# normal link command. LIBS is conditionally defined for each a.out file.
LINK_CMD = $(LINK.c) -o $@ $(LIBS)

# a sample target

FOO_SRCS = foo.c bar.c
FOO_OBJS = $(FOO_SRCS:.c=.o)
foo := LIBS = $(FOO_OBJS)
foo : $(FOO_OBJS)
	$(LINK_MSG)
	$(LINK_CMD)
#
# how to make things in ../src
%.c : ../src/%.c
	- at ln -s $< 2>/dev/null

# vanilla object files (assume Unix)
%.o : %.c
	$(COMPILE.c) -o $@ $<

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

We run this using Sun's make but I don't think there is anything particularly
exotic to this example that won't work on "normal" make.

--ed
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Ed Nieters		     INTERnet: nieters at crd.ge.com
GE Corporate R&D	     UUCPnet:  uunet!crd.ge.com!nieters	       
Schenectady, NY 12301	     BELLnet:  (518) 387-5187



More information about the Comp.unix.questions mailing list