>>>>> "Benjamin" == Benjamin Herrenschmidt <[email protected]> writes:
Benjamin> That would merge all entries in the specified file with the
Benjamin> current .config.
You don't need it to be a Makefile target, it can be an external
script. Would this one (untested!) do what you want?
Sam
--
Samuel Tardieu -- [email protected] -- http://www.rfc1149.net/
#! /usr/bin/python
#
# (c) 2006 Samuel Tardieu <[email protected]>
#
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
#
# Usage: mergeconfig config1 config2 ... > newconfig
#
# To get the formatting back, it is advised to run "make oldconfig" on the
# result.
#
# Be careful in not using the same file as input and output
import sre, sys
_not_set = sre.compile('# (CONFIG_\S+) is not set')
_set = sre.compile('(CONFIG_[^=]+)=(.*)')
def read_config(fn):
"""Read a kernel configuration file and return a dictionary with
all the options present in the file. If an option is commented out,
set its value as None."""
d = {}
for l in file(fn):
l = l.rstrip('\r\n')
x = _not_set.match(l)
if x: d[x.group(1)] = None
x = _set.match(l)
if x: d[x.group(1)] = x.group(2)
return d
def merge_option(o, v1, v2):
"""Merge option value v1 and v2."""
if 'y' in [v1, v2]: return 'y'
if 'm' in [v1, v2]: return 'm'
if v1 != v2:
sys.stderr.write('Option %s has two incompatible values: %s and %s' %
(o, v1, v2))
sys.exit(1)
return v1
def merge_config_into(a, b):
"""Merge configuration dictionary a into configuration dictionary b.
In addition, this function returns b after the merge."""
for k, v in a.items():
try:
b[v] = merge_option(k, v, b[v])
except KeyError:
b[k] = v
return b
def output_config(d):
for k, v in d.items():
if v is None: print '# %s is not set' % k
else: print '%s=%s' % (k, v)
if __name__ == '__main__':
output_config (reduce(lambda x, y: merge_config_into(x, read_config(y)),
sys.argv[1:], {}))
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]