diff mbox

kbuild: collect shorthands into the top Makefile

Message ID 1414567651-2503-1-git-send-email-yamada.m@jp.panasonic.com (mailing list archive)
State New, archived
Headers show

Commit Message

Masahiro Yamada Oct. 29, 2014, 7:27 a.m. UTC
The motivation of this commit is to avoid duplicated definitions
of "clean" and "hdr-inst" shorthands.

The shorthand "clean" is defined in both the top Makefile and
scripts/Makefile.clean.

Likewise, "hdr-inst" is defined in both the top Makefile and
scripts/Makefile.headersinst.

The idea here is define and export them in the top Makefile
because $(srctree) is constant during the build process.

For consistency, "build" and "modbuiltin" should be also moved.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---

 Makefile                     | 13 ++++++-------
 scripts/Kbuild.include       | 12 ------------
 scripts/Makefile.clean       |  5 -----
 scripts/Makefile.headersinst |  1 -
 4 files changed, 6 insertions(+), 25 deletions(-)

Comments

Sam Ravnborg Oct. 29, 2014, 6:59 p.m. UTC | #1
On Wed, Oct 29, 2014 at 04:27:31PM +0900, Masahiro Yamada wrote:
> The motivation of this commit is to avoid duplicated definitions
> of "clean" and "hdr-inst" shorthands.
> 
> The shorthand "clean" is defined in both the top Makefile and
> scripts/Makefile.clean.
> 
> Likewise, "hdr-inst" is defined in both the top Makefile and
> scripts/Makefile.headersinst.
> 
> The idea here is define and export them in the top Makefile
> because $(srctree) is constant during the build process.
> 
> For consistency, "build" and "modbuiltin" should be also moved.

As a general rule the exported names are always UPPERCASE, and local variables
are lowercase. (srctree, objtree are the exceptions).
This patch define new lowercase variables that conflicts with this.

And it is not that logical these are picked up from the enviroment.
Could you find a central place to define them rahter than using
the environemnt to export them?

	Sam
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Masahiro Yamada Oct. 31, 2014, 2:12 a.m. UTC | #2
Hi Sam,

On Wed, 29 Oct 2014 19:59:07 +0100
Sam Ravnborg <sam@ravnborg.org> wrote:

> On Wed, Oct 29, 2014 at 04:27:31PM +0900, Masahiro Yamada wrote:
> > The motivation of this commit is to avoid duplicated definitions
> > of "clean" and "hdr-inst" shorthands.
> > 
> > The shorthand "clean" is defined in both the top Makefile and
> > scripts/Makefile.clean.
> > 
> > Likewise, "hdr-inst" is defined in both the top Makefile and
> > scripts/Makefile.headersinst.
> > 
> > The idea here is define and export them in the top Makefile
> > because $(srctree) is constant during the build process.
> > 
> > For consistency, "build" and "modbuiltin" should be also moved.
> 
> As a general rule the exported names are always UPPERCASE, and local variables
> are lowercase. (srctree, objtree are the exceptions).
> This patch define new lowercase variables that conflicts with this.
> 
> And it is not that logical these are picked up from the enviroment.
> Could you find a central place to define them rahter than using
> the environemnt to export them?

Maybe we can collect them into scripts/Kbuild.include
although it might be too much for Makefile.clean to include
the whole things in Kbuild.include.


Best Regards
Masahiro Yamada

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Michal Marek Nov. 25, 2014, 9:23 p.m. UTC | #3
Dne 31.10.2014 v 03:12 Masahiro Yamada napsal(a):
> Hi Sam,
> 
> On Wed, 29 Oct 2014 19:59:07 +0100
> Sam Ravnborg <sam@ravnborg.org> wrote:
> 
>> On Wed, Oct 29, 2014 at 04:27:31PM +0900, Masahiro Yamada wrote:
>>> The motivation of this commit is to avoid duplicated definitions
>>> of "clean" and "hdr-inst" shorthands.
>>>
>>> The shorthand "clean" is defined in both the top Makefile and
>>> scripts/Makefile.clean.
>>>
>>> Likewise, "hdr-inst" is defined in both the top Makefile and
>>> scripts/Makefile.headersinst.
>>>
>>> The idea here is define and export them in the top Makefile
>>> because $(srctree) is constant during the build process.
>>>
>>> For consistency, "build" and "modbuiltin" should be also moved.
>>
>> As a general rule the exported names are always UPPERCASE, and local variables
>> are lowercase. (srctree, objtree are the exceptions).
>> This patch define new lowercase variables that conflicts with this.
>>
>> And it is not that logical these are picked up from the enviroment.
>> Could you find a central place to define them rahter than using
>> the environemnt to export them?
> 
> Maybe we can collect them into scripts/Kbuild.include
> although it might be too much for Makefile.clean to include
> the whole things in Kbuild.include.

Kbuild.include sounds like a good idea to me. It would also allow to
de-duplicate the $(cmd) defition in Makefile.include.

BTW:
$ time -p make $(perl -e 'print "-f scripts/Kbuild.include "x1500')
make: *** No targets.  Stop.
real 0.44
user 0.18
sys 0.08

So 0.44s in total for the 1500 or so subdirectories we visit during make
clean. But the subprocesses can run in parallel, so the real difference
is negligible.

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 52c1297..cb29318 100644
--- a/Makefile
+++ b/Makefile
@@ -440,6 +440,12 @@  export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o    \
 export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
 			 --exclude CVS --exclude .pc --exclude .hg --exclude .git
 
+# Shorthands
+export build := -f $(srctree)/scripts/Makefile.build obj
+export modbuiltin := -f $(srctree)/scripts/Makefile.modbuiltin obj
+export clean := -f $(srctree)/scripts/Makefile.clean obj
+export hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
+
 # ===========================================================================
 # Rules shared between *config targets and build targets
 
@@ -1035,8 +1041,6 @@  firmware_install: FORCE
 #Default location for installed headers
 export INSTALL_HDR_PATH = $(objtree)/usr
 
-hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
-
 # If we do an all arch process set dst to asm-$(hdr-arch)
 hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
 
@@ -1580,11 +1584,6 @@  ifneq ($(cmd_files),)
   include $(cmd_files)
 endif
 
-# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
-# Usage:
-# $(Q)$(MAKE) $(clean)=dir
-clean := -f $(srctree)/scripts/Makefile.clean obj
-
 endif	# skip-makefile
 
 PHONY += FORCE
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 65e7b08..98f081b 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -167,18 +167,6 @@  ld-ifversion = $(shell [ $(call ld-version) $(1) $(2) ] && echo $(3))
 
 ######
 
-###
-# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
-# Usage:
-# $(Q)$(MAKE) $(build)=dir
-build := -f $(srctree)/scripts/Makefile.build obj
-
-###
-# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj=
-# Usage:
-# $(Q)$(MAKE) $(modbuiltin)=dir
-modbuiltin := -f $(srctree)/scripts/Makefile.modbuiltin obj
-
 # Prefix -I with $(srctree) if it is not an absolute path.
 # skip if -I has no parameter
 addtree = $(if $(patsubst -I%,%,$(1)), \
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index b1c668d..2acaabd 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -7,11 +7,6 @@  src := $(obj)
 PHONY := __clean
 __clean:
 
-# Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir
-# Usage:
-# $(Q)$(MAKE) $(clean)=dir
-clean := -f $(srctree)/scripts/Makefile.clean obj
-
 # The filename Kbuild has precedence over Makefile
 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
 include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index 8ccf830..1106d6c 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -122,7 +122,6 @@  $(check-file): scripts/headers_check.pl $(output-files) FORCE
 endif
 
 # Recursion
-hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
 .PHONY: $(subdirs)
 $(subdirs):
 	$(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@