On Thu, Oct 7, 2010 at 4:44 PM, David Boyce <[email protected]> wrote:
> I like to use full paths everywhere, using a
> BASE_DIR variable which can be inherited from an env var or derived
> from $(MAKEFILES), but that's just me.
Sorry, I meant MAKEFILE_LIST. Something like:
ifndef BASE_DIR
export BASE_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
endif
.PHONY: all
all:
@echo BASE_DIR=$(BASE_DIR)
Though fully-qualified paths are most useful in a non-recursive model,
the above should work fine in a recursive setup too. Also, I use
conditionals instead of ?= so BASE_DIR will be a simply-expanded
variable. This is more efficient because $(realpath) usually requires
a system call and BASE_DIR does tend to be heavily used.
Interestingly (I just noticed), the above produces a BASE_DIR with a
trailing slash but if you use
$(realpath $(dir $(firstword $(MAKEFILE_LIST))))
instead there's no trailing slash. Depending on personal style you may
prefer one or the other.
This requires GNU make 3.81 BTW.
David Boyce
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make