1 # $Id: aclocal.m4,v 1.20 1998/03/03 19:04:48 reid Exp $
3 # Extra autoconf macros for the Glasgow fptools
7 # 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 # 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)
47 # Is altzone available?
50 [AC_CACHE_CHECK([altzone], ac_cv_altzone,
51 [AC_TRY_LINK([#if TIME_WITH_SYS_TIME
52 # include <sys/time.h>
56 # include <sys/time.h>
62 ac_cv_altzone=yes, ac_cv_altzone=no)])
63 if test "$ac_cv_altzone" = yes; then
64 AC_DEFINE(HAVE_ALTZONE)
69 dnl ** check for leading underscores in symbol names
71 # Test for determining whether symbol names have a leading
74 # We assume that they _haven't_ if anything goes wrong.
76 AC_DEFUN(AC_UNDERSCORE,
77 [AC_CHECK_LIB(elf, nlist, LIBS="-lelf $LIBS")dnl
78 AC_CACHE_CHECK([leading underscore in symbol names], ac_cv_lead_uscore,
80 # Hack!: nlist() under Digital UNIX insist on there being an _,
81 # but symbol table listings show none. What is going on here?!?
83 changequote(<<, >>)dnl
86 alpha-dec-osf*) ac_cv_lead_uscore='no';;
89 AC_TRY_RUN([#ifdef HAVE_NLIST_H
91 changequote(<<, >>)dnl
93 struct nlist xYzzY[] = {{"_xYzzY", 0},{0}};
101 if(nlist(argv[0], xYzzY) == 0 && xYzzY[0].n_value != 0)
106 }], ac_cv_lead_uscore=yes, ac_cv_lead_uscore=no, ac_cv_lead_uscore=NO)
109 LeadingUnderscore=`echo $ac_cv_lead_uscore | sed 'y/yesno/YESNO/'`
110 AC_SUBST(LeadingUnderscore)
114 # Check for Happy and version.
117 [AC_PATH_PROG(HappyCmd,happy)
118 AC_CACHE_CHECK([for version of happy], ac_cv_happy_version,
119 [if test x"$HappyCmd" != x; then
120 ac_cv_happy_version="`$HappyCmd -v |
122 grep 'Happy Version' | sed -e 's/Happy Version \([^ ]*\).*/\1/g'`" ;
125 ac_cv_happy_version="";
127 if expr "$ac_cv_happy_version" "<" 1.4 > /dev/null 2>&1; then
129 echo "Happy version 1.4 or later is required to compile GHC."
133 HappyVersion=$ac_cv_happy_version;
134 AC_SUBST(HappyVersion)
138 # What's the best way of doing context diffs?
140 # (NB: NeXTStep thinks diff'ing a file against itself is "trouble")
142 AC_DEFUN(AC_PROG_DIFF,
143 [AC_CACHE_CHECK([for ok way to do context diffs], ac_cv_context_diffs,
144 [echo foo > conftest1
146 if diff -C 1 conftest1 conftest2 > /dev/null 2>&1 ; then
147 ac_cv_context_diffs='diff -C 1'
149 if diff -c1 conftest1 conftest2 > /dev/null 2>&1 ; then
150 ac_cv_context_diffs='diff -c1'
152 echo "Can't figure out how to do context diffs."
153 echo "Neither \`diff -C 1' nor \`diff -c1' works."
157 rm -f conftest1 conftest2
159 ContextDiffCmd=$ac_cv_context_diffs
160 AC_SUBST(ContextDiffCmd)
164 # Finding the Right Yacc
166 AC_DEFUN(AC_PROG_YACCY,
168 if test "$YACC" = "yacc"; then
169 AC_CACHE_CHECK([if it is an OK yacc], ac_cv_prog_yacc,
170 [AC_CHECK_PROG(WhatCmd, what, what, :)
171 $WhatCmd $YACC > conftest.out
172 if egrep 'y1\.c 1\..*SMI' conftest.out >/dev/null 2>&1; then
173 echo "I don't trust your $YaccCmd; it looks like an old Sun yacc"
174 if test -f /usr/lang/yacc; then
175 echo "I'm going to use /usr/lang/yacc instead"
176 ac_cv_prog_yacc=/usr/lang/yacc
178 echo "I'm assuming the worst...no parser generator at all"
181 elif egrep 'y1\.c.*Revision: 4\.2\.6\.3.*DEC' conftest.out >/dev/null 2>&1; then
182 echo "I don't trust your $YaccCmd; it looks like a lame DEC yacc"
183 echo "I'm assuming the worst...no parser generator at all"
186 ac_cv_prog_yacc=$YACC
191 ac_cv_prog_yacc=$YACC
193 YaccCmd=$ac_cv_prog_yacc
197 dnl Checking for ar and its arguments + whether we need ranlib.
199 # ArCmd and RANLIB are AC_SUBST'ed
201 AC_DEFUN(AC_PROG_AR_AND_RANLIB,
202 [AC_PATH_PROG(ArCmd,ar)
203 if test -z "$ArCmd"; then
204 echo "You don't seem to have ar in your PATH...I have no idea how to make a library"
207 if $ArCmd clqs conftest.a >/dev/null 2>/dev/null; then
210 elif $ArCmd cqs conftest.a >/dev/null 2>/dev/null; then
213 elif $ArCmd clq conftest.a >/dev/null 2>/dev/null; then
216 elif $ArCmd cq conftest.a >/dev/null 2>/dev/null; then
219 elif $ArCmd cq conftest.a 2>&1 | grep 'no archive members specified' >/dev/null 2>/dev/null; then
223 echo "I can't figure out how to use your $ArCmd"
227 test -n "$ArCmd" && test -n "$verbose" && echo " setting ArCmd to $ArCmd"
229 if test -z "$NeedRanLib"; then
231 test -n "$verbose" && echo " setting RANLIB to $RANLIB"
239 dnl AC_SHEBANG_PERL - can we she-bang perl?
241 AC_DEFUN(AC_SHEBANG_PERL,
242 [AC_CACHE_CHECK([if your perl works in shell scripts], ac_cv_shebang_perl,
247 (SHELL=/bin/sh; export SHELL; ./conftest 69 > /dev/null)
248 if test $? -ne 69; then
249 ac_cv_shebang_perl=yes
251 ac_cv_shebang_perl=no
257 # Extra testing of the result AC_PROG_CC, testing the gcc version no.
258 # *Must* be called after AC_PROG_CC
260 AC_DEFUN(AC_HAVE_GCC,
261 [AC_CACHE_CHECK([whether you have an ok gcc], ac_cv_have_gcc,
262 [if test -z "$GCC"; then
264 echo "You would be better off with gcc"
265 echo "Perhaps it is already installed, but not in your PATH?"
269 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' `"
271 if test `eval $cmd_string 2>/dev/null` != "1"; then
273 echo "I'm not sure if your version of gcc will work,"
274 echo "but it's worth a shot, eh?"
279 HaveGcc=`echo $ac_cv_have_gcc | sed 'y/yesno/YESNO/'`
284 # AC_PROG_GNUCPP gathers the path to the cpp that the
285 # gcc driver calls upon.
287 # Substitutes: GNUCPP and RAWCPP (latter is 'GNUCPP -traditional')
289 AC_DEFUN(AC_PROG_GNUCPP,
290 [AC_CACHE_CHECK([how to invoke GNU cpp directly], ac_cv_gnu_cpp,
291 [if test "$HaveGcc" = "YES"; then
293 gcc -v -E conftest.c >/dev/null 2>conftest.out
295 echo 'tr/\x5c/\//; /(\S+\/cpp)/ && print "[$]1";' > conftest.pl
296 ac_cv_gnu_cpp="`eval $PerlCmd -n conftest.pl conftest.out`"
299 # We need to be able to invoke CPP directly, preferably
300 # with input from stdin (mkdependHS and hscpp depend on
301 # this at the moment).
302 # Take a guess at what to use, this probably won't work.
303 echo Warning: GNU cpp not found, using $CPP
307 GNUCPP=$ac_cv_gnu_cpp
308 RAWCPP="$GNUCPP -traditional"
314 # Small feature test for perl version. Assumes PerlCmd
315 # contains path to perl binary
317 AC_DEFUN(AC_CHECK_PERL_VERSION,
318 [$PerlCmd -v >conftest.out 2>&1
319 if grep "version 4" conftest.out >/dev/null 2>&1; then
320 if grep "Patch level: 35" conftest.out >/dev/null 2>&1; then
322 ************************************************************************
323 Uh-oh...looks like you have Perl 4.035.
325 Perl version 4.035 has a bug to do with recursion that will bite if
326 you run the lit2texi script, when making Info files from
327 literate files of various sorts. Either use perl5, the last version of perl4
328 (4.036), or an older version (e.g., perl 4.019). Failing that, don't create
330 ************************************************************************
334 if grep "version 5" conftest.out >/dev/null 2>&1; then
337 echo "I'm not sure if your version of perl will work,"
338 echo "but it's worth a shot, eh?"
344 dnl ** figure out whether types can be word-aligned
345 dnl (test based on test in smalltalk-1.1.5 configuration)
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 test = *($1 *)&vec[1];
368 testptr = ($1 *)&vec[1];
374 AC_CV_NAME=$ac_cv_sizeof_unsigned_int,
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