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