#!/bin/sh
# ######################################################################
#
# Component :	tconfigure
#
# Synopsis  :	XCra Configuration Tool
#
# Copyright (C) 1995, 1995 Stephane Carrez
#
# This file is part of Xcra.
#
# Xcra 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.
#
# Xcra 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.
#
# ######################################################################
#
# Path of the C preprocessor
#
if test -f /usr/ccs/lib/cpp; then
    CPP="/usr/ccs/lib/cpp"
else
    CPP="/lib/cpp";
fi

case $# in
    3)
	;;
    *)
	echo "Usage: tconfigure perl-path src dst" 1>&2
	exit 1;
	;;
esac
CONFIG_FILE=../config.h

#
# First, translate:
#   - empty lines in `/**/#ELINE' marks,
#   - shell commments `# xxx ' in `/**/# xxx'
#
(cat $CONFIG_FILE;
 sed -e 's,^$,/\*\*/#ELINE,' \
    -e 's,^#[	]*$,/\*\*/#,' \
    -e 's,^#[^eidu],/\*\*/&,' $2
) |

#
# Unifdef
#
$CPP -P |

#
# Reformat:
#   - regenerate emply lines (from #ELINE marks),
#   - remote cpp empty lines
#
sed -e '/^$/d' -e "s,PERL_PATH,$1," -e 's,^#ELINE$,,' > $3

