# @(#)genlib version 3.19
# script to be executed in *csh*
# laboratoire masi cao-vlsi, UPMC, copyright 1990
# software support e-mail : cao-vlsi@masi.ibp.fr
# Author : Frederic Petrot 07/10/92
# Modifications, and all that stuff, by Fred also

if( $1 == "" ) then 
	echo "usage : genlib [-gv] program (without extension)";
	exit( 1 );
else if( $2 == "" ) then
	set name = $1;
	set talk = 0;
	set erase = 1;
else if( $1 == "-v" ) then
	set name = $2;
	set talk = 1;
	set erase = 1;
else if( $1 == "-g" ) then
	set name = $2;
	set talk = 0;
	set erase = 0;
else if(( $1 == "-gv" ) || ( $1 == "-vg" )) then
	set name = $2;
	set talk = 1;
	set erase = 0;
else
	echo "usage : genlib [-gv] program (without extension)";
	exit( 1 );
endif

set lib = (-L$ALLIANCE_LIB \
           -lMgn319 \
           -lMlu411 \
           -lMpu402 \
           -lMcp401 \
           -lMap402 \
           -lMmg401 \
           -lMcl408 \
           -lMal404 \
           -lMvl406 \
           -lMel406 \
           -lMsl608 \
           -lMhl402 \
           -lMlo404 \
           -lMph402 \
           -lMut315)
set include = (-I$ALLIANCE_INCLUDE)
/bin/rm $name.grr $name.o >& /dev/null
echo ""
echo "             @@@@ @                        @@@@@@         @   @@@      "
echo "           @@    @@                          @@          @@@   @@      "
echo "          @@      @                          @@           @    @@      "
echo "         @@             @@@@@   @@@ @@@      @@                @@ @@   "
echo "         @@            @     @   @@@   @     @@        @@@@    @@@  @@ "
echo "         @@     @@@@@ @@     @@  @@    @@    @@          @@    @@    @@"
echo "         @@     @ @@  @@@@@@@@@  @@    @@    @@          @@    @@    @@"
echo "         @@    @  @@  @@         @@    @@    @@          @@    @@    @@"
echo "          @@      @@  @@      @  @@    @@    @@      @   @@    @@    @@"
echo "           @@    @@    @@    @@  @@    @@    @@     @    @@    @@@  @@ "
echo "             @@@@        @@@@   @@@@  @@@@ @@@@@@@@@@  @@@@@@ @@@ @@   "
echo ""
echo "                         Procedural Generation Language"
echo ""
echo "                    Alliance CAD System 2.0,     genlib 3.16"
echo "                    Copyright (c) 91-93, MASI, CAO-VLSI Team"
echo "                    E-mail support:     cao-vlsi@masi.ibp.fr"
echo ""
if( $talk ) echo "Compiling $name.c ...";
$cc $include -g -o $name $name.c $lib >& $name.grr;
if( $status ) then
	echo "Compilation aborted";
	more $name.grr;
	echo "Errors report in $name.grr file";
	exit(1);
endif
if( $talk ) then
	if ($?MBK_CATA_LIB) then
		echo "MBK_CATA_LIB   : $MBK_CATA_LIB  "
	else
		echo "MBK_CATA_LIB   : .              "
	endif
	if ($?MBK_WORK_LIB) then
		echo "MBK_WORK_LIB   : $MBK_WORK_LIB  "
	else
		echo "MBK_WORK_LIB   : .              "
	endif
	if ($?MBK_IN_LO) then
		echo "MBK_IN_LO      : $MBK_IN_LO     "
	else
		echo "MBK_IN_LO      : al             "
	endif
	if ($?MBK_OUT_LO) then
		echo "MBK_OUT_LO     : $MBK_OUT_LO    "
	else
		echo "MBK_OUT_LO     : al             "
	endif
	if ($?MBK_IN_PH) then
		echo "MBK_IN_PH      : $MBK_IN_PH     "
	else
		echo "MBK_IN_PH      : ap             "
	endif
	if ($?MBK_OUT_PH) then
		echo "MBK_OUT_PH     : $MBK_OUT_PH    "
	else
		echo "MBK_OUT_PH     : ap             "
	endif
	if ($?MBK_CATAL_NAME) then
		echo "MBK_CATAL_NAME : $MBK_CATAL_NAME"
	else
		echo "MBK_CATAL_NAME : CATAL          "
	endif
endif
if( $talk ) echo "Executing ...";
$name;
set exit_code = $status;
if( $talk ) echo "Removing tmp files ...";
if( $erase ) /bin/rm $name;
/bin/rm $name.o $name.grr >& /dev/null;
exit( $exit_code );
