summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2004-08-28 13:36:16 +0000
committerdes <des@FreeBSD.org>2004-08-28 13:36:16 +0000
commit044539800adf94b9334ee9189188caa2d2e28afa (patch)
tree6bb2534f2c73163ef328dadd60f70fa5edd2e4c1 /tools
parent3f14b0370ba09e638ca854434053ec3f3510603d (diff)
downloadFreeBSD-src-044539800adf94b9334ee9189188caa2d2e28afa.zip
FreeBSD-src-044539800adf94b9334ee9189188caa2d2e28afa.tar.gz
Add genericize, a Perl script that converts a kernel config into something
more easily diffable against GENERIC.
Diffstat (limited to 'tools')
-rw-r--r--tools/tools/README2
-rw-r--r--tools/tools/genericize/Makefile5
-rwxr-xr-xtools/tools/genericize/genericize.pl108
3 files changed, 115 insertions, 0 deletions
diff --git a/tools/tools/README b/tools/tools/README
index 4f3206f..fb28a80 100644
--- a/tools/tools/README
+++ b/tools/tools/README
@@ -23,6 +23,8 @@ gdb_regofs A simple tool that prints out a register offset table
for mapping gdb(1) register numbers to struct reg and
struct fpreg offsets. The tool is useful on selected
platforms only.
+genericize Turn a kernel config into something that can more easily
+ be diffed against the appropriate GENERIC.
hcomp Compress header files by removing comments and whitespace.
html-mv Rename HTML generated filenames to human readable filenames.
ifinfo Uses the interface MIB to print out all the information
diff --git a/tools/tools/genericize/Makefile b/tools/tools/genericize/Makefile
new file mode 100644
index 0000000..54b3fdb
--- /dev/null
+++ b/tools/tools/genericize/Makefile
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+SCRIPTS= genericize.pl
+
+.include <bsd.prog.mk>
diff --git a/tools/tools/genericize/genericize.pl b/tools/tools/genericize/genericize.pl
new file mode 100755
index 0000000..3cef7b1
--- /dev/null
+++ b/tools/tools/genericize/genericize.pl
@@ -0,0 +1,108 @@
+#!/usr/bin/perl -w
+#-
+# Copyright (c) 2004 Dag-Erling Coïdan Smørgrav
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer
+# in this position and unchanged.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+use strict;
+
+MAIN:{
+ my %config;
+ my $machine;
+ my $ident;
+
+ while (<>) {
+ chomp();
+ s/\s*(\#.*)?$//;
+ next unless $_;
+ #print("$_\n");
+ my ($keyword, $values) = split(' ', $_, 2);
+ foreach my $value (split(/,\s*/, $values)) {
+ if ($keyword eq 'machine') {
+ $machine = $value;
+ } elsif ($keyword eq 'ident') {
+ $ident = $value;
+ } else {
+ $config{$keyword}->{$value} = 1;
+ }
+ #print "$keyword $value\n";
+ }
+ }
+
+ my $generic = "/usr/src/sys/$machine/conf/GENERIC";
+ local *GENERIC;
+ open(GENERIC, "<", $generic)
+ or die("$generic: $!\n");
+ my $blank = 0;
+ while (<GENERIC>) {
+ my $line = $_;
+ chomp();
+ ++$blank unless $_;
+ s/\s*(\#.*)?$//;
+ next unless $_;
+ my ($keyword, $value) = split(' ', $_);
+ if ($keyword eq 'machine') {
+ die("$generic is for $value, not $machine\n")
+ unless ($value eq $machine);
+ if ($blank) {
+ print "\n";
+ $blank = 0;
+ }
+ } elsif ($keyword eq 'ident') {
+ $line =~ s/$value/$ident/;
+ } elsif ($config{$keyword}->{$value}) {
+ delete($config{$keyword}->{$value});
+ delete($config{$keyword})
+ unless %{$config{$keyword}};
+ } else {
+ next;
+ }
+ if ($blank) {
+ print "\n";
+ $blank = 0;
+ }
+ print $line;
+ }
+ close(GENERIC);
+
+ if (%config) {
+ print "\n# Addenda\n";
+ foreach my $keyword (sort(keys(%config))) {
+ foreach my $value (sort(keys(%{$config{$keyword}}))) {
+ print "$keyword";
+ if (length($keyword) < 7) {
+ print "\t";
+ } elsif (length($keyword) == 7) {
+ print " ";
+ }
+ print "\t$value\n";
+ }
+ }
+ }
+ exit(0);
+}
OpenPOWER on IntegriCloud