1 dnl $Id: aclocal.m4,v 1.21 1998/04/07 21:24:55 sof Exp $
3 dnl Extra autoconf macros for the Glasgow fptools
7 dnl Are we running under the GNU libc? Need -D_GNU_SOURCE to get
11 [AC_CACHE_CHECK([GNU libc], ac_cv_gnu_libc,
13 [#include <features.h>
17 ], ac_cv_gnu_libc=yes, ac_cv_gnu_libc=no)])
18 if test "$ac_cv_gnu_libc" = yes; then
19 AC_DEFINE(_GNU_SOURCE)
24 dnl Has timezone the type time_t or long (HP-UX 10.20 apparently
27 AC_DEFUN(AC_TYPE_TIMEZONE,
28 [AC_CACHE_CHECK([type of timezone], ac_cv_type_timezone,
29 [AC_TRY_COMPILE([#if TIME_WITH_SYS_TIME
30 # include <sys/time.h>
34 # include <sys/time.h>
40 extern time_t timezone;
42 [int i;], ac_cv_type_timezone=time_t, ac_cv_type_timezone=long)])
43 AC_DEFINE_UNQUOTED(TYPE_TIMEZONE, $ac_cv_type_timezone)
46 dnl *** Is altzone available? ***
49 [AC_CACHE_CHECK([altzone], ac_cv_altzone,
50 [AC_TRY_LINK([#if TIME_WITH_SYS_TIME
51 # include <sys/time.h>
55 # include <sys/time.h>
61 ac_cv_altzone=yes, ac_cv_altzone=no)])
62 if test "$ac_cv_altzone" = yes; then
63 AC_DEFINE(HAVE_ALTZONE)
67 dnl ** check for leading underscores in symbol names
69 dnl Test for determining whether symbol names have a leading
72 dnl We assume that they _haven't_ if anything goes wrong.
74 AC_DEFUN(AC_UNDERSCORE,
75 [AC_CHECK_LIB(elf, nlist, LIBS="-lelf $LIBS")dnl
76 AC_CACHE_CHECK([leading underscore in symbol names], ac_cv_lead_uscore,
79 dnl Hack!: nlist() under Digital UNIX insist on there being an _,
80 dnl but symbol table listings show none. What is going on here?!?
82 changequote(<<, >>)dnl
85 alpha-dec-osf*) ac_cv_lead_uscore='no';;
88 AC_TRY_RUN([#ifdef HAVE_NLIST_H
90 changequote(<<, >>)dnl
92 struct nlist xYzzY[] = {{"_xYzzY", 0},{0}};
100 if(nlist(argv[0], xYzzY) == 0 && xYzzY[0].n_value != 0)
105 }], ac_cv_lead_uscore=yes, ac_cv_lead_uscore=no, ac_cv_lead_uscore=NO)
108 LeadingUnderscore=`echo $ac_cv_lead_uscore | sed 'y/yesno/YESNO/'`
109 AC_SUBST(LeadingUnderscore)
113 dnl Check for Happy and version.
116 [AC_PATH_PROG(HappyCmd,happy)
117 AC_CACHE_CHECK([for version of happy], ac_cv_happy_version,
118 [if test x"$HappyCmd" != x; then
119 ac_cv_happy_version="`$HappyCmd -v |
121 grep 'Happy Version' | sed -e 's/Happy Version \([^ ]*\).*/\1/g'`" ;
124 ac_cv_happy_version="";
126 if expr "$ac_cv_happy_version" "<" 1.4 > /dev/null 2>&1; then
128 echo "Happy version 1.4 or later is required to compile GHC."
132 HappyVersion=$ac_cv_happy_version;
133 AC_SUBST(HappyVersion)
137 dnl What's the best way of doing context diffs?
139 dnl (NB: NeXTStep thinks diff'ing a file against itself is "trouble")
141 AC_DEFUN(AC_PROG_DIFF,
142 [AC_CACHE_CHECK([for ok way to do context diffs], ac_cv_context_diffs,
143 [echo foo > conftest1
145 if diff -C 1 conftest1 conftest2 > /dev/null 2>&1 ; then
146 ac_cv_context_diffs='diff -C 1'
148 if diff -c1 conftest1 conftest2 > /dev/null 2>&1 ; then
149 ac_cv_context_diffs='diff -c1'
151 echo "Can't figure out how to do context diffs."
152 echo "Neither \`diff -C 1' nor \`diff -c1' works."
156 rm -f conftest1 conftest2
158 ContextDiffCmd=$ac_cv_context_diffs
159 AC_SUBST(ContextDiffCmd)
163 dnl Finding the Right Yacc
165 AC_DEFUN(AC_PROG_YACCY,
167 if test "$YACC" = "yacc"; then
168 AC_CACHE_CHECK([if it is an OK yacc], ac_cv_prog_yacc,
169 [AC_CHECK_PROG(WhatCmd, what, what, :)
170 $WhatCmd $YACC > conftest.out
171 if egrep 'y1\.c 1\..*SMI' conftest.out >/dev/null 2>&1; then
172 echo "I don't trust your $YaccCmd; it looks like an old Sun yacc"
173 if test -f /usr/lang/yacc; then
174 echo "I'm going to use /usr/lang/yacc instead"
175 ac_cv_prog_yacc=/usr/lang/yacc
177 echo "I'm assuming the worst...no parser generator at all"
180 elif egrep 'y1\.c.*Revision: 4\.2\.6\.3.*DEC' conftest.out >/dev/null 2>&1; then
181 echo "I don't trust your $YaccCmd; it looks like a lame DEC yacc"
182 echo "I'm assuming the worst...no parser generator at all"
185 ac_cv_prog_yacc=$YACC
190 ac_cv_prog_yacc=$YACC
192 YaccCmd=$ac_cv_prog_yacc
196 dnl *** Checking for ar and its arguments + whether we need ranlib.
198 dnl ArCmd and RANLIB are AC_SUBST'ed
200 AC_DEFUN(AC_PROG_AR_AND_RANLIB,
201 [AC_PATH_PROG(ArCmd,ar)
202 if test -z "$ArCmd"; then
203 echo "You don't seem to have ar in your PATH...I have no idea how to make a library"
206 if $ArCmd clqs conftest.a >/dev/null 2>/dev/null; then
209 elif $ArCmd cqs conftest.a >/dev/null 2>/dev/null; then
212 elif $ArCmd clq conftest.a >/dev/null 2>/dev/null; then
215 elif $ArCmd cq conftest.a >/dev/null 2>/dev/null; then
218 elif $ArCmd cq conftest.a 2>&1 | grep 'no archive members specified' >/dev/null 2>/dev/null; then
222 echo "I can't figure out how to use your $ArCmd"
226 test -n "$ArCmd" && test -n "$verbose" && echo " setting ArCmd to $ArCmd"
228 if test -z "$NeedRanLib"; then
230 test -n "$verbose" && echo " setting RANLIB to $RANLIB"
238 dnl AC_SHEBANG_PERL - can we she-bang perl?
240 AC_DEFUN(AC_SHEBANG_PERL,
241 [AC_CACHE_CHECK([if your perl works in shell scripts], ac_cv_shebang_perl,
246 (SHELL=/bin/sh; export SHELL; ./conftest 69 > /dev/null)
247 if test $? -ne 69; then
248 ac_cv_shebang_perl=yes
250 ac_cv_shebang_perl=no
256 dnl Extra testing of the result AC_PROG_CC, testing the gcc version no.
257 dnl *Must* be called after AC_PROG_CC
259 AC_DEFUN(AC_HAVE_GCC,
260 [AC_CACHE_CHECK([whether you have an ok gcc], ac_cv_have_gcc,
261 [if test -z "$GCC"; then
263 echo "You would be better off with gcc"
264 echo "Perhaps it is already installed, but not in your PATH?"
268 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' `"
270 if test `eval $cmd_string 2>/dev/null` != "1"; then
272 echo "I'm not sure if your version of gcc will work,"
273 echo "but it's worth a shot, eh?"
278 HaveGcc=`echo $ac_cv_have_gcc | sed 'y/yesno/YESNO/'`
283 dnl AC_PROG_GNUCPP gathers the path to the cpp that the
284 dnl gcc driver calls upon.
286 dnl Substitutes: GNUCPP and RAWCPP (latter is 'GNUCPP -traditional')
288 AC_DEFUN(AC_PROG_GNUCPP,
289 [AC_CACHE_CHECK([how to invoke GNU cpp directly], ac_cv_gnu_cpp,
290 [if test "$HaveGcc" = "YES"; then
292 gcc -v -E conftest.c >/dev/null 2>conftest.out
294 echo 'tr/\x5c/\//; /(\S+\/cpp)/ && print "[$]1";' > conftest.pl
295 ac_cv_gnu_cpp="`eval $PerlCmd -n conftest.pl conftest.out`"
298 # We need to be able to invoke CPP directly, preferably
299 # with input from stdin (mkdependHS and hscpp depend on
300 # this at the moment).
301 # Take a guess at what to use, this probably won't work.
302 echo Warning: GNU cpp not found, using $CPP
306 GNUCPP=$ac_cv_gnu_cpp
307 RAWCPP="$GNUCPP -traditional"
312 dnl Small feature test for perl version. Assumes PerlCmd
313 dnl contains path to perl binary
315 AC_DEFUN(AC_CHECK_PERL_VERSION,
316 [$PerlCmd -v >conftest.out 2>&1
317 if grep "version 4" conftest.out >/dev/null 2>&1; then
318 if grep "Patch level: 35" conftest.out >/dev/null 2>&1; then
320 ************************************************************************
321 Uh-oh...looks like you have Perl 4.035.
323 Perl version 4.035 has a bug to do with recursion that will bite if
324 you run the lit2texi script, when making Info files from
325 literate files of various sorts. Either use perl5, the last version of perl4
326 (4.036), or an older version (e.g., perl 4.019). Failing that, don't create
328 ************************************************************************
332 if grep "version 5" conftest.out >/dev/null 2>&1; then
335 echo "I'm not sure if your version of perl will work,"
336 echo "but it's worth a shot, eh?"
342 dnl ** figure out the alignment restriction of a type
343 dnl (required SIZEOF test but AC_CHECK_SIZEOF doesn't call PROVIDE
344 dnl so we can't call REQUIRE)
346 dnl GHC_CHECK_ALIGNMENT(TYPE)
347 AC_DEFUN(GHC_CHECK_ALIGNMENT,
348 [changequote(<<, >>)dnl
349 dnl The name to #define.
350 define(<<AC_TYPE_NAME>>, translit(alignment_$1, [a-z *], [A-Z_P]))dnl
351 dnl The cache variable name.
352 define(<<AC_CV_NAME>>, translit(ac_cv_alignment_$1, [ *], [_p]))dnl
353 dnl The name of the corresponding size.
354 define(<<AC_CV_SIZEOF_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
356 AC_MSG_CHECKING(alignment of $1)
357 AC_CACHE_VAL(AC_CV_NAME,
364 #define offsetof(ty,field) ((size_t)((char *)&((ty *)0)->field - (char *)(ty *)0))
369 FILE *f=fopen("conftestval", "w");
371 fprintf(f, "%d\n", offsetof(struct { char c; $1 ty;},ty));
374 AC_CV_NAME=`cat conftestval`,
375 AC_CV_NAME=$AC_CV_SIZEOF_NAME,
376 AC_CV_NAME=$AC_CV_SIZEOF_NAME)])
377 AC_MSG_RESULT($AC_CV_NAME)
378 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
379 AC_PROVIDE($AC_TYPE_NAME)
380 undefine([AC_TYPE_NAME])dnl
381 undefine([AC_CV_NAME])dnl
382 undefine([AC_CV_SIZEOF_NAME])dnl