Mercurial > hg > octave-nkf
annotate mkoctfile.in @ 10050:dc88a0b6472c
support old style jacobian for fsolve
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sat, 02 Jan 2010 21:55:17 +0100 |
parents | 59ed11557715 |
children | 4906ccf5d95e |
rev | line source |
---|---|
2163 | 1 #! /bin/sh |
7016 | 2 ## |
3 ## mkoctfile -- create a .oct file suitable for dynamic linking by | |
4 ## Octave. | |
7017 | 5 ## |
6 ## Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005, | |
9245 | 7 ## 2006, 2007, 2009 John W. Eaton |
7017 | 8 ## |
7016 | 9 ## This file is part of Octave. |
9187
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
10 ## |
7016 | 11 ## Octave is free software; you can redistribute it and/or modify it |
12 ## under the terms of the GNU General Public License as published by the | |
13 ## Free Software Foundation; either version 3 of the License, or (at | |
14 ## your option) any later version. | |
9187
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
15 ## |
7016 | 16 ## Octave is distributed in the hope that it will be useful, but WITHOUT |
17 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
18 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
19 ## for more details. | |
9187
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
20 ## |
7016 | 21 ## You should have received a copy of the GNU General Public License |
22 ## along with Octave; see the file COPYING. If not, see | |
23 ## <http://www.gnu.org/licenses/>. | |
2163 | 24 |
3051 | 25 # Exit immediately on any error. |
26 | |
2163 | 27 set -e |
28 | |
6311 | 29 : ${SED=%OCTAVE_CONF_SED%} |
30 | |
6086 | 31 OCTAVE_VERSION=%OCTAVE_CONF_VERSION% |
6311 | 32 OCTAVE_PREFIX=%OCTAVE_CONF_PREFIX% |
33 | |
6682 | 34 DEFAULT_BINDIR=%OCTAVE_BINDIR% |
35 DEFAULT_INCLUDEDIR=%OCTAVE_CONF_INCLUDEDIR% | |
6710 | 36 DEFAULT_LIBDIR=%OCTAVE_CONF_LIBDIR% |
6311 | 37 DEFAULT_OCTINCLUDEDIR=%OCTAVE_CONF_OCTINCLUDEDIR% |
38 DEFAULT_OCTLIBDIR=%OCTAVE_CONF_OCTLIBDIR% | |
39 | |
40 if [ -n "$OCTAVE_HOME" ]; then | |
6682 | 41 DEFAULT_BINDIR="`echo $DEFAULT_BINDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`" |
42 DEFAULT_INCLUDEDIR="`echo $DEFAULT_INCLUDEDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`" | |
6710 | 43 DEFAULT_LIBDIR="`echo $DEFAULT_LIBDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`" |
6319 | 44 DEFAULT_OCTINCLUDEDIR="`echo $DEFAULT_OCTINCLUDEDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`" |
45 DEFAULT_OCTLIBDIR="`echo $DEFAULT_OCTLIBDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`" | |
6311 | 46 fi |
47 | |
6682 | 48 : ${BINDIR=$DEFAULT_BINDIR} |
49 : ${INCLUDEDIR=$DEFAULT_INCLUDEDIR} | |
6710 | 50 : ${LIBDIR=$DEFAULT_LIBDIR} |
6311 | 51 : ${OCTINCLUDEDIR=$DEFAULT_OCTINCLUDEDIR} |
52 : ${OCTLIBDIR=$DEFAULT_OCTLIBDIR} | |
53 | |
9794
0d4613a736e9
convert build system to use automake and libtool
John W. Eaton <jwe@octave.org>
parents:
9538
diff
changeset
|
54 DEFAULT_INCFLAGS="-I$OCTINCLUDEDIR/.. -I$OCTINCLUDEDIR" |
6311 | 55 if [ "$INCLUDEDIR" != /usr/include ]; then |
56 DEFAULT_INCFLAGS="$DEFAULT_INCFLAGS -I$INCLUDEDIR" | |
57 fi | |
58 | |
59 DEFAULT_LFLAGS="-L$OCTLIBDIR" | |
6710 | 60 if [ "$LIBDIR" != /usr/lib ]; then |
61 DEFAULT_LFLAGS="$DEFAULT_LFLAGS -L$LIBDIR" | |
62 fi | |
5285 | 63 |
3051 | 64 # Default values for these variables are filled in when Octave is |
9187
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
65 # compiled. |
3051 | 66 |
6682 | 67 : ${EXEEXT=%OCTAVE_CONF_EXEEXT%} |
68 | |
3590 | 69 : ${CPPFLAGS=%OCTAVE_CONF_CPPFLAGS%} |
6311 | 70 : ${INCFLAGS=$DEFAULT_INCFLAGS} |
3590 | 71 : ${F77=%OCTAVE_CONF_F77%} |
72 : ${FFLAGS=%OCTAVE_CONF_FFLAGS%} | |
73 : ${FPICFLAG=%OCTAVE_CONF_FPICFLAG%} | |
74 : ${CC=%OCTAVE_CONF_CC%} | |
75 : ${CFLAGS=%OCTAVE_CONF_CFLAGS%} | |
76 : ${CPICFLAG=%OCTAVE_CONF_CPICFLAG%} | |
77 : ${CXX=%OCTAVE_CONF_CXX%} | |
78 : ${CXXFLAGS=%OCTAVE_CONF_CXXFLAGS%} | |
79 : ${CXXPICFLAG=%OCTAVE_CONF_CXXPICFLAG%} | |
80 : ${XTRA_CFLAGS=%OCTAVE_CONF_XTRA_CFLAGS%} | |
81 : ${XTRA_CXXFLAGS=%OCTAVE_CONF_XTRA_CXXFLAGS%} | |
3051 | 82 |
3846 | 83 : ${DEPEND_FLAGS=%OCTAVE_CONF_DEPEND_FLAGS%} |
84 : ${DEPEND_EXTRA_SED_PATTERN=%OCTAVE_CONF_DEPEND_EXTRA_SED_PATTERN%} | |
85 | |
4759 | 86 : ${DL_LD=%OCTAVE_CONF_DL_LD%} |
87 : ${DL_LDFLAGS=%OCTAVE_CONF_MKOCTFILE_DL_LDFLAGS%} | |
3051 | 88 |
3859 | 89 : ${RLD_FLAG=%OCTAVE_CONF_RLD_FLAG%} |
90 : ${RDYNAMIC_FLAG=%OCTAVE_CONF_RDYNAMIC_FLAG%} | |
4228 | 91 : ${LIBOCTAVE=-loctave} |
92 : ${LIBOCTINTERP=-loctinterp} | |
9515 | 93 : ${READLINE_LIBS=-lreadline} |
4228 | 94 : ${LIBCRUFT=-lcruft} |
3859 | 95 : ${BLAS_LIBS=%OCTAVE_CONF_BLAS_LIBS%} |
9538
d0239bddf621
use OCTAVE_CHECK_LIB to check for zlib
John W. Eaton <jwe@octave.org>
parents:
9515
diff
changeset
|
96 : ${FFTW3_LDFLAGS=%OCTAVE_CONF_FFTW3_LDFLAGS%} |
d0239bddf621
use OCTAVE_CHECK_LIB to check for zlib
John W. Eaton <jwe@octave.org>
parents:
9515
diff
changeset
|
97 : ${FFTW3_LIBS=%OCTAVE_CONF_FFTW3_LIBS%} |
d0239bddf621
use OCTAVE_CHECK_LIB to check for zlib
John W. Eaton <jwe@octave.org>
parents:
9515
diff
changeset
|
98 : ${FFTW3F_LDFLAGS=%OCTAVE_CONF_FFTW3F_LDFLAGS%} |
d0239bddf621
use OCTAVE_CHECK_LIB to check for zlib
John W. Eaton <jwe@octave.org>
parents:
9515
diff
changeset
|
99 : ${FFTW3F_LIBS=%OCTAVE_CONF_FFTW3F_LIBS%} |
3859 | 100 : ${LIBS=%OCTAVE_CONF_LIBS%} |
101 : ${FLIBS=%OCTAVE_CONF_FLIBS%} | |
102 : ${LD_CXX=%OCTAVE_CONF_LD_CXX%} | |
103 : ${LDFLAGS=%OCTAVE_CONF_LDFLAGS%} | |
104 : ${LD_STATIC_FLAG=%OCTAVE_CONF_LD_STATIC_FLAG%} | |
6311 | 105 : ${LFLAGS=$DEFAULT_LFLAGS} |
3859 | 106 |
3051 | 107 : ${ALL_FFLAGS="$FFLAGS"} |
108 | |
3131 | 109 : ${ALL_CFLAGS="$INCFLAGS $XTRA_CFLAGS $CFLAGS"} |
3051 | 110 |
3131 | 111 : ${ALL_CXXFLAGS="$INCFLAGS $XTRA_CXXFLAGS $CXXFLAGS"} |
3051 | 112 |
3887 | 113 : ${ALL_LDFLAGS="$LD_STATIC_FLAG $CPICFLAG $LDFLAGS"} |
3859 | 114 |
4228 | 115 : ${OCTAVE_LIBS="$LIBOCTINTERP $LIBOCTAVE $SPECIAL_MATH_LIB $LIBCRUFT"} |
3859 | 116 |
3051 | 117 # Local variables. |
118 | |
9538
d0239bddf621
use OCTAVE_CHECK_LIB to check for zlib
John W. Eaton <jwe@octave.org>
parents:
9515
diff
changeset
|
119 FFTW_LIBS="$FFTW3_LDFLAGS $FFTW3_LIBS $FFTW3F_LDFLAGS $FFTW3F_LIBS" |
d0239bddf621
use OCTAVE_CHECK_LIB to check for zlib
John W. Eaton <jwe@octave.org>
parents:
9515
diff
changeset
|
120 |
3051 | 121 usage_msg="usage: mkoctfile [options] file ..." |
122 | |
5285 | 123 version_msg="mkoctfile, version $OCTAVE_VERSION" |
124 | |
3051 | 125 cfiles= |
126 ccfiles= | |
127 f77files= | |
128 objfiles= | |
6294 | 129 libfiles= |
3051 | 130 octfiles= |
131 octfile= | |
3860 | 132 outputfile= |
3088 | 133 incflags= |
3180 | 134 defs= |
3051 | 135 ldflags= |
136 dbg=: | |
4873 | 137 pass_on_options= |
3058 | 138 strip=false |
4199 | 139 no_oct_file_strip_on_this_platform=%NO_OCT_FILE_STRIP% |
3735 | 140 link=true |
3859 | 141 link_stand_alone=false |
5864 | 142 output_ext=".oct" |
3846 | 143 depend=false |
144 compile=true | |
3051 | 145 |
146 if [ $# -eq 0 ]; then | |
3847 | 147 echo $usage_msg 1>&2 |
3846 | 148 exit 1 |
2163 | 149 fi |
150 | |
5285 | 151 if [ $# -eq 1 ]; then |
152 case "$1" in | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
153 -v | -version | --version) |
5285 | 154 echo $version_msg 1>&2 |
155 exit 0 | |
156 ;; | |
157 esac | |
158 fi | |
159 | |
3051 | 160 while [ $# -gt 0 ]; do |
161 file= | |
162 case "$1" in | |
163 *.c) | |
164 file=$1 | |
165 cfiles="$cfiles $file" | |
166 ;; | |
167 *.cc | *.C | *.cpp) | |
168 file=$1 | |
169 ccfiles="$ccfiles $file" | |
170 ;; | |
5970 | 171 *.f | *.F | *.f90 | *.F90) |
3051 | 172 file=$1 |
173 f77files="$f77files $file" | |
174 ;; | |
175 *.o) | |
176 file=$1 | |
177 objfiles="$objfiles $file" | |
178 ;; | |
6294 | 179 *.a) |
180 file=$1 | |
181 libfiles="$libfiles $file" | |
182 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
183 -d | -debug | --debug | -v | -verbose | --verbose) |
3051 | 184 dbg=echo |
185 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
186 -h | -\? | -help | --help) |
3847 | 187 echo $usage_msg 1>&2 |
3051 | 188 cat << EOF |
2163 | 189 |
3051 | 190 Options: |
191 | |
3233 | 192 -h, -?, --help Print this message. |
3734 | 193 |
3088 | 194 -IDIR Add -IDIR to compile commands. |
3734 | 195 |
5483 | 196 -idirafter DIR Add -idirafter DIR to compile commands. |
197 | |
3180 | 198 -DDEF Add -DDEF to compile commands. |
3734 | 199 |
3058 | 200 -lLIB Add library LIB to link command. |
3734 | 201 |
3087 | 202 -LDIR Add -LDIR to link command. |
3734 | 203 |
3846 | 204 -M, --depend Generate dependency files (.d) for C and C++ |
205 source files. | |
206 | |
5199 | 207 -RDIR Add -RDIR to link command. |
208 | |
6153 | 209 -Wl,... Pass flags though the linker like -Wl,-rpath=... |
210 | |
211 -W... Pass flags though the compiler like -Wa,OPTION. | |
5199 | 212 |
3859 | 213 -c, --compile Compile, but do not link. |
3735 | 214 |
3859 | 215 -o FILE, --output FILE Output file name. Default extension is .oct |
5864 | 216 (or .mex if --mex is specified) unless linking |
217 a stand-alone executable. | |
3734 | 218 |
5904 | 219 -g Enable debugging options for compilers. |
220 | |
3734 | 221 -p VAR, --print VAR Print configuration variable VAR. Recognized |
222 variables are: | |
223 | |
9187
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
224 ALL_CFLAGS FLIBS |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
225 ALL_CXXFLAGS FPICFLAG |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
226 ALL_FFLAGS INCFLAGS |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
227 ALL_LDFLAGS LDFLAGS |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
228 BLAS_LIBS LD_CXX |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
229 CC LD_STATIC_FLAG |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
230 CFLAGS LFLAGS |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
231 CPICFLAG LIBCRUFT |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
232 CPPFLAGS LIBOCTAVE |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
233 CXX LIBOCTINTERP |
9515 | 234 CXXFLAGS LIBS |
235 CXXPICFLAG OCTAVE_LIBS | |
236 DEPEND_EXTRA_SED_PATTERN RDYNAMIC_FLAG | |
237 DEPEND_FLAGS READLINE_LIBS | |
9187
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
238 DL_LD RLD_FLAG |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
239 DL_LDFLAGS SED |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
240 F77 XTRA_CFLAGS |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
241 FFLAGS XTRA_CXXFLAGS |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
242 FFTW_LIBS |
3859 | 243 |
244 --link-stand-alone Link a stand-alone executable file. | |
245 | |
5864 | 246 --mex Assume we are creating a MEX file. Set the |
247 default output extension to ".mex". | |
248 | |
3058 | 249 -s, --strip Strip output file. |
3734 | 250 |
3058 | 251 -v, --verbose Echo commands as they are executed. |
3051 | 252 |
253 FILE Compile or link FILE. Recognized file types are: | |
254 | |
3847 | 255 .c C source |
256 .cc C++ source | |
257 .C C++ source | |
258 .cpp C++ source | |
5970 | 259 .f Fortran source (fixed form) |
260 .F Fortran source (fixed form) | |
261 .f90 Fortran source (free form) | |
262 .F90 Fortran source (free form) | |
3847 | 263 .o object file |
6294 | 264 .a library file |
2163 | 265 |
3051 | 266 EOF |
267 exit 0 | |
268 ;; | |
3088 | 269 -I*) |
3176 | 270 incflags="$incflags $1" |
3088 | 271 ;; |
5483 | 272 -idirafter) |
273 shift | |
274 if [ $# -gt 0 ]; then | |
275 incflags="$incflags -idirafter $1" | |
276 else | |
6782 | 277 echo "mkoctfile: include directory name missing" 1>&2 |
5483 | 278 fi |
279 ;; | |
3180 | 280 -D*) |
281 defs="$defs $1" | |
282 ;; | |
6153 | 283 -[lLR]* | -Wl,*) |
3176 | 284 ldflags="$ldflags $1" |
3058 | 285 ;; |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
286 -M | -depend | --depend) |
3846 | 287 depend=true |
288 compile=false | |
289 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
290 -o | -ouput | --output) |
3051 | 291 shift |
292 if [ $# -gt 0 ]; then | |
3860 | 293 outputfile="$1" |
3051 | 294 else |
3847 | 295 echo "mkoctfile: output file name missing" 1>&2 |
3051 | 296 fi |
297 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
298 -p | -print | --print) |
3734 | 299 shift |
300 if [ $# -gt 0 ]; then | |
301 eval echo \${$1} | |
302 exit 0 | |
303 else | |
3847 | 304 echo "mkoctfile: --print requires argument" 1>&2 |
3734 | 305 exit 1 |
306 fi | |
307 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
308 -s | -strip | --strip) |
4199 | 309 if $no_oct_file_strip_on_this_platform; then |
310 echo "mkoctfile: stripping disabled on this platform" 1>&2 | |
311 else | |
312 strip=true | |
313 fi | |
3051 | 314 ;; |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
315 -c | -compile | --compile) |
3735 | 316 link=false |
317 ;; | |
5904 | 318 -g) |
319 ALL_CFLAGS="$ALL_CFLAGS -g" | |
320 ALL_CXXFLAGS="$ALL_CXXFLAGS -g" | |
321 ALL_FFLAGS="$ALL_FFLAGS -g" | |
322 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
323 -link-stand-alone | --link-stand-alone) |
3859 | 324 link_stand_alone=true |
325 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
326 -mex | --mex) |
6009 | 327 incflags="$incflags -I." |
5864 | 328 output_ext=".mex" |
329 ;; | |
4873 | 330 -W*) |
331 pass_on_options="$pass_on_options $1" | |
332 ;; | |
3051 | 333 *) |
3847 | 334 echo "mkoctfile: unrecognized argument $1" 1>&2 |
3051 | 335 exit 1 |
336 ;; | |
337 esac | |
338 if [ -n "$file" ]; then | |
339 if [ -z "$octfile" ]; then | |
3859 | 340 octfile="$file" |
3051 | 341 fi |
342 fi | |
343 shift | |
344 done | |
2163 | 345 |
3859 | 346 if $link_stand_alone; then |
3860 | 347 if [ -n "$outputfile" ]; then |
348 output_option="-o $outputfile" | |
349 fi | |
3859 | 350 else |
3860 | 351 if [ -n "$outputfile" ]; then |
352 octfile="$outputfile" | |
9957
59ed11557715
mkoctfile: if output file is specified and it does not end in output_ext, append output_ext
John W. Eaton <jwe@octave.org>
parents:
9956
diff
changeset
|
353 case "$octfile" in |
59ed11557715
mkoctfile: if output file is specified and it does not end in output_ext, append output_ext
John W. Eaton <jwe@octave.org>
parents:
9956
diff
changeset
|
354 *$output_ext) |
59ed11557715
mkoctfile: if output file is specified and it does not end in output_ext, append output_ext
John W. Eaton <jwe@octave.org>
parents:
9956
diff
changeset
|
355 ;; |
59ed11557715
mkoctfile: if output file is specified and it does not end in output_ext, append output_ext
John W. Eaton <jwe@octave.org>
parents:
9956
diff
changeset
|
356 *) |
59ed11557715
mkoctfile: if output file is specified and it does not end in output_ext, append output_ext
John W. Eaton <jwe@octave.org>
parents:
9956
diff
changeset
|
357 octfile="$octfile$output_ext" |
59ed11557715
mkoctfile: if output file is specified and it does not end in output_ext, append output_ext
John W. Eaton <jwe@octave.org>
parents:
9956
diff
changeset
|
358 ;; |
59ed11557715
mkoctfile: if output file is specified and it does not end in output_ext, append output_ext
John W. Eaton <jwe@octave.org>
parents:
9956
diff
changeset
|
359 esac |
3860 | 360 else |
6187 | 361 octfile=`basename $octfile` |
5864 | 362 octfile=`echo $octfile | $SED 's,\.[^.]*$,,'`$output_ext |
3860 | 363 fi |
3859 | 364 fi |
365 | |
3846 | 366 # Generate dependency files for C and C++ files. |
367 | |
368 if $depend; then | |
369 if [ -n "$cfiles" ]; then | |
370 for f in $cfiles; do | |
4084 | 371 b=`echo $f | $SED 's,\.c$,,'` |
3846 | 372 d=$b.d |
3847 | 373 cmd="rm -f $d" |
374 $dbg $cmd | |
375 eval $cmd | |
4206 | 376 cmd="$CC $DEPEND_FLAGS $CPPFLAGS $ALL_CFLAGS $incflags $def $f | $SED $DEPEND_EXTRA_SED_PATTERN -e 's,^[^:]*/\(.*\.o\):,\1:,' -e 's,$b\.o,pic/& & $d,g' > $d-t && mv $d-t $d" |
3846 | 377 $dbg $cmd |
378 eval $cmd | |
379 done | |
380 fi | |
381 | |
382 if [ -n "$ccfiles" ]; then | |
383 for f in $ccfiles; do | |
384 case $f in | |
3847 | 385 *.cc) |
4084 | 386 b=`echo $f | $SED 's,\.cc$,,'` |
3847 | 387 ;; |
388 *.C) | |
4084 | 389 b=`echo $f | $SED 's,\.C$,,'` |
3847 | 390 ;; |
391 *.cpp) | |
4084 | 392 b=`echo $f | $SED 's,\.cpp$,,'` |
3847 | 393 ;; |
3846 | 394 esac |
395 d=$b.d | |
3847 | 396 cmd="rm -f $d" |
397 $dbg $cmd | |
398 eval $cmd | |
4206 | 399 cmd="$CXX $DEPEND_FLAGS $CPPFLAGS $ALL_CXXFLAGS $incflags $defs $f | $SED $DEPEND_EXTRA_SED_PATTERN -e 's,^[^:]*/\(.*\.o\):,\1:,' -e 's,$b\.o,pic/& & $d,g' > $d-t && mv $d-t $d" |
3846 | 400 $dbg $cmd |
401 eval $cmd | |
402 done | |
403 fi | |
404 # If generating dependencies, that's all we do. | |
405 exit 0 | |
406 fi | |
407 | |
3051 | 408 # Compile Fortran, C, and C++ files. Add the name of each object file |
409 # that is produced to the overall list of object files. | |
2163 | 410 |
3051 | 411 if [ -n "$f77files" ]; then |
412 for f in $f77files; do | |
413 case $f in | |
414 *.f) | |
9956
f26a33e21db9
mkoctfile: when compiling files in subdirectories, place object files in current directory by default
John W. Eaton <jwe@octave.org>
parents:
9954
diff
changeset
|
415 b=`echo $f | $SED 's,.*/,,; s,\.f$,,'` |
3051 | 416 ;; |
417 *.F) | |
9956
f26a33e21db9
mkoctfile: when compiling files in subdirectories, place object files in current directory by default
John W. Eaton <jwe@octave.org>
parents:
9954
diff
changeset
|
418 b=`echo $f | $SED 's,.*/,,; s,\.F$,,'` |
3051 | 419 ;; |
5970 | 420 *.f90) |
9956
f26a33e21db9
mkoctfile: when compiling files in subdirectories, place object files in current directory by default
John W. Eaton <jwe@octave.org>
parents:
9954
diff
changeset
|
421 b=`echo $f | $SED 's,.*/,,; s,\.f90$,,'` |
5970 | 422 ;; |
423 *.F90) | |
9956
f26a33e21db9
mkoctfile: when compiling files in subdirectories, place object files in current directory by default
John W. Eaton <jwe@octave.org>
parents:
9954
diff
changeset
|
424 b=`echo $f | $SED 's,.*/,,; s,\.F90$,,'` |
5970 | 425 ;; |
3051 | 426 esac |
3847 | 427 if [ -n "$F77" ]; then |
5159 | 428 if [ -n "$outputfile" ]; then |
9187
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
429 if $link; then |
5159 | 430 o=$b.o |
431 else | |
432 o=$outputfile | |
433 fi | |
434 else | |
435 o=$b.o | |
436 fi | |
3847 | 437 objfiles="$objfiles $o" |
5970 | 438 cmd="$F77 -c $FPICFLAG $ALL_FFLAGS $incflags $defs $pass_on_options $f -o $o" |
3847 | 439 $dbg $cmd |
440 eval $cmd | |
441 else | |
442 echo "mkoctfile: no way to compile Fortran file $f" 1>&2 | |
443 fi | |
3051 | 444 done |
445 fi | |
2163 | 446 |
3051 | 447 if [ -n "$cfiles" ]; then |
448 for f in $cfiles; do | |
3847 | 449 if [ -n "$CC" ]; then |
9956
f26a33e21db9
mkoctfile: when compiling files in subdirectories, place object files in current directory by default
John W. Eaton <jwe@octave.org>
parents:
9954
diff
changeset
|
450 b=`echo $f | $SED 's,.*/,,; s,\.c$,,'` |
5159 | 451 if [ -n "$outputfile" ]; then |
452 if $link; then | |
453 o=$b.o | |
454 else | |
455 o=$outputfile | |
456 fi | |
457 else | |
458 o=$b.o | |
459 fi | |
3847 | 460 objfiles="$objfiles $o" |
4873 | 461 cmd="$CC -c $CPPFLAGS $CPICFLAG $ALL_CFLAGS $pass_on_options $incflags $defs $f -o $o" |
3847 | 462 $dbg $cmd |
463 eval $cmd | |
464 else | |
465 echo "mkoctfile: no way to compile C++ file $f" 1>&2 | |
466 fi | |
3051 | 467 done |
468 fi | |
2163 | 469 |
3051 | 470 if [ -n "$ccfiles" ]; then |
471 for f in $ccfiles; do | |
3847 | 472 if [ -n "$CXX" ]; then |
473 case $f in | |
474 *.cc) | |
9956
f26a33e21db9
mkoctfile: when compiling files in subdirectories, place object files in current directory by default
John W. Eaton <jwe@octave.org>
parents:
9954
diff
changeset
|
475 b=`echo $f | $SED 's,.*/,,; s,\.cc$,,'` |
3847 | 476 ;; |
477 *.C) | |
9956
f26a33e21db9
mkoctfile: when compiling files in subdirectories, place object files in current directory by default
John W. Eaton <jwe@octave.org>
parents:
9954
diff
changeset
|
478 b=`echo $f | $SED 's,.*/,,; s,\.C$,,'` |
3847 | 479 ;; |
480 *.cpp) | |
9956
f26a33e21db9
mkoctfile: when compiling files in subdirectories, place object files in current directory by default
John W. Eaton <jwe@octave.org>
parents:
9954
diff
changeset
|
481 b=`echo $f | $SED 's,.*/,,; s,\.cpp$,,'` |
3847 | 482 ;; |
483 esac | |
5159 | 484 if [ -n "$outputfile" ]; then |
485 if $link; then | |
486 o=$b.o | |
487 else | |
488 o=$outputfile | |
489 fi | |
490 else | |
491 o=$b.o | |
492 fi | |
3847 | 493 objfiles="$objfiles $o" |
4873 | 494 cmd="$CXX -c $CPPFLAGS $CXXPICFLAG $ALL_CXXFLAGS $pass_on_options $incflags $defs $f -o $o" |
3847 | 495 $dbg $cmd |
496 eval $cmd | |
497 else | |
498 echo "mkoctfile: no way to compile C++ file $f" 1>&2 | |
499 fi | |
3051 | 500 done |
501 fi | |
502 | |
3660 | 503 ## Uncomment the following group of lines if you get `Text file busy' |
504 ## errors from ld. This may happen if the .oct file is currently | |
505 ## running while you are trying to recompile it. We try moving first, | |
3733 | 506 ## since on some systems (HP-UX, maybe others) it is possible to |
3660 | 507 ## rename running programs but not remove them. |
508 | |
3663 | 509 ## if [ -f "$octfile" ]; then |
3847 | 510 ## cmd="mv $octfile $octfile.bak" |
511 ## $dbg $cmd | |
512 ## eval $cmd | |
513 ## cmd="rm -f $octfile.bak" | |
514 ## $dbg $cmd | |
515 ## eval $cmd | |
3663 | 516 ## fi |
3659 | 517 |
3051 | 518 # Link all the object files. |
519 | |
5285 | 520 if $link && [ -n "$objfiles" ]; then |
3859 | 521 if $link_stand_alone; then |
522 if [ -n "$LD_CXX" ]; then | |
9515 | 523 cmd="$LD_CXX $CPPFLAGS $ALL_CXXFLAGS $RDYNAMIC_FLAG $ALL_LDFLAGS $pass_on_options $output_option $objfiles $libfiles $ldflags $LFLAGS $RLD_FLAG $OCTAVE_LIBS $BLAS_LIBS $FFTW_LIBS $READLINE_LIBS $LIBS $FLIBS" |
3859 | 524 $dbg $cmd |
525 eval $cmd | |
526 else | |
527 echo "mkoctfile: no way to link stand-alone executable file" 1>&2 | |
528 exit 1 | |
529 fi | |
530 else | |
4793 | 531 LINK_DEPS="$LFLAGS $OCTAVE_LIBS $LDFLAGS $BLAS_LIBS $FFTW_LIBS $LIBS $FLIBS" |
6294 | 532 cmd="$DL_LD $DL_LDFLAGS $pass_on_options -o $octfile $objfiles $libfiles $ldflags $LINK_DEPS" |
3859 | 533 $dbg $cmd |
534 eval $cmd | |
535 fi | |
3058 | 536 |
537 # Maybe strip it. | |
538 | |
3847 | 539 if $strip; then |
540 cmd="strip $octfile" | |
541 $dbg $cmd | |
542 eval $cmd | |
543 fi | |
3735 | 544 fi |
3058 | 545 |
546 exit 0 |