Subject: Re: Make .PATH strangeness
To: None <tsarna@endicor.com>
From: Mike Long <mikel@shore.net>
List: netbsd-help
Date: 12/02/1997 19:35:02
>From: Ty Sarna <tsarna@endicor.com>
>Date: Tue, 2 Dec 1997 16:40:13 -0600 (CST)
>
>Imagine the following situation:
>
>/path/prog1	sources for a program
>/path/prog2	current dir, sources for a second program
>
>Makefile in prog2 has:
>
>.PATH: /path/prog1
>
>and also creates a local copy of /path/prog1/src.c, by copying it to
>${OBJDIR} and patching it. Make happily follows the rules to create the
>local copy before trying to compile src.c, and then inists on compiling
>/path/prog1/src.c instead of ${.OBJDIR}/src.c. Even if I use:
>
>.PATH: ${.OBJDIR} /path/prog1
>
>It wants to compile the /path/prog1 version!

It looks like what you're trying to do is use the same filename for
two different files (patched and unpatched), which is a Bad Idea.

>Is there any workaround, short of using a different filename in
>/path/prog2 (my current solution)?

You could add something like this to prog2/Makefile:

----------------------------------------------------------------------
orig-src.c:
	ln -s ${.CURDIR}/../prog1/src.c $@

src.c: orig-src.c src.c.diff
	cp orig-src.c $@
	patch -o $@ < ${.CURDIR}/src.c.diff

CLEANFILES+=orig-src.c
----------------------------------------------------------------------

Now the unpatched file has a different name from the patched file, so
make won't get confused.
-- 
Mike Long <mikel@shore.net>                http://www.shore.net/~mikel
"Every normal man must be tempted at times to spit on his hands,
hoist the black flag, and begin slitting throats." -- H.L. Mencken