1232
|
1 dnl aclocal.m4 -- extra macros for configuring Octave |
|
2 dnl |
1885
|
3 dnl Copyright (C) 1996 John W. Eaton |
1232
|
4 dnl |
|
5 dnl This file is part of Octave. |
|
6 dnl |
|
7 dnl Octave is free software; you can redistribute it and/or modify it |
|
8 dnl under the terms of the GNU General Public License as published by the |
|
9 dnl Free Software Foundation; either version 2, or (at your option) any |
|
10 dnl later version. |
|
11 dnl |
|
12 dnl Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 dnl ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 dnl FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 dnl for more details. |
|
16 dnl |
|
17 dnl You should have received a copy of the GNU General Public License |
|
18 dnl along with Octave; see the file COPYING. If not, write to the Free |
1315
|
19 dnl Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1232
|
20 |
|
21 dnl See what libraries are used by the C++ compiler. Need this for |
|
22 dnl dynamic linking. |
|
23 dnl |
|
24 dnl Write a minimal program and compile it with -v. I don't know what |
|
25 dnl to do if your compiler doesn't have -v... |
|
26 dnl |
|
27 dnl OCTAVE_CXXLIBS() |
|
28 AC_DEFUN(OCTAVE_CXXLIBS, |
|
29 [AC_REQUIRE([AC_PROG_CXXCPP]) |
|
30 AC_REQUIRE([AC_PROG_CXX]) |
|
31 AC_MSG_CHECKING([for C++ libraries]) |
|
32 AC_CACHE_VAL(octave_cv_cxxlibs, |
|
33 [AC_LANG_SAVE |
|
34 AC_LANG_CPLUSPLUS |
|
35 XCXXFLAGS="$CXXFLAGS" |
|
36 CXXFLAGS="$XCXXFLAGS -v" |
|
37 export CXXFLAGS |
|
38 dnl |
|
39 dnl This may be too tricky and break with future autoconf releases, |
|
40 dnl but it works with version 2.3, even with the Ultrix /bin/sh. |
|
41 dnl |
|
42 dnl I don't think that stripping commas out of this will ever hurt. |
|
43 dnl |
|
44 coutput=`( AC_TRY_LINK([], [], []) ) AC_FD_CC>&1 | sed 's/,/ /g'` |
|
45 CXXFLAGS="$XCXXFLAGS" |
|
46 AC_LANG_RESTORE |
|
47 changequote(, )dnl |
|
48 dnl |
|
49 octave_cv_cxxlibs= |
|
50 lflags= |
|
51 want_arg= |
|
52 dnl |
|
53 for arg in $coutput; do |
|
54 if test x$want_arg = x; then |
|
55 want_arg= |
|
56 case $arg in |
|
57 /*.a) |
|
58 exists=false |
|
59 for f in $lflags; do |
|
60 if test x$arg = x$f; then |
|
61 exists=true |
|
62 fi |
|
63 done |
|
64 if $exists; then |
|
65 arg= |
|
66 else |
|
67 lflags="$lflags $arg" |
|
68 fi |
|
69 ;; |
|
70 -[LR]*) |
|
71 exists=false |
|
72 for f in $lflags; do |
|
73 if test x$arg = x$f; then |
|
74 exists=true |
|
75 fi |
|
76 done |
|
77 ;; |
|
78 -l*) |
|
79 if test x$arg = x-lang-c++; then |
|
80 arg= |
|
81 else |
|
82 lflags="$lflags $arg" |
|
83 fi |
|
84 ;; |
|
85 -u) |
|
86 want_arg=$arg |
|
87 ;; |
|
88 *) |
|
89 arg= |
|
90 ;; |
|
91 esac |
|
92 else |
|
93 want_arg= |
|
94 fi |
|
95 if test x$arg != x; then |
|
96 octave_cv_cxxlibs="$octave_cv_cxxlibs $arg" |
|
97 fi |
|
98 done |
|
99 dnl |
|
100 changequote([, ])]) |
|
101 AC_MSG_RESULT([$octave_cv_cxxlibs]) |
|
102 CXXLIBS="$octave_cv_cxxlibs" |
|
103 AC_SUBST(CXXLIBS)]) |
|
104 |
|
105 dnl See what libraries are used by the Fortran compiler. |
|
106 dnl |
|
107 dnl Write a minimal program and compile it with -v. I don't know what |
|
108 dnl to do if your compiler doesn't have -v... |
|
109 dnl |
|
110 dnl OCTAVE_FLIBS() |
|
111 AC_DEFUN(OCTAVE_FLIBS, |
2039
|
112 [AC_MSG_CHECKING([for Fortran libraries]) |
1232
|
113 AC_CACHE_VAL(octave_cv_flibs, |
|
114 [changequote(, )dnl |
|
115 echo " END" > conftest.f |
|
116 foutput=`${F77-f77} -v -o conftest conftest.f 2>&1` |
|
117 dnl |
|
118 dnl The easiest thing to do for xlf output is to replace all the commas |
|
119 dnl with spaces. Try to only do that if the output is really from xlf, |
|
120 dnl since doing that causes problems on other systems. |
|
121 dnl |
|
122 xlf_p=`echo $foutput | grep xlfentry` |
|
123 if test -n "$xlf_p"; then |
|
124 foutput=`echo $foutput | sed 's/,/ /g'` |
|
125 fi |
|
126 dnl |
|
127 ld_run_path=`echo $foutput | \ |
|
128 sed -n -e 's/.*\(LD_RUN_PATH *= *[^ ]*\).*/\1/p' | \ |
|
129 sed -e 's/LD_RUN_PATH *= *//'` |
|
130 dnl |
|
131 dnl We are only supposed to find this on Solaris systems, and this |
|
132 dnl substitution is probably only going to work with gcc on those |
|
133 dnl systems... |
|
134 dnl |
|
135 if test -n "$ld_run_path"; then |
|
136 ld_run_path="-Xlinker -R -Xlinker $ld_run_path" |
|
137 fi |
|
138 dnl |
|
139 flibs= |
|
140 lflags= |
|
141 dnl |
|
142 dnl If want_arg is set, we know we want the arg to be added to the list, |
|
143 dnl so we don't have to examine it. |
|
144 dnl |
|
145 want_arg= |
|
146 dnl |
|
147 for arg in $foutput; do |
|
148 old_want_arg=$want_arg |
|
149 want_arg= |
|
150 case "$old_want_arg" in |
|
151 '') |
|
152 case $arg in |
|
153 /*.a | /*values-X*.o) |
|
154 exists=false |
|
155 for f in $lflags; do |
|
156 if test x$arg = x$f; then |
|
157 exists=true |
|
158 fi |
|
159 done |
|
160 if $exists; then |
|
161 arg= |
|
162 else |
|
163 lflags="$lflags $arg" |
|
164 fi |
|
165 ;; |
|
166 -lang*) |
|
167 arg= |
|
168 ;; |
|
169 -[lLR]) |
|
170 want_arg=$arg |
|
171 arg= |
|
172 ;; |
|
173 -[lLR]*) |
|
174 exists=false |
|
175 for f in $lflags; do |
|
176 if test x$arg = x$f; then |
|
177 exists=true |
|
178 fi |
|
179 done |
|
180 if $exists || test x$arg = x-lm -o x$arg = x-lc; then |
|
181 arg= |
|
182 else |
|
183 lflags="$lflags $arg" |
|
184 fi |
|
185 ;; |
|
186 -u) |
|
187 want_arg=$arg |
|
188 ;; |
|
189 -Y) |
|
190 want_arg=$arg |
|
191 arg= |
|
192 ;; |
|
193 *) |
|
194 arg= |
|
195 ;; |
|
196 esac |
|
197 ;; |
|
198 -[lLR]) |
|
199 arg="$old_want_arg $arg" |
|
200 ;; |
|
201 -Y) |
|
202 dnl |
|
203 dnl Should probably try to ensure unique directory options here too. |
|
204 dnl This probably only applies to Solaris systems, and then will only |
|
205 dnl work with gcc... |
|
206 dnl |
|
207 arg=`echo $arg | sed -e 's%^P,%%'` |
|
208 SAVE_IFS=$IFS |
|
209 IFS=: |
|
210 list= |
|
211 for elt in $arg; do |
|
212 list="$list -L $elt" |
|
213 done |
|
214 IFS=$SAVE_IFS |
|
215 arg="$list" |
|
216 ;; |
|
217 esac |
|
218 dnl |
|
219 if test -n "$arg"; then |
|
220 flibs="$flibs $arg" |
|
221 fi |
|
222 done |
1953
|
223 if test -n "$ld_run_path"; then |
|
224 flibs_result="$ld_run_path $flibs" |
|
225 else |
|
226 flibs_result="$flibs" |
|
227 fi |
1232
|
228 changequote([, ])dnl |
1953
|
229 octave_cv_flibs="$flibs_result"]) |
1232
|
230 FLIBS="$octave_cv_flibs" |
|
231 AC_MSG_RESULT([$FLIBS])]) |
|
232 |
1257
|
233 dnl See if the Fortran compiler uses uppercase external names. |
|
234 dnl |
|
235 dnl OCTAVE_F77_UPPERCASE_NAMES() |
|
236 AC_DEFUN(OCTAVE_F77_UPPERCASE_NAMES, |
|
237 [AC_MSG_CHECKING([whether $F77 uses uppercase external names]) |
|
238 AC_CACHE_VAL(octave_cv_f77_uppercase_names, |
|
239 [octave_cv_f77_uppercase_names=no |
|
240 cat > conftest.f <<EOF |
|
241 subroutine xxyyzz () |
|
242 return |
|
243 end |
|
244 EOF |
|
245 if ${F77-f77} -c conftest.f 1>&AC_FD_CC 2>&AC_FD_CC; then |
|
246 if test "`${NM-nm} conftest.o | grep XXYYZZ`" != ""; then |
|
247 octave_cv_f77_uppercase_names=yes |
|
248 fi |
|
249 fi]) |
|
250 AC_MSG_RESULT([$octave_cv_f77_uppercase_names]) |
|
251 if test "$octave_cv_f77_uppercase_names" = yes; then |
|
252 AC_DEFINE(F77_UPPERCASE_NAMES, 1) |
|
253 fi]) |
|
254 |
1232
|
255 dnl See if the Fortran compiler appends underscores to external names. |
|
256 dnl |
|
257 dnl OCTAVE_F77_APPEND_UNDERSCORE() |
|
258 AC_DEFUN(OCTAVE_F77_APPEND_UNDERSCORE, |
|
259 [AC_MSG_CHECKING([whether $F77 appends underscores to external names]) |
1257
|
260 AC_REQUIRE([OCTAVE_F77_UPPERCASE_NAMES]) |
1232
|
261 AC_CACHE_VAL(octave_cv_f77_append_underscore, |
|
262 [octave_cv_f77_append_underscore=no |
|
263 cat > conftest.f <<EOF |
|
264 subroutine xxyyzz () |
|
265 return |
|
266 end |
|
267 EOF |
|
268 if ${F77-f77} -c conftest.f 1>&AC_FD_CC 2>&AC_FD_CC; then |
1257
|
269 if test "$octave_cv_f77_uppercase_names" = yes; then |
|
270 if test "`${NM-nm} conftest.o | grep XXYYZZ_`" != ""; then |
|
271 octave_cv_f77_append_underscore=yes |
|
272 fi |
|
273 else |
|
274 if test "`${NM-nm} conftest.o | grep xxyyzz_`" != ""; then |
|
275 octave_cv_f77_append_underscore=yes |
|
276 fi |
1232
|
277 fi |
|
278 fi]) |
|
279 AC_MSG_RESULT([$octave_cv_f77_append_underscore]) |
|
280 if test "$octave_cv_f77_append_underscore" = yes; then |
|
281 AC_DEFINE(F77_APPEND_UNDERSCORE, 1) |
|
282 fi]) |
|
283 |
|
284 dnl See if the Fortran compiler is compatible with f2c. |
|
285 dnl |
|
286 dnl Write a minimal program, compile it, and see if it works as |
|
287 dnl expected. |
|
288 dnl |
|
289 dnl OCTAVE_F2C_F77_COMPAT() |
|
290 AC_DEFUN(OCTAVE_F2C_F77_COMPAT, |
|
291 [AC_REQUIRE([OCTAVE_FLIBS]) |
|
292 AC_REQUIRE([OCTAVE_F77_APPEND_UNDERSCORE]) |
|
293 AC_MSG_CHECKING([$F77/f2c compatibility]) |
|
294 AC_CACHE_VAL(octave_cv_f2c_f77_compat, |
|
295 [trap 'rm -f ftest* ctest* core; exit 1' 1 3 15 |
|
296 octave_cv_f2c_f77_compat=no |
|
297 cat > ftest.f <<EOF |
|
298 INTEGER FUNCTION FORSUB (C, D) |
|
299 CHARACTER *(*) C |
|
300 INTEGER L |
|
301 DOUBLE PRECISION D |
|
302 L = LEN (C) |
|
303 WRITE (*, '(A,1X,I2)') C(1:L), INT (D) |
|
304 FORSUB = 1 |
|
305 RETURN |
|
306 END |
|
307 EOF |
|
308 ${F77-f77} -c ftest.f 1>&AC_FD_CC 2>&AC_FD_CC |
|
309 dnl |
|
310 changequote(, ) |
|
311 cat > ctest.c <<EOF |
|
312 #include "confdefs.h" |
|
313 static char s[14]; |
|
314 int main () |
|
315 { |
|
316 double d = 10.0; |
|
317 int len; |
|
318 strcpy (s, "FOO-I-HITHERE"); |
|
319 len = strlen (s); |
|
320 #ifdef F77_APPEND_UNDERSCORE |
|
321 return (! forsub_ (s, &d, len)); |
|
322 #else |
|
323 return (! forsub (s, &d, len)); |
|
324 #endif |
|
325 } |
2126
|
326 #if defind (sun) |
1232
|
327 int MAIN_ () { return 0; } |
2126
|
328 #elif defined (linux) && defined (__ELF__) |
|
329 int MAIN__ () { return 0; } |
1232
|
330 #endif |
|
331 EOF |
|
332 changequote([, ]) |
|
333 dnl |
|
334 if ${CC-cc} -c ctest.c 1>&AC_FD_CC 2>&AC_FD_CC; then |
|
335 if ${CC-cc} -o ctest ctest.o ftest.o $FLIBS -lm 1>&AC_FD_CC 2>&AC_FD_CC; then |
|
336 ctest_output=`./ctest 2>&1` |
|
337 status=$? |
|
338 if test $status -eq 0 && test "$ctest_output" = "FOO-I-HITHERE 10"; then |
|
339 octave_cv_f2c_f77_compat=yes |
|
340 fi |
|
341 fi |
|
342 fi]) |
|
343 rm -f ftest* ctest* core |
|
344 AC_MSG_RESULT([$octave_cv_f2c_f77_compat])]) |
1707
|
345 |
|
346 dnl The following test is from Karl Berry's Kpathseach library. I'm |
|
347 dnl including it here in case we someday want to make the use of |
|
348 dnl kpathsea optional. |
1708
|
349 dnl |
|
350 dnl Some BSD putenv's, e.g., FreeBSD, do malloc/free's on the environment. |
|
351 dnl This test program is due to Mike Hibler <mike@cs.utah.edu>. |
|
352 dnl We don't actually need to run this if we don't have putenv, but it |
|
353 dnl doesn't hurt. |
|
354 AC_DEFUN(OCTAVE_SMART_PUTENV, |
|
355 [AC_MSG_CHECKING(whether putenv uses malloc) |
1707
|
356 AC_CACHE_VAL(octave_cv_func_putenv_malloc, |
|
357 [AC_TRY_RUN([ |
|
358 #define VAR "YOW_VAR" |
|
359 #define STRING1 "GabbaGabbaHey" |
|
360 #define STRING2 "Yow!!" /* should be shorter than STRING1 */ |
|
361 extern char *getenv (); /* in case char* and int don't mix gracefully */ |
|
362 main () |
|
363 { |
|
364 char *str1, *rstr1, *str2, *rstr2; |
|
365 str1 = getenv (VAR); |
|
366 if (str1) |
|
367 exit (1); |
|
368 str1 = malloc (strlen (VAR) + 1 + strlen (STRING1) + 1); |
|
369 if (str1 == 0) |
|
370 exit (2); |
|
371 strcpy (str1, VAR); |
|
372 strcat (str1, "="); |
|
373 strcat (str1, STRING1); |
|
374 if (putenv (str1) < 0) |
|
375 exit (3); |
|
376 rstr1 = getenv (VAR); |
|
377 if (rstr1 == 0) |
|
378 exit (4); |
|
379 rstr1 -= strlen (VAR) + 1; |
|
380 if (strncmp (rstr1, VAR, strlen (VAR))) |
|
381 exit (5); |
|
382 str2 = malloc (strlen (VAR) + 1 + strlen (STRING2) + 1); |
|
383 if (str2 == 0 || str1 == str2) |
|
384 exit (6); |
|
385 strcpy (str2, VAR); |
|
386 strcat (str2, "="); |
|
387 strcat (str2, STRING2); |
|
388 if (putenv (str2) < 0) |
|
389 exit (7); |
|
390 rstr2 = getenv (VAR); |
|
391 if (rstr2 == 0) |
|
392 exit (8); |
|
393 rstr2 -= strlen (VAR) + 1; |
|
394 #if 0 |
|
395 printf ("rstr1=0x%x, rstr2=0x%x\n", rstr1, rstr2); |
|
396 /* |
|
397 * If string from first call was reused for the second call, |
|
398 * you had better not do a free on the first string! |
|
399 */ |
|
400 if (rstr1 == rstr2) |
|
401 printf ("#define SMART_PUTENV\n"); |
|
402 else |
|
403 printf ("#undef SMART_PUTENV\n"); |
|
404 #endif |
|
405 exit (rstr1 == rstr2 ? 0 : 1); |
|
406 }], octave_cv_func_putenv_malloc=yes, octave_cv_func_putenv_malloc=no, |
|
407 octave_cv_func_putenv_malloc=no)])dnl |
|
408 AC_MSG_RESULT($octave_cv_func_putenv_malloc) |
|
409 if test $octave_cv_func_putenv_malloc = yes; then |
|
410 AC_DEFINE(SMART_PUTENV) |
1708
|
411 fi]) |
1788
|
412 dnl |
|
413 dnl This is a GNU libc invention, and this check is also from Karl |
|
414 dnl Berry's kpathsea library. |
|
415 dnl |
|
416 AC_DEFUN(OCTAVE_PROGRAM_INVOCATION_NAME, |
|
417 [AC_MSG_CHECKING(whether program_invocation_name is predefined) |
|
418 AC_CACHE_VAL(octave_cv_var_program_inv_name, |
|
419 [AC_TRY_LINK(, [main() { program_invocation_name = "love"; }], |
|
420 octave_cv_var_program_inv_name=yes, octave_cv_var_program_inv_name=no)])dnl |
|
421 AC_MSG_RESULT($octave_cv_var_program_inv_name) |
|
422 if test $octave_cv_var_program_inv_name = yes; then |
|
423 AC_DEFINE(HAVE_PROGRAM_INVOCATION_NAME) |
|
424 fi]) |