%% "Balzli, Robert" <[EMAIL PROTECTED]> writes:

  br> I'm trying to create a pattern rule that has the object directory
  br> different than that of the source directory. The document for gnu 
  br> make it tells me that the directory from the target is always
  br> attached to the stem in order to generate the matching dependency. 
  br> This won't work for me. Here is my example

  br> SRC_PATH = src/a src/b
  br> SRC = src/a/one.c src/b/two.c
  br> OBJ_PATH = obj/nt/debug/ 
  br> OBJ = obj/nt/debug/one.o obj/nt/debug/two.o

  br> How do I write a pattern rule for such a case?
  br> Would something like this work?

  br> $(OBJ_PATH)/%.o : $(SRC_PATH)/%.c

  br> Or would this work?
  br> $(OBJ)/%.o : $(SRC)/%.c

Neither of these will work.  Try expanding the variables and you'll see
why; the first one expands to this:

  obj/nt/debug//%.o : src/a src/b/%.c

which is obviously not going to work, since "src/a src/b/%.c" is not
going to do what you want.

Ditto for the second one, and even worse; that expands to this:

  obj/nt/debug/one.o obj/nt/debug/two.o/%.o : src/a/one.c src/b/two.c/%.c

which is completely nonsensical.

What you need to do is write one pattern rule for each individual
combination of object and source directories:

  obj/nt/debug/%.o : src/a/%.c
            ...
  obj/nt/debug/%.o : src/b/%.c
            ...

etc.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[EMAIL PROTECTED]>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

Reply via email to