head	1.1;
access;
symbols
	dws_pl15i:1.1
	cluster_15h:1.1
	dws_pl15h_ibcs:1.1;
locks; strict;
comment	@# @;


1.1
date	94.02.26.22.05.14;	author dws;	state Exp;
branches;
next	;


desc
@@


1.1
log
@Added iBCS emulation support.
@
text
@#!/bin/sh
# $Id: confconv,v 1.0 1994/02/20 23:28:29 st Exp st $
#
# confconv - Convert Linux 0.99.14 'config.in' file to pseudo-BSD-style
#            config file for 'config'.
#
# usage: confconv < <config.in> > <config-file>
#
# Scott Telford (s.telford@@ed.ac.uk) 94/02/16.
# 
# Based on Linux 0.99.14 'Configure' script by raymondc@@microsoft.com.
#
# See 'Configure' script for config.in file format.
# 
# Conversion rules:
# input:				output:
#
# * <comment>				# <comment>
# bool <prompt> <variable> y		options <variable>         # <prompt>
# bool <prompt> <variable> n		#options <variable>        # <prompt>
# int <prompt> <variable> <num>		options <variable> = <num> # <prompt>
#
# lines in false if/then/else/fi clauses are output but commented-out.

[ -z "$BASH" ] && { echo "confconv requires bash" 1>&2; exit 1; }

# Disable filename globbing once and for all.
# Enable function cacheing.
set -f -h

# bool processes a boolean argument
#
#	bool tail
#
function bool () {
	# Slimier hack to get bash to rescan a line.
	eval "set -- $1"
	# Special case: CONFIG_M486 => cpu i486
	if [ "$2" = "CONFIG_M486" ] ; then
		case $3 in
		y)
			echo "cpu	i486"
			;;
		n)
			echo "cpu	i386"
			;;
		esac
	else
		case $3 in
		y)
			echo "options ${2#CONFIG_}	# $1"
			;;
		n)
			echo "#options ${2#CONFIG_}	# $1"
			;;
		esac
	fi
	eval "$2=$3"
}

# int processes an integer argument
#
#	int tail
#
function int () {
	# Slimier hack to get bash to rescan a line.
	eval "set -- $1"
	echo "options ${2#CONFIG_} = $3	# $1"
	eval "$2=$3"
}


stack=''
branch='t'

# output default preamble

echo "# Linux kernel config file automatically generated from config.in file."
echo
echo "ident	DEFAULT"
echo
echo "config vmlinux root on CURRENT"
echo
echo "videomode	NORMAL_VGA"
echo

while IFS='@@' read raw_input_line
do
	# Slimy hack to get bash to rescan a line.
	read cmd rest <<-END_OF_COMMAND
		$raw_input_line
	END_OF_COMMAND

	if [ "$cmd" = "*" ]; then
		if [ "$branch" = "t" ]; then
			echo "# $rest" 
		fi
	else
		prevcmd=""
		case "$cmd" in
		:)	;;
		int)	if [ "$branch" = "t" ] ; then
				int "$rest" 
			else
				eval "set -- $rest"
				echo "#options ${2#CONFIG_} = $3	# $1"
			fi
			;;
		bool)	if [ "$branch" = "t" ] ; then 
				bool "$rest"
			else
				eval "set -- $rest"
				echo "#options ${2#CONFIG_}	# $1"
			fi
			;;
		exec)	[ "$branch" = "t" ] && ( sh -c "$rest" ) ;;
		if)	stack="$branch $stack"
			if [ "$branch" = "t" ] && eval "$rest"; then
				branch=t
			else
				branch=f
			fi ;;
		else)	if [ "$branch" = "t" ]; then
				branch=f
			else
				read branch rest <<-END_OF_STACK
					$stack
				END_OF_STACK
			fi ;;
		fi)	[ -z "$stack" ] && echo "Error!  Extra fi." 1>&2
			read branch stack <<-END_OF_STACK
				$stack
			END_OF_STACK
			;;
		esac
	fi
done

[ -z "$stack" ] || echo "Error!  Unterminated if." 1>&2

exit 0
@
