Mercurial > octave-nkf
annotate mkoctfile.in @ 10843:229675bb7647 ss-3-3-52
version is now 3.3.52
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 01 Aug 2010 11:49:45 -0400 |
parents | cd16c1c3bc73 |
children | 860427ac9b77 |
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 ;; |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
287 -M | -depend | --depend) |
3846 | 288 depend=true |
289 compile=false | |
290 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
291 -o | -ouput | --output) |
3051 | 292 shift |
293 if [ $# -gt 0 ]; then | |
3860 | 294 outputfile="$1" |
3051 | 295 else |
3847 | 296 echo "mkoctfile: output file name missing" 1>&2 |
3051 | 297 fi |
298 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
299 -p | -print | --print) |
3734 | 300 shift |
301 if [ $# -gt 0 ]; then | |
302 eval echo \${$1} | |
303 exit 0 | |
304 else | |
3847 | 305 echo "mkoctfile: --print requires argument" 1>&2 |
3734 | 306 exit 1 |
307 fi | |
308 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
309 -s | -strip | --strip) |
4199 | 310 if $no_oct_file_strip_on_this_platform; then |
311 echo "mkoctfile: stripping disabled on this platform" 1>&2 | |
312 else | |
313 strip=true | |
314 fi | |
3051 | 315 ;; |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
316 -c | -compile | --compile) |
3735 | 317 link=false |
318 ;; | |
5904 | 319 -g) |
320 ALL_CFLAGS="$ALL_CFLAGS -g" | |
321 ALL_CXXFLAGS="$ALL_CXXFLAGS -g" | |
322 ALL_FFLAGS="$ALL_FFLAGS -g" | |
323 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
324 -link-stand-alone | --link-stand-alone) |
3859 | 325 link_stand_alone=true |
326 ;; | |
9954
de6b6173c990
mkoctfile.in: accept long options with single -
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
327 -mex | --mex) |
6009 | 328 incflags="$incflags -I." |
5864 | 329 output_ext=".mex" |
330 ;; | |
4873 | 331 -W*) |
332 pass_on_options="$pass_on_options $1" | |
333 ;; | |
3051 | 334 *) |
3847 | 335 echo "mkoctfile: unrecognized argument $1" 1>&2 |
3051 | 336 exit 1 |
337 ;; | |
338 esac | |
339 if [ -n "$file" ]; then | |
340 if [ -z "$octfile" ]; then | |
3859 | 341 octfile="$file" |
3051 | 342 fi |
343 fi | |
344 shift | |
345 done | |
2163 | 346 |
3859 | 347 if $link_stand_alone; then |
3860 | 348 if [ -n "$outputfile" ]; then |
349 output_option="-o $outputfile" | |
350 fi | |
3859 | 351 else |
3860 | 352 if [ -n "$outputfile" ]; then |
353 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
|
354 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
|
355 *$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
|
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 *) |
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 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
|
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 esac |
3860 | 361 else |
6187 | 362 octfile=`basename $octfile` |
5864 | 363 octfile=`echo $octfile | $SED 's,\.[^.]*$,,'`$output_ext |
3860 | 364 fi |
3859 | 365 fi |
366 | |
3846 | 367 # Generate dependency files for C and C++ files. |
368 | |
369 if $depend; then | |
370 if [ -n "$cfiles" ]; then | |
371 for f in $cfiles; do | |
4084 | 372 b=`echo $f | $SED 's,\.c$,,'` |
3846 | 373 d=$b.d |
3847 | 374 cmd="rm -f $d" |
375 $dbg $cmd | |
376 eval $cmd | |
4206 | 377 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 | 378 $dbg $cmd |
379 eval $cmd | |
380 done | |
381 fi | |
382 | |
383 if [ -n "$ccfiles" ]; then | |
384 for f in $ccfiles; do | |
385 case $f in | |
3847 | 386 *.cc) |
4084 | 387 b=`echo $f | $SED 's,\.cc$,,'` |
3847 | 388 ;; |
389 *.C) | |
4084 | 390 b=`echo $f | $SED 's,\.C$,,'` |
3847 | 391 ;; |
392 *.cpp) | |
4084 | 393 b=`echo $f | $SED 's,\.cpp$,,'` |
3847 | 394 ;; |
3846 | 395 esac |
396 d=$b.d | |
3847 | 397 cmd="rm -f $d" |
398 $dbg $cmd | |
399 eval $cmd | |
4206 | 400 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 | 401 $dbg $cmd |
402 eval $cmd | |
403 done | |
404 fi | |
405 # If generating dependencies, that's all we do. | |
406 exit 0 | |
407 fi | |
408 | |
3051 | 409 # Compile Fortran, C, and C++ files. Add the name of each object file |
410 # that is produced to the overall list of object files. | |
2163 | 411 |
3051 | 412 if [ -n "$f77files" ]; then |
413 for f in $f77files; do | |
414 case $f in | |
415 *.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
|
416 b=`echo $f | $SED 's,.*/,,; s,\.f$,,'` |
3051 | 417 ;; |
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 ;; |
5970 | 421 *.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
|
422 b=`echo $f | $SED 's,.*/,,; s,\.f90$,,'` |
5970 | 423 ;; |
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 ;; |
3051 | 427 esac |
3847 | 428 if [ -n "$F77" ]; then |
5159 | 429 if [ -n "$outputfile" ]; then |
9187
a3237ae32c0d
eliminate last remnants of F2C variables
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
430 if $link; then |
5159 | 431 o=$b.o |
432 else | |
433 o=$outputfile | |
434 fi | |
435 else | |
436 o=$b.o | |
437 fi | |
3847 | 438 objfiles="$objfiles $o" |
5970 | 439 cmd="$F77 -c $FPICFLAG $ALL_FFLAGS $incflags $defs $pass_on_options $f -o $o" |
3847 | 440 $dbg $cmd |
441 eval $cmd | |
442 else | |
443 echo "mkoctfile: no way to compile Fortran file $f" 1>&2 | |
444 fi | |
3051 | 445 done |
446 fi | |
2163 | 447 |
3051 | 448 if [ -n "$cfiles" ]; then |
449 for f in $cfiles; do | |
3847 | 450 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
|
451 b=`echo $f | $SED 's,.*/,,; s,\.c$,,'` |
5159 | 452 if [ -n "$outputfile" ]; then |
453 if $link; then | |
454 o=$b.o | |
455 else | |
456 o=$outputfile | |
457 fi | |
458 else | |
459 o=$b.o | |
460 fi | |
3847 | 461 objfiles="$objfiles $o" |
4873 | 462 cmd="$CC -c $CPPFLAGS $CPICFLAG $ALL_CFLAGS $pass_on_options $incflags $defs $f -o $o" |
3847 | 463 $dbg $cmd |
464 eval $cmd | |
465 else | |
466 echo "mkoctfile: no way to compile C++ file $f" 1>&2 | |
467 fi | |
3051 | 468 done |
469 fi | |
2163 | 470 |
3051 | 471 if [ -n "$ccfiles" ]; then |
472 for f in $ccfiles; do | |
3847 | 473 if [ -n "$CXX" ]; then |
474 case $f in | |
475 *.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
|
476 b=`echo $f | $SED 's,.*/,,; s,\.cc$,,'` |
3847 | 477 ;; |
478 *.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
|
479 b=`echo $f | $SED 's,.*/,,; s,\.C$,,'` |
3847 | 480 ;; |
481 *.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
|
482 b=`echo $f | $SED 's,.*/,,; s,\.cpp$,,'` |
3847 | 483 ;; |
484 esac | |
5159 | 485 if [ -n "$outputfile" ]; then |
486 if $link; then | |
487 o=$b.o | |
488 else | |
489 o=$outputfile | |
490 fi | |
491 else | |
492 o=$b.o | |
493 fi | |
3847 | 494 objfiles="$objfiles $o" |
4873 | 495 cmd="$CXX -c $CPPFLAGS $CXXPICFLAG $ALL_CXXFLAGS $pass_on_options $incflags $defs $f -o $o" |
3847 | 496 $dbg $cmd |
497 eval $cmd | |
498 else | |
499 echo "mkoctfile: no way to compile C++ file $f" 1>&2 | |
500 fi | |
3051 | 501 done |
502 fi | |
503 | |
3660 | 504 ## Uncomment the following group of lines if you get `Text file busy' |
505 ## errors from ld. This may happen if the .oct file is currently | |
506 ## running while you are trying to recompile it. We try moving first, | |
3733 | 507 ## since on some systems (HP-UX, maybe others) it is possible to |
3660 | 508 ## rename running programs but not remove them. |
509 | |
3663 | 510 ## if [ -f "$octfile" ]; then |
3847 | 511 ## cmd="mv $octfile $octfile.bak" |
512 ## $dbg $cmd | |
513 ## eval $cmd | |
514 ## cmd="rm -f $octfile.bak" | |
515 ## $dbg $cmd | |
516 ## eval $cmd | |
3663 | 517 ## fi |
3659 | 518 |
3051 | 519 # Link all the object files. |
520 | |
5285 | 521 if $link && [ -n "$objfiles" ]; then |
3859 | 522 if $link_stand_alone; then |
523 if [ -n "$LD_CXX" ]; then | |
9515 | 524 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 | 525 $dbg $cmd |
526 eval $cmd | |
527 else | |
528 echo "mkoctfile: no way to link stand-alone executable file" 1>&2 | |
529 exit 1 | |
530 fi | |
531 else | |
4793 | 532 LINK_DEPS="$LFLAGS $OCTAVE_LIBS $LDFLAGS $BLAS_LIBS $FFTW_LIBS $LIBS $FLIBS" |
6294 | 533 cmd="$DL_LD $DL_LDFLAGS $pass_on_options -o $octfile $objfiles $libfiles $ldflags $LINK_DEPS" |
3859 | 534 $dbg $cmd |
535 eval $cmd | |
536 fi | |
3058 | 537 |
538 # Maybe strip it. | |
539 | |
3847 | 540 if $strip; then |
541 cmd="strip $octfile" | |
542 $dbg $cmd | |
543 eval $cmd | |
544 fi | |
3735 | 545 fi |
3058 | 546 |
547 exit 0 |