diff --git a/make/common/MakeIncludeEnd.gmk b/make/common/MakeIncludeEnd.gmk index 7023a861fa1..47be7c65c72 100644 --- a/make/common/MakeIncludeEnd.gmk +++ b/make/common/MakeIncludeEnd.gmk @@ -27,10 +27,15 @@ # MakeIncludeEnd.gmk should be included last of all in all include files ################################################################################ -# Hook to include the corresponding custom file, if present. -ifneq ($(NO_CUSTOM_EXTENSIONS), true) - CUSTOM_POST_NAME := $(subst .gmk,-post.gmk, $(THIS_INCLUDE)) - $(eval $(call IncludeCustomExtension, $(CUSTOM_POST_NAME))) +ifneq ($(INCLUDE_GUARD_$(THIS_INCLUDE)), true) + # This was the first time this file was included. Prevent future inclusion. + INCLUDE_GUARD_$(THIS_INCLUDE) := true + + # Hook to include the corresponding custom file, if present. + ifneq ($(NO_CUSTOM_EXTENSIONS), true) + CUSTOM_POST_NAME := $(subst .gmk,-post.gmk, $(THIS_INCLUDE)) + $(eval $(call IncludeCustomExtension, $(CUSTOM_POST_NAME))) + endif endif # Pop our helper name off the stack diff --git a/make/common/MakeIncludeStart.gmk b/make/common/MakeIncludeStart.gmk index 3904633f9f2..f1d690ddb41 100644 --- a/make/common/MakeIncludeStart.gmk +++ b/make/common/MakeIncludeStart.gmk @@ -70,7 +70,6 @@ INCLUDE_STACK := $(THIS_INCLUDE) $(INCLUDE_STACK) # Setup an automatic include guard ifneq ($(INCLUDE_GUARD_$(THIS_INCLUDE)), true) - INCLUDE_GUARD_$(THIS_INCLUDE) := true INCLUDE := true # Hook to include the corresponding custom file, if present.