iverilog/iverilog-vpi.sh

150 lines
2.9 KiB
Bash
Raw Normal View History

2002-04-07 02:47:10 +02:00
#!/bin/sh
#
# This source code is free software; you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# Library General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program 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 Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc.,
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
#ident "$Id: iverilog-vpi.sh,v 1.17 2007/02/06 05:07:31 steve Exp $"
2002-04-07 02:47:10 +02:00
# These are the variables used for compiling files
CC=@IVCC@
CXX=@IVCXX@
CFLAGS="@PIC@ @IVCFLAGS@ -I@INCLUDEDIR@"
2002-04-07 02:47:10 +02:00
# These are used for linking...
LD=$CC
LDFLAGS="@SHARED@ -L@LIBDIR@"
LDLIBS="-lveriuser -lvpi"
2002-04-07 02:47:10 +02:00
2002-05-10 05:54:46 +02:00
CCSRC=
CXSRC=
2002-04-07 02:47:10 +02:00
OBJ=
LIB=
OUT=
2004-05-20 02:40:34 +02:00
INCOPT=
DEFS=
2002-04-07 02:47:10 +02:00
# --
# parse the command line switches. This collects the source files
# and precompiled object files, and maybe user libraries. As we are
# going, guess an output file name.
for parm
do
case $parm
in
*.c) CCSRC="$CCSRC $parm"
2002-04-07 02:47:10 +02:00
if [ x$OUT = x ]; then
OUT=`basename $parm .c`
fi
;;
*.cc) CXSRC="$CXSRC $parm"
LD=$CXX
2002-05-10 05:54:46 +02:00
if [ x$OUT = x ]; then
OUT=`basename $parm .cc`
fi
;;
2006-09-26 20:54:42 +02:00
*.cpp) CXSRC="$CXSRC $parm"
LD=$CXX
if [ x$OUT = x ]; then
OUT=`basename $parm .cpp`
fi
;;
2002-04-07 02:47:10 +02:00
*.o) OBJ="$OBJ $parm"
if [ x$OUT = x ]; then
OUT=`basename $parm .o`
fi
;;
2002-07-05 19:17:20 +02:00
--name=*)
OUT=`echo $parm | cut -b8-`
;;
2002-04-07 02:47:10 +02:00
-l*) LIB="$LIB $parm"
;;
2004-05-20 02:40:34 +02:00
-I*) INCOPT="$INCOPT $parm"
;;
-D*) DEFS="$DEFS $parm"
2004-05-20 02:40:34 +02:00
;;
--cflags)
echo "$CFLAGS"
exit;
;;
--ldflags)
echo "$LDFLAGS"
exit;
;;
--ldlibs)
echo "$LDLIBS"
exit;
;;
--install-dir)
echo "@LIBDIR@/ivl"
exit
;;
2002-04-07 02:47:10 +02:00
esac
done
if [ x$OUT = x ]; then
echo "Usage: $0 [src and obj files]..." 1>&2
2002-04-07 02:47:10 +02:00
exit 0
fi
# Put the .vpi on the result file.
OUT=$OUT".vpi"
2002-05-15 03:25:25 +02:00
compile_errors=0
2002-04-07 02:47:10 +02:00
# Compile all the source files into object files
2002-10-20 01:18:52 +02:00
for src in $CCSRC
2002-04-07 02:47:10 +02:00
do
base=`basename $src .c`
obj=$base".o"
echo "Compiling $src..."
$CC -c -o $obj $DEFS $CFLAGS $INCOPT $src || compile_errors=`expr $compile_errors + 1`
2002-04-07 02:47:10 +02:00
OBJ="$OBJ $obj"
done
2002-10-20 01:18:52 +02:00
for src in $CXSRC
2002-05-10 05:54:46 +02:00
do
base=`basename $src .cc`
obj=$base".o"
echo "Compiling $src..."
$CXX -c -o $obj $DEFS $CFLAGS $INCOPT $src || compile_errors=`expr $compile_errors + 1`
2002-05-10 05:54:46 +02:00
OBJ="$OBJ $obj"
done
2002-05-15 03:25:25 +02:00
if test $compile_errors -gt 0
then
echo "$0: $compile_errors file(s) failed to compile."
2002-05-15 03:25:25 +02:00
exit $compile_errors
fi
2002-04-07 02:47:10 +02:00
echo "Making $OUT from $OBJ..."
exec $LD -o $OUT $LDFLAGS $OBJ $LIB $LDLIBS