help-make
[Top][All Lists]
Advanced

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

__FILE__


From: Noel Yap
Subject: __FILE__
Date: Wed, 17 Sep 2003 11:05:08 -0400

I just wanted to share the following.  I created two functions:

define _include-makefile
  __FILE__ := $(1)
  include $(1)
  __FILE__ := $(2)
endef

# include makefile passing in its name as __FILE__
include-makefile = $(eval $(call _include-makefile,$(1),$(__FILE__)))

That can be used by doing something like:

$(call include-makefile,another/makefile)

such that another/makefile will know it's path relative to the includer so it, 
in turn, can do something like:

$(call include-makefile,$(dir $(__FILE__))/yet-another-makefile)

I think I had posted something similar a while back, but this version uses 
function-local variables to save and restore the previous __FILE__ value.

HTH,
Noel
-- 
NOTICE: If received in error, please destroy and notify sender.  Sender does 
not waive confidentiality or privilege, and use is prohibited.




reply via email to

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