# make localmodconfig failing to function properly?

## graysky

The announcement of several new make scripts in the 2.6.32 release notes is very exciting.

 *Quote:*   

> 1.8. Easy local kernel configuration
> 
> Most people uses the kernel shipped by distros - and that's good. But some people like to compile their own kernels from kernel.org, or maybe they like following the Linux development and want to try it. Configuring your own kernel, however, has become a very difficult and tedious task - there're too many options, and some times userspace software will stop working if you don't enable some key option. You can use a standard distro .config file, but it takes too many time to compile all the options it enables.
> 
> To make easier the process of configuration, a new build target has been added: make localmodconfig. It runs "lsmod" to find all the modules loaded on the current running system. It will read all the Makefiles to map which CONFIG enables a module. It will read the Kconfig files to find the dependencies and selects that may be needed to support a CONFIG. Finally, it reads the .config file and removes any module "=m" that is not needed to enable the currently loaded modules. With this tool, you can strip a distro .config of all the unuseful drivers that are not needed in our machine, and it will take much less time to build the kernel. There's an additional "make localyesconfig" target, in case you don't want to use modules and/or initrds.

 

localmodconfig  - Update current config disabling modules not loaded

localyesconfig  - Update current config converting local mods to core

So if I run them in that order, first the 'make localmodconfig' should only enable modules that I have currently loaded then the 'make localyesconfig' should switch them from modules to compiled into the kernel when I build it -- this is isn't the case for me.  

```
$ extract linux-2.6.35.tar.bz2 && cd linux-2.6.35

$ make mrproper

$ zcat /proc/config.gz > .config

$ make localmodconfig

$ make menuconfig
```

After running the the "make localmodconfig" script, have TONS of options that don't apply to my system flagged as modules when I inspect it via a "make menuconfig."  For example:

```
Device Drivers>Graphics support>Direct Rendering Manager

<M> ATI Radeon

[*] Enable modesetting on radeon by default

<M> Intel 830M, 845G, 852M, 855GM, 865G

<M> i915 driver
```

My system does not have ATI anything on board, nor does it have that those Intel chips.  

Here is another representation that there are many extra module options:

My distro's kernel config I'm using as a starting point:

```
$ cat .config | grep =m | wc -l

2434
```

The kernel config after I run the make localmodconfig:

```
cat .config-make | grep =m | wc -l

341
```

According to /proc/modules I only have 76 modules currently loaded:

```
$ cat /proc/modules | wc -l

76
```

What am I doing wrong?

----------

## idella4

graysky

Frankly it looks as if you've done nothing wrong.  Just maybe

```

zcat /proc/config.gz > .config 

```

didn't quite go as expected.  Just compare with the long way.

```

cp /proc/config.gz .

gzip -dv config.gz

cp config /usr/src/linux/.config

```

just maybe.

----------

## graysky

No such luck  :Sad:   Same effect.  I gotta think there's something wrong with the script or with my expectations.

----------

## idella4

I'd say the script.

Try it on a previous kernel.

----------

## graysky

I did - several including 2.6.32, 2.6.34, and 2.6.35 all w/ the same result.

----------

## krinn

 *graysky wrote:*   

> It will read the Kconfig files to find the dependencies and selects that may be needed to support a CONFIG.

 

just that 76 modules need more than 76 options in a kernel to be selected.

as an easy sample i would say if your lsmod show snd_hda_intel, the script need also alsa as module in order to select snd_hda_intel (even the module itself won't be build, the option will be taken as module and count as one)

And it can goes really fast at growing numbers: i see snd_hda_intel need snd_page_alloc and snd_page_alloc might need something other too that also need something to be check first before getting picked up...

So 341 seems ok, average 4 options need to pickup one module, that might seems big, not really when you see how many options must be taken just to enable a sound card.

cat /proc/modules | grep snd | wc -l

----------

## graysky

I see your point - perhaps wc is a poor measure.  What I can tell you is that I see absolutely no need for the ATI stuff to be present for my box.  When I go on to run a "make localyesconfig" to convert those modules to hard-code, I can't build the nvidia kernel mod for the new kernel because it contains that ATI crap.

----------

## graysky

Solved.  Tomk in this thread reported that for some reason, calling the streamline_config.pl script from the Makefile fails to give the advertised behavior.  Running it yourself however, does!

```
# chmod +x ./scripts/kconfig/streamline_config.pl && ./scripts/kconfig/streamline_config.pl > config_strip

# mv config_strip .config

# make oldconfig
```

----------

