First off, I *have* read the info pages about vpath and
http://www.paulandlesley.org/gmake/vpath.html.  I think I know why gmake's
doing this, I just don't like it.

Consider this Makefile:

--------------------------------------CUT---------------------------------------
PWD=$(shell pwd)

vpath %.a $(PWD)/lib

LIBDIR = $(PWD)/lib

TARGET = libtest.a

all: $(TARGET)

$(TARGET):
        touch $(@)

install: all $(LIBDIR)/$(TARGET)

$(LIBDIR)/$(TARGET): $(TARGET)
        cp $(<) $(@)

clean:
        -rm -f $(TARGET)
--------------------------------------CUT---------------------------------------

and then this script:

$ mkdir lib
$ make
Makefile:12: Commands were specified for file `libtest.a' at Makefile:17,
Makefile:12: but `libtest.a' is now considered the same file as 
`/home/msterret/testgmake/lib/libtest.a'.
Makefile:12: Commands for `/home/msterret/testgmake/lib/libtest.a' will be ignored in 
favor of those for `libtest.a'.
gmake: Circular /home/msterret/testgmake/lib/libtest.a <- 
/home/msterret/testgmake/lib/libtest.a dependency dropped.
cp  /home/msterret/testgmake/lib/libtest.a
cp: missing destination file
Try `cp --help' for more information.
gmake: *** [/home/msterret/testgmake/lib/libtest.a] Error 1

Eeeeeeeew.  In addition, it ends up doing the $(LIBDIR)/$(TARGET) target
which, for us, basically means it just installed a non-working library.
It's too bad that there's not a variable that's the *opposite* of GPATH.
Then I could set it appropriately and not have this problem.

What I want to do is have a vpath statement similar to the one above
in our "global" Makefile.  Then, in the application Makefiles I can say
something like:

    $(TARGET): $(OBJS) $(LIBS)
            $(CCLD) $(OBJS) $(LIBS) -o $@

Where LIBS looks like -la -lb -lc, etc. and gmake will use vpath to find
the libraries.

This works great for the application directories, but when I'm in the
library directory, it produces the ugliness above.  I could probably set
vpath conditionally by looking at pwd, but that seems like a kludge.

Can I do what I want in a better way?

Michael Sterrett
  -Mr. Bones.-
[EMAIL PROTECTED]

Reply via email to