Mercurial > hg > octave-nkf
annotate mkoctfile.in @ 11273:bd2643f0ce57 ss-3-3-54
snapshot 3.3.54
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 19 Nov 2010 16:05:58 -0500 |
parents | 860427ac9b77 |
children | 5eb10763069f |
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} |
10773
cd16c1c3bc73
fix F77_INTEGER_8_FLAG problem in mkoctfile.in
Jaroslav Hajek <highegg@gmail.com>
parents:
10721
diff
changeset
|
106 : ${F77_INTEGER_8_FLAG=%OCTAVE_CONF_F77_INTEGER_8_FLAG%} |
3859 | 107 |
10721
4906ccf5d95e
use F77_INTEGER8_FLAG in BLAS checking as well as ALL_FFLAGS in mkoctfile
Jaroslav Hajek <highegg@gmail.com>
parents:
9957
diff
changeset
|
108 : ${ALL_FFLAGS="$FFLAGS $F77_INTEGER_8_FLAG"} |
3051 | 109 |
3131 | 110 : ${ALL_CFLAGS="$INCFLAGS $XTRA_CFLAGS $CFLAGS"} |
3051 | 111 |
3131 | 112 : ${ALL_CXXFLAGS="$INCFLAGS $XTRA_CXXFLAGS $CXXFLAGS"} |
3051 | 113 |
3887 | 114 : ${ALL_LDFLAGS="$LD_STATIC_FLAG $CPICFLAG $LDFLAGS"} |
3859 | 115 |
4228 | 116 : ${OCTAVE_LIBS="$LIBOCTINTERP $LIBOCTAVE $SPECIAL_MATH_LIB $LIBCRUFT"} |
3859 | 117 |
3051 | 118 # Local variables. |
119 | |
9538
d0239bddf621
use OCTAVE_CHECK_LIB to check for zlib
John W. Eaton <jwe@octave.org>
parents:
9515
diff
changeset
|
120 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
|
121 |
3051 | 122 usage_msg="usage: mkoctfile [options] file ..." |
123 | |
5285 | 124 version_msg="mkoctfile, version $OCTAVE_VERSION" |
125 | |
3051 | 126 cfiles= |
127 ccfiles= | |
128 f77files= | |
129 objfiles= | |
6294 | 130 libfiles= |
3051 | 131 octfiles= |
132 octfile= | |
3860 | 133 outputfile= |
3088 | 134 incflags= |
3180 | 135 defs= |
3051 | 136 ldflags= |
137 dbg=: | |
4873 | 138 pass_on_options= |
3058 | 139 strip=false |
4199 | 140 no_oct_file_strip_on_this_platform=%NO_OCT_FILE_STRIP% |
3735 | 141 link=true |
3859 | 142 link_stand_alone=false |
5864 | 143 output_ext=".oct" |
3846 | 144 depend=false |
145 compile=true | |
3051 | 146 |
147 if [ $# -eq 0 ]; then | |
3847 | 148 echo $usage_msg 1>&2 |
3846 | 149 exit 1 |
2163 | 150 fi |
151 | |
5285 | 152 if [ $# -eq 1 ]; then |
153 case "$1" in | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
154 -v | -version | --version) |
5285 | 155 echo $version_msg 1>&2 |
156 exit 0 | |
157 ;; | |
158 esac | |
159 fi | |
160 | |
3051 | 161 while [ $# -gt 0 ]; do |
162 file= | |
163 case "$1" in | |
164 *.c) | |
165 file=$1 | |
166 cfiles="$cfiles $file" | |
167 ;; | |
168 *.cc | *.C | *.cpp) | |
169 file=$1 | |
170 ccfiles="$ccfiles $file" | |
171 ;; | |
5970 | 172 *.f | *.F | *.f90 | *.F90) |
3051 | 173 file=$1 |
174 f77files="$f77files $file" | |
175 ;; | |
176 *.o) | |
177 file=$1 | |
178 objfiles="$objfiles $file" | |
179 ;; | |
6294 | 180 *.a) |
181 file=$1 | |
182 libfiles="$libfiles $file" | |
183 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
184 -d | -debug | --debug | -v | -verbose | --verbose) |
3051 | 185 dbg=echo |
186 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
187 -h | -\? | -help | --help) |
3847 | 188 echo $usage_msg 1>&2 |
3051 | 189 cat << EOF |
2163 | 190 |
3051 | 191 Options: |
192 | |
3233 | 193 -h, -?, --help Print this message. |
3734 | 194 |
3088 | 195 -IDIR Add -IDIR to compile commands. |
3734 | 196 |
5483 | 197 -idirafter DIR Add -idirafter DIR to compile commands. |
198 | |
3180 | 199 -DDEF Add -DDEF to compile commands. |
3734 | 200 |
3058 | 201 -lLIB Add library LIB to link command. |
3734 | 202 |
3087 | 203 -LDIR Add -LDIR to link command. |
3734 | 204 |
3846 | 205 -M, --depend Generate dependency files (.d) for C and C++ |
206 source files. | |
207 | |
5199 | 208 -RDIR Add -RDIR to link command. |
209 | |
6153 | 210 -Wl,... Pass flags though the linker like -Wl,-rpath=... |
211 | |
212 -W... Pass flags though the compiler like -Wa,OPTION. | |
5199 | 213 |
3859 | 214 -c, --compile Compile, but do not link. |
3735 | 215 |
3859 | 216 -o FILE, --output FILE Output file name. Default extension is .oct |
5864 | 217 (or .mex if --mex is specified) unless linking |
218 a stand-alone executable. | |
3734 | 219 |
5904 | 220 -g Enable debugging options for compilers. |
221 | |
3734 | 222 -p VAR, --print VAR Print configuration variable VAR. Recognized |
223 variables are: | |
224 | |
9187
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
225 ALL_CFLAGS FLIBS |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
226 ALL_CXXFLAGS FPICFLAG |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
227 ALL_FFLAGS INCFLAGS |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
228 ALL_LDFLAGS LDFLAGS |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
229 BLAS_LIBS LD_CXX |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
230 CC LD_STATIC_FLAG |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
231 CFLAGS LFLAGS |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
232 CPICFLAG LIBCRUFT |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
233 CPPFLAGS LIBOCTAVE |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
234 CXX LIBOCTINTERP |
9515 | 235 CXXFLAGS LIBS |
236 CXXPICFLAG OCTAVE_LIBS | |
237 DEPEND_EXTRA_SED_PATTERN RDYNAMIC_FLAG | |
238 DEPEND_FLAGS READLINE_LIBS | |
9187
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
239 DL_LD RLD_FLAG |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
240 DL_LDFLAGS SED |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
241 F77 XTRA_CFLAGS |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
242 FFLAGS XTRA_CXXFLAGS |
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
243 FFTW_LIBS |
3859 | 244 |
245 --link-stand-alone Link a stand-alone executable file. | |
246 | |
5864 | 247 --mex Assume we are creating a MEX file. Set the |
248 default output extension to ".mex". | |
249 | |
3058 | 250 -s, --strip Strip output file. |
3734 | 251 |
3058 | 252 -v, --verbose Echo commands as they are executed. |
3051 | 253 |
254 FILE Compile or link FILE. Recognized file types are: | |
255 | |
3847 | 256 .c C source |
257 .cc C++ source | |
258 .C C++ source | |
259 .cpp C++ source | |
5970 | 260 .f Fortran source (fixed form) |
261 .F Fortran source (fixed form) | |
262 .f90 Fortran source (free form) | |
263 .F90 Fortran source (free form) | |
3847 | 264 .o object file |
6294 | 265 .a library file |
2163 | 266 |
3051 | 267 EOF |
268 exit 0 | |
269 ;; | |
3088 | 270 -I*) |
3176 | 271 incflags="$incflags $1" |
3088 | 272 ;; |
5483 | 273 -idirafter) |
274 shift | |
275 if [ $# -gt 0 ]; then | |
276 incflags="$incflags -idirafter $1" | |
277 else | |
6782 | 278 echo "mkoctfile: include directory name missing" 1>&2 |
5483 | 279 fi |
280 ;; | |
3180 | 281 -D*) |
282 defs="$defs $1" | |
283 ;; | |
6153 | 284 -[lLR]* | -Wl,*) |
3176 | 285 ldflags="$ldflags $1" |
3058 | 286 ;; |
10901
860427ac9b77
Add ability to pass -pthread through to linker in mkoctfile.
Rik <octave@nomad.inbox5.com>
parents:
10773
diff
changeset
|
287 -pthread) |
860427ac9b77
Add ability to pass -pthread through to linker in mkoctfile.
Rik <octave@nomad.inbox5.com>
parents:
10773
diff
changeset
|
288 ldflags="$ldflags $1" |
860427ac9b77
Add ability to pass -pthread through to linker in mkoctfile.
Rik <octave@nomad.inbox5.com>
parents:
10773
diff
changeset
|
289 ;; |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
290 -M | -depend | --depend) |
3846 | 291 depend=true |
292 compile=false | |
293 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
294 -o | -ouput | --output) |
3051 | 295 shift |
296 if [ $# -gt 0 ]; then | |
3860 | 297 outputfile="$1" |
3051 | 298 else |
3847 | 299 echo "mkoctfile: output file name missing" 1>&2 |
3051 | 300 fi |
301 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
302 -p | -print | --print) |
3734 | 303 shift |
304 if [ $# -gt 0 ]; then | |
305 eval echo \${$1} | |
306 exit 0 | |
307 else | |
3847 | 308 echo "mkoctfile: --print requires argument" 1>&2 |
3734 | 309 exit 1 |
310 fi | |
311 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
312 -s | -strip | --strip) |
4199 | 313 if $no_oct_file_strip_on_this_platform; then |
314 echo "mkoctfile: stripping disabled on this platform" 1>&2 | |
315 else | |
316 strip=true | |
317 fi | |
3051 | 318 ;; |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
319 -c | -compile | --compile) |
3735 | 320 link=false |
321 ;; | |
5904 | 322 -g) |
323 ALL_CFLAGS="$ALL_CFLAGS -g" | |
324 ALL_CXXFLAGS="$ALL_CXXFLAGS -g" | |
325 ALL_FFLAGS="$ALL_FFLAGS -g" | |
326 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
327 -link-stand-alone | --link-stand-alone) |
3859 | 328 link_stand_alone=true |
329 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
330 -mex | --mex) |
6009 | 331 incflags="$incflags -I." |
5864 | 332 output_ext=".mex" |
333 ;; | |
4873 | 334 -W*) |
335 pass_on_options="$pass_on_options $1" | |
336 ;; | |
3051 | 337 *) |
3847 | 338 echo "mkoctfile: unrecognized argument $1" 1>&2 |
3051 | 339 exit 1 |
340 ;; | |
341 esac | |
342 if [ -n "$file" ]; then | |
343 if [ -z "$octfile" ]; then | |
3859 | 344 octfile="$file" |
3051 | 345 fi |
346 fi | |
347 shift | |
348 done | |
2163 | 349 |
3859 | 350 if $link_stand_alone; then |
3860 | 351 if [ -n "$outputfile" ]; then |
352 output_option="-o $outputfile" | |
353 fi | |
3859 | 354 else |
3860 | 355 if [ -n "$outputfile" ]; then |
356 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
|
357 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
|
358 *$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
|
359 ;; |
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
|
360 *) |
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
|
361 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
|
362 ;; |
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
|
363 esac |
3860 | 364 else |
6187 | 365 octfile=`basename $octfile` |
5864 | 366 octfile=`echo $octfile | $SED 's,\.[^.]*$,,'`$output_ext |
3860 | 367 fi |
3859 | 368 fi |
369 | |
3846 | 370 # Generate dependency files for C and C++ files. |
371 | |
372 if $depend; then | |
373 if [ -n "$cfiles" ]; then | |
374 for f in $cfiles; do | |
4084 | 375 b=`echo $f | $SED 's,\.c$,,'` |
3846 | 376 d=$b.d |
3847 | 377 cmd="rm -f $d" |
378 $dbg $cmd | |
379 eval $cmd | |
4206 | 380 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 | 381 $dbg $cmd |
382 eval $cmd | |
383 done | |
384 fi | |
385 | |
386 if [ -n "$ccfiles" ]; then | |
387 for f in $ccfiles; do | |
388 case $f in | |
3847 | 389 *.cc) |
4084 | 390 b=`echo $f | $SED 's,\.cc$,,'` |
3847 | 391 ;; |
392 *.C) | |
4084 | 393 b=`echo $f | $SED 's,\.C$,,'` |
3847 | 394 ;; |
395 *.cpp) | |
4084 | 396 b=`echo $f | $SED 's,\.cpp$,,'` |
3847 | 397 ;; |
3846 | 398 esac |
399 d=$b.d | |
3847 | 400 cmd="rm -f $d" |
401 $dbg $cmd | |
402 eval $cmd | |
4206 | 403 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 | 404 $dbg $cmd |
405 eval $cmd | |
406 done | |
407 fi | |
408 # If generating dependencies, that's all we do. | |
409 exit 0 | |
410 fi | |
411 | |
3051 | 412 # Compile Fortran, C, and C++ files. Add the name of each object file |
413 # that is produced to the overall list of object files. | |
2163 | 414 |
3051 | 415 if [ -n "$f77files" ]; then |
416 for f in $f77files; do | |
417 case $f in | |
418 *.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
|
419 b=`echo $f | $SED 's,.*/,,; s,\.f$,,'` |
3051 | 420 ;; |
421 *.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
|
422 b=`echo $f | $SED 's,.*/,,; s,\.F$,,'` |
3051 | 423 ;; |
5970 | 424 *.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
|
425 b=`echo $f | $SED 's,.*/,,; s,\.f90$,,'` |
5970 | 426 ;; |
427 *.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
|
428 b=`echo $f | $SED 's,.*/,,; s,\.F90$,,'` |
5970 | 429 ;; |
3051 | 430 esac |
3847 | 431 if [ -n "$F77" ]; then |
5159 | 432 if [ -n "$outputfile" ]; then |
9187
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
433 if $link; then |
5159 | 434 o=$b.o |
435 else | |
436 o=$outputfile | |
437 fi | |
438 else | |
439 o=$b.o | |
440 fi | |
3847 | 441 objfiles="$objfiles $o" |
5970 | 442 cmd="$F77 -c $FPICFLAG $ALL_FFLAGS $incflags $defs $pass_on_options $f -o $o" |
3847 | 443 $dbg $cmd |
444 eval $cmd | |
445 else | |
446 echo "mkoctfile: no way to compile Fortran file $f" 1>&2 | |
447 fi | |
3051 | 448 done |
449 fi | |
2163 | 450 |
3051 | 451 if [ -n "$cfiles" ]; then |
452 for f in $cfiles; do | |
3847 | 453 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
|
454 b=`echo $f | $SED 's,.*/,,; s,\.c$,,'` |
5159 | 455 if [ -n "$outputfile" ]; then |
456 if $link; then | |
457 o=$b.o | |
458 else | |
459 o=$outputfile | |
460 fi | |
461 else | |
462 o=$b.o | |
463 fi | |
3847 | 464 objfiles="$objfiles $o" |
4873 | 465 cmd="$CC -c $CPPFLAGS $CPICFLAG $ALL_CFLAGS $pass_on_options $incflags $defs $f -o $o" |
3847 | 466 $dbg $cmd |
467 eval $cmd | |
468 else | |
469 echo "mkoctfile: no way to compile C++ file $f" 1>&2 | |
470 fi | |
3051 | 471 done |
472 fi | |
2163 | 473 |
3051 | 474 if [ -n "$ccfiles" ]; then |
475 for f in $ccfiles; do | |
3847 | 476 if [ -n "$CXX" ]; then |
477 case $f in | |
478 *.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
|
479 b=`echo $f | $SED 's,.*/,,; s,\.cc$,,'` |
3847 | 480 ;; |
481 *.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
|
482 b=`echo $f | $SED 's,.*/,,; s,\.C$,,'` |
3847 | 483 ;; |
484 *.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
|
485 b=`echo $f | $SED 's,.*/,,; s,\.cpp$,,'` |
3847 | 486 ;; |
487 esac | |
5159 | 488 if [ -n "$outputfile" ]; then |
489 if $link; then | |
490 o=$b.o | |
491 else | |
492 o=$outputfile | |
493 fi | |
494 else | |
495 o=$b.o | |
496 fi | |
3847 | 497 objfiles="$objfiles $o" |
4873 | 498 cmd="$CXX -c $CPPFLAGS $CXXPICFLAG $ALL_CXXFLAGS $pass_on_options $incflags $defs $f -o $o" |
3847 | 499 $dbg $cmd |
500 eval $cmd | |
501 else | |
502 echo "mkoctfile: no way to compile C++ file $f" 1>&2 | |
503 fi | |
3051 | 504 done |
505 fi | |
506 | |
3660 | 507 ## Uncomment the following group of lines if you get `Text file busy' |
508 ## errors from ld. This may happen if the .oct file is currently | |
509 ## running while you are trying to recompile it. We try moving first, | |
3733 | 510 ## since on some systems (HP-UX, maybe others) it is possible to |
3660 | 511 ## rename running programs but not remove them. |
512 | |
3663 | 513 ## if [ -f "$octfile" ]; then |
3847 | 514 ## cmd="mv $octfile $octfile.bak" |
515 ## $dbg $cmd | |
516 ## eval $cmd | |
517 ## cmd="rm -f $octfile.bak" | |
518 ## $dbg $cmd | |
519 ## eval $cmd | |
3663 | 520 ## fi |
3659 | 521 |
3051 | 522 # Link all the object files. |
523 | |
5285 | 524 if $link && [ -n "$objfiles" ]; then |
3859 | 525 if $link_stand_alone; then |
526 if [ -n "$LD_CXX" ]; then | |
9515 | 527 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 | 528 $dbg $cmd |
529 eval $cmd | |
530 else | |
531 echo "mkoctfile: no way to link stand-alone executable file" 1>&2 | |
532 exit 1 | |
533 fi | |
534 else | |
4793 | 535 LINK_DEPS="$LFLAGS $OCTAVE_LIBS $LDFLAGS $BLAS_LIBS $FFTW_LIBS $LIBS $FLIBS" |
6294 | 536 cmd="$DL_LD $DL_LDFLAGS $pass_on_options -o $octfile $objfiles $libfiles $ldflags $LINK_DEPS" |
3859 | 537 $dbg $cmd |
538 eval $cmd | |
539 fi | |
3058 | 540 |
541 # Maybe strip it. | |
542 | |
3847 | 543 if $strip; then |
544 cmd="strip $octfile" | |
545 $dbg $cmd | |
546 eval $cmd | |
547 fi | |
3735 | 548 fi |
3058 | 549 |
550 exit 0 |