iverilog/iverilog-vpi.sh

156 lines
3.0 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.15 2006/02/21 02:38:44 steve Exp $"
2002-04-07 02:47:10 +02:00
# These are the variables used for compiling files
CC=gcc
CXX=g++
CFLAGS="@PIC@ -O -I@INCLUDEDIR@"
2002-04-07 02:47:10 +02:00
# These are used for linking...
LD=gcc
LDFLAGS32="@SHARED@ -L@LIBDIR@"
LDFLAGS64="@SHARED@ -L@LIBDIR64@"
LDFLAGS="$LDFLAGS64"
LDLIBS="-lveriuser -lvpi"
2002-04-07 02:47:10 +02:00
INSTDIR64="@VPIDIR1@"
INSTDIR32="@VPIDIR2@"
if test x$INSTDIR32 = x
then
2003-10-14 20:05:18 +02:00
INSTDIR32=$INSTDIR64
fi
INSTDIR="$INSTDIR64"
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=
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
;;
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"
echo "$parm"
;;
-m32) LDFLAGS="-m32 $LDFLAGS32"
CFLAGS="-m32 $CFLAGS"
INSTDIR="$INSTDIR32"
;;
--cflags)
echo "$CFLAGS"
exit;
;;
--ldflags)
echo "$LDFLAGS"
exit;
;;
--ldlibs)
echo "$LDLIBS"
exit;
;;
--install-dir)
echo "@LIBDIR@/ivl/$INSTDIR"
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..."
2004-05-20 02:40:34 +02:00
$CC -c -o $obj $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..."
2004-05-20 02:40:34 +02:00
$CXX -c -o $obj $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 "Some ($compile_errors) files failed to compile."
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