diff mbox series

ARM: simplify the build rule of mach-types.h

Message ID 20210528034913.2157657-1-masahiroy@kernel.org (mailing list archive)
State New, archived
Headers show
Series ARM: simplify the build rule of mach-types.h | expand

Commit Message

Masahiro Yamada May 28, 2021, 3:49 a.m. UTC
The directory of mach-types.h is created a couple of lines above:

  _dummy := $(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)') \

The 'mkdir -p' command is redundant.

scripts/Kbuild.include defines real-prereqs as a shorthand for
$(filter-out $(PHONY),$^). Let's use it to simplify the code.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 arch/arm/tools/Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

David Laight May 31, 2021, 8:59 a.m. UTC | #1
From: Masahiro Yamada
> Sent: 28 May 2021 04:49
> 
> The directory of mach-types.h is created a couple of lines above:
> 
>   _dummy := $(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)') \
> 
> The 'mkdir -p' command is redundant.
(In the rule itself)
...
>  quiet_cmd_gen_mach = GEN     $@
> -      cmd_gen_mach = mkdir -p $(dir $@) && \
> -		     $(AWK) -f $(filter-out $(PHONY),$^) > $@
> +      cmd_gen_mach = $(AWK) -f $(real-prereqs) > $@

There is a much easier way to get directories created.
gmake lets you define dependencies that only need to exist
(ie there file timestamps are't checked)
These are ideal for creating directories.

So if can define:

%/.:
	mkdir -p $@

You can just use

$(OBJ)/$(FILE): | ${OBJ)/.

to get any directories created.

Annoyingly gmake doesn't seem to support the 'dynamic dependencies'
of SYSV make (it's only useful feature).
So you can't use:
xxxxx: | $$@D/.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
diff mbox series

Patch

diff --git a/arch/arm/tools/Makefile b/arch/arm/tools/Makefile
index 87de1f63f649..057639019059 100644
--- a/arch/arm/tools/Makefile
+++ b/arch/arm/tools/Makefile
@@ -33,8 +33,7 @@  _dummy := $(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)') \
           $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)')
 
 quiet_cmd_gen_mach = GEN     $@
-      cmd_gen_mach = mkdir -p $(dir $@) && \
-		     $(AWK) -f $(filter-out $(PHONY),$^) > $@
+      cmd_gen_mach = $(AWK) -f $(real-prereqs) > $@
 
 $(kapi)/mach-types.h: $(src)/gen-mach-types $(src)/mach-types FORCE
 	$(call if_changed,gen_mach)