Re: Kbuilds and Makefiles in building the kernel
Nick Huang <[email protected]> Sat, 29 Nov 2025 12:09:51 +0800
| Newsgroups | org.kernel.vger.linux-newbie |
|---|---|
| Message-ID | <CABZAGRE7jbjUbE8kbGmAe_pY=YiXhKr1woFNgwba68DENUBXoA@mail.gmail.com> |
Nagy =C3=81brah=C3=A1m Zsombor <[email protected]> =E6=96=BC 2025=E5=B9= =B411=E6=9C=8828=E6=97=A5=E9=80=B1=E4=BA=94 =E4=B8=8B=E5=8D=884:18=E5=AF=AB= =E9=81=93=EF=BC=9A > > On Fri, 2025-11-28 at 08:12 +0800, Nick Huang wrote: > > Nagy =C3=81brah=C3=A1m Zsombor <[email protected]> =E6=96=BC 2025=E5= =B9=B411=E6=9C=8828=E6=97=A5 =E9=80=B1=E4=BA=94 =E4=B8=8A=E5=8D=881:37=E5= =AF=AB=E9=81=93=EF=BC=9A > > > > > > On Thu, 2025-11-27 at 19:26 +0800, Nick Huang wrote: > > > > Abraham Zsombor Nagy <[email protected]> =E6=96=BC 2025=E5=B9=B41= 1=E6=9C=8827=E6=97=A5=E9=80=B1=E5=9B=9B > > > > =E4=B8=8B=E5=8D=886:43=E5=AF=AB=E9=81=93=EF=BC=9A > > > > > > > > > > Hello, > > > > > > > > > > https://docs.kernel.org/kbuild/makefiles.html#the-kbuild-files > > > > > stat > > > > > es > > > > > that when a directory contains a Kbuild file, the Makefile is > > > > > skipped in > > > > > that directory. > > > > > > > > > > It feels to me that both files are in use e.g. under arch/x86/ > > > > > directory. > > > > > > > > > > I'm trying to see what files are the core of the kernel and > > > > > what > > > > > files > > > > > can be configured for x86 by partially parsing the Makefiles > > > > > and > > > > > the > > > > > Kbuild files. Would it be sufficient to parse them as: > > > > > > > > > > if file =3D=3D "Makefile" or file =3D=3D "Kbuild": > > > > > > > > > > > parse(file) > > > > > > > > > > or it should prefer the Kbuild file when present, or it is > > > > > using > > > > > some > > > > > other logic? > > > > > > > > > > Sincerely, > > > > > > > > > > Abraham Nagy > > > > > > > > > > > > > > > > > > Hi Abraham Zsombor Nagy > > > > What functionality are you trying to add that would require > > > > modifying > > > > the Makefile or Kbuild? > > > > > > > > Sincerely, > > > > Nick Huang > > > > > > Hi Nick, > > > > > > I'm not modifying the build files, only writing a script that walks > > > through the source tree and parses Makefiles and Kbuild files to > > > list > > > what source files are linked to the kernel by default and by > > > CONFIG_* > > > options. This is to see what to read through to get a basic > > > understanding of the kernel at a given config. > > > > > > As I understand the documentation linked above, I should skip > > > Makefiles > > > when Kbuild files are present in a directory, but Makefiles feels > > > to > > > have important lines too. > > > > > > The approach is something like to extract object files and > > > subdirectories from lines that start with python regex "^\S+-y" or > > > "^\S+-\$\(CONFIG.*\)". > > > > > > Sincerely, > > > Abraham > > > > > > > > > > Hi Abraham > > You can use git grep -n "CONFIG_**" to find the files you need. > > > > Sincerely, > > Nick > > Hello Nick, > > Thank you, I've just tried git grep, it seems convenient, however I > still need to further script and fine-tune the output, in which case I > think having a customizable walk algorithm is the way to start with. > > find/git & grep walks through the directory tree that could include > build files and sources that are from an incompatible set of config > options. Also, there are some Makefiles that end the line with a > backslash '\' saying to process the next line too, but which won't have > regex match. > > A custom algorithm can start from a Makefile (and Kbuild file?)_and > walk directories only that are visible from there. This way I can > enforce a horizon of config options that are meaningfully able to > extend the kernel. E.g. starting with minimal config, seeing the > available additional configs, then in subsequent calls adding configs > one by one until I have a whole kernel (but without extra parts). > > Make menuconfig combined with git grep and a text editor could help, > but it would require more manual handling to achieve the same. > > Sincerely, > Abraham Hi Abraham Are you trying to find out which configs can be enabled? If so, I suggest you check the description of each Kconfig to see if it=E2=80=99s wh= at you need, or if you have a clear idea of the functionality you want to implement. Is your main goal to build a Linux kernel? Sincerely, Nick