5

To build the linux kernel from source, I would normally do something like:

make mrproper
make menuconfig
make

In the menuconfig step, I enable some modules I want to have built into the kernel that aren't part of the default config file (defconfig).

Now suppose I know in advance what modules I want to enable in menuconfig, but want to automate the build process from a script (i.e. non-interactively). I don't want to edit the .config file manually before issuing make as I may not correctly resolve the dependencies of the modules I want to install.

Is there some way of replacing the menuconfig step with something like

make updateconfig module_name

?

PS I don't want to do menuconfig the first time and then save the updated .config as a new default config.

user12066
  • 613
  • 6
  • 23
  • Create once a config file and run `make olddefconfig` each time you want to update the kernel. And why you don't want to go this direction? – 0andriy Jun 13 '16 at 18:07
  • I ended up doing something like this. My process was: make mrproper; merge some default config files to create a new .config; make olddefconfig in order to specify any remaining options non-interactively; make – user12066 Jun 14 '16 at 07:24
  • Btw, you might put in your local branch something like `tiny.config` and adjust `scripts/kconfig/Makefile` to support it in the same way. In this case you will never have a conflicts if your "third-party" defconfig file has been changed. – 0andriy Jun 14 '16 at 16:17

4 Answers4

5

I was looking for the answer to Adding an entry to the Linux Kernel .config file

i.e. you can do:

make CONFIG_XILINX_FIXED_DEVTREE_ADDR=y

and the specified module option will be compiled in. Presumably this also takes care of the module dependencies; I've tried it on a module with some dependencies and it seems to work ok.

Community
  • 1
  • 1
user12066
  • 613
  • 6
  • 23
  • So, for module we need: `make CONFIG_XILINX_FIXED_DEVTREE_ADDR=m modules`? – osgx Jun 13 '16 at 11:59
  • This way is bad since you have to know ahead what dependencies are. OTOH it is one good for fast compilation test of module in question. – 0andriy Jun 13 '16 at 18:10
  • 1
    The main reason I needed it is because I am compiling a third-party linux distribution from source but I don't want to change the third-party defconfig file. I suppose a better way would be to create a version-controlled vendor branch and commit changes to that. – user12066 Jun 14 '16 at 07:22
  • And why is it the problem (I mean modifying defconfig)? Are they using Git or not? Btw, I'm using several branches based on let's say "third-party" Linux kernel, though it's just a plain upstream. I do update my local branch whenever I need to adjust my configuration. An example: https://github.com/andy-shev/linux/commits/eds – 0andriy Jun 14 '16 at 14:06
  • It's not a problem, I just haven't done it that way yet. Thanks for your comments. – user12066 Jun 14 '16 at 16:12
4

make menuconfig is one of five similar tools that can configure the Linux kernel source, a necessary early step needed to compile the source code. make menuconfig, with a menu-driven user interface, allows the user to choose the features of the Linux kernel (and other options) that will be compiled.

make menuconfig is tool which will load all attribute which define in Kconfig and create new .config. First you will have to add your attribute to Kconfig then it'll show in menuconfig.

 Example :
 I want to add new backlight driver in kernel.
 1. open Kconfig 'drivers/video/backlight/Kconfig' and add below line---

    config BACKLIGHT_LOCOMO
    tristate "Sharp LOCOMO LCD/Backlight Driver"
    depends on SHARP_LOCOMO
    default y
    help
      If you have a Sharp Zaurus SL-5500 (Collie) or SL-5600 (Poodle) say y to
      enable the LCD/backlight driver.

    2. Add CONFIG_BACKLIGHT_LOCOMO to make file.
        obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o

Now run make mrproper and make menuconfig. It'll show in menu.


Otherwise you can manually add to .config 'CONFIG_BACKLIGHT_LOCOMO=y'.

Arvind Yadav
  • 441
  • 2
  • 4
2

There is a config script in the tree that allows callers to enable and disable options in .config from the shell. It doesn't look like it does any dependency resolution, though, so perhaps it makes sense to run make olddefconfig after using it, as other comments mention.

Simon Ruggier
  • 411
  • 3
  • 5
2

There is also the merge_config.sh script in the tree that allows to merge an additional config-fragment file to your config. Have a look at this answer for details.

rtrrtr
  • 563
  • 5
  • 7