<commit_before>#
# RECURSIVE-TARGETS.MK --Define devkit's recursive targets.
#
# Remarks:
# The recursive targets are invoked on all subdirectories that contain
# a Makefile matching the following patterns in order:
#
#  * Makefile-<OS> --OS-specific make rules (e.g. Makefile-linux)
#  * Makefile-<ARCH> --architecture-specific make rules
#  * Makefile --a "normal" make file.
#
# Note that if *any* of these files exist, the recursion will occur,
# using the first Makefile that matches.  So, it is possible to create
# sub-directories that are only processed for particular OS or ARCH,
# or that have customised behaviour for OS, ARCH.
#
# The recursive targets and their meaning are documented in the GNU
# make manual.
#
# For every recursive target, there are two special targets:
# * pre-*target* --actions to perform *before* recursing into sub-directories
# * post-*target* --actions to perform *after* recursing into sub-directories
#
# These targets can be used to control when particular actions are run.
#
# See Also:
# http://www.gnu.org/software/make/manual/make.html#Standard-Targets
#
std-targets = build install test uninstall install-strip \
	clean distclean tags dist doc coverage
devkit-targets = src toc lint tidy todo
recursive-targets = $(std-targets) $(devkit-targets)

+var[recursive_rule]:;@: # disable +var[recursive_rule]

#
# recursive_rule: --Define a set of targets that implement recursion.
#
# Parameters:
# $1 --the name of the recursive target
# $2 --flag: define the action for the recursive target.
#
define recursive_rule
.PHONY:	$1 pre-$1
ifeq "$2" "1"
$1:	$$(SUBDIRS:%=$1@%);	$$(ECHO_TARGET)
else
$1:	$$(SUBDIRS:%=$1@%)
endif
pre-$1:	;			$$(ECHO_TARGET)
$1 $(SUBDIRS:%=$1@%):	pre-$1
post-$1: | $(SUBDIRS:%=$1@%)
$1@%:
	@$$(ECHO_TARGET)
	@if [ -e $$*/Makefile-$(OS) ]; then \
            $$(ECHO) ++ make: recursively building $$@ for $(OS); \
            $$(MAKE) --directory $$* -f Makefile-$(OS) $1; \
        elif [ -e $$*/Makefile-$(ARCH) ]; then \
            $$(ECHO) ++ make: recursively building $$@ for $(ARCH); \
            $$(MAKE) --directory $$* -f Makefile-$(ARCH) $1; \
        elif [ -e $$*/Makefile ]; then \
            $$(ECHO) ++ make: recursively building $$@; \
            $$(MAKE) --directory $$* $1; \
        fi
endef

$(foreach target,$(recursive-targets),$(eval $(call recursive_rule,$(target),1)))<commit_msg>fail if recursive directory doesn't exist<commit_after>#
# RECURSIVE-TARGETS.MK --Define devkit's recursive targets.
#
# Remarks:
# The recursive targets are invoked on all subdirectories that contain
# a Makefile matching the following patterns in order:
#
#  * Makefile-<OS> --OS-specific make rules (e.g. Makefile-linux)
#  * Makefile-<ARCH> --architecture-specific make rules
#  * Makefile --a "normal" make file.
#
# Note that if *any* of these files exist, the recursion will occur,
# using the first Makefile that matches.  So, it is possible to create
# sub-directories that are only processed for particular OS or ARCH,
# or that have customised behaviour for OS, ARCH.
#
# The recursive targets and their meaning are documented in the GNU
# make manual.
#
# For every recursive target, there are two special targets:
# * pre-*target* --actions to perform *before* recursing into sub-directories
# * post-*target* --actions to perform *after* recursing into sub-directories
#
# These targets can be used to control when particular actions are run.
#
# See Also:
# http://www.gnu.org/software/make/manual/make.html#Standard-Targets
#
std-targets = build install test uninstall install-strip \
	clean distclean tags dist doc coverage
devkit-targets = src toc lint tidy todo
recursive-targets = $(std-targets) $(devkit-targets)

+var[recursive_rule]:;@: # disable +var[recursive_rule]

#
# recursive_rule: --Define a set of targets that implement recursion.
#
# Parameters:
# $1 --the name of the recursive target
# $2 --flag: define the action for the recursive target.
#
define recursive_rule
.PHONY:	$1 pre-$1
ifeq "$2" "1"
$1:	$$(SUBDIRS:%=$1@%);	$$(ECHO_TARGET)
else
$1:	$$(SUBDIRS:%=$1@%)
endif
pre-$1:	;			$$(ECHO_TARGET)
$1 $(SUBDIRS:%=$1@%):	pre-$1
post-$1: | $(SUBDIRS:%=$1@%)
$1@%:
	@$$(ECHO_TARGET)
	@if [ -e $$*/Makefile-$(OS) ]; then \
            $$(ECHO) ++ make: recursively building $$@ for $(OS); \
            $$(MAKE) --directory $$* -f Makefile-$(OS) $1; \
        elif [ -e $$*/Makefile-$(ARCH) ]; then \
            $$(ECHO) ++ make: recursively building $$@ for $(ARCH); \
            $$(MAKE) --directory $$* -f Makefile-$(ARCH) $1; \
        elif [ -e $$*/Makefile ]; then \
            $$(ECHO) ++ make: recursively building $$@; \
            $$(MAKE) --directory $$* $1; \
	else (cd $$*); fi
endef

$(foreach target,$(recursive-targets),$(eval $(call recursive_rule,$(target),1)))
{'fraction_non_alphanumeric': 0.16075896580483737, 'fraction_numerical': 0.008757297748123435, 'mean_word_length': 3.5772900763358777, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3679361', 'n_tokens_mistral': 1641, 'n_tokens_neox': 1554, 'n_words': 518}