1 dnl $Id: aclocal.m4,v 1.22 1998/04/10 12:38:38 simonm 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)
110 case $LeadingUnderscore in
111 YES) AC_DEFINE(LEADING_UNDERSCORE);;
116 dnl Check for Happy and version.
119 [AC_PATH_PROG(HappyCmd,happy)
120 AC_CACHE_CHECK([for version of happy], ac_cv_happy_version,
121 [if test x"$HappyCmd" != x; then
122 ac_cv_happy_version="`$HappyCmd -v |
124 grep 'Happy Version' | sed -e 's/Happy Version \([^ ]*\).*/\1/g'`" ;
127 ac_cv_happy_version="";
129 if expr "$ac_cv_happy_version" "<" 1.4 > /dev/null 2>&1; then
131 echo "Happy version 1.4 or later is required to compile GHC."
135 HappyVersion=$ac_cv_happy_version;
136 AC_SUBST(HappyVersion)
140 dnl What's the best way of doing context diffs?
142 dnl (NB: NeXTStep thinks diff'ing a file against itself is "trouble")
144 AC_DEFUN(AC_PROG_DIFF,
145 [AC_CACHE_CHECK([for ok way to do context diffs], ac_cv_context_diffs,
146 [echo foo > conftest1
148 if diff -C 1 conftest1 conftest2 > /dev/null 2>&1 ; then
149 ac_cv_context_diffs='diff -C 1'
151 if diff -c1 conftest1 conftest2 > /dev/null 2>&1 ; then
152 ac_cv_context_diffs='diff -c1'
154 echo "Can't figure out how to do context diffs."
155 echo "Neither \`diff -C 1' nor \`diff -c1' works."
159 rm -f conftest1 conftest2
161 ContextDiffCmd=$ac_cv_context_diffs
162 AC_SUBST(ContextDiffCmd)
166 dnl Finding the Right Yacc
168 AC_DEFUN(AC_PROG_YACCY,
170 if test "$YACC" = "yacc"; then
171 AC_CACHE_CHECK([if it is an OK yacc], ac_cv_prog_yacc,
172 [AC_CHECK_PROG(WhatCmd, what, what, :)
173 $WhatCmd $YACC > conftest.out
174 if egrep 'y1\.c 1\..*SMI' conftest.out >/dev/null 2>&1; then
175 echo "I don't trust your $YaccCmd; it looks like an old Sun yacc"
176 if test -f /usr/lang/yacc; then
177 echo "I'm going to use /usr/lang/yacc instead"
178 ac_cv_prog_yacc=/usr/lang/yacc
180 echo "I'm assuming the worst...no parser generator at all"
183 elif egrep 'y1\.c.*Revision: 4\.2\.6\.3.*DEC' conftest.out >/dev/null 2>&1; then
184 echo "I don't trust your $YaccCmd; it looks like a lame DEC yacc"
185 echo "I'm assuming the worst...no parser generator at all"
188 ac_cv_prog_yacc=$YACC
193 ac_cv_prog_yacc=$YACC
195 YaccCmd=$ac_cv_prog_yacc
199 dnl *** Checking for ar and its arguments + whether we need ranlib.
201 dnl ArCmd and RANLIB are AC_SUBST'ed
203 AC_DEFUN(AC_PROG_AR_AND_RANLIB,
204 [AC_PATH_PROG(ArCmd,ar)
205 if test -z "$ArCmd"; then
206 echo "You don't seem to have ar in your PATH...I have no idea how to make a library"
209 if $ArCmd clqs conftest.a >/dev/null 2>/dev/null; then
212 elif $ArCmd cqs conftest.a >/dev/null 2>/dev/null; then
215 elif $ArCmd clq conftest.a >/dev/null 2>/dev/null; then
218 elif $ArCmd cq conftest.a >/dev/null 2>/dev/null; then
221 elif $ArCmd cq conftest.a 2>&1 | grep 'no archive members specified' >/dev/null 2>/dev/null; then
225 echo "I can't figure out how to use your $ArCmd"
229 test -n "$ArCmd" && test -n "$verbose" && echo " setting ArCmd to $ArCmd"
231 if test -z "$NeedRanLib"; then
233 test -n "$verbose" && echo " setting RANLIB to $RANLIB"
241 dnl AC_SHEBANG_PERL - can we she-bang perl?
243 AC_DEFUN(AC_SHEBANG_PERL,
244 [AC_CACHE_CHECK([if your perl works in shell scripts], ac_cv_shebang_perl,
249 (SHELL=/bin/sh; export SHELL; ./conftest 69 > /dev/null)
250 if test $? -ne 69; then
251 ac_cv_shebang_perl=yes
253 ac_cv_shebang_perl=no
259 dnl Extra testing of the result AC_PROG_CC, testing the gcc version no.
260 dnl *Must* be called after AC_PROG_CC
262 AC_DEFUN(AC_HAVE_GCC,
263 [AC_CACHE_CHECK([whether you have an ok gcc], ac_cv_have_gcc,
264 [if test -z "$GCC"; then
266 echo "You would be better off with gcc"
267 echo "Perhaps it is already installed, but not in your PATH?"
271 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' `"
273 if test `eval $cmd_string 2>/dev/null` != "1"; then
275 echo "I'm not sure if your version of gcc will work,"
276 echo "but it's worth a shot, eh?"
281 HaveGcc=`echo $ac_cv_have_gcc | sed 'y/yesno/YESNO/'`
286 dnl AC_PROG_GNUCPP gathers the path to the cpp that the
287 dnl gcc driver calls upon.
289 dnl Substitutes: GNUCPP and RAWCPP (latter is 'GNUCPP -traditional')
291 AC_DEFUN(AC_PROG_GNUCPP,
292 [AC_CACHE_CHECK([how to invoke GNU cpp directly], ac_cv_gnu_cpp,
293 [if test "$HaveGcc" = "YES"; then
295 gcc -v -E conftest.c >/dev/null 2>conftest.out
297 echo 'tr/\x5c/\//; /(\S+\/cpp)/ && print "[$]1";' > conftest.pl
298 ac_cv_gnu_cpp="`eval $PerlCmd -n conftest.pl conftest.out`"
301 # We need to be able to invoke CPP directly, preferably
302 # with input from stdin (mkdependHS and hscpp depend on
303 # this at the moment).
304 # Take a guess at what to use, this probably won't work.
305 echo Warning: GNU cpp not found, using $CPP
309 GNUCPP=$ac_cv_gnu_cpp
310 RAWCPP="$GNUCPP -traditional"
315 dnl Small feature test for perl version. Assumes PerlCmd
316 dnl contains path to perl binary
318 AC_DEFUN(AC_CHECK_PERL_VERSION,
319 [$PerlCmd -v >conftest.out 2>&1
320 if grep "version 4" conftest.out >/dev/null 2>&1; then
321 if grep "Patch level: 35" conftest.out >/dev/null 2>&1; then
323 ************************************************************************
324 Uh-oh...looks like you have Perl 4.035.
326 Perl version 4.035 has a bug to do with recursion that will bite if
327 you run the lit2texi script, when making Info files from
328 literate files of various sorts. Either use perl5, the last version of perl4
329 (4.036), or an older version (e.g., perl 4.019). Failing that, don't create
331 ************************************************************************
335 if grep "version 5" conftest.out >/dev/null 2>&1; then
338 echo "I'm not sure if your version of perl will work,"
339 echo "but it's worth a shot, eh?"
345 dnl ** figure out the alignment restriction of a type
346 dnl (required SIZEOF test but AC_CHECK_SIZEOF doesn't call PROVIDE
347 dnl so we can't call REQUIRE)
349 dnl GHC_CHECK_ALIGNMENT(TYPE)
350 AC_DEFUN(GHC_CHECK_ALIGNMENT,
351 [changequote(<<, >>)dnl
352 dnl The name to #define.
353 define(<<AC_TYPE_NAME>>, translit(alignment_$1, [a-z *], [A-Z_P]))dnl
354 dnl The cache variable name.
355 define(<<AC_CV_NAME>>, translit(ac_cv_alignment_$1, [ *], [_p]))dnl
356 dnl The name of the corresponding size.
357 define(<<AC_CV_SIZEOF_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
359 AC_MSG_CHECKING(alignment of $1)
360 AC_CACHE_VAL(AC_CV_NAME,
367 #define offsetof(ty,field) ((size_t)((char *)&((ty *)0)->field - (char *)(ty *)0))
372 FILE *f=fopen("conftestval", "w");
374 fprintf(f, "%d\n", offsetof(struct { char c; $1 ty;},ty));
377 AC_CV_NAME=`cat conftestval`,
378 AC_CV_NAME=$AC_CV_SIZEOF_NAME,
379 AC_CV_NAME=$AC_CV_SIZEOF_NAME)])
380 AC_MSG_RESULT($AC_CV_NAME)
381 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
382 AC_PROVIDE($AC_TYPE_NAME)
383 undefine([AC_TYPE_NAME])dnl
384 undefine([AC_CV_NAME])dnl
385 undefine([AC_CV_SIZEOF_NAME])dnl