[project @ 2003-08-19 09:25:34 by panne]
[ghc-hetmet.git] / aclocal.m4
1 # Extra autoconf macros for the Glasgow fptools
2 #
3 # To be a good autoconf citizen, names of local macros have prefixed with FP_ to
4 # ensure we don't clash with any pre-supplied autoconf ones.
5
6
7 # FP_PROG_CONTEXT_DIFF
8 # --------------------
9 # Figure out how to do context diffs. Sets the output variable ContextDiffCmd.
10 # NB: NeXTStep thinks diff'ing a file against itself is "trouble".
11 # Used by ghc, glafp-utils/ltx, and glafp-utils/runstdtest
12 AC_DEFUN([FP_PROG_CONTEXT_DIFF],
13 [AC_CACHE_CHECK([for a working context diff], [fp_cv_context_diff],
14 [echo foo > conftest1
15 echo foo > conftest2
16 fp_cv_context_diff=no
17 for fp_var in '-C 1' '-c1'
18 do
19   if diff $fp_var conftest1 conftest2 > /dev/null 2>&1; then
20     fp_cv_context_diff="diff $fp_var"
21     break
22   fi
23 done])
24 if test x"$fp_cv_context_diff" = xno; then
25    AC_MSG_ERROR([cannot figure out how to do context diffs])
26 fi
27 AC_SUBST(ContextDiffCmd, [$fp_cv_context_diff])
28 ])# FP_PROG_CONTEXT_DIFF
29
30
31 # FP_DECL_ALTZONE
32 # -------------------
33 # Defines HAVE_DECL_ALTZONE to 1 if declared, 0 otherwise.
34 # Used by base package.
35 AC_DEFUN([FP_DECL_ALTZONE],
36 [AC_REQUIRE([AC_HEADER_TIME])dnl
37 AC_CHECK_HEADERS([sys/time.h])
38 AC_CHECK_DECLS([altzone], [], [],[#if TIME_WITH_SYS_TIME
39 # include <sys/time.h>
40 # include <time.h>
41 #else
42 # if HAVE_SYS_TIME_H
43 #  include <sys/time.h>
44 # else
45 #  include <time.h>
46 # endif
47 #endif])
48 ])# FP_DECL_ALTZONE
49
50
51 # FP_COMPUTE_INT(EXPRESSION, VARIABLE, INCLUDES, IF-FAILS)
52 # ---------------------------------------------------------
53 # Assign VARIABLE the value of the compile-time EXPRESSION using INCLUDES for
54 # compilation. Execute IF-FAILS when unable to determine the value. Works for
55 # cross-compilation, too.
56 # Note: We are lazy and use an internal autoconf macro, but it is supported in
57 # autoconf versions 2.50 up to the actual 2.57, so there is little risk.
58 AC_DEFUN([FP_COMPUTE_INT],
59 [_AC_COMPUTE_INT([$1], [$2], [$3], [$4])[]dnl
60 ])# FP_COMPUTE_INT
61
62
63 # FP_CHECK_ALIGNMENT(TYPE, [IGNORED], [INCLUDES = DEFAULT-INCLUDES])
64 # ------------------------------------------------------------------
65 # A variation of AC_CHECK_SIZEOF for computing the alignment restrictions of a
66 # given type. Defines ALIGNMENT_TYPE.
67 AC_DEFUN([FP_CHECK_ALIGNMENT],
68 [AS_LITERAL_IF([$1], [],
69                [AC_FATAL([$0: requires literal arguments])])dnl
70 AC_CHECK_TYPE([$1], [], [], [$3])
71 AC_CACHE_CHECK([alignment of $1], AS_TR_SH([fp_cv_alignment_$1]),
72 [if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
73   FP_COMPUTE_INT([(long) (&((struct { char c; $1 ty; } *)0)->ty)],
74                  [AS_TR_SH([fp_cv_alignment_$1])],
75                  [AC_INCLUDES_DEFAULT([$3])],
76                  [AC_MSG_FAILURE([cannot compute alignment ($1), 77])])
77 else
78   AS_TR_SH([fp_cv_alignment_$1])=0
79 fi])dnl
80 AC_DEFINE_UNQUOTED(AS_TR_CPP(alignment_$1), $AS_TR_SH([fp_cv_alignment_$1]),
81                    [The alignment of a `$1'.])
82 ])# FP_CHECK_ALIGNMENT
83
84
85 dnl ** check for leading underscores in symbol names
86 dnl 
87 dnl Test for determining whether symbol names have a leading
88 dnl underscore.
89 dnl 
90 dnl We assume that they _haven't_ if anything goes wrong.
91 dnl
92 dnl Some nlist implementations seem to try to be compatible by ignoring
93 dnl a leading underscore sometimes (eg. FreeBSD).  We therefore have
94 dnl to work around this by checking for *no* leading underscore first.
95 dnl Sigh.  --SDM
96 dnl
97 dnl Similarly on OpenBSD, but this test doesn't help. -- dons
98 dnl
99 AC_DEFUN(FPTOOLS_UNDERSCORE,
100 [AC_CHECK_LIB(elf, nlist, LIBS="-lelf $LIBS")dnl
101 AC_CACHE_CHECK([leading underscore in symbol names], fptools_cv_lead_uscore,
102
103 dnl
104 dnl Hack!: nlist() under Digital UNIX insist on there being an _,
105 dnl but symbol table listings shows none. What is going on here?!?
106 dnl
107 dnl Another hack: cygwin doesn't come with nlist.h , so we hardwire
108 dnl the underscoredness of that "platform"
109 changequote(<<, >>)dnl
110 <<
111 case $HostPlatform in
112 *openbsd*) # x86 openbsd is ELF from 3.4 >, meaning no leading uscore
113     case $build in
114         i386-*2\.[[0-9]] | i386-*3\.[[0-3]] ) fptools_cv_lead_uscore='yes' ;;
115         *)      fptools_cv_lead_uscore='no' ;;
116     esac ;;
117 alpha-dec-osf*) fptools_cv_lead_uscore='no';;
118 *cygwin32) fptools_cv_lead_uscore='yes';;
119 *mingw32) fptools_cv_lead_uscore='yes';;
120 *) >>
121 changequote([, ])dnl
122 AC_TRY_RUN([#ifdef HAVE_NLIST_H
123 #include <nlist.h>
124 changequote(<<, >>)dnl
125 <<
126 struct nlist xYzzY1[] = {{"xYzzY1", 0},{0}};
127 struct nlist xYzzY2[] = {{"_xYzzY2", 0},{0}};
128 #endif
129
130 main(argc, argv)
131 int argc;
132 char **argv;
133 {
134 #ifdef HAVE_NLIST_H
135     if(nlist(argv[0], xYzzY1) == 0 && xYzzY1[0].n_value != 0)
136         exit(1);
137     if(nlist(argv[0], xYzzY2) == 0 && xYzzY2[0].n_value != 0)
138         exit(0);>>
139 changequote([, ])dnl
140 #endif
141     exit(1);
142 }], fptools_cv_lead_uscore=yes, fptools_cv_lead_uscore=no, fptools_cv_lead_uscore=NO)
143 ;;
144 esac);
145 LeadingUnderscore=`echo $fptools_cv_lead_uscore | sed 'y/yesno/YESNO/'`
146 AC_SUBST(LeadingUnderscore)
147 case $LeadingUnderscore in
148 YES) AC_DEFINE(LEADING_UNDERSCORE);;
149 esac
150 ])
151
152 dnl
153 dnl FPTOOLS_PROG_CHECK_VERSION(VERSIONSTR1, TEST, VERSIONSTR2,
154 dnl                            ACTION-IF-TRUE [, ACTION-IF-FALSE])
155 dnl
156 dnl compare versions field-wise (separator is '.')
157 dnl TEST is one of {-lt,-le,-eq,-ge,-gt}
158 dnl
159 dnl quite shell-independant and SUSv2 compliant code
160 dnl
161 dnl NOTE: the loop could be unrolled within autoconf, but the
162 dnl       macro code would be a) longer and b) harder to debug... ;)
163 dnl
164 AC_DEFUN(FPTOOLS_PROG_CHECK_VERSION,
165 [if ( IFS=".";
166       a="[$1]";  b="[$3]";
167       while test -n "$a$b"
168       do
169               set -- [$]a;  h1="[$]1";  shift 2>/dev/null;  a="[$]*"
170               set -- [$]b;  h2="[$]1";  shift 2>/dev/null;  b="[$]*"
171               test -n "[$]h1" || h1=0;  test -n "[$]h2" || h2=0
172               test [$]{h1} -eq [$]{h2} || break
173       done
174       test [$]{h1} [$2] [$]{h2}
175     )
176 then ifelse([$4],,[:],[
177   $4])
178 ifelse([$5],,,
179 [else
180   $5])
181 fi
182 ])])dnl
183
184
185 dnl
186 dnl Check for Greencard and version.
187 dnl
188 AC_DEFUN(FPTOOLS_GREENCARD,
189 [
190 AC_PATH_PROG(GreencardCmd,greencard)
191 AC_CACHE_CHECK([for version of greencard], fptools_cv_greencard_version,
192 changequote(, )dnl
193 [if test x"$GreencardCmd" != x; then
194    fptools_cv_greencard_version="`$GreencardCmd --version |
195                           grep 'version' | sed -e 's/greencard. version \([^ ]*\).*/\1/g'`"
196 else
197    fptools_cv_greencard_version=""
198 fi
199 changequote([, ])dnl
200 ])
201 FPTOOLS_PROG_CHECK_VERSION([$fptools_cv_greencard_version],-lt,$1,
202   [AC_MSG_ERROR([greencard version $1 or later is required (found '$fptools_cv_greencard_version')])])dnl
203 GreencardVersion=$fptools_cv_greencard_version
204 AC_SUBST(GreencardVersion)
205 ])
206
207 dnl
208 dnl Check for Happy and version.  If we're building GHC, then we need
209 dnl at least Happy version 1.13.  If there's no installed Happy, we look
210 dnl for a happy source tree and point the build system at that instead.
211 dnl
212 AC_DEFUN(FPTOOLS_HAPPY,
213 [
214 if test -d $srcdir/happy; then
215    SrcTreeHappyCmd=$hardtop/happy/src/happy-inplace
216 fi
217 if test x"$UseSrcTreeHappy" = xYES; then
218   HappyCmd=$SrcTreeHappyCmd
219 else
220   AC_PATH_PROG(HappyCmd,happy,$SrcTreeHappyCmd)
221 fi
222 AC_CACHE_CHECK([for version of happy], fptools_cv_happy_version,
223 changequote(, )dnl
224 [if test x"$HappyCmd" = x"$SrcTreeHappyCmd"; then
225    fptools_cv_happy_version=`grep '^ProjectVersion[     ]*=' $srcdir/happy/mk/version.mk | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`;
226 elif test x"$HappyCmd" != x; then
227    fptools_cv_happy_version="`$HappyCmd -v |
228                           grep 'Happy Version' | sed -e 's/Happy Version \([^ ]*\).*/\1/g'`" ;
229 else
230    fptools_cv_happy_version="";
231 fi;
232 changequote([, ])dnl
233 ])
234 if test -d $srcdir/ghc -a ! -f $srcdir/ghc/compiler/parser/Parser.hs; then
235   FPTOOLS_PROG_CHECK_VERSION([$fptools_cv_happy_version],-lt,[1.13],
236   [AC_MSG_ERROR([Happy version 1.13 or later is required to compile GHC.])])dnl
237 fi
238 HappyVersion=$fptools_cv_happy_version;
239 AC_SUBST(HappyVersion)
240 ])
241
242 dnl
243 dnl Check for Haddock and version.  If there's no installed Haddock, we look
244 dnl for a haddock source tree and point the build system at that instead.
245 dnl
246 AC_DEFUN(FPTOOLS_HADDOCK,
247 [
248 if test -d $srcdir/haddock; then
249    SrcTreeHaddockCmd=$hardtop/haddock/src/haddock-inplace
250 fi
251 if test x"$UseSrcTreeHaddock" = xYES; then
252   HaddockCmd=$SrcTreeHaddockCmd
253 else
254   AC_PATH_PROG(HaddockCmd,haddock,$SrcTreeHaddockCmd)
255 fi
256 dnl Darn, I forgot to make Haddock print out its version number when
257 dnl invoked with -v.  We could try generating some HTML and grepping
258 dnl through that to find the version number, but I think we'll make
259 dnl do without it for now.
260 ])
261
262 dnl
263 dnl Check for Alex and version.  If we're building GHC, then we need
264 dnl at least Alex version 2.0.  If there's no installed Alex, we look
265 dnl for a alex source tree and point the build system at that instead.
266 dnl
267 AC_DEFUN(FPTOOLS_ALEX,
268 [
269 if test -d $srcdir/alex; then
270    SrcTreeAlexCmd=$hardtop/alex/src/alex-inplace
271 fi
272 if test x"$UseSrcTreeAlex" = xYES; then
273   AlexCmd=$SrcTreeAlexCmd
274 else
275   AC_PATH_PROG(AlexCmd,alex,$SrcTreeAlexCmd)
276 fi
277 AC_CACHE_CHECK([for version of alex], fptools_cv_alex_version,
278 changequote(, )dnl
279 [if test x"$AlexCmd" = x"$SrcTreeAlexCmd"; then
280    fptools_cv_alex_version=`grep '^ProjectVersion[      ]*=' $srcdir/alex/mk/version.mk | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`;
281 elif test x"$AlexCmd" != x; then
282    fptools_cv_alex_version="`$AlexCmd -v |
283                           grep 'Alex [Vv]ersion' | sed -e 's/Alex [Vv]ersion \([0-9\.]*\).*/\1/g'`" ;
284 else
285    fptools_cv_alex_version="";
286 fi;
287 changequote([, ])dnl
288 ])
289 dnl if test -d $srcdir/ghc -a ! -f $srcdir/ghc/compiler/parser/Lexer.hs; then
290 dnl   FPTOOLS_PROG_CHECK_VERSION([$fptools_cv_alex_version],-lt,[2.0],
291 dnl   [AC_MSG_ERROR([Alex version 2.0 or later is required to compile GHC.])])dnl
292 dnl fi
293 AlexVersion=$fptools_cv_alex_version;
294 AC_SUBST(AlexVersion)
295 ])
296
297
298 dnl
299 dnl Check whether ld supports -x
300 dnl
301 AC_DEFUN(FPTOOLS_LD_X,
302 [AC_CACHE_CHECK([whether ld understands -x], fptools_cv_ld_x,
303 [
304 echo 'foo() {}' > conftest.c
305 ${CC-cc} -c conftest.c
306 if ${LdCmd} -r -x -o foo.o conftest.o; then
307    fptools_cv_ld_x=yes
308 else
309    fptools_cv_ld_x=no
310 fi
311 rm -rf conftest.c conftest.o foo.o
312 ])
313 if test "$fptools_cv_ld_x" = yes; then
314         LdXFlag=-x
315 else
316         LdXFlag=
317 fi
318 AC_SUBST(LdXFlag)
319 ])
320
321
322 dnl *** Checking for ar and its arguments + whether we need ranlib.
323 dnl
324 dnl ArCmd, ArSupportsInput and RANLIB are AC_SUBST'ed
325 dnl On Digital UNIX, we test for the -Z (compress) and
326 dnl -input (take list of files from external file) flags.
327 dnl 
328 AC_DEFUN(FPTOOLS_PROG_AR_AND_RANLIB,
329 [AC_PATH_PROG(ArCmdRaw,ar)
330 if test -z "$ArCmdRaw"; then
331     echo "You don't seem to have ar in your PATH...I have no idea how to make a library"
332     exit 1;
333 fi
334 dnl GNU ar needs special treatment: it appears to have problems with
335 dnl object files with the same name if you use the 's' modifier, but
336 dnl simple 'ar q' works fine, and doesn't need a separate ranlib.
337 if $ArCmdRaw --version | grep 'GNU' >/dev/null 2>/dev/null; then
338     ArCmdArgs='q'
339     NeedRanLib=''
340 elif $ArCmdRaw clqsZ conftest.a >/dev/null 2>/dev/null; then
341     ArCmdArgs="clqsZ"
342     NeedRanLib=''
343 elif $ArCmdRaw clqs conftest.a >/dev/null 2>/dev/null; then
344     ArCmdArgs="clqs"
345     NeedRanLib=''
346 elif $ArCmdRaw cqs conftest.a >/dev/null 2>/dev/null; then
347     ArCmdArgs="cqs"
348     NeedRanLib=''
349 elif $ArCmdRaw clq conftest.a >/dev/null 2>/dev/null; then
350     ArCmdArgs="clq"
351     NeedRanLib='YES'
352 elif $ArCmdRaw cq conftest.a >/dev/null 2>/dev/null; then
353     ArCmdArgs="cq"
354     NeedRanLib='YES'
355 elif $ArCmdRaw cq conftest.a 2>&1 | grep 'no archive members specified' >/dev/null 2>/dev/null; then
356     ArCmdArgs="cq"
357     NeedRanLib='YES'
358 else
359     echo "I can't figure out how to use your $ArCmd"
360     exit 1
361 fi
362 rm -rf conftest*
363 case $HostPlatform in
364  *mingw32) 
365           ArCmd="`cygpath -w ${ArCmdRaw} | sed -e 's@\\\\@/@g' ` ${ArCmdArgs}"
366           ;;
367  *) ArCmd="${ArCmdRaw} ${ArCmdArgs}"
368     ;;
369 esac
370 test -n "$ArCmd" && test -n "$verbose" && echo "        setting ArCmd to $ArCmd"
371 AC_SUBST(ArCmd)
372 if $ArCmd conftest.a -input /dev/null >/dev/null 2>/dev/null; then
373     ArSupportsInput='-input'
374 else
375     ArSupportsInput=''
376 fi
377 rm -rf conftest*
378 test -n "$ArSupportsInput" && test -n "$verbose" && echo "        setting ArSupportsInput to $ArSupportsInput"
379 AC_SUBST(ArSupportsInput)
380 if test -z "$NeedRanLib"; then
381     RANLIB=':'
382     test -n "$verbose" && echo "        setting RANLIB to $RANLIB"
383     AC_SUBST(RANLIB)
384 else
385     AC_PROG_RANLIB
386 fi
387 ])
388
389 dnl
390 dnl AC_SHEBANG_PERL - can we she-bang perl?
391 dnl
392 AC_DEFUN(FPTOOLS_SHEBANG_PERL,
393 [AC_CACHE_CHECK([if your perl works in shell scripts], fptools_cv_shebang_perl,
394 [echo "#!$PerlCmd"'
395 exit $1;
396 ' > conftest
397 chmod u+x conftest
398 (SHELL=/bin/sh; export SHELL; ./conftest 69 > /dev/null)
399 if test $? -ne 69; then
400    fptools_cv_shebang_perl=yes
401 else
402    fptools_cv_shebang_perl=no
403 fi
404 rm -f conftest
405 ])])
406
407 dnl
408 dnl Extra testing of the result AC_PROG_CC, testing the gcc version no.
409 dnl *Must* be called after AC_PROG_CC
410 dnl
411 AC_DEFUN(FPTOOLS_HAVE_GCC,
412 [AC_CACHE_CHECK([whether you have an ok gcc], fptools_cv_have_gcc,
413 [if test -z "$GCC"; then
414     echo ''
415     echo "You would be better off with gcc"
416     echo "Perhaps it is already installed, but not in your PATH?"
417     fptools_cv_have_gcc='no'
418 else
419 changequote(, )dnl
420     gcc_version_str="`$CC -v 2>&1 | grep 'version ' | sed -e 's/.*version [^0-9]*\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\1\.\2/g' `"
421 changequote([, ])dnl
422     fptools_cv_have_gcc='yes'
423     FPTOOLS_PROG_CHECK_VERSION($gcc_version_str, -lt, "2.0",
424         fptools_cv_have_gcc='no'
425         echo ""
426         echo "your gcc version appears to be ..."
427         $CC --version
428         echo "gcc prior to 2.0 and have never worked with ghc."
429         echo "we recommend 2.95.3, although versions back to 2.7.2 should be ok."
430         AC_MSG_ERROR([gcc 1.X has never been supported])
431     )
432 fi
433 ])
434 HaveGcc=`echo $fptools_cv_have_gcc | sed 'y/yesno/YESNO/'`
435 AC_SUBST(HaveGcc)
436 ])
437
438 dnl
439 dnl Some OSs (Mandrake Linux, in particular) configure GCC with
440 dnl -momit-leaf-frame-pointer on by default.  If this is the case, we
441 dnl need to turn it off for mangling to work.  The test is currently a bit
442 dnl crude, using only the version number of gcc.
443 dnl
444 AC_DEFUN(FPTOOLS_GCC_NEEDS_NO_OMIT_LFPTR,
445 [AC_CACHE_CHECK([whether gcc needs -mno-omit-leaf-frame-pointer], fptools_cv_gcc_needs_no_omit_lfptr,
446 [
447  fptools_cv_gcc_needs_no_omit_lfptr='no'
448  FPTOOLS_PROG_CHECK_VERSION($gcc_version_str, -ge, "3.2",
449      fptools_cv_gcc_needs_no_omit_lfptr='yes')
450 ])
451 if test "$fptools_cv_gcc_needs_no_omit_lfptr" = "yes"; then
452    AC_DEFINE(HAVE_GCC_MNO_OMIT_LFPTR)
453 fi
454 ])
455
456 dnl Small feature test for perl version. Assumes PerlCmd
457 dnl contains path to perl binary
458 dnl
459 AC_DEFUN(FPTOOLS_CHECK_PERL_VERSION,
460 [$PerlCmd -v >conftest.out 2>&1
461 if grep "version 5" conftest.out >/dev/null 2>&1; then
462    :
463 else
464    if grep "v5.6" conftest.out >/dev/null 2>&1; then
465       :
466    else
467       if grep "v5.8" conftest.out >/dev/null 2>&1; then
468          :
469       else
470          if grep "version 6" conftest.out >/dev/null 2>&1; then
471             :
472          else
473             echo "Your version of perl probably won't work."
474          fi  
475       fi
476    fi
477 fi
478 rm -fr conftest*
479 ])
480
481 dnl
482 dnl Getting at the right version of 'find'
483 dnl (i.e., not the MS util on a Win32 box).
484 dnl
485 AC_DEFUN(FPTOOLS_FIND_FIND,
486 [
487 AC_PATH_PROG(Find2Cmd, find)
488 $Find2Cmd --version > conftest.out 2>&1 
489 if grep "FIND: Parameter format" conftest.out >/dev/null 2>&1 ; then
490    # Encountered MS' find utility, which is not what we're after.
491    #
492    # HACK - AC_CHECK_PROG is useful here in that does let you reject
493    # an (absolute) entry in the path (Find2Cmd). It is not so useful
494    # in that it doesn't let you (AFAIU) set VARIABLE equal to the 
495    # absolute path eventually found. So, hack around this by inspecting
496    # what variables hold the abs. path & use them directly.
497    AC_CHECK_PROG(FindCmd,find,`echo $ac_dir/$ac_word`,find,,$Find2Cmd)
498 else
499 FindCmd=$Find2Cmd
500 AC_SUBST(FindCmd)
501 fi
502 ])
503
504 dnl
505 dnl FPTOOLS_NOCACHE_CHECK prints a message, then sets the
506 dnl values of the second argument to the result of running
507 dnl the commands given by the third. It does not cache its
508 dnl result, so it is suitable for checks which should be
509 dnl run every time.
510 dnl
511 AC_DEFUN(FPTOOLS_NOCACHE_CHECK,
512 [AC_MSG_CHECKING([$1])
513  $3
514  AC_MSG_RESULT([$][$2])
515 ])
516
517 dnl
518 dnl FPTOOLS_GHC_VERSION(version)
519 dnl FPTOOLS_GHC_VERSION(major, minor [, patchlevel])
520 dnl FPTOOLS_GHC_VERSION(version, major, minor, patchlevel)
521 dnl
522 dnl Test for version of installed ghc.  Uses $GHC.
523 dnl [original version pinched from c2hs]
524 dnl
525 AC_DEFUN(FPTOOLS_GHC_VERSION,
526 [FPTOOLS_NOCACHE_CHECK([version of ghc], [fptools_version_of_ghc],
527 ["${WithGhc-ghc}" --version > conftestghc 2>&1
528   cat conftestghc >&AC_FD_CC
529 #Useless Use Of cat award...
530   fptools_version_of_ghc=`cat conftestghc | sed -n -e 's/, patchlevel *\([[0-9]]\)/.\1/;s/.* version \([[0-9]][[0-9.]]*\).*/\1/p'`
531   rm -fr conftest*
532   if test "[$]fptools_version_of_ghc" = ""
533   then
534     fptools_version_of_ghc='unknown'
535   fi
536 fptools_version_of_ghc[_major]=`echo [$]fptools_version_of_ghc | sed -e 's/^\([[0-9]]\).*/\1/'`
537 fptools_version_of_ghc[_minor]=`echo [$]fptools_version_of_ghc | sed -e 's/^[[0-9]]\.\([[0-9]]*\).*/\1/'`
538 fptools_version_of_ghc[_pl]=`echo [$]fptools_version_of_ghc | sed -n -e 's/^[[0-9]]\.[[0-9]]*\.\([[0-9]]*\)/\1/p'`
539 #
540 if test "[$]fptools_version_of_ghc[_pl]" = ""
541 then
542   fptools_version_of_ghc[_all]="[$]fptools_version_of_ghc[_major].[$]fptools_version_of_ghc[_minor]"
543   fptools_version_of_ghc[_pl]="0"
544 else
545   fptools_version_of_ghc[_all]="[$]fptools_version_of_ghc[_major].[$]fptools_version_of_ghc[_minor].[$]fptools_version_of_ghc[_pl]"
546 fi
547 #
548 ifelse($#, [1], [dnl
549 [$1]="[$]fptools_version_of_ghc[_all]"
550 ], $#, [2], [dnl
551 [$1]="[$]fptools_version_of_ghc[_major]"
552 [$2]="[$]fptools_version_of_ghc[_minor]"
553 ], $#, [3], [dnl
554 [$1]="[$]fptools_version_of_ghc[_major]"
555 [$2]="[$]fptools_version_of_ghc[_minor]"
556 [$3]="[$]fptools_version_of_ghc[_pl]"
557 ], $#, [4], [dnl
558 [$1]="[$]fptools_version_of_ghc[_all]"
559 [$2]="[$]fptools_version_of_ghc[_major]"
560 [$3]="[$]fptools_version_of_ghc[_minor]"
561 [$4]="[$]fptools_version_of_ghc[_pl]"
562 ])
563 ])
564 ])dnl
565
566
567 dnl ** Map an arithmetic C type to a Haskell type.
568 dnl    Based on autconf's AC_CHECK_SIZEOF.
569
570 dnl FPTOOLS_CHECK_HTYPE(TYPE [, DEFAULT_VALUE, [, VALUE-FOR-CROSS-COMPILATION])
571 AC_DEFUN(FPTOOLS_CHECK_HTYPE,
572 [changequote(<<, >>)dnl
573 dnl The name to #define.
574 define(<<AC_TYPE_NAME>>, translit(htype_$1, [a-z *], [A-Z_P]))dnl
575 dnl The cache variable name.
576 define(<<AC_CV_NAME>>, translit(fptools_cv_htype_$1, [ *], [_p]))dnl
577 changequote([, ])dnl
578 AC_MSG_CHECKING(Haskell type for $1)
579 AC_CACHE_VAL(AC_CV_NAME,
580 [AC_TRY_RUN([#include <stdio.h>
581 #include <stddef.h>
582
583 #ifdef HAVE_SYS_TYPES_H
584 # include <sys/types.h>
585 #endif
586
587 #ifdef HAVE_UNISTD_H
588 # include <unistd.h>
589 #endif
590
591 #ifdef HAVE_SYS_STAT_H
592 # include <sys/stat.h>
593 #endif
594
595 #ifdef HAVE_FCNTL_H
596 # include <fcntl.h>
597 #endif
598
599 #ifdef HAVE_SIGNAL_H
600 # include <signal.h>
601 #endif
602
603 #ifdef HAVE_TIME_H
604 # include <time.h>
605 #endif
606
607 #ifdef HAVE_TERMIOS_H
608 # include <termios.h>
609 #endif
610
611 #ifdef HAVE_STRING_H
612 # include <string.h>
613 #endif
614
615 #ifdef HAVE_CTYPE_H
616 # include <ctype.h>
617 #endif
618
619 #ifdef HAVE_GL_GL_H
620 # include <GL/gl.h>
621 #endif
622
623 #ifdef HAVE_OPENGL_GL_H
624 # include <OpenGL/gl.h>
625 #endif
626
627 #ifdef HAVE_SYS_RESOURCE_H
628 # include <sys/resource.h>
629 #endif
630
631 typedef $1 testing;
632
633 main() {
634   FILE *f=fopen("conftestval", "w");
635   if (!f) exit(1);
636   if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
637     fprintf(f, "%s%d\n",
638            ((testing)(-1) < (testing)0) ? "Int" : "Word",
639            sizeof(testing)*8);
640   } else {
641     fprintf(f,"%s\n",
642            (sizeof(testing) >  sizeof(double)) ? "LDouble" :
643            (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
644   }
645   fclose(f);
646   exit(0);
647 }], AC_CV_NAME=`cat conftestval`,
648 ifelse([$2], , AC_CV_NAME=NotReallyAType,      AC_CV_NAME=$2),
649 ifelse([$3], , AC_CV_NAME=NotReallyATypeCross, AC_CV_NAME=$3))]) dnl
650 AC_MSG_RESULT($AC_CV_NAME)
651 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
652 undefine([AC_TYPE_NAME])dnl
653 undefine([AC_CV_NAME])dnl
654 ])
655
656
657 dnl ** Obtain the value of a C constant.
658 dnl    The value will be `(-1)' if the constant is undefined.
659 dnl
660 dnl    This is set up so that the argument can be a shell variable.
661 dnl
662 AC_DEFUN(FPTOOLS_CHECK_CCONST,
663 [
664 eval "cv_name=ac_cv_cconst_$1"
665 AC_MSG_CHECKING(value of $1)
666 AC_CACHE_VAL($cv_name,
667 [AC_TRY_RUN([#include <stdio.h>
668 #include <errno.h>
669 main()
670 {
671   FILE *f=fopen("conftestval", "w");
672   if (!f) exit(1);
673   fprintf(f, "%d\n", $1);
674   exit(0);
675 }], 
676 eval "$cv_name=`cat conftestval`",
677 eval "$cv_name=-1",
678 eval "$cv_name=-1")])dnl
679 eval "fptools_check_cconst_result=`echo '$'{$cv_name}`"
680 AC_MSG_RESULT($fptools_check_cconst_result)
681 AC_DEFINE_UNQUOTED(CCONST_$1, $fptools_check_cconst_result)
682 unset fptools_check_cconst_result
683 ])
684
685 dnl ** Invoke AC_CHECK_CCONST on each argument (which have to separate with 
686 dnl    spaces)
687 dnl
688 AC_DEFUN(FPTOOLS_CHECK_CCONSTS,
689 [for ac_const_name in $1
690 do
691 FPTOOLS_CHECK_CCONST($ac_const_name)dnl
692 done
693 ])
694
695
696 dnl *** Can we open files in binary mode? ***
697 dnl 
698 AC_DEFUN(FPTOOLS_O_BINARY,
699 [
700 AC_REQUIRE([AC_PROG_CC])
701 AC_MSG_CHECKING(whether we can open files in binary mode)
702 AC_CACHE_VAL(fptools_cv_have_o_binary,
703 [
704 AC_LANG_SAVE
705 AC_LANG_C
706 AC_TRY_COMPILE(
707 [#ifdef HAVE_FCNTL_H
708 #include <fcntl.h>
709 #endif],
710 [int x = O_BINARY;],
711 fptools_cv_have_o_binary=yes,
712 fptools_cv_have_o_binary=no)
713 AC_LANG_RESTORE
714 ])
715 AC_MSG_RESULT($fptools_cv_have_o_binary)
716 if test "$fptools_cv_have_o_binary" = yes; then
717 AC_DEFINE(HAVE_O_BINARY)
718 fi
719 ])
720
721
722 dnl Based on AC_TRY_LINK - run iftrue if links cleanly with no warning
723
724 dnl FPTOOLS_TRY_LINK_NOWARN(flags,main?,iftrue,iffalse)
725
726 AC_DEFUN(FPTOOLS_TRY_LINK_NOWARN,
727 [
728 ac_save_LIBS="$LIBS"
729 LIBS=[$1];
730 cat > conftest.$ac_ext <<EOF
731 dnl This sometimes fails to find confdefs.h, for some reason.
732 dnl [#]line __oline__ "[$]0"
733 [#]line __oline__ "configure"
734 #include "confdefs.h"
735 [$2]
736 int t() { return 0; }
737 EOF
738 if AC_TRY_EVAL(ac_link); then
739   ifelse([$3], , :, [
740     LIBS="$ac_save_LIBS"
741     rm -rf conftest*
742     $3])
743   ifelse([$4], , , [else
744     LIBS="$ac_save_LIBS"
745     rm -rf conftest*
746     $4
747 ])dnl
748 fi
749 rm -f conftest*
750 ]
751 )
752
753 dnl Loosely based on AC_CHECK_LIB in acgeneral.m4 in autoconf distribution
754
755 dnl FPTOOLS_CHECK_FLAG_NOWARN(NAME, FLAG, CODE, iftrue, iffalse)
756
757 AC_DEFUN(FPTOOLS_CHECK_FLAG_NOWARN,
758 [AC_MSG_CHECKING([for $1])
759  AC_CACHE_VAL(ac_cv_flag_$1,
760    [FPTOOLS_TRY_LINK_NOWARN("$2", [main() { $3; exit(0); } ],
761      eval "ac_cv_flag_$1=yes",
762      eval "ac_cv_flag_$1=no"
763    )]
764  )
765 if eval "test \"`echo '$ac_cv_flag_'$1`\" = yes"; then
766   AC_MSG_RESULT(yes)
767   LIBS="$2 $LIBS"
768   $4
769 else
770   AC_MSG_RESULT(no)
771   $5
772 fi
773 ])
774
775 dnl FPTOOLS_CHECK_LIB_NOWARN(LIBRARY, FUNCTION)
776
777 AC_DEFUN(FPTOOLS_CHECK_LIB_NOWARN,
778 [FPTOOLS_CHECK_FLAG_NOWARN([function_$2],[],[extern char $2(); $2();],
779 [changequote(, )dnl
780   ac_tr_lib=HAVE_LIB`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
781  changequote([, ])dnl
782  AC_DEFINE_UNQUOTED($ac_tr_lib)
783 ],
784 [FPTOOLS_CHECK_FLAG_NOWARN([library_$1],[-l$1],[extern char $2(); $2();],
785 [changequote(, )dnl
786   ac_tr_lib=HAVE_LIB`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
787  changequote([, ])dnl
788  AC_DEFINE_UNQUOTED($ac_tr_lib)
789 ],
790 []
791 )])]
792 )
793
794
795 dnl ** Check which CATALOG file we have to use with DocBook SGML.
796 dnl
797 dnl FPTOOLS_DOCBOOK_CATALOG(VARIABLE, JADE, STYLESHEET, CATALOGS-TO-CHECK-FOR)
798 dnl
799 dnl If any of the catalogs given in CATALOGS-TO-CHECK-FOR works on this
800 dnl platform, let VARIABLE refer to this catalog; otherwise, VARIABLE
801 dnl is set to "no".  JADE is the jade executable and STYLESHEET
802 dnl a DocBook style sheet.
803 dnl
804 AC_DEFUN(FPTOOLS_DOCBOOK_CATALOG,
805 [AC_CACHE_CHECK([for DocBook CATALOG], fptools_cv_sgml_catalog,
806 [
807 cat > conftest.sgml << EOF
808 <!DOCTYPE Article PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
809 <Article>
810 <ArtHeader>
811 <Title>Test</Title>
812 <Author><OtherName>Test</OtherName></Author>
813 <Address>Test</Address>
814 <PubDate>Test</PubDate>
815 </ArtHeader>
816 <Sect1><Title>Test</Title>
817 <Para>
818 Test.
819 </Para>
820 </Sect1>
821 </Article>
822 EOF
823 fptools_cv_sgml_catalog=no
824 if test -z "$SGML_CATALOG_FILES" ; then
825  for fptools_catalog in $4; do
826    ac_try="$2 -t rtf -d $3#print -c $fptools_catalog conftest.sgml"
827    if AC_TRY_EVAL(ac_try); then
828      fptools_cv_sgml_catalog=[$]fptools_catalog
829      break
830    fi
831  done
832 else
833 # If the env var SGML_CATALOG_FILES is defined, assume things are cool.
834   fptools_cv_sgml_catalog="yes"
835 fi
836 ])
837 rm -rf conftest*
838 if test $fptools_cv_sgml_catalog != "no"; then
839   $1=$fptools_cv_sgml_catalog
840 fi
841 ])
842
843 dnl ######################################################################
844 dnl FPTOOLS_SEARCH_LIBS(INCLUDES, FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
845 dnl                     [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
846 dnl Search for a library defining FUNC, if it's not already available.
847 dnl This is almost the same as AC_SEARCH_LIBS, but the INCLUDES can be
848 dnl specified.
849 dnl ######################################################################
850
851 AC_DEFUN(FPTOOLS_SEARCH_LIBS,
852 [AC_PREREQ([2.13])
853 AC_CACHE_CHECK([for library containing $2], [ac_cv_search_$2],
854 [ac_func_search_save_LIBS="$LIBS"
855 ac_cv_search_$2="no"
856 AC_TRY_LINK([$1], [$2()], [ac_cv_search_$2="none required"])
857 test "$ac_cv_search_$2" = "no" && for i in $3; do
858 LIBS="-l$i $6 $ac_func_search_save_LIBS"
859 AC_TRY_LINK([$1], [$2()],
860 [ac_cv_search_$2="-l$i"
861 break])
862 done
863 LIBS="$ac_func_search_save_LIBS"])
864 if test "$ac_cv_search_$2" != "no"; then
865   test "$ac_cv_search_$2" = "none required" || LIBS="$ac_cv_search_$2 $LIBS"
866   $4
867 else :
868   $5
869 fi])
870
871 dnl ####################### -*- Mode: M4 -*- ###########################
872 dnl Copyright (C) 98, 1999 Matthew D. Langston <langston@SLAC.Stanford.EDU>
873 dnl
874 dnl This file is free software; you can redistribute it and/or modify it
875 dnl under the terms of the GNU General Public License as published by
876 dnl the Free Software Foundation; either version 2 of the License, or
877 dnl (at your option) any later version.
878 dnl
879 dnl This file is distributed in the hope that it will be useful, but
880 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
881 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
882 dnl General Public License for more details.
883 dnl
884 dnl You should have received a copy of the GNU General Public License
885 dnl along with this file; if not, write to:
886 dnl
887 dnl   Free Software Foundation, Inc.
888 dnl   Suite 330
889 dnl   59 Temple Place
890 dnl   Boston, MA 02111-1307, USA.
891 dnl ####################################################################
892
893
894 dnl @synopsis FPTOOLS_CHECK_LIBM
895 dnl 
896 dnl Search for math library (typically -lm).
897 dnl
898 dnl The variable LIBM (which is not an output variable by default) is
899 dnl set to a value which is suitable for use in a Makefile (for example,
900 dnl in make's LOADLIBES macro) provided you AC_SUBST it first.
901 dnl
902 dnl @author Matthew D. Langston <langston@SLAC.Stanford.EDU>
903
904 # FPTOOLS_CHECK_LIBM - check for math library
905 AC_DEFUN(FPTOOLS_CHECK_LIBM,
906 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
907 LIBM=
908 case "$host" in
909 *-*-beos*)
910   # These system don't have libm
911   ;;
912 *-ncr-sysv4.3*)
913   AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
914   AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
915   ;;
916 *)
917   AC_CHECK_LIB(m, main, LIBM="-lm")
918   ;;
919 esac
920 ])
921
922 dnl ######################################################################
923 dnl Note: Caching has been completely rewritten, but is still no perfect yet.
924 dnl ######################################################################
925
926 dnl ########################### -*- Mode: M4 -*- #######################
927 dnl Copyright (C) 98, 1999 Matthew D. Langston <langston@SLAC.Stanford.EDU>
928 dnl
929 dnl This file is free software; you can redistribute it and/or modify it
930 dnl under the terms of the GNU General Public License as published by
931 dnl the Free Software Foundation; either version 2 of the License, or
932 dnl (at your option) any later version.
933 dnl
934 dnl This file is distributed in the hope that it will be useful, but
935 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
936 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
937 dnl General Public License for more details.
938 dnl
939 dnl You should have received a copy of the GNU General Public License
940 dnl along with this file; if not, write to:
941 dnl
942 dnl   Free Software Foundation, Inc.
943 dnl   Suite 330
944 dnl   59 Temple Place
945 dnl   Boston, MA 02111-1307, USA.
946 dnl ####################################################################
947
948 dnl @synopsis FPTOOLS_HAVE_OPENGL
949 dnl 
950 dnl Search for OpenGL.  We search first for Mesa (a GPL'ed version of
951 dnl OpenGL) before a vendor's version of OpenGL if we were specifically
952 dnl asked to with `--with-Mesa=yes' or `--with-Mesa'.
953 dnl
954 dnl The four "standard" OpenGL libraries are searched for: "-lGL",
955 dnl "-lGLU", "-lGLX" (or "-lMesaGL", "-lMesaGLU" as the case may be) and
956 dnl "-lglut".
957 dnl
958 dnl All of the libraries that are found (since "-lglut" or "-lGLX" might
959 dnl be missing) are added to the shell output variable "GL_LIBS", along
960 dnl with any other libraries that are necessary to successfully link an
961 dnl OpenGL application (e.g. the X11 libraries).  Care has been taken to
962 dnl make sure that all of the libraries in "GL_LIBS" are listed in the
963 dnl proper order.
964 dnl
965 dnl Additionally, the shell output variable "GL_CFLAGS" is set to any
966 dnl flags (e.g. "-I" flags) that are necessary to successfully compile
967 dnl an OpenGL application.
968 dnl
969 dnl The following shell variable (which are not output variables) are
970 dnl also set to either "yes" or "no" (depending on which libraries were
971 dnl found) to help you determine exactly what was found.
972 dnl
973 dnl   have_GL
974 dnl   have_GLU
975 dnl   have_GLX
976 dnl   have_glut
977 dnl
978 dnl A complete little toy "Automake `make distcheck'" package of how to
979 dnl use this macro is available at:
980 dnl
981 dnl   ftp://ftp.slac.stanford.edu/users/langston/autoconf/ac_opengl-0.01.tar.gz
982 dnl
983 dnl Please note that as the ac_opengl macro and the toy example evolves,
984 dnl the version number increases, so you may have to adjust the above
985 dnl URL accordingly.
986 dnl
987 dnl @author Matthew D. Langston <langston@SLAC.Stanford.EDU>
988
989 AC_DEFUN(FPTOOLS_HAVE_OPENGL,
990 [
991   AC_REQUIRE([AC_PROG_CC])
992   AC_REQUIRE([AC_PATH_X])
993   AC_REQUIRE([AC_PATH_XTRA])
994   AC_REQUIRE([FPTOOLS_CHECK_LIBM])
995
996 dnl Check for Mesa first if we were asked to.
997   AC_ARG_ENABLE(Mesa,
998 [  --enable-mesa
999         Prefer Mesa over a vendor's native OpenGL library (default=no)
1000 ],
1001                 use_Mesa=$enableval,
1002                 use_Mesa=no)
1003
1004   if test x"$use_Mesa" = xyes; then
1005      GL_search_list="MesaGL  GL  opengl32"
1006     GLU_search_list="MesaGLU GLU glu32"
1007     GLX_search_list="MesaGLX GLX"
1008   else
1009      GL_search_list="GL  opengl32 MesaGL"
1010     GLU_search_list="GLU glu32    MesaGLU"
1011     GLX_search_list="GLX          MesaGLX"
1012   fi      
1013
1014   AC_LANG_SAVE
1015   AC_LANG_C
1016
1017 dnl If we are running under X11 then add in the appropriate libraries.
1018   if test x"$no_x" != xyes; then
1019 dnl Add everything we need to compile and link X programs to GL_CFLAGS
1020 dnl and GL_X_LIBS/GLUT_X_LIBS.
1021     GL_CFLAGS="$CPPFLAGS $X_CFLAGS"
1022     GL_X_LIBS="$X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS $LIBM"
1023     GLUT_X_LIBS="$X_LIBS $X_PRE_LIBS -lXmu -lXt -lXi -lXext -lX11 $X_EXTRA_LIBS $LIBM"
1024   fi
1025   GL_save_CPPFLAGS="$CPPFLAGS"
1026   CPPFLAGS="$GL_CFLAGS"
1027
1028   GL_save_LIBS="$LIBS"
1029   LIBS="$GL_X_LIBS"
1030
1031   FPTOOLS_SEARCH_LIBS([#include <GL/gl.h>],   glEnd,         $GL_search_list,  have_GL=yes,   have_GL=no)
1032   FPTOOLS_SEARCH_LIBS([#include <GL/glu.h>],  gluNewQuadric, $GLU_search_list, have_GLU=yes,  have_GLU=no)
1033   FPTOOLS_SEARCH_LIBS([#include <GL/glx.h>],  glXWaitX,      $GLX_search_list, have_GLX=yes,  have_GLX=no)
1034
1035   if test -n "$LIBS"; then
1036     GL_LIBS="$LDFLAGS $LIBS"
1037   else
1038     GL_LIBS="$LDFLAGS"
1039     GL_CFLAGS=
1040   fi
1041
1042   LIBS="$GLUT_X_LIBS"
1043
1044   FPTOOLS_SEARCH_LIBS([#include <GL/glut.h>], glutMainLoop,  glut32 glut,      have_glut=yes, have_glut=no)
1045
1046   if test -n "$LIBS"; then
1047     GLUT_LIBS="$LDFLAGS $LIBS"
1048   fi
1049
1050   AC_CACHE_CHECK([OpenGL flags], mdl_cv_gl_cflags, [mdl_cv_gl_cflags="$GL_CFLAGS"])
1051   GL_CFLAGS="$mdl_cv_gl_cflags"
1052   AC_SUBST(GL_CFLAGS)
1053   AC_CACHE_CHECK([OpenGL libs],  mdl_cv_gl_libs,   [mdl_cv_gl_libs="$GL_LIBS"])
1054   GL_LIBS="$mdl_cv_gl_libs"
1055   AC_SUBST(GL_LIBS)
1056   AC_CACHE_CHECK([GLUT libs],  mdl_cv_glut_libs,   [mdl_cv_glut_libs="$GLUT_LIBS"])
1057   GLUT_LIBS="$mdl_cv_glut_libs"
1058   AC_SUBST(GLUT_LIBS)
1059
1060 dnl Reset GL_X_LIBS/GLUT_X_LIBS regardless, since they were just temporary variables
1061 dnl and we don't want to be global namespace polluters.
1062   GL_X_LIBS=
1063   GLUT_X_LIBS=
1064
1065   LIBS="$GL_save_LIBS"
1066   CPPFLAGS="$GL_save_CPPFLAGS"
1067
1068   AC_LANG_RESTORE
1069 ])
1070
1071 # LocalWords:  fi
1072
1073
1074 dnl
1075 dnl Check to see whether CC (gcc) supports a particular option.
1076 dnl
1077 AC_DEFUN(FPTOOLS_CC_FLAG,
1078 [
1079 AC_CACHE_CHECK([whether $CC accepts $1], [ac_cv_cc_$2],
1080 [save_CFLAGS="$CFLAGS"
1081  CFLAGS="$CFLAGS $1"
1082  AC_LANG_C
1083  AC_TRY_COMPILE(,[int main(){return(0);}],
1084                  [ac_cv_cc_$2=yes],
1085                  [ac_cv_cc_$2=no])
1086  CFLAGS="$save_CFLAGS"
1087 ])
1088 if test "$ac_cv_cc_$2"x = "yesx"; then
1089   $2=$1;
1090 else
1091   $2="";
1092 fi;
1093 ])
1094
1095 dnl
1096 dnl Check to see whether 'struct msghdr' contains msg_control
1097 dnl 
1098 AC_DEFUN(FPTOOLS_MSGHDR_MSG_CONTROL,
1099 [AC_CACHE_CHECK([for msg_control in struct msghdr], fptools_cv_struct_msghdr_msg_control,
1100 [AC_TRY_COMPILE([#include <sys/types.h>
1101 #include <sys/uio.h>
1102 #include <sys/socket.h>], [struct msghdr m; m.msg_control;],
1103 fptools_cv_struct_msghdr_msg_control=yes, fptools_cv_struct_msghdr_msg_control=no)])
1104 if test $fptools_cv_struct_msghdr_msg_control = yes; then
1105   AC_DEFINE(HAVE_MSGHDR_MSG_CONTROL)
1106 fi
1107 AC_SUBST(HAVE_MSGHDR_MSG_CONTROL)dnl
1108 ])
1109
1110 dnl
1111 dnl Check to see whether 'struct msghdr' contains msg_accrights
1112 dnl 
1113 AC_DEFUN(FPTOOLS_MSGHDR_MSG_ACCRIGHTS,
1114 [AC_CACHE_CHECK([for msg_accrights in struct msghdr], fptools_cv_struct_msghdr_msg_accrights,
1115 [AC_TRY_COMPILE([#include <sys/types.h>
1116 #include <sys/uio.h>
1117 #include <sys/socket.h>], [struct msghdr m; m.msg_accrights;],
1118 fptools_cv_struct_msghdr_msg_accrights=yes, fptools_cv_struct_msghdr_msg_accrights=no)])
1119 if test $fptools_cv_struct_msghdr_msg_accrights = yes; then
1120   AC_DEFINE(HAVE_MSGHDR_MSG_ACCRIGHTS)
1121 fi
1122 AC_SUBST(HAVE_MSGHDR_MSG_ACCRIGHTS)dnl
1123 ])
1124