From d7a748edb80dbcd83cc1b4f0d9884738571426fe Mon Sep 17 00:00:00 2001 From: Paul Slootman Date: Sat, 1 Aug 1998 20:01:24 +0000 Subject: [PATCH] Added capability to edit .config by hand, and process those changes with "make subconfig". This file converts .config into scripts/autoconf.h . --- scripts/mk_autoconf.pl | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 scripts/mk_autoconf.pl diff --git a/scripts/mk_autoconf.pl b/scripts/mk_autoconf.pl new file mode 100755 index 00000000..52e7f4ec --- /dev/null +++ b/scripts/mk_autoconf.pl @@ -0,0 +1,50 @@ +#!/usr/bin/perl + +# GPL Paul Slootman 1998 +# +# script to convert .config as generated by 'make menuconfig' into +# scripts/autoconf.h , so that one can edit .config by hand and then +# non-interactively create a configuration ready for building. Useful +# for package building (I'm thinking Debian or Red Hat here). + +open(IN, "<.config") || die "Can't open .config: $!\n"; +open(OUT, ">scripts/autoconf.h") || die "Can't open scripts/autoconf.h: $!\n"; + +while () { + chop; + next if /^#\s*$/; # empty comment line; ignore + if (/^\s*$/) { # empty line; echo + print OUT "\n"; + next; + } + if (/^# ([^\s]+) is not set/) { # unset variables + print OUT "#undef $1\n"; + next; + } + if (/^#\s+([^\s].*)\s*/) { # comment + print OUT "/*\n * $1\n */\n"; + print OUT "#define AUTOCONF_INCLUDED\n" if /Automatically generated by/; + next; + } + if (/(\w+)=(.*)/) { # assignment + $var = $1; + $val = $2; + if ($val eq 'y') { # boolean true value + print OUT "#define $var 1\n"; + next; + } + if ($val =~ /^['"](.*)["']$/) { # string value + print OUT "#define $var \"$1\"\n"; + next; + } + if ($val =~ /^(\d+)$/) { # numeric value + print OUT "#define $var ($1)\n"; + next; + } + die "Unexpected input at line $.: $_\n"; + } +} + +close(IN); +close(OUT); +exit(0);