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 ;; |
2351
|
166 -bI:*) |
|
167 exists=false |
|
168 for f in $lflags; do |
|
169 if test x$arg = x$f; then |
|
170 exists=true |
|
171 fi |
|
172 done |
|
173 if $exists; then |
|
174 arg= |
|
175 else |
|
176 lflags="$lflags -Xlinker $arg" |
|
177 fi |
|
178 ;; |
1232
|
179 -lang*) |
|
180 arg= |
|
181 ;; |
|
182 -[lLR]) |
|
183 want_arg=$arg |
|
184 arg= |
|
185 ;; |
|
186 -[lLR]*) |
|
187 exists=false |
|
188 for f in $lflags; do |
|
189 if test x$arg = x$f; then |
|
190 exists=true |
|
191 fi |
|
192 done |
|
193 if $exists || test x$arg = x-lm -o x$arg = x-lc; then |
|
194 arg= |
|
195 else |
|
196 lflags="$lflags $arg" |
|
197 fi |
|
198 ;; |
|
199 -u) |
|
200 want_arg=$arg |
|
201 ;; |
|
202 -Y) |
|
203 want_arg=$arg |
|
204 arg= |
|
205 ;; |
|
206 *) |
|
207 arg= |
|
208 ;; |
|
209 esac |
|
210 ;; |
|
211 -[lLR]) |
|
212 arg="$old_want_arg $arg" |
|
213 ;; |
|
214 -Y) |
|
215 dnl |
|
216 dnl Should probably try to ensure unique directory options here too. |
|
217 dnl This probably only applies to Solaris systems, and then will only |
|
218 dnl work with gcc... |
|
219 dnl |
|
220 arg=`echo $arg | sed -e 's%^P,%%'` |
|
221 SAVE_IFS=$IFS |
|
222 IFS=: |
|
223 list= |
|
224 for elt in $arg; do |
|
225 list="$list -L $elt" |
|
226 done |
|
227 IFS=$SAVE_IFS |
|
228 arg="$list" |
|
229 ;; |
|
230 esac |
|
231 dnl |
|
232 if test -n "$arg"; then |
|
233 flibs="$flibs $arg" |
|
234 fi |
|
235 done |
1953
|
236 if test -n "$ld_run_path"; then |
|
237 flibs_result="$ld_run_path $flibs" |
|
238 else |
|
239 flibs_result="$flibs" |
|
240 fi |
1232
|
241 changequote([, ])dnl |
1953
|
242 octave_cv_flibs="$flibs_result"]) |
1232
|
243 FLIBS="$octave_cv_flibs" |
|
244 AC_MSG_RESULT([$FLIBS])]) |
|
245 |
1257
|
246 dnl See if the Fortran compiler uses uppercase external names. |
|
247 dnl |
|
248 dnl OCTAVE_F77_UPPERCASE_NAMES() |
|
249 AC_DEFUN(OCTAVE_F77_UPPERCASE_NAMES, |
|
250 [AC_MSG_CHECKING([whether $F77 uses uppercase external names]) |
|
251 AC_CACHE_VAL(octave_cv_f77_uppercase_names, |
|
252 [octave_cv_f77_uppercase_names=no |
|
253 cat > conftest.f <<EOF |
|
254 subroutine xxyyzz () |
|
255 return |
|
256 end |
|
257 EOF |
|
258 if ${F77-f77} -c conftest.f 1>&AC_FD_CC 2>&AC_FD_CC; then |
|
259 if test "`${NM-nm} conftest.o | grep XXYYZZ`" != ""; then |
|
260 octave_cv_f77_uppercase_names=yes |
|
261 fi |
|
262 fi]) |
|
263 AC_MSG_RESULT([$octave_cv_f77_uppercase_names]) |
|
264 if test "$octave_cv_f77_uppercase_names" = yes; then |
|
265 AC_DEFINE(F77_UPPERCASE_NAMES, 1) |
|
266 fi]) |
|
267 |
1232
|
268 dnl See if the Fortran compiler appends underscores to external names. |
|
269 dnl |
|
270 dnl OCTAVE_F77_APPEND_UNDERSCORE() |
|
271 AC_DEFUN(OCTAVE_F77_APPEND_UNDERSCORE, |
|
272 [AC_MSG_CHECKING([whether $F77 appends underscores to external names]) |
1257
|
273 AC_REQUIRE([OCTAVE_F77_UPPERCASE_NAMES]) |
1232
|
274 AC_CACHE_VAL(octave_cv_f77_append_underscore, |
|
275 [octave_cv_f77_append_underscore=no |
|
276 cat > conftest.f <<EOF |
|
277 subroutine xxyyzz () |
|
278 return |
|
279 end |
|
280 EOF |
|
281 if ${F77-f77} -c conftest.f 1>&AC_FD_CC 2>&AC_FD_CC; then |
1257
|
282 if test "$octave_cv_f77_uppercase_names" = yes; then |
|
283 if test "`${NM-nm} conftest.o | grep XXYYZZ_`" != ""; then |
|
284 octave_cv_f77_append_underscore=yes |
|
285 fi |
|
286 else |
|
287 if test "`${NM-nm} conftest.o | grep xxyyzz_`" != ""; then |
|
288 octave_cv_f77_append_underscore=yes |
|
289 fi |
1232
|
290 fi |
|
291 fi]) |
|
292 AC_MSG_RESULT([$octave_cv_f77_append_underscore]) |
|
293 if test "$octave_cv_f77_append_underscore" = yes; then |
|
294 AC_DEFINE(F77_APPEND_UNDERSCORE, 1) |
|
295 fi]) |
|
296 |
|
297 dnl See if the Fortran compiler is compatible with f2c. |
|
298 dnl |
|
299 dnl Write a minimal program, compile it, and see if it works as |
|
300 dnl expected. |
|
301 dnl |
|
302 dnl OCTAVE_F2C_F77_COMPAT() |
|
303 AC_DEFUN(OCTAVE_F2C_F77_COMPAT, |
|
304 [AC_REQUIRE([OCTAVE_FLIBS]) |
|
305 AC_REQUIRE([OCTAVE_F77_APPEND_UNDERSCORE]) |
|
306 AC_MSG_CHECKING([$F77/f2c compatibility]) |
|
307 AC_CACHE_VAL(octave_cv_f2c_f77_compat, |
|
308 [trap 'rm -f ftest* ctest* core; exit 1' 1 3 15 |
|
309 octave_cv_f2c_f77_compat=no |
|
310 cat > ftest.f <<EOF |
|
311 INTEGER FUNCTION FORSUB (C, D) |
|
312 CHARACTER *(*) C |
|
313 INTEGER L |
|
314 DOUBLE PRECISION D |
|
315 L = LEN (C) |
|
316 WRITE (*, '(A,1X,I2)') C(1:L), INT (D) |
|
317 FORSUB = 1 |
|
318 RETURN |
|
319 END |
|
320 EOF |
|
321 ${F77-f77} -c ftest.f 1>&AC_FD_CC 2>&AC_FD_CC |
|
322 dnl |
|
323 changequote(, ) |
|
324 cat > ctest.c <<EOF |
|
325 #include "confdefs.h" |
|
326 static char s[14]; |
|
327 int main () |
|
328 { |
|
329 double d = 10.0; |
|
330 int len; |
|
331 strcpy (s, "FOO-I-HITHERE"); |
|
332 len = strlen (s); |
|
333 #ifdef F77_APPEND_UNDERSCORE |
|
334 return (! forsub_ (s, &d, len)); |
|
335 #else |
|
336 return (! forsub (s, &d, len)); |
|
337 #endif |
|
338 } |
2218
|
339 #if defined (sun) |
1232
|
340 int MAIN_ () { return 0; } |
2126
|
341 #elif defined (linux) && defined (__ELF__) |
|
342 int MAIN__ () { return 0; } |
1232
|
343 #endif |
|
344 EOF |
|
345 changequote([, ]) |
|
346 dnl |
|
347 if ${CC-cc} -c ctest.c 1>&AC_FD_CC 2>&AC_FD_CC; then |
|
348 if ${CC-cc} -o ctest ctest.o ftest.o $FLIBS -lm 1>&AC_FD_CC 2>&AC_FD_CC; then |
|
349 ctest_output=`./ctest 2>&1` |
|
350 status=$? |
|
351 if test $status -eq 0 && test "$ctest_output" = "FOO-I-HITHERE 10"; then |
|
352 octave_cv_f2c_f77_compat=yes |
|
353 fi |
|
354 fi |
|
355 fi]) |
|
356 rm -f ftest* ctest* core |
|
357 AC_MSG_RESULT([$octave_cv_f2c_f77_compat])]) |
1707
|
358 |
|
359 dnl The following test is from Karl Berry's Kpathseach library. I'm |
|
360 dnl including it here in case we someday want to make the use of |
|
361 dnl kpathsea optional. |
1708
|
362 dnl |
|
363 dnl Some BSD putenv's, e.g., FreeBSD, do malloc/free's on the environment. |
|
364 dnl This test program is due to Mike Hibler <mike@cs.utah.edu>. |
|
365 dnl We don't actually need to run this if we don't have putenv, but it |
|
366 dnl doesn't hurt. |
|
367 AC_DEFUN(OCTAVE_SMART_PUTENV, |
|
368 [AC_MSG_CHECKING(whether putenv uses malloc) |
1707
|
369 AC_CACHE_VAL(octave_cv_func_putenv_malloc, |
|
370 [AC_TRY_RUN([ |
|
371 #define VAR "YOW_VAR" |
|
372 #define STRING1 "GabbaGabbaHey" |
|
373 #define STRING2 "Yow!!" /* should be shorter than STRING1 */ |
|
374 extern char *getenv (); /* in case char* and int don't mix gracefully */ |
|
375 main () |
|
376 { |
|
377 char *str1, *rstr1, *str2, *rstr2; |
|
378 str1 = getenv (VAR); |
|
379 if (str1) |
|
380 exit (1); |
|
381 str1 = malloc (strlen (VAR) + 1 + strlen (STRING1) + 1); |
|
382 if (str1 == 0) |
|
383 exit (2); |
|
384 strcpy (str1, VAR); |
|
385 strcat (str1, "="); |
|
386 strcat (str1, STRING1); |
|
387 if (putenv (str1) < 0) |
|
388 exit (3); |
|
389 rstr1 = getenv (VAR); |
|
390 if (rstr1 == 0) |
|
391 exit (4); |
|
392 rstr1 -= strlen (VAR) + 1; |
|
393 if (strncmp (rstr1, VAR, strlen (VAR))) |
|
394 exit (5); |
|
395 str2 = malloc (strlen (VAR) + 1 + strlen (STRING2) + 1); |
|
396 if (str2 == 0 || str1 == str2) |
|
397 exit (6); |
|
398 strcpy (str2, VAR); |
|
399 strcat (str2, "="); |
|
400 strcat (str2, STRING2); |
|
401 if (putenv (str2) < 0) |
|
402 exit (7); |
|
403 rstr2 = getenv (VAR); |
|
404 if (rstr2 == 0) |
|
405 exit (8); |
|
406 rstr2 -= strlen (VAR) + 1; |
|
407 #if 0 |
|
408 printf ("rstr1=0x%x, rstr2=0x%x\n", rstr1, rstr2); |
|
409 /* |
|
410 * If string from first call was reused for the second call, |
|
411 * you had better not do a free on the first string! |
|
412 */ |
|
413 if (rstr1 == rstr2) |
|
414 printf ("#define SMART_PUTENV\n"); |
|
415 else |
|
416 printf ("#undef SMART_PUTENV\n"); |
|
417 #endif |
|
418 exit (rstr1 == rstr2 ? 0 : 1); |
|
419 }], octave_cv_func_putenv_malloc=yes, octave_cv_func_putenv_malloc=no, |
|
420 octave_cv_func_putenv_malloc=no)])dnl |
|
421 AC_MSG_RESULT($octave_cv_func_putenv_malloc) |
|
422 if test $octave_cv_func_putenv_malloc = yes; then |
|
423 AC_DEFINE(SMART_PUTENV) |
1708
|
424 fi]) |
1788
|
425 dnl |
|
426 dnl This is a GNU libc invention, and this check is also from Karl |
|
427 dnl Berry's kpathsea library. |
|
428 dnl |
|
429 AC_DEFUN(OCTAVE_PROGRAM_INVOCATION_NAME, |
|
430 [AC_MSG_CHECKING(whether program_invocation_name is predefined) |
|
431 AC_CACHE_VAL(octave_cv_var_program_inv_name, |
|
432 [AC_TRY_LINK(, [main() { program_invocation_name = "love"; }], |
|
433 octave_cv_var_program_inv_name=yes, octave_cv_var_program_inv_name=no)])dnl |
|
434 AC_MSG_RESULT($octave_cv_var_program_inv_name) |
|
435 if test $octave_cv_var_program_inv_name = yes; then |
|
436 AC_DEFINE(HAVE_PROGRAM_INVOCATION_NAME) |
|
437 fi]) |
2469
|
438 dnl |
|
439 dnl These two checks for signal functions were originally part of the |
|
440 dnl aclocal.m4 file distributed with bash 2.0. |
|
441 dnl |
|
442 dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7) |
|
443 AC_DEFUN(OCTAVE_SIGNAL_CHECK, |
|
444 [AC_REQUIRE([AC_TYPE_SIGNAL]) |
|
445 AC_MSG_CHECKING(for type of signal functions) |
|
446 AC_CACHE_VAL(octave_cv_signal_vintage, |
|
447 [ |
|
448 AC_TRY_LINK([#include <signal.h>],[ |
|
449 sigset_t ss; |
|
450 struct sigaction sa; |
|
451 sigemptyset(&ss); sigsuspend(&ss); |
|
452 sigaction(SIGINT, &sa, (struct sigaction *) 0); |
|
453 sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0); |
|
454 ], octave_cv_signal_vintage=posix, |
|
455 [ |
|
456 AC_TRY_LINK([#include <signal.h>], [ |
|
457 int mask = sigmask(SIGINT); |
|
458 sigsetmask(mask); sigblock(mask); sigpause(mask); |
|
459 ], octave_cv_signal_vintage=4.2bsd, |
|
460 [ |
|
461 AC_TRY_LINK([ |
|
462 #include <signal.h> |
|
463 RETSIGTYPE foo() { }], [ |
|
464 int mask = sigmask(SIGINT); |
|
465 sigset(SIGINT, foo); sigrelse(SIGINT); |
|
466 sighold(SIGINT); sigpause(SIGINT); |
2491
|
467 ], octave_cv_signal_vintage=svr3, octave_cv_signal_vintage=v7 |
2469
|
468 )] |
|
469 )] |
|
470 ) |
|
471 ]) |
|
472 AC_MSG_RESULT($octave_cv_signal_vintage) |
2491
|
473 if test "$octave_cv_signal_vintage" = posix; then |
2469
|
474 AC_DEFINE(HAVE_POSIX_SIGNALS) |
2491
|
475 elif test "$octave_cv_signal_vintage" = "4.2bsd"; then |
2469
|
476 AC_DEFINE(HAVE_BSD_SIGNALS) |
2491
|
477 elif test "$octave_cv_signal_vintage" = svr3; then |
2469
|
478 AC_DEFINE(HAVE_USG_SIGHOLD) |
|
479 fi |
|
480 ]) |
|
481 dnl |
|
482 AC_DEFUN(OCTAVE_REINSTALL_SIGHANDLERS, |
|
483 [AC_REQUIRE([AC_TYPE_SIGNAL]) |
|
484 AC_REQUIRE([OCTAVE_SIGNAL_CHECK]) |
|
485 AC_MSG_CHECKING([if signal handlers must be reinstalled when invoked]) |
|
486 AC_CACHE_VAL(octave_cv_must_reinstall_sighandlers, |
|
487 [AC_TRY_RUN([ |
|
488 #include <signal.h> |
|
489 #ifdef HAVE_UNISTD_H |
|
490 #include <unistd.h> |
|
491 #endif |
|
492 typedef RETSIGTYPE sigfunc(); |
|
493 int nsigint; |
|
494 #ifdef HAVE_POSIX_SIGNALS |
|
495 sigfunc * |
|
496 set_signal_handler(sig, handler) |
|
497 int sig; |
|
498 sigfunc *handler; |
|
499 { |
|
500 struct sigaction act, oact; |
|
501 act.sa_handler = handler; |
|
502 act.sa_flags = 0; |
|
503 sigemptyset (&act.sa_mask); |
|
504 sigemptyset (&oact.sa_mask); |
|
505 sigaction (sig, &act, &oact); |
|
506 return (oact.sa_handler); |
|
507 } |
|
508 #else |
|
509 #define set_signal_handler(s, h) signal(s, h) |
|
510 #endif |
|
511 RETSIGTYPE |
|
512 sigint(s) |
|
513 int s; |
|
514 { |
|
515 nsigint++; |
|
516 } |
|
517 main() |
|
518 { |
|
519 nsigint = 0; |
|
520 set_signal_handler(SIGINT, sigint); |
|
521 kill((int)getpid(), SIGINT); |
|
522 kill((int)getpid(), SIGINT); |
|
523 exit(nsigint != 2); |
|
524 } |
|
525 ], octave_cv_must_reinstall_sighandlers=no, octave_cv_must_reinstall_sighandlers=yes, |
|
526 AC_MSG_ERROR(cannot check signal handling if cross compiling))]) |
|
527 AC_MSG_RESULT($octave_cv_must_reinstall_sighandlers) |
2491
|
528 if test "$octave_cv_must_reinstall_sighandlers" = yes; then |
2469
|
529 AC_DEFINE(MUST_REINSTALL_SIGHANDLERS) |
|
530 fi |
|
531 ]) |