Muli Ben-Yehuda <[EMAIL PROTECTED]> writes:

> Let's say that I have a complex project, using many Makefiles. In some
> of them, I'd like to refer to other directories of the project. So
> far, I've been using various combinations on ../, ../../, etc, but
> that's awfully brittle when you start moving directories around (not
> to mention potentially dangerous). Is there a way, which does NOT
> involve setting an environment variable, to refer to the top level
> project directory? Specifically, I have a Rules.make in that
> directory, which is included from the other Makefiles. If I could make
> the Rules.make contain the top level directory in a variable, it would
> solve most of my problems. 
> 
> Now that I think of it, another way would be to change the build
> structure from recursive builds to a centralized build - all
> directories are built from the top level directory. Let's say that I
> do want to use recrusive build, though. What trick am I missing? 

Provide a reassonable (relative) default in every Makefile

UNTESTED:

In top-level Makefile

ifndef TOPDIR
TOPDIR := $(shell pwd)
endif

export TOPDIR

In all the other makefiles

ifndef TOPDIR
TOPDIR := <default path to TOPDIR>
export TOPDIR
endif

include $(TOPDIR)/Rules.mk

On the command line you'll be able to change it at will

$ make TOPDIR=<path>

HIH, let me know if you run into problems.

-- 
Oleg Goldshmidt | [EMAIL PROTECTED]

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to