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
|
|
|
|
|
#
|
2007-02-06 06:07:31 +01:00
|
|
|
#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
|
2007-02-06 06:07:31 +01:00
|
|
|
CC=@IVCC@
|
|
|
|
|
CXX=@IVCXX@
|
|
|
|
|
CFLAGS="@PIC@ @IVCFLAGS@ -I@INCLUDEDIR@"
|
2002-04-07 02:47:10 +02:00
|
|
|
|
|
|
|
|
# These are used for linking...
|
2007-11-29 19:31:25 +01:00
|
|
|
LD=$CC
|
2008-01-26 02:33:32 +01:00
|
|
|
LDFLAGS="@SHARED@ -L@LIBDIR@"
|
2003-08-26 06:45:47 +02:00
|
|
|
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=
|
2007-11-29 19:16:07 +01:00
|
|
|
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
|
|
|
|
|
|
2002-09-19 01:25:18 +02:00
|
|
|
*.c) CCSRC="$CCSRC $parm"
|
2002-04-07 02:47:10 +02:00
|
|
|
if [ x$OUT = x ]; then
|
|
|
|
|
OUT=`basename $parm .c`
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
|
2002-09-19 01:25:18 +02:00
|
|
|
*.cc) CXSRC="$CXSRC $parm"
|
2006-02-21 03:38:44 +01:00
|
|
|
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"
|
2007-11-29 19:16:07 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
-D*) DEFS="$DEFS $parm"
|
2004-05-20 02:40:34 +02:00
|
|
|
;;
|
|
|
|
|
|
2003-08-26 06:45:47 +02:00
|
|
|
--cflags)
|
|
|
|
|
echo "$CFLAGS"
|
|
|
|
|
exit;
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
--ldflags)
|
|
|
|
|
echo "$LDFLAGS"
|
|
|
|
|
exit;
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
--ldlibs)
|
|
|
|
|
echo "$LDLIBS"
|
|
|
|
|
exit;
|
|
|
|
|
;;
|
2003-10-14 02:31:31 +02:00
|
|
|
|
|
|
|
|
--install-dir)
|
2008-01-26 02:33:32 +01:00
|
|
|
echo "@LIBDIR@/ivl"
|
2003-10-14 02:31:31 +02:00
|
|
|
exit
|
|
|
|
|
;;
|
2002-04-07 02:47:10 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [ x$OUT = x ]; then
|
2003-10-14 02:31:31 +02:00
|
|
|
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..."
|
2007-11-29 19:16:07 +01:00
|
|
|
$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..."
|
2007-11-29 19:16:07 +01:00
|
|
|
$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
|
2007-12-30 21:19:36 +01:00
|
|
|
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..."
|
2002-09-24 03:50:53 +02:00
|
|
|
exec $LD -o $OUT $LDFLAGS $OBJ $LIB $LDLIBS
|