1 dnl $Id: aclocal.m4,v 1.24 1998/08/06 10:28:34 simonm Exp $
3 dnl Extra autoconf macros for the Glasgow fptools
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.
10 dnl Are we running under the GNU libc? Need -D_GNU_SOURCE to get
13 AC_DEFUN(FPTOOLS_GNU_LIBC,
14 [AC_CACHE_CHECK([GNU libc], fptools_cv_gnu_libc,
16 [#include <features.h>
20 ], fptools_cv_gnu_libc=yes, fptools_cv_gnu_libc=no)])
21 if test "$fptools_cv_gnu_libc" = yes; then
22 AC_DEFINE(_GNU_SOURCE)
27 dnl Has timezone the type time_t or long (HP-UX 10.20 apparently
30 AC_DEFUN(FPTOOLS_TYPE_TIMEZONE,
31 [AC_CACHE_CHECK([type of timezone], fptools_cv_type_timezone,
32 [AC_TRY_COMPILE([#if TIME_WITH_SYS_TIME
33 # include <sys/time.h>
37 # include <sys/time.h>
43 extern time_t timezone;
45 [int i;], fptools_cv_type_timezone=time_t, fptools_cv_type_timezone=long)])
46 AC_DEFINE_UNQUOTED(TYPE_TIMEZONE, $fptools_cv_type_timezone)
49 dnl *** Is altzone available? ***
51 AC_DEFUN(FPTOOLS_ALTZONE,
52 [AC_CACHE_CHECK([altzone], fptools_cv_altzone,
53 [AC_TRY_LINK([#if TIME_WITH_SYS_TIME
54 # include <sys/time.h>
58 # include <sys/time.h>
64 fptools_cv_altzone=yes, fptools_cv_altzone=no)])
65 if test "$fptools_cv_altzone" = yes; then
66 AC_DEFINE(HAVE_ALTZONE)
70 dnl ** check for leading underscores in symbol names
72 dnl Test for determining whether symbol names have a leading
75 dnl We assume that they _haven't_ if anything goes wrong.
77 AC_DEFUN(FPTOOLS_UNDERSCORE,
78 [AC_CHECK_LIB(elf, nlist, LIBS="-lelf $LIBS")dnl
79 AC_CACHE_CHECK([leading underscore in symbol names], fptools_cv_lead_uscore,
82 dnl Hack!: nlist() under Digital UNIX insist on there being an _,
83 dnl but symbol table listings shows none. What is going on here?!?
85 changequote(<<, >>)dnl
88 alpha-dec-osf*) fptools_cv_lead_uscore='no';;
91 AC_TRY_RUN([#ifdef HAVE_NLIST_H
93 changequote(<<, >>)dnl
95 struct nlist xYzzY[] = {{"_xYzzY", 0},{0}};
103 if(nlist(argv[0], xYzzY) == 0 && xYzzY[0].n_value != 0)
108 }], fptools_cv_lead_uscore=yes, fptools_cv_lead_uscore=no, fptools_cv_lead_uscore=NO)
111 LeadingUnderscore=`echo $fptools_cv_lead_uscore | sed 'y/yesno/YESNO/'`
112 AC_SUBST(LeadingUnderscore)
113 case $LeadingUnderscore in
114 YES) AC_DEFINE(LEADING_UNDERSCORE);;
119 dnl Check for Happy and version.
121 AC_DEFUN(FPTOOLS_HAPPY,
122 [AC_PATH_PROG(HappyCmd,happy)
123 AC_CACHE_CHECK([for version of happy], fptools_cv_happy_version,
124 [if test x"$HappyCmd" != x; then
125 fptools_cv_happy_version="`$HappyCmd -v |
127 grep 'Happy Version' | sed -e 's/Happy Version \([^ ]*\).*/\1/g'`" ;
130 fptools_cv_happy_version="";
132 if expr "$fptools_cv_happy_version" "<" 1.4 > /dev/null 2>&1; then
134 echo "Happy version 1.4 or later is required to compile GHC."
138 HappyVersion=$ac_cv_happy_version;
139 AC_SUBST(HappyVersion)
143 dnl What's the best way of doing context diffs?
145 dnl (NB: NeXTStep thinks diff'ing a file against itself is "trouble")
147 AC_DEFUN(FPTOOLS_PROG_DIFF,
148 [AC_CACHE_CHECK([for ok way to do context diffs], fptools_cv_context_diffs,
149 [echo foo > conftest1
151 if diff -C 1 conftest1 conftest2 > /dev/null 2>&1 ; then
152 fptools_cv_context_diffs='diff -C 1'
154 if diff -c1 conftest1 conftest2 > /dev/null 2>&1 ; then
155 fptools_cv_context_diffs='diff -c1'
157 echo "Can't figure out how to do context diffs."
158 echo "Neither \`diff -C 1' nor \`diff -c1' works."
162 rm -f conftest1 conftest2
164 ContextDiffCmd=$fptools_cv_context_diffs
165 AC_SUBST(ContextDiffCmd)
169 dnl Finding the Right Yacc
171 AC_DEFUN(FPTOOLS_PROG_YACCY,
173 if test "$YACC" = "yacc"; then
174 AC_CACHE_CHECK([if it is an OK yacc], ac_cv_prog_yacc,
175 [AC_CHECK_PROG(WhatCmd, what, what, :)
176 $WhatCmd $YACC > conftest.out
177 if egrep 'y1\.c 1\..*SMI' conftest.out >/dev/null 2>&1; then
178 echo "I don't trust your $YaccCmd; it looks like an old Sun yacc"
179 if test -f /usr/lang/yacc; then
180 echo "I'm going to use /usr/lang/yacc instead"
181 ac_cv_prog_yacc=/usr/lang/yacc
183 echo "I'm assuming the worst...no parser generator at all"
186 elif egrep 'y1\.c.*Revision: 4\.2\.6\.3.*DEC' conftest.out >/dev/null 2>&1; then
187 echo "I don't trust your $YaccCmd; it looks like a lame DEC yacc"
188 echo "I'm assuming the worst...no parser generator at all"
191 ac_cv_prog_yacc=$YACC
196 ac_cv_prog_yacc=$YACC
198 YaccCmd=$ac_cv_prog_yacc
202 dnl *** Checking for ar and its arguments + whether we need ranlib.
204 dnl ArCmd and RANLIB are AC_SUBST'ed
206 AC_DEFUN(FPTOOLS_PROG_AR_AND_RANLIB,
207 [AC_PATH_PROG(ArCmd,ar)
208 if test -z "$ArCmd"; then
209 echo "You don't seem to have ar in your PATH...I have no idea how to make a library"
212 if $ArCmd clqs conftest.a >/dev/null 2>/dev/null; then
215 elif $ArCmd cqs conftest.a >/dev/null 2>/dev/null; then
218 elif $ArCmd clq conftest.a >/dev/null 2>/dev/null; then
221 elif $ArCmd cq conftest.a >/dev/null 2>/dev/null; then
224 elif $ArCmd cq conftest.a 2>&1 | grep 'no archive members specified' >/dev/null 2>/dev/null; then
228 echo "I can't figure out how to use your $ArCmd"
232 test -n "$ArCmd" && test -n "$verbose" && echo " setting ArCmd to $ArCmd"
234 if test -z "$NeedRanLib"; then
236 test -n "$verbose" && echo " setting RANLIB to $RANLIB"
244 dnl AC_SHEBANG_PERL - can we she-bang perl?
246 AC_DEFUN(FPTOOLS_SHEBANG_PERL,
247 [AC_CACHE_CHECK([if your perl works in shell scripts], fptools_cv_shebang_perl,
252 (SHELL=/bin/sh; export SHELL; ./conftest 69 > /dev/null)
253 if test $? -ne 69; then
254 fptools_cv_shebang_perl=yes
256 fptools_cv_shebang_perl=no
262 dnl Extra testing of the result AC_PROG_CC, testing the gcc version no.
263 dnl *Must* be called after AC_PROG_CC
265 AC_DEFUN(FPTOOLS_HAVE_GCC,
266 [AC_CACHE_CHECK([whether you have an ok gcc], fptools_cv_have_gcc,
267 [if test -z "$GCC"; then
269 echo "You would be better off with gcc"
270 echo "Perhaps it is already installed, but not in your PATH?"
271 fptools_cv_have_gcc='no'
274 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' `"
276 if test `eval $cmd_string 2>/dev/null` != "1"; then
278 echo "I'm not sure if your version of gcc will work,"
279 echo "but it's worth a shot, eh?"
281 fptools_cv_have_gcc='yes'
284 HaveGcc=`echo $fptools_cv_have_gcc | sed 'y/yesno/YESNO/'`
289 dnl FPTOOLS_PROG_GNUCPP gathers the path to the cpp that the
290 dnl gcc driver calls upon.
292 dnl Substitutes: GNUCPP and RAWCPP (latter is 'GNUCPP -traditional')
294 AC_DEFUN(FPTOOLS_PROG_GNUCPP,
295 [AC_CACHE_CHECK([how to invoke GNU cpp directly], fptools_cv_gnu_cpp,
296 [if test "$HaveGcc" = "YES"; then
298 gcc -v -E conftest.c >/dev/null 2>conftest.out
300 echo 'tr/\x5c/\//; /(\S+\/cpp)/ && print "[$]1";' > conftest.pl
301 fptools_cv_gnu_cpp="`eval $PerlCmd -n conftest.pl conftest.out`"
304 # We need to be able to invoke CPP directly, preferably
305 # with input from stdin (mkdependHS and hscpp depend on
306 # this at the moment).
307 # Take a guess at what to use, this probably won't work.
308 echo Warning: GNU cpp not found, using $CPP
309 fptools_cv_gnu_cpp = $CPP
312 GNUCPP=$fptools_cv_gnu_cpp
313 RAWCPP="$GNUCPP -traditional"
318 dnl Small feature test for perl version. Assumes PerlCmd
319 dnl contains path to perl binary
321 AC_DEFUN(FPTOOLS_CHECK_PERL_VERSION,
322 [$PerlCmd -v >conftest.out 2>&1
323 if grep "version 4" conftest.out >/dev/null 2>&1; then
324 if grep "Patch level: 35" conftest.out >/dev/null 2>&1; then
326 ************************************************************************
327 Uh-oh...looks like you have Perl 4.035.
329 Perl version 4.035 has a bug to do with recursion that will bite if
330 you run the lit2texi script, when making Info files from
331 literate files of various sorts. Either use perl5, the last version of perl4
332 (4.036), or an older version (e.g., perl 4.019). Failing that, don't create
334 ************************************************************************
338 if grep "version 5" conftest.out >/dev/null 2>&1; then
341 echo "I'm not sure if your version of perl will work,"
342 echo "but it's worth a shot, eh?"
348 dnl ** figure out the alignment restriction of a type
349 dnl (required SIZEOF test but AC_CHECK_SIZEOF doesn't call PROVIDE
350 dnl so we can't call REQUIRE)
352 dnl FPTOOLS_CHECK_ALIGNMENT(TYPE)
353 AC_DEFUN(FPTOOLS_CHECK_ALIGNMENT,
354 [changequote(<<, >>)dnl
355 dnl The name to #define.
356 define(<<AC_TYPE_NAME>>, translit(alignment_$1, [a-z *], [A-Z_P]))dnl
357 dnl The cache variable name.
358 define(<<AC_CV_NAME>>, translit(ac_cv_alignment_$1, [ *], [_p]))dnl
359 dnl The name of the corresponding size.
360 define(<<AC_CV_SIZEOF_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
362 AC_MSG_CHECKING(alignment of $1)
363 AC_CACHE_VAL(AC_CV_NAME,
370 #define offsetof(ty,field) ((size_t)((char *)&((ty *)0)->field - (char *)(ty *)0))
375 FILE *f=fopen("conftestval", "w");
377 fprintf(f, "%d\n", offsetof(struct { char c; $1 ty;},ty));
380 AC_CV_NAME=`cat conftestval`,
381 AC_CV_NAME=$AC_CV_SIZEOF_NAME,
382 AC_CV_NAME=$AC_CV_SIZEOF_NAME)])
383 AC_MSG_RESULT($AC_CV_NAME)
384 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
385 AC_PROVIDE($AC_TYPE_NAME)
386 undefine([AC_TYPE_NAME])dnl
387 undefine([AC_CV_NAME])dnl
388 undefine([AC_CV_SIZEOF_NAME])dnl
391 dnl ** figure out whether C compiler supports 'long long's
392 dnl (Closely based on Andreas Zeller's macro for testing
393 dnl for this under C++)
395 dnl If the C compiler supports `long long' types,
396 dnl define `HAVE_LONG_LONG'.
398 AC_DEFUN(FPTOOLS_C_LONG_LONG,
400 AC_REQUIRE([AC_PROG_CC])
401 AC_MSG_CHECKING(whether ${CC} supports long long types)
402 AC_CACHE_VAL(fptools_cv_have_long_long,
406 AC_TRY_COMPILE(,[long long a;],
407 fptools_cv_have_long_long=yes,
408 fptools_cv_have_long_long=no)
411 AC_MSG_RESULT($fptools_cv_have_long_long)
412 if test "$fptools_cv_have_long_long" = yes; then
413 AC_DEFINE(HAVE_LONG_LONG)