3

As the options make menuconfig and make nconfig allow a nice way to configure the kernel options, are there any way to get this hierachical structure for print it?

Something similar to the "tree" command ouput.

1
3

Thanks to the replay of @jeff-schaller I did a contribution to the project Kconfiglib and now there is a new example script for this task. These are the steps to use it:

Inside the directory with the linux source, clone the repo:

root@23e196045c6f:/usr/src/linux-source-4.9# git clone git://github.com/ulfalizer/Kconfiglib.git
Cloning into 'Kconfiglib'...
remote: Counting objects: 3367, done.
remote: Compressing objects: 100% (57/57), done.
remote: Total 3367 (delta 64), reused 89 (delta 50), pack-reused 3259
Receiving objects: 100% (3367/3367), 1.25 MiB | 1.79 MiB/s, done.
Resolving deltas: 100% (2184/2184), done.

Patch the makefile:

root@23e196045c6f:/usr/src/linux-source-4.9# patch -p1 < Kconfiglib/makefile.patch
patching file scripts/kconfig/Makefile

Configure as needed, basically for get a .config file:

root@23e196045c6f:/usr/src/linux-source-4.9# make menuconfig

Run the script with the config file:

root@23e196045c6f:/usr/src/linux-source-4.9# make scriptconfig SCRIPT=Kconfiglib/examples/print_config_tree.py SCRIPT_ARG=.config

======== Linux/x86 4.9.65 Kernel Configuration ========

[*] 64-bit kernel (64BIT)
    General setup
        ()  Cross-compiler tool prefix (CROSS_COMPILE)
        [ ] Compile also drivers which will not load (COMPILE_TEST)
        ()  Local version - append to kernel release (LOCALVERSION)
        [ ] Automatically append version information to the version string (LOCALVERSION_AUTO)
        -*- Kernel compression mode
                --> Gzip (KERNEL_GZIP)
                    Bzip2 (KERNEL_BZIP2)
                    LZMA (KERNEL_LZMA)
...

But the nice thing is that it is possible to pass differente kernel configurations and match the changes easily:

root@23e196045c6f:/usr/src/linux-source-4.9# make scriptconfig SCRIPT=Kconfiglib/examples/print_config_tree.py SCRIPT_ARG=/tmp/config1 > config1-list.txt

root@23e196045c6f:/usr/src/linux-source-4.9# make scriptconfig SCRIPT=Kconfiglib/examples/print_config_tree.py SCRIPT_ARG=/tmp/config2 > config2-list.txt

And finally now with a diff tool:

Kconfiglib with print_config_tree.py

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.