From: Masahiro Yamada <masahiroy@kernel.org>
To: Randy Dunlap <rdunlap@infradead.org>
Cc: Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Michal Marek <michal.lkml@markovi.net>,
"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 7/7] kbuild: doc: document subdir-y syntax
Date: Sat, 28 Nov 2020 17:58:44 +0900 [thread overview]
Message-ID: <CAK7LNASZKsfyj9K_QxLoHZkSpfHvUHwgm5pwq=DJUnMCdczjPw@mail.gmail.com> (raw)
In-Reply-To: <5c40293a-a24a-2c85-e7ef-a08a8c732d19@infradead.org>
On Tue, Nov 24, 2020 at 3:03 AM Randy Dunlap <rdunlap@infradead.org> wrote:
>
> On 11/22/20 8:54 PM, Masahiro Yamada wrote:
> > There is no explanation about subdir-y.
> >
> > Let's document it.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> > Documentation/kbuild/makefiles.rst | 14 ++++++++++++++
> > 1 file changed, 14 insertions(+)
> >
> > diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst
> > index 159e470f2616..6332b9ca7942 100644
> > --- a/Documentation/kbuild/makefiles.rst
> > +++ b/Documentation/kbuild/makefiles.rst
> > @@ -319,6 +319,20 @@ more details, with real examples.
> > that directory specifies obj-y, those objects will be left orphan.
> > It is very likely a bug of the Makefile or of dependencies in Kconfig.
> >
> > + Kbuild also supports dedicated syntax, subdir-y and subdir-m, for
> > + descending into subdirectories. It is a good fit when you know they
> > + do not contain kernel-space objects at all. A typical usage is to let
> > + Kbuild descend into subdirectories to build tools.
> > +
> > + Examples::
> > +
> > + subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins
> > + subdir-$(CONFIG_MODVERSIONS) += genksyms
> > + subdir-$(CONFIG_SECURITY_SELINUX) += selinux
> > +
> > + Unlike obj-y/m, subdir-y/m does not need the trailing slash since this
> > + syntax is always used for directories.
> > +
>
> Just curious: Is a trailing slash allowed here? say for consistency?
If you use a trailing slash for the subdir-y syntax,
it will still work.
Only the problem I see is that the build log will look clumsy
due to the double slashes "//".
For example, if you change scripts/Makefile as follows:
diff --git a/scripts/Makefile b/scripts/Makefile
index b5418ec587fb..554534449877 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -32,9 +32,9 @@ hostprogs += unifdef
# The module linker script is preprocessed on demand
targets += module.lds
-subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins
-subdir-$(CONFIG_MODVERSIONS) += genksyms
-subdir-$(CONFIG_SECURITY_SELINUX) += selinux
+subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins/
+subdir-$(CONFIG_MODVERSIONS) += genksyms/
+subdir-$(CONFIG_SECURITY_SELINUX) += selinux/
# Let clean descend into subdirs
subdir- += basic dtc gdb kconfig mod
The build log will look like follows:
masahiro@grover:~/workspace/linux$ make allmodconfig; make scripts
#
# configuration written to .config
#
SYNC include/config/auto.conf
HOSTCC scripts/dtc/dtc.o
HOSTCC scripts/dtc/flattree.o
HOSTCC scripts/dtc/fstree.o
HOSTCC scripts/dtc/data.o
HOSTCC scripts/dtc/livetree.o
HOSTCC scripts/dtc/treesource.o
HOSTCC scripts/dtc/srcpos.o
HOSTCC scripts/dtc/checks.o
HOSTCC scripts/dtc/util.o
LEX scripts/dtc/dtc-lexer.lex.c
YACC scripts/dtc/dtc-parser.tab.[ch]
HOSTCC scripts/dtc/dtc-lexer.lex.o
HOSTCC scripts/dtc/dtc-parser.tab.o
HOSTLD scripts/dtc/dtc
HOSTCXX scripts/gcc-plugins//latent_entropy_plugin.so
GENSEED scripts/gcc-plugins//randomize_layout_seed.h
HOSTCXX scripts/gcc-plugins//randomize_layout_plugin.so
HOSTCXX scripts/gcc-plugins//stackleak_plugin.so
HOSTCC scripts/genksyms//genksyms.o
YACC scripts/genksyms//parse.tab.[ch]
HOSTCC scripts/genksyms//parse.tab.o
LEX scripts/genksyms//lex.lex.c
HOSTCC scripts/genksyms//lex.lex.o
HOSTLD scripts/genksyms//genksyms
HOSTCC scripts/selinux//genheaders/genheaders
HOSTCC scripts/selinux//mdp/mdp
HOSTCC scripts/kallsyms
HOSTCC scripts/sorttable
HOSTCC scripts/asn1_compiler
HOSTCC scripts/extract-cert
HOSTCC scripts/bin2c
HOSTCC scripts/recordmcount
HOSTCC scripts/sign-file
HOSTCC scripts/insert-sys-cert
I can fix Kbuild to avoid "//", but I do not want to support two ways.
So, I'd recommend not to add the trailing slash to subdir-y.
For the others, thank you for pointing out my typos.
>
> > It is good practice to use a `CONFIG_` variable when assigning directory
> > names. This allows kbuild to totally skip the directory if the
> > corresponding `CONFIG_` option is neither 'y' nor 'm'.
> >
>
> Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
>
> thanks.
>
> --
> ~Randy
--
Best Regards
Masahiro Yamada
next prev parent reply other threads:[~2020-11-28 18:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-23 4:53 [PATCH 1/7] kbuild: doc: update the description about kbuild Makefiles Masahiro Yamada
2020-11-23 4:53 ` [PATCH 2/7] kbuild: doc: replace arch/$(ARCH)/ with arch/$(SRCARCH)/ Masahiro Yamada
2020-11-23 17:39 ` Randy Dunlap
2020-11-23 4:53 ` [PATCH 3/7] kbuild: doc: fix 'List directories to visit when descending' section Masahiro Yamada
2020-11-23 4:57 ` Masahiro Yamada
2020-11-23 4:54 ` [PATCH 4/7] kbuild: doc: merge 'Special Rules' and 'Custom kbuild commands' sections Masahiro Yamada
2020-11-23 4:54 ` [PATCH 5/7] kbuild: doc: split if_changed explanation to a separate section Masahiro Yamada
2020-11-23 17:51 ` Randy Dunlap
2020-11-23 4:54 ` [PATCH 6/7] kbuild: doc: clarify the difference between extra-y and always-y Masahiro Yamada
2020-11-23 18:00 ` Randy Dunlap
2020-11-23 4:54 ` [PATCH 7/7] kbuild: doc: document subdir-y syntax Masahiro Yamada
2020-11-23 18:03 ` Randy Dunlap
2020-11-28 8:58 ` Masahiro Yamada [this message]
2020-11-28 16:56 ` Randy Dunlap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAK7LNASZKsfyj9K_QxLoHZkSpfHvUHwgm5pwq=DJUnMCdczjPw@mail.gmail.com' \
--to=masahiroy@kernel.org \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.lkml@markovi.net \
--cc=rdunlap@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.