Fix the debugger to finish correctly.
[iverilog.git] / iverilog-vpi.sh
blobc82689a4f6f81bc0f1d59081fab74e7af201a428
1 #!/bin/sh
3 # This source code is free software; you can redistribute it
4 # and/or modify it in source code form under the terms of the GNU
5 # Library General Public License as published by the Free Software
6 # Foundation; either version 2 of the License, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Library General Public License for more details.
14 # You should have received a copy of the GNU Library General Public
15 # License along with this program; if not, write to the Free
16 # Software Foundation, Inc.,
17 # 59 Temple Place - Suite 330
18 # Boston, MA 02111-1307, USA
20 #ident "$Id: iverilog-vpi.sh,v 1.17 2007/02/06 05:07:31 steve Exp $"
22 # These are the variables used for compiling files
23 CC=@IVCC@
24 CXX=@IVCXX@
25 CFLAGS="@PIC@ @IVCFLAGS@ -I@INCLUDEDIR@"
27 # These are used for linking...
28 LD=gcc
29 LDFLAGS32="@SHARED@ -L@LIBDIR@"
30 LDFLAGS64="@SHARED@ -L@LIBDIR64@"
31 LDFLAGS="$LDFLAGS64"
32 LDLIBS="-lveriuser -lvpi"
34 INSTDIR64="@VPIDIR1@"
35 INSTDIR32="@VPIDIR2@"
36 if test x$INSTDIR32 = x
37 then
38 INSTDIR32=$INSTDIR64
41 INSTDIR="$INSTDIR64"
43 CCSRC=
44 CXSRC=
45 OBJ=
46 LIB=
47 OUT=
48 INCOPT=
50 # --
51 # parse the command line switches. This collects the source files
52 # and precompiled object files, and maybe user libraries. As we are
53 # going, guess an output file name.
54 for parm
56 case $parm
59 *.c) CCSRC="$CCSRC $parm"
60 if [ x$OUT = x ]; then
61 OUT=`basename $parm .c`
65 *.cc) CXSRC="$CXSRC $parm"
66 LD=$CXX
67 if [ x$OUT = x ]; then
68 OUT=`basename $parm .cc`
72 *.cpp) CXSRC="$CXSRC $parm"
73 LD=$CXX
74 if [ x$OUT = x ]; then
75 OUT=`basename $parm .cpp`
79 *.o) OBJ="$OBJ $parm"
80 if [ x$OUT = x ]; then
81 OUT=`basename $parm .o`
85 --name=*)
86 OUT=`echo $parm | cut -b8-`
89 -l*) LIB="$LIB $parm"
92 -I*) INCOPT="$INCOPT $parm"
93 echo "$parm"
96 -m32) LDFLAGS="-m32 $LDFLAGS32"
97 CFLAGS="-m32 $CFLAGS"
98 INSTDIR="$INSTDIR32"
101 --cflags)
102 echo "$CFLAGS"
103 exit;
106 --ldflags)
107 echo "$LDFLAGS"
108 exit;
111 --ldlibs)
112 echo "$LDLIBS"
113 exit;
116 --install-dir)
117 echo "@LIBDIR@/ivl/$INSTDIR"
118 exit
120 esac
122 done
124 if [ x$OUT = x ]; then
125 echo "Usage: $0 [src and obj files]..." 1>&2
126 exit 0
129 # Put the .vpi on the result file.
130 OUT=$OUT".vpi"
132 compile_errors=0
134 # Compile all the source files into object files
135 for src in $CCSRC
137 base=`basename $src .c`
138 obj=$base".o"
140 echo "Compiling $src..."
141 $CC -c -o $obj $CFLAGS $INCOPT $src || compile_errors=`expr $compile_errors + 1`
142 OBJ="$OBJ $obj"
143 done
145 for src in $CXSRC
147 base=`basename $src .cc`
148 obj=$base".o"
150 echo "Compiling $src..."
151 $CXX -c -o $obj $CFLAGS $INCOPT $src || compile_errors=`expr $compile_errors + 1`
152 OBJ="$OBJ $obj"
153 done
155 if test $compile_errors -gt 0
156 then
157 echo "Some ($compile_errors) files failed to compile."
158 exit $compile_errors
161 echo "Making $OUT from $OBJ..."
162 exec $LD -o $OUT $LDFLAGS $OBJ $LIB $LDLIBS