make file not in current directory 

Newsgroups: comp.os.linux.misc,comp.unix.questions
Date: Thu, 27 Mar 2003 08:56:42 -0600
> What is the right way of specifying make rules for files that are
> not in current directory? For example:
> %.ps : %.dvi %.chk

Not all makes are the same, but the implementation I use on Solaris does not allow more than ONE % on the right side. So, I believe this would be an error or not interpretted as you indend. GNU make may be different. What you are trying to do works for me, on Solaris 8, when there is only one % on the right.

Chuck Dillon

make file not in current directory 

> What is the right way of specifying make rules for files that are
> not in current directory?

There is none. The concept (a) does not apply, (b) is meaningless, (c) is ill-conceived.

> %.ps : %.dvi %.chk
>      $(DVIPS) -o $@ $<
> I want it to be a general purpose rule for files that are in current
> directory, and those which aren't. But it seems to me that it does

It is.

> not apply to files not in current directory, correct? How can I make
> it happen?

You probably need to change your perception.

> Further detailed info. I have another rule:
> ps : ${TEX_DEST_DIR}/$(TEX_SOURCE_BASE).ps
> and the .dvi has already been generated in ${TEX_DEST_DIR}. But when
> I issue make, I got:
> make: *** No rule to make target `../../tmp/path/test.ps', needed by `ps'.  Stop.

And where are you when you do this?

In any case, the correct way to do what you want is

export VPATH:=$(TEX_SOURCE_DIR)
ps:
     $(MAKE) -C $(TEX_DEST_DIR) foo.ps

I.e. makefiles are expected to be one per dir.

Probably.

Peter

make file not in current directory 

> In any case, the correct way to do what you want is
>
>    export VPATH:=$(TEX_SOURCE_DIR)
>    ps:
>      $(MAKE) -C $(TEX_DEST_DIR) foo.ps
>
> I.e. makefiles are expected to be one per dir.

This is non-portable for those (bsd-based) `make's that do not use -C. I suspect you'd want to use (cd $(TEX_DEST_DIR); $(MAKE) ) instead.

Or something.

~Tim