[PATCH v2 1/2] selftests/powerpc: Convert pmu Makefile to for loop style

Madhavan Srinivasan maddy at linux.ibm.com
Thu May 2 18:21:56 AEST 2024


On 4/22/24 7:04 PM, Michael Ellerman wrote:
> The pmu Makefile has grown more sub directories over the years. Rather
> than open coding the rules for each subdir, use for loops.

Nice cleanup. Thanks.

Tested-by: Madhavan Srinivasan <maddy at linux.ibm.com>


> Signed-off-by: Michael Ellerman <mpe at ellerman.id.au>
> ---
>   tools/testing/selftests/powerpc/pmu/Makefile | 43 ++++++++++----------
>   1 file changed, 22 insertions(+), 21 deletions(-)
>
> v2: Actually send both patches.
>
> diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing/selftests/powerpc/pmu/Makefile
> index 1fcacae1b188..773933e5180e 100644
> --- a/tools/testing/selftests/powerpc/pmu/Makefile
> +++ b/tools/testing/selftests/powerpc/pmu/Makefile
> @@ -9,7 +9,9 @@ top_srcdir = ../../../../..
>   include ../../lib.mk
>   include ../flags.mk
>   
> -all: $(TEST_GEN_PROGS) ebb sampling_tests event_code_tests
> +SUB_DIRS := ebb sampling_tests event_code_tests
> +
> +all: $(TEST_GEN_PROGS) $(SUB_DIRS)
>   
>   $(TEST_GEN_PROGS): $(EXTRA_SOURCES)
>   
> @@ -23,12 +25,16 @@ $(OUTPUT)/count_stcx_fail: loop.S $(EXTRA_SOURCES)
>   
>   $(OUTPUT)/per_event_excludes: ../utils.c
>   
> +$(SUB_DIRS):
> +	BUILD_TARGET=$(OUTPUT)/$@; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $@ all
> +
>   DEFAULT_RUN_TESTS := $(RUN_TESTS)
>   override define RUN_TESTS
>   	$(DEFAULT_RUN_TESTS)
> -	+TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests
> -	+TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests
> -	+TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests
> +	+ at for TARGET in $(SUB_DIRS); do \
> +		BUILD_TARGET=$(OUTPUT)/$$TARGET; \
> +		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests; \
> +	done;
>   endef
>   
>   emit_tests:
> @@ -36,34 +42,29 @@ emit_tests:
>   		BASENAME_TEST=`basename $$TEST`;	\
>   		echo "$(COLLECTION):$$BASENAME_TEST";	\
>   	done
> -	+TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests
> -	+TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests
> -	+TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests
> +	+ at for TARGET in $(SUB_DIRS); do \
> +		BUILD_TARGET=$(OUTPUT)/$$TARGET; \
> +		$(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests; \
> +	done;
>   
>   DEFAULT_INSTALL_RULE := $(INSTALL_RULE)
>   override define INSTALL_RULE
>   	$(DEFAULT_INSTALL_RULE)
> -	+TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install
> -	+TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install
> -	+TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install
> +	+ at for TARGET in $(SUB_DIRS); do \
> +		BUILD_TARGET=$(OUTPUT)/$$TARGET; \
> +		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install; \
> +	done;
>   endef
>   
>   DEFAULT_CLEAN := $(CLEAN)
>   override define CLEAN
>   	$(DEFAULT_CLEAN)
>   	$(RM) $(TEST_GEN_PROGS) $(OUTPUT)/loop.o
> -	+TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean
> -	+TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean
> -	+TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean
> +	+ at for TARGET in $(SUB_DIRS); do \
> +		BUILD_TARGET=$(OUTPUT)/$$TARGET; \
> +		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean; \
> +	done;
>   endef
>   
> -ebb:
> -	TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all
> -
> -sampling_tests:
> -	TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all
> -
> -event_code_tests:
> -	TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all
>   
>   .PHONY: all run_tests ebb sampling_tests event_code_tests emit_tests


More information about the Linuxppc-dev mailing list