On Wed, Feb 8, 2012 at 2:53 PM, Mason <mpeg.b...@free.fr> wrote:

> [ Please CC replies to my address. ]
>

That violates one of the prime rules of list etiquette, but
i'll accommodate it this once...


> DIR := $(DIRECTORY_OF_THIS_MAKEFILE_RELATIVE_TO_ROOT) # e.g. src/tata
> LIST := x.c y.c
> SRC += $(LIST:%=$(DIR)/%)
>

What i do for such a case is something like:

First, all of my subdirs include the top-level config/common makefile, like
so:

include ../../config.make

and that file has a snippet like:

CONFIG.MAKEFILE := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
$(CONFIG.MAKEFILE):
TOP_SRCDIR_REL := $(dir $(CONFIG.MAKEFILE))
TOP_SRCDIR_REL := $(patsubst %/,%,$(TOP_SRCDIR_REL))# horrible kludge
TOP_SRCDIR := $(realpath $(TOP_SRCDIR_REL))
TOP_INCDIR := $(TOP_SRCDIR_REL)/include
INCLUDES += -I. -I$(TOP_INCDIR)
CPPFLAGS += $(INCLUDES)


Then TOP_SRCDIR_REL is the relative path to the top dir (where the common
makefile lives (in my case named "config.make")) and some other vars are
set up based on that.

There is quite possibly a more elegant solution out there somewhere, though.

-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
_______________________________________________
Help-make mailing list
Help-make@gnu.org
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to