|
| >
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
| #! /bin/sh
#
# mkoctfile -- create a .oct file suitable for dynamic linking by
# Octave.
echo mkoctfile with optimisation level 0
# Exit immediately on any error.
set -e
# Default values for these variables are filled in when Octave is
# compiled.
: ${CPPFLAGS=""}
: ${INCFLAGS="-I/usr/include -I/usr/include/octave-2.0.16"}
: ${F77="g77"}
: ${FFLAGS="-O0"}
: ${FPICFLAG="-fPIC"}
: ${CC="gcc"}
: ${CFLAGS="-DHAVE_CONFIG_H -mieee-fp -O0"}
: ${CPICFLAG="-fPIC"}
: ${CXX="c++"}
: ${CXXFLAGS="-O0"}
: ${CXXPICFLAG="-fPIC"}
: ${XTRA_CFLAGS="-mieee-fp -fno-rtti -fno-exceptions -fno-implicit-templates"}
: ${XTRA_CXXFLAGS="-mieee-fp -fno-rtti -fno-exceptions -fno-implicit-templates"}
: ${SH_LD="c++"}
: ${SH_LDFLAGS="-shared"}
: ${ALL_FFLAGS="$FFLAGS"}
: ${ALL_CFLAGS="$INCFLAGS $XTRA_CFLAGS $CFLAGS"}
: ${ALL_CXXFLAGS="$INCFLAGS $XTRA_CXXFLAGS $CXXFLAGS"}
# Local variables.
usage_msg="usage: mkoctfile [options] file ..."
cfiles=
ccfiles=
f77files=
objfiles=
octfiles=
octfile=
incflags=
defs=
ldflags=
dbg=:
strip=false
if [ $# -eq 0 ]; then
echo $usage_msg
exit 1;
fi
while [ $# -gt 0 ]; do
file=
case "$1" in
*.c)
file=$1
cfiles="$cfiles $file"
;;
*.cc | *.C | *.cpp)
file=$1
ccfiles="$ccfiles $file"
;;
*.f | *.F)
file=$1
f77files="$f77files $file"
;;
*.o)
file=$1
objfiles="$objfiles $file"
;;
-d | --debug | -v | --verbose)
dbg=echo
;;
-h | -\? | --help)
echo $usage_msg
cat << EOF
Options:
-h, -?, --help Print this message.
-IDIR Add -IDIR to compile commands.
-DDEF Add -DDEF to compile commands.
-lLIB Add library LIB to link command.
-LDIR Add -LDIR to link command.
-o FILE, --output FILE Output file name. Default extension is .oct.
-s, --strip Strip output file.
-v, --verbose Echo commands as they are executed.
FILE Compile or link FILE. Recognized file types are:
.c C source
.cc C++ source
.C C++ source
.cpp C++ source
.f Fortran source
.F Fortran source
.o object file
EOF
exit 0
;;
-I*)
incflags="$incflags $1"
;;
-D*)
defs="$defs $1"
;;
-[lL]*)
ldflags="$ldflags $1"
;;
-o | --output)
shift
if [ $# -gt 0 ]; then
octfile=`echo $1 | sed 's,\.[^.]*$,,'`.oct
else
echo "mkoctfile: output file name missing"
fi
;;
-s | --strip)
strip=true
;;
*)
echo "mkoctfile: unrecognized argument $1"
exit 1
;;
esac
if [ -n "$file" ]; then
if [ -z "$octfile" ]; then
octfile=`echo $file | sed 's,\.[^.]*$,,'`.oct
fi
fi
shift
done
# Compile Fortran, C, and C++ files. Add the name of each object file
# that is produced to the overall list of object files.
if [ -n "$f77files" ]; then
for f in $f77files; do
case $f in
*.f)
b=`echo $f | sed 's,\.f$,,'`
;;
*.F)
b=`echo $f | sed 's,\.F$,,'`
;;
esac
o=$b.o
objfiles="$objfiles $o"
$dbg $F77 -c $FPICFLAG $ALL_FFLAGS $f -o $o
eval $F77 -c $FPICFLAG $ALL_FFLAGS $f -o $o
done
fi
if [ -n "$cfiles" ]; then
for f in $cfiles; do
b=`echo $f | sed 's,\.c$,,'`
o=$b.o
objfiles="$objfiles $o"
$dbg $CC -c $CPPFLAGS $CPICFLAG $ALL_CFLAGS $incflags $defs $f -o $o
eval $CC -c $CPPFLAGS $CPICFLAG $ALL_CFLAGS $incflags $defs $f -o $o
done
fi
if [ -n "$ccfiles" ]; then
for f in $ccfiles; do
case $f in
*.cc)
b=`echo $f | sed 's,\.cc$,,'`
;;
*.C)
b=`echo $f | sed 's,\.C$,,'`
;;
*.cpp)
b=`echo $f | sed 's,\.cpp$,,'`
;;
esac
o=$b.o
objfiles="$objfiles $o"
$dbg $CXX -c $CPPFLAGS $CXXPICFLAG $ALL_CXXFLAGS $incflags $defs $f -o $o
eval $CXX -c $CPPFLAGS $CXXPICFLAG $ALL_CXXFLAGS $incflags $defs $f -o $o
done
fi
# Link all the object files.
$dbg $SH_LD $SH_LDFLAGS -o $octfile $objfiles $ldflags
eval $SH_LD $SH_LDFLAGS -o $octfile $objfiles $ldflags
# Maybe strip it.
if $strip; then
$dbg strip $octfile
eval strip $octfile
fi
exit 0
|