[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: David Greene
Date: Wed, 10 May 2006 10:16:53 -0500
User-agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.7.8) Gecko/20050512

I can't seem to get the behavior I expect using .SECONDEXPANSION.

I've got a simple test build tree that looks like this:


The idea is thart an executable "hello" will be built in
the build directory and main.o will be built in build/core/main.o.

The Makefile is simple:

SRCDIR   := $(shell pwd)


core_BUILDDIR := $(BUILDDIR)/core
core_SRCS     := $(SRCDIR)/core/main.c
core_OBJS     := $(BUILDDIR)/core/main.o


#VPATH := $(SRCDIR)/core

$(TARGET): $(core_OBJS)
        $(CC) -o $@ $^

%.o: $$(subst $(BUILDDIR),$(SRCDIR),$$*.c)
        $(CC) -c $< -o $@

#%.o: $$(subst $(BUILDDIR),$(SRCDIR),%.c)
#       $(CC) -c $< -o $@

However, make can't figure out how to build main.o:

  cd ~/projects/maketest && make --warn-undefined-variables -p

  # GNU Make 3.81
  # Copyright (C) 2006  Free Software Foundation, Inc.
  # This is free software; see the source for copying conditions.
  # There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A

  # This program built for i686-pc-linux-gnu
  make: *** No rule to make target
  `/usr/people/dag/projects/maketest/build/core/main.o', needed by
  `/usr/people/dag/projects/maketest/build/hello'.  Stop.

  # Make data base, printed on Wed May 10 09:57:03 2006
  # Implicit Rules

  %.o: $(subst
  #  commands to execute (from `Makefile', line 16):
          $(CC) -c $< -o $@

>From what I understand of the database dump, this looks ok.  Using "%"
instead of "$$*" doesn't help.

Setting VPATH does help but the real project I'm working on has
thousands of files spread across various directories and are
likely named similarly.  It would be painful to manually specify
a VPATH for each target.  My thought was that secondary expansion
would allow me to make the object file in the BUILDDIR depend
directly on the source file in the SRCDIR.

What am I missing?

Thanks for your help.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]