.DEFAULT_GOAL := 5

#
# This rule is here to make directories, so the behavior of .INCLUDE_DIRS
# may be more clearly illustrated.
#
.PHONY: dirs
dirs:
	@mkdir -p 1 2 3 4 5

#
# Print out .INCLUDE_DIRS at each level of recursion.  At each level
# of recursion, the list of .INCLUDE_DIRS grows.  In the middle.
#
0 1 2 3 4 5 :: dirs
	@echo "$@: .INCLUDE_DIRS: '${.INCLUDE_DIRS}'"

#
# Invoke the next level of recursion.
#
# Note that there is only one instance of --include-dir=... on the
# command line below.  There should be one directory ($PWD) ahead
# of the built-in ones.  Instead, we see that the value of .INCLUDE_DIRS
# seems to be passed along to recursive makes.
#
1 2 3 4 5 ::
	@$(MAKE) $(shell expr $@ - 1) \
	   --no-print-dir \
	   --include-dir=${PWD}/$(shell expr $@ - 1) \
	   -f $(lastword ${MAKEFILE_LIST})

