#! /bin/sh

CONFIG_H=include/config.h
CONFIG_IN=config.in
CONFIG_OUT=config.out
CONFIG_MK=.config

if [ -f config.org ]
then
	echo -n >$CONFIG_OUT
else
	mv config.in config.org
fi

cat << 'END' > $CONFIG_H

/*
	HAN - HANgul On Linux Console -
	Copyright (C) 1992, 1993 Oh SungKyu(hanmaum@baram.kaist.ac.kr)

	KON - Kanji ON Linux Console -
	Copyright (C) 1992, 1993
		MAEDA Atusi (mad@math.keio.ac.jp)
		Takashi MANABE (manabe@tut.ac.jp)

	HAN 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 of the License, or
	(at your option) any later version.

	HAN 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.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
	NOTE: This is automatically generated config.
	>>>>>>>>>>>>>> DO NOT EDIT !! <<<<<<<<<<<<<<
*/

#ifndef	CONFIG_H
#define	CONFIG_H

END

echo "INCDIR  = "`pwd`/include > $CONFIG_MK
echo "LIB     = "`pwd`/lib/libgon.a >> $CONFIG_MK

cat << 'END' >> $CONFIG_MK

TOPDIR	= 
BINDIR	= $(TOPDIR)/usr/bin
LIBDIR	= $(TOPDIR)/etc
MANDIR	= $(TOPDIR)/usr/man/ko_KR.euc/man1
CONFIG_NAME = han.cfg
OPTS    = -DCONFIG_NAME=\"$(LIBDIR)/$(CONFIG_NAME)\" -I$(INCDIR)
CFLAGS  = -O -Wall $(OPTS)
LD      = gcc $(CFLAGS)
RM      = rm -f
INSTALL = install -c -s
SUBDIRS = lib src font tools

END

echo "HAN HANgul On Linux console"

while read mess
do
	echo $mess >>$CONFIG_OUT
	echo >>$CONFIG_H
	echo '/*' $mess '*/' >>$CONFIG_H
	read sig def
	echo -n $mess '['$def']? '
	read ans < /dev/tty
	if [ "$ans" = "" ]
	then
		ans=$def
	fi
	echo $sig $ans >>$CONFIG_OUT
	if [ "$def" != "y" -a "$def" != "n" ]
	then
		if [ "$sig" = "SELECTION" ]
		then
			echo "#define" $ans >>$CONFIG_H
		else
			echo $expr >>$CONFIG_OUT
			echo -n "#define	"$sig"	" >>$CONFIG_H
		fi
	else
		if [ "$ans" = "y" ]
		then
			echo "#define" $sig >>$CONFIG_H
			echo $sig" = "$sig >>$CONFIG_MK
		fi
	fi
	prep=$ans
done

mv config.out config.in

echo "#endif" >>$CONFIG_H

cat << 'END'

END
