#!/usr/bin/env perl # # Copyright 2005-2009 - Steven Rostedt # Licensed under the terms of the GNU GPL License version 2 # # It's simple enough to figure out how this works. # If not, then you can ask me at stripconfig@goodmis.org # # What it does? # # If you have installed a Linux kernel from a distribution # that turns on way too many modules than you need, and # you only want the modules you use, then this program # is perfect for you. # # It gives you the ability to turn off all the modules that are # not loaded on your system. # # Howto: # # 1. Boot up the kernel that you want to stream line the config on. # 2. Change directory to the directory holding the source of the # kernel that you just booted. # 3. Copy the configuraton file to this directory as .config # 4. Have all your devices that you need modules for connected and # operational (make sure that their corresponding modules are loaded) # 5. Run this script redirecting the output to some other file # like config_strip. # 6. Back up your old config (if you want too). # 7. copy the config_strip file to .config # 8. Run "make oldconfig" # # Now your kernel is ready to be built with only the modules that # are loaded. # # Here's what I did with my Debian distribution. # # cd /usr/src/linux-2.6.10 # cp /boot/config-2.6.10-1-686-smp .config # ~/bin/streamline_config > config_strip # mv .config config_sav # mv config_strip .config # make oldconfig # use warnings; use strict; use Getopt::Long; # set the environment variable LOCALMODCONFIG_DEBUG to get # debug output. my $debugprint = 0; $debugprint = 1 if (defined($ENV{LOCALMODCONFIG_DEBUG})); sub dprint { return if (!$debugprint); print STDERR @_; } my $config = ".config"; my $uname = `uname -r`; chomp $uname; my @searchconfigs = ( { "file" => ".config", "exec" => "cat", }, { "file" => "/proc/config.gz", "exec" => "zcat", }, { "file" => "/boot/config-$uname", "exec" => "cat", }, { "file" => "/boot/vmlinuz-$uname", "exec" => "scripts/extract-ikconfig", "test" => "scripts/extract-ikconfig", }, { "file" => "vmlinux", "exec" => "scripts/extract-ikconfig", "test" => "scripts/extract-ikconfig", }, { "file" => "/lib/modules/$uname/kernel/kernel/configs.ko", "exec" => "scripts/extract-ikconfig", "test" => "scripts/extract-ikconfig", }, { "file" => "kernel/configs.ko", "exec" => "scripts/extract-ikconfig", "test" => "scripts/extract-ikconfig", }, { "file" => "kernel/configs.o", "exec" => "scripts/extract-ikconfig", "test" => "scripts/extract-ikconfig", }, ); sub read_config { foreach my $conf (@searchconfigs) { my $file = $conf->{"file"}; next if ( ! -f "$file"); if (defined($conf->{"test"})) { `$conf->{"test"} $conf->{"file"} 2>/dev/null`; next if ($?); } my $exec = $conf->{"exec"}; print STDERR "using config: '$file'\n"; open(my $infile, '-|', "$exec $file") || die "Failed to run $exec $file"; my @x = <$infile>; close $infile; return @x; } die "No config file found"; } my @config_file = read_config; # Parse options my $localmodconfig = 0; my $localyesconfig = 0; GetOptions("localmodconfig" => \$localmodconfig, "localyesconfig" => \$localyesconfig); # Get the build source and top level Kconfig file (passed in) my $ksource = ($ARGV[0] ? $ARGV[0] : '.'); my $kconfig = $ARGV[1]; my $lsmod_file = $ENV{'LSMOD'}; my @makefiles = `find $ksource -name Makefile -or -name Kbuild 2>/dev/null`; chomp @makefiles; my %depends; my %selects; my %prompts; my %objects; my $var; my $iflevel = 0; my @ifdeps; # prevent recursion my %read_kconfigs; sub read_kconfig { my ($kconfig) = @_; my $state = "NONE"; my $config; my $cont = 0; my $line; my $source = "$ksource/$kconfig"; my $last_source = ""; # Check for any environment variables used while ($source =~ /\$\((\w+)\)/ && $last_source ne $source) { my $env = $1; $last_source = $source; $source =~ s/\$\($env\)/$ENV{$env}/; } open(my $kinfile, '<', $source) || die "Can't open $kconfig"; while (<$kinfile>) { chomp; # Make sure that lines ending with \ continue if ($cont) { $_ = $line . " " . $_; } if (s/\\$//) { $cont = 1; $line = $_; next; } $cont = 0; # collect any Kconfig sources if (/^source\s+"?([^"]+)/) { my $kconfig = $1; # prevent reading twice. if (!defined($read_kconfigs{$kconfig})) { $read_kconfigs{$kconfig} = 1; read_kconfig($kconfig); } next; } # configs found if (/^\s*(menu)?config\s+(\S+)\s*$/) { $state = "NEW"; $config = $2; # Add depends for 'if' nesting for (my $i = 0; $i < $iflevel; $i++) { if ($i) { $depends{$config} .= " " . $ifdeps[$i]; } else { $depends{$config} = $ifdeps[$i]; } $state = "DEP"; } # collect the depends for the config } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) { $state = "DEP"; $depends{$config} = $1; } elsif ($state eq "DEP" && /^\s*depends\s+on\s+(.*)$/) { $depends{$config} .= " " . $1; } elsif ($state eq "DEP" && /^\s*def(_(bool|tristate)|ault)\s+(\S.*)$/) { my $dep = $3; if ($dep !~ /^\s*(y|m|n)\s*$/) { $dep =~ s/.*\sif\s+//; $depends{$config} .= " " . $dep; dprint "Added default depends $dep to $config\n"; } # Get the configs that select this config } elsif ($state ne "NONE" && /^\s*select\s+(\S+)/) { my $conf = $1; if (defined($selects{$conf})) {
/*
 *  Matchbox Window Manager II - A lightweight window manager not for the
 *                               desktop.
 *
 *  Authored By Matthew Allum <mallum@o-hand.com>
 *
 *  Copyright (c) 2005 OpenedHand Ltd - http://o-hand.com
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 */

#include "mb-wm-config.h"
#include "mb-wm-debug.h"

#include <stdlib.h>

#if MBWM_WANT_DEBUG
int mbwm_debug_flags = 0;

static const struct { const char *key; MBWMDebugFlag flag; } debug_keys[]