OSDN Git Service

Make $(my-dir) fail if it's called after including $(CLEAR_VARS)
authorDave Bort <dbort@android.com>
Tue, 19 May 2009 23:12:22 +0000 (16:12 -0700)
committerJoe Onorato <joeo@android.com>
Wed, 23 Sep 2009 19:58:20 +0000 (12:58 -0700)
core/definitions.mk

index a16ce03..297e6b7 100644 (file)
@@ -109,7 +109,14 @@ endef
 
 # Figure out where we are.
 define my-dir
-$(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST),$(MAKEFILE_LIST))))
+$(strip \
+  $(eval md_file_ := $$(lastword $$(MAKEFILE_LIST))) \
+  $(if $(filter $(CLEAR_VARS),$(md_file_)), \
+    $(error LOCAL_PATH must be set before including $$(CLEAR_VARS)) \
+   , \
+    $(patsubst %/,%,$(dir $(md_file_))) \
+   ) \
+ )
 endef
 
 ###########################################################