cd2aa5de9b0b19fd4a491a49d9fdf8008575b875
[ghc-hetmet.git] / ghc / rts / gmp / aclocal.m4
1 dnl aclocal.m4 generated automatically by aclocal 1.4
2
3 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 dnl This program is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
10 dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11 dnl PARTICULAR PURPOSE.
12
13 dnl  GMP specific autoconf macros
14
15
16 dnl  Copyright (C) 2000 Free Software Foundation, Inc.
17 dnl
18 dnl  This file is part of the GNU MP Library.
19 dnl
20 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
21 dnl  it under the terms of the GNU Lesser General Public License as published
22 dnl  by the Free Software Foundation; either version 2.1 of the License, or (at
23 dnl  your option) any later version.
24 dnl
25 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
26 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
27 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
28 dnl  License for more details.
29 dnl
30 dnl  You should have received a copy of the GNU Lesser General Public License
31 dnl  along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
32 dnl  the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
33 dnl  MA 02111-1307, USA.
34
35
36 dnl  GMP_HEADER_GETVAL(NAME,FILE)
37 dnl  ----------------------------
38 dnl  Expand to the value of a "#define NAME" from the given FILE.
39 dnl  The regexps here aren't very rugged, but are enough for gmp.
40 dnl  /dev/null as a parameter prevents a hang if $2 is accidentally omitted.
41
42 define(GMP_HEADER_GETVAL,
43 [patsubst(patsubst(
44 esyscmd([grep "^#define $1 " $2 /dev/null 2>/dev/null]),
45 [^.*$1[         ]+],[]),
46 [[
47         ]*$],[])])
48
49
50 dnl  GMP_VERSION
51 dnl  -----------
52 dnl  The gmp version number, extracted from the #defines in gmp.h.
53 dnl  Two digits like 3.0 if patchlevel <= 0, or three digits like 3.0.1 if
54 dnl  patchlevel > 0.
55
56 define(GMP_VERSION,
57 [GMP_HEADER_GETVAL(__GNU_MP_VERSION,gmp.h)[]dnl
58 .GMP_HEADER_GETVAL(__GNU_MP_VERSION_MINOR,gmp.h)[]dnl
59 ifelse(m4_eval(GMP_HEADER_GETVAL(__GNU_MP_VERSION_PATCHLEVEL,gmp.h) > 0),1,
60 [.GMP_HEADER_GETVAL(__GNU_MP_VERSION_PATCHLEVEL,gmp.h)])])
61
62
63 dnl  GMP_PROG_M4()
64 dnl  -------------
65 dnl
66 dnl  Find a working m4, either in $PATH or likely locations, and setup $M4
67 dnl  and an AC_SUBST accordingly.  If $M4 is already set then it's a user
68 dnl  choice and is accepted with no checks.  GMP_PROG_M4 is like
69 dnl  AC_PATH_PROG or AC_CHECK_PROG, but it tests each m4 found to see if
70 dnl  it's good enough.
71 dnl 
72 dnl  See mpn/asm-defs.m4 for details on the known bad m4s.
73
74 AC_DEFUN(GMP_PROG_M4,
75 [AC_CACHE_CHECK([for suitable m4],
76                 gmp_cv_prog_m4,
77 [if test -n "$M4"; then
78   gmp_cv_prog_m4="$M4"
79 else
80   cat >conftest.m4 <<\EOF
81 dnl  must protect this against being expanded during autoconf m4!
82 [define(dollarhash,``$][#'')dnl
83 ifelse(dollarhash(x),1,`define(t1,Y)',
84 ``bad: $][# not supported (SunOS /usr/bin/m4)
85 '')dnl
86 ifelse(eval(89),89,`define(t2,Y)',
87 `bad: eval() doesnt support 8 or 9 in a constant (OpenBSD 2.6 m4)
88 ')dnl
89 ifelse(t1`'t2,YY,`good
90 ')dnl]
91 EOF
92   echo "trying m4" 1>&AC_FD_CC
93   gmp_tmp_val="`(m4 conftest.m4) 2>&AC_FD_CC`"
94   echo "$gmp_tmp_val" 1>&AC_FD_CC
95   if test "$gmp_tmp_val" = good; then
96     gmp_cv_prog_m4="m4"
97   else
98     IFS="${IFS=         }"; ac_save_ifs="$IFS"; IFS=":"
99 dnl $ac_dummy forces splitting on constant user-supplied paths.
100 dnl POSIX.2 word splitting is done only on the output of word expansions,
101 dnl not every word.  This closes a longstanding sh security hole.
102     ac_dummy="$PATH:/usr/5bin"
103     for ac_dir in $ac_dummy; do
104       test -z "$ac_dir" && ac_dir=.
105       echo "trying $ac_dir/m4" 1>&AC_FD_CC
106       gmp_tmp_val="`($ac_dir/m4 conftest.m4) 2>&AC_FD_CC`"
107       echo "$gmp_tmp_val" 1>&AC_FD_CC
108       if test "$gmp_tmp_val" = good; then
109         gmp_cv_prog_m4="$ac_dir/m4"
110         break
111       fi
112     done
113     IFS="$ac_save_ifs"
114     if test -z "$gmp_cv_prog_m4"; then
115       AC_MSG_ERROR([No usable m4 in \$PATH or /usr/5bin (see config.log for reasons).])
116     fi
117   fi
118   rm -f conftest.m4
119 fi])
120 M4="$gmp_cv_prog_m4"
121 AC_SUBST(M4)
122 ])
123
124
125 dnl  GMP_PROG_CC_FIND([CC_LIST], [REQ_64BIT_CC])
126 dnl  Find first working compiler in CC_LIST.
127 dnl  If REQ_64BIT_CC is "yes", the compiler is required to be able to 
128 dnl  produce 64-bit code.
129 dnl  NOTE: If a compiler needs any special flags for producing 64-bit code,
130 dnl  these have to be found in shell variable `gmp_cflags64_{cc}', where `{cc}'
131 dnl  is the name of the compiler.
132 dnl  Set CC to the name of the first working compiler.
133 dnl  If a 64-bit compiler is found, set CC64 to the name of the compiler and
134 dnl  CFLAGS64 to flags to use.
135 dnl  This macro does not test if any of the compilers found is a GNU compiler.
136 dnl  To do this, when you have finally made up your mind on which one to use, 
137 dnl  and set CC accordingly, invoke [GMP_PROG_CC_SELECT].  That macro will 
138 dnl  also make sure that your selection of CFLAGS is valid.
139 dnl
140 AC_DEFUN(GMP_PROG_CC_FIND,
141 [AC_BEFORE([$0], [CC_PROG_CPP])
142 ifelse([$1], , gmp_cc_list="gcc cc", gmp_cc_list="[$1]")
143 ifelse([$2], , gmp_req_64bit_cc="no", gmp_req_64bit_cc="[$2]")
144
145 CC32=
146 CC64=
147 for c in $gmp_cc_list; do
148   # Avoid cache hits.
149   unset CC
150   unset ac_cv_prog_CC
151   AC_CHECK_TOOL(CC, $c, $c)
152   if test -n "$CC"; then
153     eval c_flags=\$gmp_cflags_$c
154     GMP_PROG_CC_WORKS($CC, $c_flags,
155                       gmp_prog_cc_works=yes, 
156                       gmp_prog_cc_works=no)
157
158     if test "$gmp_prog_cc_works" != "yes"; then
159       continue
160     fi
161
162     # Save first working compiler, whether 32- or 64-bit capable.
163     if test -z "$CC32"; then
164       CC32="$CC"
165     fi
166     if test "$gmp_req_64bit_cc" = "yes"; then
167       eval c_flags=\$gmp_cflags64_$c
168
169       # Verify that the compiler works in 64-bit mode as well.
170       # /usr/ucb/cc on Solaris 7 can *compile* in 64-bit mode, but not link.
171       GMP_PROG_CC_WORKS($c, $c_flags,
172                         gmp_prog_cc_works=yes, 
173                         gmp_prog_cc_works=no)
174
175       if test "$gmp_prog_cc_works" = "yes"; then
176         GMP_CHECK_CC_64BIT($c, $c_flags)
177         if test "$gmp_cv_cc_64bit" = "yes"; then
178           test -z "$CC64" && CC64="$c"
179           test -z "$CFLAGS64" && CFLAGS64="$c_flags"
180           # We have CC64 so we're done.
181           break
182         fi
183       fi
184     else
185       # We have CC32, and we don't need a 64-bit compiler so we're done.
186       break
187     fi
188   fi
189 done
190 CC="$CC32"
191 ])dnl
192
193 dnl  GMP_PROG_CC_SELECT
194 dnl  Check that `CC' works with `CFLAGS'.  Check if `CC' is a GNU compiler.
195 dnl  Cache the result as `ac_cv_prog_CC'.
196 AC_DEFUN(GMP_PROG_CC_SELECT,
197 [AC_BEFORE([$0], [CC_PROG_CPP])
198 AC_PROG_CC_WORKS
199 AC_PROG_CC_GNU
200
201 if test "$ac_cv_prog_gcc" = "yes"; then
202   GCC=yes
203 else
204   GCC=
205 fi
206
207 # Set CFLAGS if not already set.
208 if test -z "$CFLAGS"; then
209   CFLAGS="-g"
210   if test "$GCC" = "yes"; then
211     CFLAGS="$CFLAGS -O2"
212   fi
213 fi
214
215 AC_SUBST(CC)
216 AC_CACHE_VAL(ac_cv_prog_CC, ac_cv_prog_CC="$CC")
217 AC_PROVIDE([AC_PROG_CC])
218 ])dnl
219
220 dnl  GMP_CHECK_CC_64BIT(cc, cflags64)
221 dnl  Find out if `CC' can produce 64-bit code.
222 dnl  Requires NM to be set to nm for target.
223 dnl  FIXME: Cache result.
224 AC_DEFUN(GMP_CHECK_CC_64BIT,
225 [
226   gmp_tmp_CC_save="$CC"
227   CC="[$1]"
228   AC_MSG_CHECKING([whether the C compiler ($CC) is 64-bit capable])
229   if test -z "$NM"; then
230     echo; echo ["configure: $0: fatal: need nm"]
231     exit 1
232   fi
233   gmp_tmp_CFLAGS_save="$CFLAGS"
234   CFLAGS="[$2]"
235
236   case "$target" in 
237     hppa2.0*-*-*)
238       # FIXME: If gcc is installed under another name than "gcc", we will 
239       # test the wrong thing.
240       if test "$CC" != "gcc"; then
241         dnl Let compiler version A.10.32.30 or higher be ok.
242         dnl Bad compiler output:
243         dnl   ccom: HP92453-01 G.10.32.05 HP C Compiler
244         dnl Good compiler output:
245         dnl   ccom: HP92453-01 A.10.32.30 HP C Compiler
246         echo >conftest.c
247         gmp_tmp_vs=`$CC $CFLAGS -V -c -o conftest.o conftest.c 2>&1 | grep "^ccom:"`
248         rm conftest*
249         gmp_tmp_v1=`echo $gmp_tmp_vs | sed 's/.* .\.\(.*\)\..*\..* HP C.*/\1/'`
250         gmp_tmp_v2=`echo $gmp_tmp_vs | sed 's/.* .\..*\.\(.*\)\..* HP C.*/\1/'`
251         gmp_tmp_v3=`echo $gmp_tmp_vs | sed 's/.* .\..*\..*\.\(.*\) HP C.*/\1/'`
252         gmp_cv_cc_64bit=no
253         test -n "$gmp_tmp_v1" && test "$gmp_tmp_v1" -ge "10" \
254           && test -n "$gmp_tmp_v2" && test "$gmp_tmp_v2" -ge "32" \
255           && test -n "$gmp_tmp_v3" && test "$gmp_tmp_v3" -ge "30" \
256           && gmp_cv_cc_64bit=yes
257       else      # gcc
258         # FIXME: Compile a minimal file and determine if the resulting object 
259         # file is an ELF file.  If so, gcc can produce 64-bit code.
260         # Do we have file(1) for target?
261         gmp_cv_cc_64bit=no
262       fi
263       ;;
264     mips-sgi-irix6.*)
265       # We use `-n32' to cc and `-mabi=n32' to gcc, resulting in 64-bit 
266       # arithmetic but not 64-bit pointers, so the general test for sizeof
267       # (void *) is not valid.
268       # Simply try to compile an empty main.  If that succeeds return
269       # true.
270       AC_TRY_COMPILE( , ,
271                      gmp_cv_cc_64bit=yes, gmp_cv_cc_64bit=no,
272                      gmp_cv_cc_64bit=no)
273       ;;
274     *-*-*)
275       # Allocate an array of size sizeof (void *) and use nm to determine its 
276       # size.  We depend on the first declared variable being put at address 0.
277       cat >conftest.c <<EOF
278 [char arr[sizeof (void *)]={0};
279 char post=0;]
280 EOF
281       gmp_compile="$CC $CFLAGS -c conftest.c 1>&AC_FD_CC"
282       if AC_TRY_EVAL(gmp_compile); then
283         changequote(<,>)dnl
284         gmp_tmp_val=`$NM conftest.o | grep post | sed -e 's;[[][0-9][]]\(.*\);\1;' \
285           -e 's;[^1-9]*\([0-9]*\).*;\1;'`
286         changequote([, ])dnl
287         if test "$gmp_tmp_val" = "8"; then
288           gmp_cv_cc_64bit=yes
289         else
290           gmp_cv_cc_64bit=no
291         fi
292       else
293         echo "configure: failed program was:" >&AC_FD_CC
294         cat conftest.$ac_ext >&AC_FD_CC
295         gmp_cv_cc_64bit=no
296       fi
297       rm -f conftest*
298       ;;
299   esac
300
301   CC="$gmp_tmp_CC_save"
302   CFLAGS="$gmp_tmp_CFLAGS_save"
303   AC_MSG_RESULT($gmp_cv_cc_64bit)
304 ])dnl
305
306 dnl  GMP_INIT([M4-DEF-FILE])
307 dnl  
308 AC_DEFUN(GMP_INIT,
309 [ifelse([$1], , gmp_configm4=config.m4, gmp_configm4="[$1]")
310 gmp_tmpconfigm4=cnfm4.tmp
311 gmp_tmpconfigm4i=cnfm4i.tmp
312 gmp_tmpconfigm4p=cnfm4p.tmp
313 test -f $gmp_tmpconfigm4 && rm $gmp_tmpconfigm4
314 test -f $gmp_tmpconfigm4i && rm $gmp_tmpconfigm4i
315 test -f $gmp_tmpconfigm4p && rm $gmp_tmpconfigm4p
316 ])dnl
317
318 dnl  GMP_FINISH
319 dnl  ----------
320 dnl  Create config.m4 from its accumulated parts.
321 dnl
322 dnl  __CONFIG_M4_INCLUDED__ is used so that a second or subsequent include
323 dnl  of config.m4 is harmless.
324 dnl
325 dnl  A separate ifdef on the angle bracket quoted part ensures the quoting
326 dnl  style there is respected.  The basic defines from gmp_tmpconfigm4 are
327 dnl  fully quoted but are still put under an ifdef in case any have been
328 dnl  redefined by one of the m4 include files.
329 dnl
330 dnl  Doing a big ifdef within asm-defs.m4 and/or other macro files wouldn't
331 dnl  work, since it'd interpret parentheses and quotes in dnl comments, and
332 dnl  having a whole file as a macro argument would overflow the string space
333 dnl  on BSD m4.
334
335 AC_DEFUN(GMP_FINISH,
336 [AC_REQUIRE([GMP_INIT])
337 echo "creating $gmp_configm4"
338 echo ["dnl $gmp_configm4.  Generated automatically by configure."] > $gmp_configm4
339 if test -f $gmp_tmpconfigm4; then
340   echo ["changequote(<,>)dnl"] >> $gmp_configm4
341   echo ["ifdef(<__CONFIG_M4_INCLUDED__>,,<"] >> $gmp_configm4
342   cat $gmp_tmpconfigm4 >> $gmp_configm4
343   echo [">)"] >> $gmp_configm4
344   echo ["changequote(\`,')dnl"] >> $gmp_configm4
345   rm $gmp_tmpconfigm4
346 fi
347 echo ["ifdef(\`__CONFIG_M4_INCLUDED__',,\`"] >> $gmp_configm4
348 if test -f $gmp_tmpconfigm4i; then
349   cat $gmp_tmpconfigm4i >> $gmp_configm4
350   rm $gmp_tmpconfigm4i
351 fi
352 if test -f $gmp_tmpconfigm4p; then
353   cat $gmp_tmpconfigm4p >> $gmp_configm4
354   rm $gmp_tmpconfigm4p
355 fi
356 echo ["')"] >> $gmp_configm4
357 echo ["define(\`__CONFIG_M4_INCLUDED__')"] >> $gmp_configm4
358 ])dnl
359
360 dnl  GMP_INCLUDE(FILE)
361 AC_DEFUN(GMP_INCLUDE,
362 [AC_REQUIRE([GMP_INIT])
363 echo ["include(\`$1')"] >> $gmp_tmpconfigm4i
364 ])dnl
365
366 dnl  GMP_SINCLUDE(FILE)
367 AC_DEFUN(GMP_SINCLUDE,
368 [AC_REQUIRE([GMP_INIT])
369 echo ["sinclude(\`$1')"] >> $gmp_tmpconfigm4i
370 ])dnl
371
372 dnl GMP_DEFINE(MACRO, DEFINITION [, LOCATION])
373 dnl [ Define M4 macro MACRO as DEFINITION in temporary file.            ]
374 dnl [ If LOCATION is `POST', the definition will appear after any       ]
375 dnl [ include() directives inserted by GMP_INCLUDE/GMP_SINCLUDE.        ]
376 dnl [ Mind the quoting!  No shell variables will get expanded.          ]
377 dnl [ Don't forget to invoke GMP_FINISH to create file config.m4.       ]
378 dnl [ config.m4 uses `<' and '>' as quote characters for all defines.   ]
379 AC_DEFUN(GMP_DEFINE, 
380 [AC_REQUIRE([GMP_INIT])
381 echo ['define(<$1>, <$2>)'] >> ifelse([$3], [POST], $gmp_tmpconfigm4p, $gmp_tmpconfigm4)
382 ])dnl
383
384 dnl GMP_DEFINE_RAW(STRING, [, LOCATION])
385 dnl [ Put STRING in temporary file.                                     ]
386 dnl [ If LOCATION is `POST', the definition will appear after any       ]
387 dnl [ include() directives inserted by GMP_INCLUDE/GMP_SINCLUDE.        ]
388 dnl [ Don't forget to invoke GMP_FINISH to create file config.m4.       ]
389 AC_DEFUN(GMP_DEFINE_RAW,
390 [AC_REQUIRE([GMP_INIT])
391 echo [$1] >> ifelse([$2], [POST], $gmp_tmpconfigm4p, $gmp_tmpconfigm4)
392 ])dnl
393
394 dnl  GMP_CHECK_ASM_LABEL_SUFFIX
395 dnl  Should a label have a colon or not?
396 AC_DEFUN(GMP_CHECK_ASM_LABEL_SUFFIX,
397 [AC_CACHE_CHECK([what assembly label suffix to use],
398                gmp_cv_check_asm_label_suffix,
399 [case "$target" in 
400   *-*-hpux*) gmp_cv_check_asm_label_suffix=[""] ;;
401   *) gmp_cv_check_asm_label_suffix=[":"] ;;
402 esac
403 ])
404 echo ["define(<LABEL_SUFFIX>, <\$][1$gmp_cv_check_asm_label_suffix>)"] >> $gmp_tmpconfigm4
405 ])dnl
406
407 dnl  GMP_CHECK_ASM_UNDERSCORE([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
408 dnl  Shamelessly borrowed from glibc.
409 AC_DEFUN(GMP_CHECK_ASM_UNDERSCORE,
410 [AC_CACHE_CHECK([if symbols are prefixed by underscore], 
411                 gmp_cv_check_asm_underscore,
412 [cat > conftest.$ac_ext <<EOF
413 dnl This sometimes fails to find confdefs.h, for some reason.
414 dnl [#]line __oline__ "[$]0"
415 [#]line __oline__ "configure"
416 #include "confdefs.h"
417 int underscore_test() {
418 return; }
419 EOF
420 if AC_TRY_EVAL(ac_compile); then
421   if grep _underscore_test conftest* >/dev/null; then
422     gmp_cv_check_asm_underscore=yes
423   else
424     gmp_cv_check_asm_underscore=no
425   fi
426 else
427   echo "configure: failed program was:" >&AC_FD_CC
428   cat conftest.$ac_ext >&AC_FD_CC
429 fi
430 rm -f conftest*
431 ])
432 if test "$gmp_cv_check_asm_underscore" = "yes"; then
433   GMP_DEFINE(GSYM_PREFIX, [_])
434   ifelse([$1], , :, [$1])
435 else
436   GMP_DEFINE(GSYM_PREFIX, [])
437   ifelse([$2], , :, [$2])
438 fi    
439 ])dnl
440
441 dnl  GMP_CHECK_ASM_ALIGN_LOG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
442 dnl  Is parameter to `.align' logarithmic?
443 dnl  Requires NM to be set to nm for target.
444 AC_DEFUN(GMP_CHECK_ASM_ALIGN_LOG,
445 [AC_REQUIRE([GMP_CHECK_ASM_GLOBL])
446 AC_REQUIRE([GMP_CHECK_ASM_DATA])
447 AC_REQUIRE([GMP_CHECK_ASM_LABEL_SUFFIX])
448 AC_CACHE_CHECK([if .align assembly directive is logarithmic],
449                 gmp_cv_check_asm_align_log,
450 [if test -z "$NM"; then
451   echo; echo ["configure: $0: fatal: need nm"]
452   exit 1
453 fi
454 cat > conftest.s <<EOF
455         $gmp_cv_check_asm_data
456         .align  4
457         $gmp_cv_check_asm_globl foo
458         .byte   1
459         .align  4
460 foo$gmp_cv_check_asm_label_suffix
461         .byte   2
462 EOF
463 ac_assemble="$CCAS $CFLAGS conftest.s 1>&AC_FD_CC"
464 if AC_TRY_EVAL(ac_assemble); then
465   changequote(<,>)
466   gmp_tmp_val=`$NM conftest.o | grep foo | sed -e 's;[[][0-9][]]\(.*\);\1;' \
467        -e 's;[^1-9]*\([0-9]*\).*;\1;'`
468   changequote([, ])dnl
469   if test "$gmp_tmp_val" = "10" || test "$gmp_tmp_val" = "16"; then
470     gmp_cv_check_asm_align_log=yes
471   else
472     gmp_cv_check_asm_align_log=no
473   fi
474 else 
475   echo "configure: failed program was:" >&AC_FD_CC
476   cat conftest.s >&AC_FD_CC
477 fi
478 rm -f conftest*
479 ])
480 GMP_DEFINE_RAW(["define(<ALIGN_LOGARITHMIC>,<$gmp_cv_check_asm_align_log>)"])
481 if test "$gmp_cv_check_asm_align_log" = "yes"; then
482   ifelse([$1], , :, [$1])
483 else
484   ifelse([$2], , :, [$2])
485 fi  
486 ])dnl
487
488
489 dnl  GMP_CHECK_ASM_ALIGN_FILL_0x90
490 dnl  -----------------------------
491 dnl  Determine whether a ",0x90" suffix works on a .align directive.
492 dnl  This is only meant for use on x86, where 0x90 is a "nop".
493 dnl
494 dnl  Old gas, eg. 1.92.3 - needs ",0x90" or else the fill is an invalid 0x00.
495 dnl  New gas, eg. 2.91 - generates the good multibyte nop fills even when
496 dnl                      ",0x90" is given.
497 dnl  Solaris 2.6 as - doesn't allow ",0x90", gives a fatal error.
498 dnl  Solaris 2.8 as - gives a warning for ",0x90", no ill effect.
499 dnl
500 dnl  Note that both solaris "as"s only care about ",0x90" if they actually
501 dnl  have to use it to fill something, hence the .byte in the sample.  It's
502 dnl  only the second .align that provokes an error or warning.
503 dnl
504 dnl  We prefer to suppress the warning from solaris 2.8 to stop anyone
505 dnl  worrying something might be wrong.
506
507 AC_DEFUN(GMP_CHECK_ASM_ALIGN_FILL_0x90,
508 [AC_CACHE_CHECK([if the .align directive accepts an 0x90 fill in .text],
509                 gmp_cv_check_asm_align_fill_0x90,
510 [AC_REQUIRE([GMP_CHECK_ASM_TEXT])
511 cat > conftest.s <<EOF
512         $gmp_cv_check_asm_text
513         .align  4, 0x90
514         .byte   0
515         .align  4, 0x90
516 EOF
517 gmp_tmp_val="`$CCAS $CFLAGS conftest.s 2>&1`"
518 if test $? = 0; then
519   echo "$gmp_tmp_val" 1>&AC_FD_CC
520   if echo "$gmp_tmp_val" | grep "Warning: Fill parameter ignored for executable section"; then
521     echo "Supressing this warning by omitting 0x90" 1>&AC_FD_CC
522     gmp_cv_check_asm_align_fill_0x90=no
523   else
524     gmp_cv_check_asm_align_fill_0x90=yes
525   fi
526 else
527   echo "Non-zero exit code" 1>&AC_FD_CC
528   echo "$gmp_tmp_val" 1>&AC_FD_CC
529   gmp_cv_check_asm_align_fill_0x90=no
530 fi
531 rm -f conftest*
532 ])
533 GMP_DEFINE_RAW(
534 ["define(<ALIGN_FILL_0x90>,<$gmp_cv_check_asm_align_fill_0x90>)"])
535 ])
536
537
538 dnl  GMP_CHECK_ASM_TEXT
539 AC_DEFUN(GMP_CHECK_ASM_TEXT,
540 [AC_CACHE_CHECK([how to switch to text section], gmp_cv_check_asm_text,
541 [case "$target" in
542   *-*-aix*)
543     changequote({, })
544     gmp_cv_check_asm_text={".csect .text[PR]"}
545     changequote([, ])
546     ;;
547   *-*-hpux*) gmp_cv_check_asm_text=[".code"] ;;
548   *) gmp_cv_check_asm_text=[".text"] ;;
549 esac
550 ])
551 echo ["define(<TEXT>, <$gmp_cv_check_asm_text>)"] >> $gmp_tmpconfigm4
552 ])dnl
553
554 dnl  GMP_CHECK_ASM_DATA
555 dnl  Can we say `.data'?
556 AC_DEFUN(GMP_CHECK_ASM_DATA,
557 [AC_CACHE_CHECK([how to switch to data section], gmp_cv_check_asm_data,
558 [case "$target" in
559   *-*-aix*)
560     changequote({, })
561     gmp_cv_check_asm_data={".csect .data[RW]"}
562     changequote([, ])
563     ;;
564   *) gmp_cv_check_asm_data=[".data"] ;;
565 esac
566 ])
567 echo ["define(<DATA>, <$gmp_cv_check_asm_data>)"] >> $gmp_tmpconfigm4
568 ])dnl
569
570 dnl  GMP_CHECK_ASM_GLOBL
571 dnl  Can we say `.global'?
572 AC_DEFUN(GMP_CHECK_ASM_GLOBL,
573 [AC_CACHE_CHECK([how to export a symbol], gmp_cv_check_asm_globl,
574 [case "$target" in
575   *-*-hpux*) gmp_cv_check_asm_globl=[".export"] ;;
576   *) gmp_cv_check_asm_globl=[".globl"] ;;
577 esac
578 ])
579 echo ["define(<GLOBL>, <$gmp_cv_check_asm_globl>)"] >> $gmp_tmpconfigm4
580 ])dnl
581
582 dnl  GMP_CHECK_ASM_TYPE
583 dnl  Can we say `.type'?
584 AC_DEFUN(GMP_CHECK_ASM_TYPE,
585 [AC_CACHE_CHECK([how the .type assembly directive should be used],
586 gmp_cv_check_asm_type,
587 [ac_assemble="$CCAS $CFLAGS conftest.s 1>&AC_FD_CC"
588 for gmp_tmp_prefix in @ \# %; do
589   echo "        .type   sym,${gmp_tmp_prefix}function" > conftest.s
590   if AC_TRY_EVAL(ac_assemble); then
591     gmp_cv_check_asm_type="[.type       \$][1,${gmp_tmp_prefix}\$][2]"
592     break
593   fi
594 done
595 if test -z "$gmp_cv_check_asm_type"; then
596   gmp_cv_check_asm_type="[dnl]"
597 fi
598 ])
599 echo ["define(<TYPE>, <$gmp_cv_check_asm_type>)"] >> $gmp_tmpconfigm4
600 ])dnl
601
602 dnl  GMP_CHECK_ASM_SIZE
603 dnl  Can we say `.size'?
604 AC_DEFUN(GMP_CHECK_ASM_SIZE,
605 [AC_CACHE_CHECK([if the .size assembly directive works], gmp_cv_check_asm_size,
606 [ac_assemble="$CCAS $CFLAGS conftest.s 1>&AC_FD_CC"
607 echo '  .size   sym,1' > conftest.s
608 if AC_TRY_EVAL(ac_assemble); then
609   gmp_cv_check_asm_size="[.size \$][1,\$][2]"
610 else
611   gmp_cv_check_asm_size="[dnl]"
612 fi
613 ])
614 echo ["define(<SIZE>, <$gmp_cv_check_asm_size>)"] >> $gmp_tmpconfigm4
615 ])dnl
616
617 dnl  GMP_CHECK_ASM_LSYM_PREFIX
618 dnl  What is the prefix for a local label?
619 dnl  Requires NM to be set to nm for target.
620 AC_DEFUN(GMP_CHECK_ASM_LSYM_PREFIX,
621 [AC_REQUIRE([GMP_CHECK_ASM_LABEL_SUFFIX])
622 AC_CACHE_CHECK([what prefix to use for a local label], 
623 gmp_cv_check_asm_lsym_prefix,
624 [if test -z "$NM"; then
625   echo; echo ["$0: fatal: need nm"]
626   exit 1
627 fi
628 ac_assemble="$CCAS $CFLAGS conftest.s 1>&AC_FD_CC"
629 gmp_cv_check_asm_lsym_prefix="L"
630 for gmp_tmp_pre in L .L $ L$; do
631   cat > conftest.s <<EOF
632 dummy${gmp_cv_check_asm_label_suffix}
633 ${gmp_tmp_pre}gurkmacka${gmp_cv_check_asm_label_suffix}
634         .byte 0
635 EOF
636   if AC_TRY_EVAL(ac_assemble); then
637     $NM conftest.o >/dev/null 2>&1
638     gmp_rc=$?
639     if test "$gmp_rc" != "0"; then
640       echo "configure: $NM failure, using default"
641       break
642     fi
643     if $NM conftest.o | grep gurkmacka >/dev/null; then true; else
644       gmp_cv_check_asm_lsym_prefix="$gmp_tmp_pre"
645       break
646     fi
647   else
648     echo "configure: failed program was:" >&AC_FD_CC
649     cat conftest.s >&AC_FD_CC
650     # Use default.
651   fi
652 done
653 rm -f conftest*
654 ])
655 echo ["define(<LSYM_PREFIX>, <${gmp_cv_check_asm_lsym_prefix}>)"] >> $gmp_tmpconfigm4
656 ])
657
658 dnl  GMP_CHECK_ASM_W32
659 dnl  How to [define] a 32-bit word.
660 dnl  Requires NM to be set to nm for target.
661 AC_DEFUN(GMP_CHECK_ASM_W32,
662 [AC_REQUIRE([GMP_CHECK_ASM_DATA])
663 AC_REQUIRE([GMP_CHECK_ASM_GLOBL])
664 AC_REQUIRE([GMP_CHECK_ASM_LABEL_SUFFIX])
665 AC_CACHE_CHECK([how to [define] a 32-bit word],
666                gmp_cv_check_asm_w32,
667 [if test -z "$NM"; then
668   echo; echo ["configure: $0: fatal: need nm"]
669   exit 1
670 fi
671
672 # FIXME: HPUX puts first symbol at 0x40000000, breaking our assumption
673 # that it's at 0x0.  We'll have to declare another symbol before the
674 # .long/.word and look at the distance between the two symbols.  The
675 # only problem is that the sed expression(s) barfs (on Solaris, for
676 # example) for the symbol with value 0.  For now, HPUX uses .word.
677
678 case "$target" in 
679   *-*-hpux*)
680     gmp_cv_check_asm_w32=".word"
681     ;;
682   *-*-*)
683     ac_assemble="$CCAS $CFLAGS conftest.s 1>&AC_FD_CC"
684     for gmp_tmp_op in .long .word; do
685       cat > conftest.s <<EOF
686         $gmp_cv_check_asm_data
687         $gmp_cv_check_asm_globl foo
688         $gmp_tmp_op     0
689 foo${gmp_cv_check_asm_label_suffix}
690         .byte   0
691 EOF
692       if AC_TRY_EVAL(ac_assemble); then
693         changequote(<,>)
694         gmp_tmp_val=`$NM conftest.o | grep foo | sed -e 's;[[][0-9][]]\(.*\);\1;' \
695              -e 's;[^1-9]*\([0-9]*\).*;\1;'`
696         changequote([, ])dnl
697         if test "$gmp_tmp_val" = "4"; then
698           gmp_cv_check_asm_w32="$gmp_tmp_op"
699           break
700         fi
701       fi
702     done
703     ;;
704 esac
705
706 if test -z "$gmp_cv_check_asm_w32"; then
707   echo; echo ["configure: $0: fatal: do not know how to define a 32-bit word"]
708   exit 1
709 fi
710 rm -f conftest*
711 ])
712 echo ["define(<W32>, <$gmp_cv_check_asm_w32>)"] >> $gmp_tmpconfigm4
713 ])
714
715 dnl  GMP_CHECK_ASM_MMX([ACTION-IF-FOUND, [ACTION-IF-NOT-FOUND]])
716 dnl  Can we assemble MMX insns?
717 AC_DEFUN(GMP_CHECK_ASM_MMX,
718 [AC_REQUIRE([GMP_CHECK_ASM_TEXT])
719 AC_CACHE_CHECK([if the assembler knows about MMX instructions],
720                 gmp_cv_check_asm_mmx,
721 [cat > conftest.s <<EOF
722         $gmp_cv_check_asm_text
723         por     %mm0, %mm0
724 EOF
725 ac_assemble="$CCAS $CFLAGS conftest.s 1>&AC_FD_CC"
726 if AC_TRY_EVAL(ac_assemble); then
727   gmp_cv_check_asm_mmx=yes
728 else 
729   gmp_cv_check_asm_mmx=no
730 fi
731 rm -f conftest*
732 ])
733 if test "$gmp_cv_check_asm_mmx" = "yes"; then
734   ifelse([$1], , :, [$1])
735 else
736   AC_MSG_WARN([+----------------------------------------------------------])
737   AC_MSG_WARN([| WARNING WARNING WARNING])
738   AC_MSG_WARN([| Target CPU has MMX code, but it can't be assembled by])
739   AC_MSG_WARN([|     $CCAS $CFLAGS])
740   AC_MSG_WARN([| Non-MMX replacements will be used.])
741   AC_MSG_WARN([| This will be an inferior build.])
742   AC_MSG_WARN([+----------------------------------------------------------])
743   ifelse([$2], , :, [$2])
744 fi
745 ])dnl
746
747 dnl  GMP_CHECK_ASM_SHLDL_CL([ACTION-IF-FOUND, [ACTION-IF-NOT-FOUND]])
748 AC_DEFUN(GMP_CHECK_ASM_SHLDL_CL,
749 [AC_REQUIRE([GMP_CHECK_ASM_TEXT])
750 AC_CACHE_CHECK([if the assembler takes cl with shldl],
751                 gmp_cv_check_asm_shldl_cl,
752 [cat > conftest.s <<EOF
753         $gmp_cv_check_asm_text
754         shldl   %cl, %eax, %ebx
755 EOF
756 ac_assemble="$CCAS $CFLAGS conftest.s 1>&AC_FD_CC"
757 if AC_TRY_EVAL(ac_assemble); then
758   gmp_cv_check_asm_shldl_cl=yes
759 else 
760   gmp_cv_check_asm_shldl_cl=no
761 fi
762 rm -f conftest*
763 ])
764 if test "$gmp_cv_check_asm_shldl_cl" = "yes"; then
765   ifelse([$1], , :, [$1])
766 else
767   ifelse([$2], , :, [$2])
768 fi
769 ])dnl
770
771 dnl  GMP_PROG_CC_WORKS(CC, CFLAGS, ACTION-IF-WORKS, [ACTION-IF-NOT-WORKS])
772 dnl  Check if CC can compile and link.  Perform various target specific tests.
773 dnl  FIXME: Require `$target'.
774 AC_DEFUN(GMP_PROG_CC_WORKS,
775 [AC_LANG_C      dnl  Note: Destructive.
776 CC="[$1]"
777 CFLAGS="[$2]"
778 AC_MSG_CHECKING([if the C compiler ($CC) works with flags $CFLAGS])
779
780 # Simple test for all targets.
781 AC_TRY_COMPILER([int main(){return(0);}],
782                 tmp_works, tmp_cross)
783
784 # Target specific tests.
785 if test "$tmp_works" = "yes"; then
786   case "$target" in 
787     *-*-aix*)   # Returning a funcptr.
788       AC_TRY_COMPILE( , [} void *g(); void *f() { return g(); } int bar(){],
789                       tmp_works=yes, tmp_works=no)
790       ;;
791   esac
792 fi
793
794 if test "$tmp_works" = "yes"; then
795   [$3]
796 else
797   ifelse([$4], , :, [$4])
798 fi
799
800 AC_MSG_RESULT($tmp_works)
801 ])dnl
802
803
804 dnl  GMP_C_ANSI2KNR
805 dnl  --------------
806 dnl  Setup to use ansi2knr if necessary.
807 dnl
808 dnl  The test here is simply that if an ANSI style function works then
809 dnl  ansi2knr isn't needed.  The normal tests for whether $CC works mean we
810 dnl  don't need to worry here about anything badly broken.
811 dnl
812 dnl  AM_C_PROTOTYPES is the normal way to set up ansi2knr, but (in automake
813 dnl  March 2000) it gives the wrong answer on a C++ compiler because its
814 dnl  test requires that the compiler accept both ANSI and K&R, or otherwise
815 dnl  ansi2knr is used.  A C++ compiler fails on the K&R part, which makes
816 dnl  AM_C_PROTOTYPES think it needs ansi2knr!  GMP has no bare K&R so we
817 dnl  only need ANSI or K&R to work, not both.
818
819 AC_DEFUN(GMP_C_ANSI2KNR,
820 [AC_CACHE_CHECK([if ansi2knr should be used],
821                 gmp_cv_c_ansi2knr,
822 [cat >conftest.c <<EOF
823 int main (int argc, char *argv[]) { return 0; }
824 EOF
825 if AC_TRY_EVAL(ac_compile); then
826   gmp_cv_c_ansi2knr=no
827 else
828   gmp_cv_c_ansi2knr=yes
829 fi
830 rm -f conftest.*
831 ])
832 if test $gmp_cv_c_ansi2knr = no; then
833   U= ANSI2KNR=
834 else
835   U=_ ANSI2KNR=./ansi2knr
836   # Ensure some checks needed by ansi2knr itself.
837   AC_HEADER_STDC
838   AC_CHECK_HEADERS(string.h)
839 fi
840 AC_SUBST(U)
841 AC_SUBST(ANSI2KNR)
842 ])
843
844
845 dnl  Deal with bad synchronization of Autoconf with Libtool.
846 AC_DEFUN(AC_CANONICAL_BUILD, [_AC_CANONICAL_BUILD])
847 AC_DEFUN(AC_CHECK_TOOL_PREFIX, [_AC_CHECK_TOOL_PREFIX])
848
849
850 # serial 1
851
852 AC_DEFUN(AM_C_PROTOTYPES,
853 [AC_REQUIRE([AM_PROG_CC_STDC])
854 AC_REQUIRE([AC_PROG_CPP])
855 AC_MSG_CHECKING([for function prototypes])
856 if test "$am_cv_prog_cc_stdc" != no; then
857   AC_MSG_RESULT(yes)
858   AC_DEFINE(PROTOTYPES,1,[Define if compiler has function prototypes])
859   U= ANSI2KNR=
860 else
861   AC_MSG_RESULT(no)
862   U=_ ANSI2KNR=./ansi2knr
863   # Ensure some checks needed by ansi2knr itself.
864   AC_HEADER_STDC
865   AC_CHECK_HEADERS(string.h)
866 fi
867 AC_SUBST(U)dnl
868 AC_SUBST(ANSI2KNR)dnl
869 ])
870
871
872 # serial 1
873
874 # @defmac AC_PROG_CC_STDC
875 # @maindex PROG_CC_STDC
876 # @ovindex CC
877 # If the C compiler in not in ANSI C mode by default, try to add an option
878 # to output variable @code{CC} to make it so.  This macro tries various
879 # options that select ANSI C on some system or another.  It considers the
880 # compiler to be in ANSI C mode if it handles function prototypes correctly.
881 #
882 # If you use this macro, you should check after calling it whether the C
883 # compiler has been set to accept ANSI C; if not, the shell variable
884 # @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
885 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
886 # program @code{ansi2knr}, which comes with Ghostscript.
887 # @end defmac
888
889 AC_DEFUN(AM_PROG_CC_STDC,
890 [AC_REQUIRE([AC_PROG_CC])
891 AC_BEFORE([$0], [AC_C_INLINE])
892 AC_BEFORE([$0], [AC_C_CONST])
893 dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
894 dnl a magic option to avoid problems with ANSI preprocessor commands
895 dnl like #elif.
896 dnl FIXME: can't do this because then AC_AIX won't work due to a
897 dnl circular dependency.
898 dnl AC_BEFORE([$0], [AC_PROG_CPP])
899 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
900 AC_CACHE_VAL(am_cv_prog_cc_stdc,
901 [am_cv_prog_cc_stdc=no
902 ac_save_CC="$CC"
903 # Don't try gcc -ansi; that turns off useful extensions and
904 # breaks some systems' header files.
905 # AIX                   -qlanglvl=ansi
906 # Ultrix and OSF/1      -std1
907 # HP-UX                 -Aa -D_HPUX_SOURCE
908 # SVR4                  -Xc -D__EXTENSIONS__
909 for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
910 do
911   CC="$ac_save_CC $ac_arg"
912   AC_TRY_COMPILE(
913 [#include <stdarg.h>
914 #include <stdio.h>
915 #include <sys/types.h>
916 #include <sys/stat.h>
917 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
918 struct buf { int x; };
919 FILE * (*rcsopen) (struct buf *, struct stat *, int);
920 static char *e (p, i)
921      char **p;
922      int i;
923 {
924   return p[i];
925 }
926 static char *f (char * (*g) (char **, int), char **p, ...)
927 {
928   char *s;
929   va_list v;
930   va_start (v,p);
931   s = g (p, va_arg (v,int));
932   va_end (v);
933   return s;
934 }
935 int test (int i, double x);
936 struct s1 {int (*f) (int a);};
937 struct s2 {int (*f) (double a);};
938 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
939 int argc;
940 char **argv;
941 ], [
942 return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
943 ],
944 [am_cv_prog_cc_stdc="$ac_arg"; break])
945 done
946 CC="$ac_save_CC"
947 ])
948 if test -z "$am_cv_prog_cc_stdc"; then
949   AC_MSG_RESULT([none needed])
950 else
951   AC_MSG_RESULT($am_cv_prog_cc_stdc)
952 fi
953 case "x$am_cv_prog_cc_stdc" in
954   x|xno) ;;
955   *) CC="$CC $am_cv_prog_cc_stdc" ;;
956 esac
957 ])
958
959 # Do all the work for Automake.  This macro actually does too much --
960 # some checks are only needed if your package does certain things.
961 # But this isn't really a big deal.
962
963 # serial 1
964
965 dnl Usage:
966 dnl AM_INIT_AUTOMAKE(package,version, [no-define])
967
968 AC_DEFUN(AM_INIT_AUTOMAKE,
969 [AC_REQUIRE([AC_PROG_INSTALL])
970 PACKAGE=[$1]
971 AC_SUBST(PACKAGE)
972 VERSION=[$2]
973 AC_SUBST(VERSION)
974 dnl test to see if srcdir already configured
975 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
976   AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
977 fi
978 ifelse([$3],,
979 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
980 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
981 AC_REQUIRE([AM_SANITY_CHECK])
982 AC_REQUIRE([AC_ARG_PROGRAM])
983 dnl FIXME This is truly gross.
984 missing_dir=`cd $ac_aux_dir && pwd`
985 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
986 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
987 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
988 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
989 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
990 AC_REQUIRE([AC_PROG_MAKE_SET])])
991
992 #
993 # Check to make sure that the build environment is sane.
994 #
995
996 AC_DEFUN(AM_SANITY_CHECK,
997 [AC_MSG_CHECKING([whether build environment is sane])
998 # Just in case
999 sleep 1
1000 echo timestamp > conftestfile
1001 # Do `set' in a subshell so we don't clobber the current shell's
1002 # arguments.  Must try -L first in case configure is actually a
1003 # symlink; some systems play weird games with the mod time of symlinks
1004 # (eg FreeBSD returns the mod time of the symlink's containing
1005 # directory).
1006 if (
1007    set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
1008    if test "[$]*" = "X"; then
1009       # -L didn't work.
1010       set X `ls -t $srcdir/configure conftestfile`
1011    fi
1012    if test "[$]*" != "X $srcdir/configure conftestfile" \
1013       && test "[$]*" != "X conftestfile $srcdir/configure"; then
1014
1015       # If neither matched, then we have a broken ls.  This can happen
1016       # if, for instance, CONFIG_SHELL is bash and it inherits a
1017       # broken ls alias from the environment.  This has actually
1018       # happened.  Such a system could not be considered "sane".
1019       AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
1020 alias in your environment])
1021    fi
1022
1023    test "[$]2" = conftestfile
1024    )
1025 then
1026    # Ok.
1027    :
1028 else
1029    AC_MSG_ERROR([newly created file is older than distributed files!
1030 Check your system clock])
1031 fi
1032 rm -f conftest*
1033 AC_MSG_RESULT(yes)])
1034
1035 dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
1036 dnl The program must properly implement --version.
1037 AC_DEFUN(AM_MISSING_PROG,
1038 [AC_MSG_CHECKING(for working $2)
1039 # Run test in a subshell; some versions of sh will print an error if
1040 # an executable is not found, even if stderr is redirected.
1041 # Redirect stdin to placate older versions of autoconf.  Sigh.
1042 if ($2 --version) < /dev/null > /dev/null 2>&1; then
1043    $1=$2
1044    AC_MSG_RESULT(found)
1045 else
1046    $1="$3/missing $2"
1047    AC_MSG_RESULT(missing)
1048 fi
1049 AC_SUBST($1)])
1050
1051 # Like AC_CONFIG_HEADER, but automatically create stamp file.
1052
1053 AC_DEFUN(AM_CONFIG_HEADER,
1054 [AC_PREREQ([2.12])
1055 AC_CONFIG_HEADER([$1])
1056 dnl When config.status generates a header, we must update the stamp-h file.
1057 dnl This file resides in the same directory as the config header
1058 dnl that is generated.  We must strip everything past the first ":",
1059 dnl and everything past the last "/".
1060 AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
1061 ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
1062 <<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
1063 <<am_indx=1
1064 for am_file in <<$1>>; do
1065   case " <<$>>CONFIG_HEADERS " in
1066   *" <<$>>am_file "*<<)>>
1067     echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
1068     ;;
1069   esac
1070   am_indx=`expr "<<$>>am_indx" + 1`
1071 done<<>>dnl>>)
1072 changequote([,]))])
1073
1074 # Add --enable-maintainer-mode option to configure.
1075 # From Jim Meyering
1076
1077 # serial 1
1078
1079 AC_DEFUN(AM_MAINTAINER_MODE,
1080 [AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
1081   dnl maintainer-mode is disabled by default
1082   AC_ARG_ENABLE(maintainer-mode,
1083 [  --enable-maintainer-mode enable make rules and dependencies not useful
1084                           (and sometimes confusing) to the casual installer],
1085       USE_MAINTAINER_MODE=$enableval,
1086       USE_MAINTAINER_MODE=no)
1087   AC_MSG_RESULT($USE_MAINTAINER_MODE)
1088   AM_CONDITIONAL(MAINTAINER_MODE, test $USE_MAINTAINER_MODE = yes)
1089   MAINT=$MAINTAINER_MODE_TRUE
1090   AC_SUBST(MAINT)dnl
1091 ]
1092 )
1093
1094 # Define a conditional.
1095
1096 AC_DEFUN(AM_CONDITIONAL,
1097 [AC_SUBST($1_TRUE)
1098 AC_SUBST($1_FALSE)
1099 if $2; then
1100   $1_TRUE=
1101   $1_FALSE='#'
1102 else
1103   $1_TRUE='#'
1104   $1_FALSE=
1105 fi])
1106
1107
1108 # serial 40 AC_PROG_LIBTOOL
1109 AC_DEFUN(AC_PROG_LIBTOOL,
1110 [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
1111
1112 # Save cache, so that ltconfig can load it
1113 AC_CACHE_SAVE
1114
1115 # Actually configure libtool.  ac_aux_dir is where install-sh is found.
1116 CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
1117 LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
1118 LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
1119 DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
1120 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
1121 $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
1122 || AC_MSG_ERROR([libtool configure failed])
1123
1124 # Reload cache, that may have been modified by ltconfig
1125 AC_CACHE_LOAD
1126
1127 # This can be used to rebuild libtool when needed
1128 LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
1129
1130 # Always use our own libtool.
1131 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
1132 AC_SUBST(LIBTOOL)dnl
1133
1134 # Redirect the config.log output again, so that the ltconfig log is not
1135 # clobbered by the next message.
1136 exec 5>>./config.log
1137 ])
1138
1139 AC_DEFUN(AC_LIBTOOL_SETUP,
1140 [AC_PREREQ(2.13)dnl
1141 AC_REQUIRE([AC_ENABLE_SHARED])dnl
1142 AC_REQUIRE([AC_ENABLE_STATIC])dnl
1143 AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
1144 AC_REQUIRE([AC_CANONICAL_HOST])dnl
1145 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
1146 AC_REQUIRE([AC_PROG_RANLIB])dnl
1147 AC_REQUIRE([AC_PROG_CC])dnl
1148 AC_REQUIRE([AC_PROG_LD])dnl
1149 AC_REQUIRE([AC_PROG_NM])dnl
1150 AC_REQUIRE([AC_PROG_LN_S])dnl
1151 dnl
1152
1153 case "$target" in
1154 NONE) lt_target="$host" ;;
1155 *) lt_target="$target" ;;
1156 esac
1157
1158 # Check for any special flags to pass to ltconfig.
1159 libtool_flags="--cache-file=$cache_file"
1160 test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
1161 test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
1162 test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
1163 test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
1164 test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
1165 ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
1166 [libtool_flags="$libtool_flags --enable-dlopen"])
1167 ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
1168 [libtool_flags="$libtool_flags --enable-win32-dll"])
1169 AC_ARG_ENABLE(libtool-lock,
1170   [  --disable-libtool-lock  avoid locking (might break parallel builds)])
1171 test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
1172 test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
1173
1174 # Some flags need to be propagated to the compiler or linker for good
1175 # libtool support.
1176 case "$lt_target" in
1177 *-*-irix6*)
1178   # Find out which ABI we are using.
1179   echo '[#]line __oline__ "configure"' > conftest.$ac_ext
1180   if AC_TRY_EVAL(ac_compile); then
1181     case "`/usr/bin/file conftest.o`" in
1182     *32-bit*)
1183       LD="${LD-ld} -32"
1184       ;;
1185     *N32*)
1186       LD="${LD-ld} -n32"
1187       ;;
1188     *64-bit*)
1189       LD="${LD-ld} -64"
1190       ;;
1191     esac
1192   fi
1193   rm -rf conftest*
1194   ;;
1195
1196 *-*-sco3.2v5*)
1197   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
1198   SAVE_CFLAGS="$CFLAGS"
1199   CFLAGS="$CFLAGS -belf"
1200   AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
1201     [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
1202   if test x"$lt_cv_cc_needs_belf" != x"yes"; then
1203     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
1204     CFLAGS="$SAVE_CFLAGS"
1205   fi
1206   ;;
1207
1208 ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
1209 [*-*-cygwin* | *-*-mingw*)
1210   AC_CHECK_TOOL(DLLTOOL, dlltool, false)
1211   AC_CHECK_TOOL(AS, as, false)
1212   AC_CHECK_TOOL(OBJDUMP, objdump, false)
1213   ;;
1214 ])
1215 esac
1216 ])
1217
1218 # AC_LIBTOOL_DLOPEN - enable checks for dlopen support
1219 AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
1220
1221 # AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
1222 AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
1223
1224 # AC_ENABLE_SHARED - implement the --enable-shared flag
1225 # Usage: AC_ENABLE_SHARED[(DEFAULT)]
1226 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
1227 #   `yes'.
1228 AC_DEFUN(AC_ENABLE_SHARED, [dnl
1229 define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
1230 AC_ARG_ENABLE(shared,
1231 changequote(<<, >>)dnl
1232 <<  --enable-shared[=PKGS]  build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
1233 changequote([, ])dnl
1234 [p=${PACKAGE-default}
1235 case "$enableval" in
1236 yes) enable_shared=yes ;;
1237 no) enable_shared=no ;;
1238 *)
1239   enable_shared=no
1240   # Look at the argument we got.  We use all the common list separators.
1241   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1242   for pkg in $enableval; do
1243     if test "X$pkg" = "X$p"; then
1244       enable_shared=yes
1245     fi
1246   done
1247   IFS="$ac_save_ifs"
1248   ;;
1249 esac],
1250 enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
1251 ])
1252
1253 # AC_DISABLE_SHARED - set the default shared flag to --disable-shared
1254 AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1255 AC_ENABLE_SHARED(no)])
1256
1257 # AC_ENABLE_STATIC - implement the --enable-static flag
1258 # Usage: AC_ENABLE_STATIC[(DEFAULT)]
1259 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
1260 #   `yes'.
1261 AC_DEFUN(AC_ENABLE_STATIC, [dnl
1262 define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
1263 AC_ARG_ENABLE(static,
1264 changequote(<<, >>)dnl
1265 <<  --enable-static[=PKGS]  build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
1266 changequote([, ])dnl
1267 [p=${PACKAGE-default}
1268 case "$enableval" in
1269 yes) enable_static=yes ;;
1270 no) enable_static=no ;;
1271 *)
1272   enable_static=no
1273   # Look at the argument we got.  We use all the common list separators.
1274   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1275   for pkg in $enableval; do
1276     if test "X$pkg" = "X$p"; then
1277       enable_static=yes
1278     fi
1279   done
1280   IFS="$ac_save_ifs"
1281   ;;
1282 esac],
1283 enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
1284 ])
1285
1286 # AC_DISABLE_STATIC - set the default static flag to --disable-static
1287 AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1288 AC_ENABLE_STATIC(no)])
1289
1290
1291 # AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
1292 # Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
1293 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
1294 #   `yes'.
1295 AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl
1296 define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
1297 AC_ARG_ENABLE(fast-install,
1298 changequote(<<, >>)dnl
1299 <<  --enable-fast-install[=PKGS]  optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
1300 changequote([, ])dnl
1301 [p=${PACKAGE-default}
1302 case "$enableval" in
1303 yes) enable_fast_install=yes ;;
1304 no) enable_fast_install=no ;;
1305 *)
1306   enable_fast_install=no
1307   # Look at the argument we got.  We use all the common list separators.
1308   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1309   for pkg in $enableval; do
1310     if test "X$pkg" = "X$p"; then
1311       enable_fast_install=yes
1312     fi
1313   done
1314   IFS="$ac_save_ifs"
1315   ;;
1316 esac],
1317 enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
1318 ])
1319
1320 # AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
1321 AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1322 AC_ENABLE_FAST_INSTALL(no)])
1323
1324 # AC_PROG_LD - find the path to the GNU or non-GNU linker
1325 AC_DEFUN(AC_PROG_LD,
1326 [AC_ARG_WITH(gnu-ld,
1327 [  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
1328 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
1329 AC_REQUIRE([AC_PROG_CC])dnl
1330 AC_REQUIRE([AC_CANONICAL_HOST])dnl
1331 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
1332 ac_prog=ld
1333 if test "$ac_cv_prog_gcc" = yes; then
1334   # Check if gcc -print-prog-name=ld gives a path.
1335   AC_MSG_CHECKING([for ld used by GCC])
1336   ac_prog=`($CC -print-prog-name=ld) 2>&5`
1337   case "$ac_prog" in
1338     # Accept absolute paths.
1339 changequote(,)dnl
1340     [\\/]* | [A-Za-z]:[\\/]*)
1341       re_direlt='/[^/][^/]*/\.\./'
1342 changequote([,])dnl
1343       # Canonicalize the path of ld
1344       ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
1345       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
1346         ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
1347       done
1348       test -z "$LD" && LD="$ac_prog"
1349       ;;
1350   "")
1351     # If it fails, then pretend we aren't using GCC.
1352     ac_prog=ld
1353     ;;
1354   *)
1355     # If it is relative, then search for the first ld in PATH.
1356     with_gnu_ld=unknown
1357     ;;
1358   esac
1359 elif test "$with_gnu_ld" = yes; then
1360   AC_MSG_CHECKING([for GNU ld])
1361 else
1362   AC_MSG_CHECKING([for non-GNU ld])
1363 fi
1364 AC_CACHE_VAL(ac_cv_path_LD,
1365 [if test -z "$LD"; then
1366   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
1367   for ac_dir in $PATH; do
1368     test -z "$ac_dir" && ac_dir=.
1369     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
1370       ac_cv_path_LD="$ac_dir/$ac_prog"
1371       # Check to see if the program is GNU ld.  I'd rather use --version,
1372       # but apparently some GNU ld's only accept -v.
1373       # Break only if it was the GNU/non-GNU ld that we prefer.
1374       if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
1375         test "$with_gnu_ld" != no && break
1376       else
1377         test "$with_gnu_ld" != yes && break
1378       fi
1379     fi
1380   done
1381   IFS="$ac_save_ifs"
1382 else
1383   ac_cv_path_LD="$LD" # Let the user override the test with a path.
1384 fi])
1385 LD="$ac_cv_path_LD"
1386 if test -n "$LD"; then
1387   AC_MSG_RESULT($LD)
1388 else
1389   AC_MSG_RESULT(no)
1390 fi
1391 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
1392 AC_PROG_LD_GNU
1393 ])
1394
1395 AC_DEFUN(AC_PROG_LD_GNU,
1396 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
1397 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
1398 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
1399   ac_cv_prog_gnu_ld=yes
1400 else
1401   ac_cv_prog_gnu_ld=no
1402 fi])
1403 ])
1404
1405 # AC_PROG_NM - find the path to a BSD-compatible name lister
1406 AC_DEFUN(AC_PROG_NM,
1407 [AC_MSG_CHECKING([for BSD-compatible nm])
1408 AC_CACHE_VAL(ac_cv_path_NM,
1409 [if test -n "$NM"; then
1410   # Let the user override the test.
1411   ac_cv_path_NM="$NM"
1412 else
1413   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
1414   for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
1415     test -z "$ac_dir" && ac_dir=.
1416     if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
1417       # Check to see if the nm accepts a BSD-compat flag.
1418       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
1419       #   nm: unknown option "B" ignored
1420       if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
1421         ac_cv_path_NM="$ac_dir/nm -B"
1422         break
1423       elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
1424         ac_cv_path_NM="$ac_dir/nm -p"
1425         break
1426       else
1427         ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
1428         continue # so that we can try to find one that supports BSD flags
1429       fi
1430     fi
1431   done
1432   IFS="$ac_save_ifs"
1433   test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
1434 fi])
1435 NM="$ac_cv_path_NM"
1436 AC_MSG_RESULT([$NM])
1437 ])
1438
1439 # AC_CHECK_LIBM - check for math library
1440 AC_DEFUN(AC_CHECK_LIBM,
1441 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
1442 LIBM=
1443 case "$lt_target" in
1444 *-*-beos* | *-*-cygwin*)
1445   # These system don't have libm
1446   ;;
1447 *-ncr-sysv4.3*)
1448   AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
1449   AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
1450   ;;
1451 *)
1452   AC_CHECK_LIB(m, main, LIBM="-lm")
1453   ;;
1454 esac
1455 ])
1456
1457 # AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
1458 # the libltdl convenience library, adds --enable-ltdl-convenience to
1459 # the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
1460 # is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
1461 # to be `${top_builddir}/libltdl'.  Make sure you start DIR with
1462 # '${top_builddir}/' (note the single quotes!) if your package is not
1463 # flat, and, if you're not using automake, define top_builddir as
1464 # appropriate in the Makefiles.
1465 AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1466   case "$enable_ltdl_convenience" in
1467   no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
1468   "") enable_ltdl_convenience=yes
1469       ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
1470   esac
1471   LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la
1472   INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
1473 ])
1474
1475 # AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
1476 # the libltdl installable library, and adds --enable-ltdl-install to
1477 # the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
1478 # is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
1479 # to be `${top_builddir}/libltdl'.  Make sure you start DIR with
1480 # '${top_builddir}/' (note the single quotes!) if your package is not
1481 # flat, and, if you're not using automake, define top_builddir as
1482 # appropriate in the Makefiles.
1483 # In the future, this macro may have to be called after AC_PROG_LIBTOOL.
1484 AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1485   AC_CHECK_LIB(ltdl, main,
1486   [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
1487   [if test x"$enable_ltdl_install" = xno; then
1488      AC_MSG_WARN([libltdl not installed, but installation disabled])
1489    else
1490      enable_ltdl_install=yes
1491    fi
1492   ])
1493   if test x"$enable_ltdl_install" = x"yes"; then
1494     ac_configure_args="$ac_configure_args --enable-ltdl-install"
1495     LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la
1496     INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
1497   else
1498     ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
1499     LIBLTDL="-lltdl"
1500     INCLTDL=
1501   fi
1502 ])
1503
1504 dnl old names
1505 AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
1506 AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
1507 AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
1508 AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
1509 AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
1510 AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
1511 AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
1512
1513 dnl This is just to silence aclocal about the macro not being used
1514 ifelse([AC_DISABLE_FAST_INSTALL])dnl
1515