@@ -549,37 +549,38 @@ install-strip:
549
549
# allows parallel make across directories and lets make -k and -q work
550
550
# correctly.
551
551
552
+ # We need the $(eval) function and order-only prerequisites, which are
553
+ # available in GNU make 3.80. That also happens to be the version
554
+ # where the .VARIABLES variable was introduced, so this is a simple check.
555
+ ifndef .VARIABLES
556
+ $(error GNU make 3.80 or newer is required. You are using version $(MAKE_VERSION))
557
+ endif
558
+
552
559
# This function is only for internal use below. It should be called
553
- # with $(eval). It will set up a target so that it recurses into
554
- # subdirectories.
560
+ # using $(eval). It will set up a target so that it recurses into
561
+ # a given subdirectory. Note that to avoid a nasty bug in make 3.80,
562
+ # it is important that the expansion of this function not exceed about
563
+ # 200 bytes. This is why we make it apply to just one subdirectory at a
564
+ # time, rather than to a list of subdirectories.
555
565
# $1: target name, e.g., all
556
- # $2: list of subdirs
566
+ # $2: subdir name
557
567
# $3: target to run in subdir, usually same as $1
558
568
define _create_recursive_target
559
- .PHONY: $(patsubst % , $( 1 ) -% -recursive, $(2 ) )
560
- $(1 ) : $(patsubst % , $( 1 ) -% -recursive, $(2 ) )
561
- $(2:%= $( 1 ) -%-recursive ) :
562
- $$(MAKE ) -C $$( patsubst $( 1 ) - % -recursive, % , $$@ ) $(3 )
569
+ .PHONY: $(1 ) -$(2 ) -recurse
570
+ $(1 ) : $(1 ) -$(2 ) -recurse
571
+ $(1 ) -$( 2 ) -recurse :
572
+ $$(MAKE ) -C $( 2 ) $(3 )
563
573
endef
564
574
# Note that the use of $$ on the last line above is important; we want
565
- # those variables/functions to be evaluated when the rule is run, not
566
- # when the $(eval) is run to create the rule. In the case of
567
- # $$(MAKE), this is necessary to get make -q working.
575
+ # $(MAKE) to be evaluated when the rule is run, not when the $(eval) is run
576
+ # to create the rule. This is necessary to get make -q working.
568
577
569
- # Call this function in a makefile. In the normal case it doesn't
570
- # need any arguments.
578
+ # Call this function in a makefile that needs to recurse into subdirectories.
579
+ # In the normal case all arguments can be defaulted .
571
580
# $1: targets to make recursive (defaults to list of standard targets)
572
581
# $2: list of subdirs (defaults to SUBDIRS variable)
573
- # $3: target to run in subdir (defaults to $1)
574
- recurse = $(foreach target,$(if $1,$1,$(standard_targets ) ) ,$(eval $(call _create_recursive_target,$(target ) ,$(if $2,$2,$(SUBDIRS ) ) ,$(if $3,$3,$(target ) ) ) ) )
575
-
576
- # We need the $(eval) function and order-only prerequisites, which are
577
- # available in GNU make 3.80. That also happens to be the version
578
- # where the .VARIABLES variable was introduced, so this is a simple
579
- # check.
580
- ifndef .VARIABLES
581
- $(error GNU make 3.80 or newer is required. You are using version $(MAKE_VERSION))
582
- endif
582
+ # $3: target to run in subdir (defaults to current element of $1)
583
+ recurse = $(foreach target,$(if $1,$1,$(standard_targets ) ) ,$(foreach subdir,$(if $2,$2,$(SUBDIRS ) ) ,$(eval $(call _create_recursive_target,$(target ) ,$(subdir ) ,$(if $3,$3,$(target ) ) ) ) ) )
583
584
584
585
585
586
# #########################################################################
0 commit comments