[project @ 1998-03-03 04:45:06 by reid]
[ghc-hetmet.git] / aclocal.m4
1 # $Id: aclocal.m4,v 1.19 1998/03/03 04:45:07 reid Exp $
2 #
3 # Extra autoconf macros for the Glasgow fptools
4 #
5
6 #
7 # Are we running under the GNU libc?  Need -D_GNU_SOURCE to get 
8 # caddr_t and such.
9 #
10 AC_DEFUN(AC_GNU_LIBC,
11 [AC_CACHE_CHECK([GNU libc], ac_cv_gnu_libc,
12 [AC_EGREP_CPP(yes,
13 [#include <features.h>
14 #ifdef __GLIBC__
15 yes
16 #endif
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)
20 fi
21 ])
22
23 #
24 # Has timezone the type time_t or long (HP-UX 10.20 apparently
25 # has `long'..)
26 #
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>
31 # include <time.h>
32 #else
33 # if HAVE_SYS_TIME_H
34 #  include <sys/time.h>
35 # else
36 #  include <time.h>
37 # endif
38 #endif
39
40 extern time_t timezone;
41 ],
42 [int i;], ac_cv_type_timezone=time_t, ac_cv_type_timezone=long)])
43 AC_DEFINE_UNQUOTED(TYPE_TIMEZONE, $ac_cv_type_timezone)
44 ])
45
46 #
47 # Is altzone available?
48 #
49 AC_DEFUN(AC_ALTZONE,
50 [AC_CACHE_CHECK([altzone], ac_cv_altzone,
51 [AC_TRY_LINK([#if TIME_WITH_SYS_TIME
52 # include <sys/time.h>
53 # include <time.h>
54 #else
55 # if HAVE_SYS_TIME_H
56 #  include <sys/time.h>
57 # else
58 #  include <time.h>
59 # endif
60 #endif
61 ], [return altzone;], 
62 ac_cv_altzone=yes, ac_cv_altzone=no)])
63 if test "$ac_cv_altzone" = yes; then
64   AC_DEFINE(HAVE_ALTZONE)
65 fi
66 ])
67
68 #
69 dnl ** check for leading underscores in symbol names
70 #
71 # Test for determining whether symbol names have a leading
72 # underscore.
73 #
74 # We assume that they _haven't_ if anything goes wrong.
75 #
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,
79 #
80 # Hack!: nlist() under Digital UNIX insist on there being an _,
81 # but symbol table listings show none. What is going on here?!?
82 #
83 changequote(<<, >>)dnl
84 <<
85 case $HostPlatform in
86 alpha-dec-osf*) ac_cv_lead_uscore='no';;
87 *) >>
88 changequote([, ])dnl
89 AC_TRY_RUN([#ifdef HAVE_NLIST_H
90 #include <nlist.h>
91 changequote(<<, >>)dnl
92 <<
93 struct nlist xYzzY[] = {{"_xYzzY", 0},{0}};
94 #endif
95
96 main(argc, argv)
97 int argc;
98 char **argv;
99 {
100 #ifdef HAVE_NLIST_H
101     if(nlist(argv[0], xYzzY) == 0 && xYzzY[0].n_value != 0)
102         exit(0);>>
103 changequote([, ])dnl
104 #endif
105     exit(1);
106 }], ac_cv_lead_uscore=yes, ac_cv_lead_uscore=no, ac_cv_lead_uscore=NO)
107 ;;
108 esac);
109 LeadingUnderscore=`echo $ac_cv_lead_uscore | sed 'y/yesno/YESNO/'`
110 AC_SUBST(LeadingUnderscore)
111 ])
112
113 #
114 # Check for Happy and version.
115 #
116 AC_DEFUN(AC_HAPPY,
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 |
121 changequote(, )dnl
122                           grep 'Happy Version' | sed -e 's/Happy Version \([^ ]*\).*/\1/g'`" ;
123 changequote([, ])dnl
124 else
125    ac_cv_happy_version="";
126 fi;
127 if expr "$ac_cv_happy_version" "<" 1.4 > /dev/null 2>&1; then
128    echo
129    echo "Happy version 1.4 or later is required to compile GHC."
130    exit 1;
131 fi;
132 ])
133 HappyVersion=$ac_cv_happy_version;
134 AC_SUBST(HappyVersion)
135 ])
136
137 #
138 # What's the best way of doing context diffs?
139 #
140 # (NB: NeXTStep thinks diff'ing a file against itself is "trouble")
141 #
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
145 echo foo > conftest2
146 if diff -C 1 conftest1 conftest2 > /dev/null 2>&1 ; then
147     ac_cv_context_diffs='diff -C 1'
148 else
149     if diff -c1 conftest1 conftest2 > /dev/null 2>&1 ; then
150         ac_cv_context_diffs='diff -c1'
151     else
152         echo "Can't figure out how to do context diffs."
153         echo "Neither \`diff -C 1' nor \`diff -c1' works."
154         exit 1
155     fi
156 fi
157 rm -f conftest1 conftest2
158 ])
159 ContextDiffCmd=$ac_cv_context_diffs
160 AC_SUBST(ContextDiffCmd)
161 ])
162
163 #
164 # Finding the Right Yacc
165 #
166 AC_DEFUN(AC_PROG_YACCY,
167 [AC_PROG_YACC
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
177         else
178            echo "I'm assuming the worst...no parser generator at all"
179            ac_cv_prog_yacc=:
180         fi
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"
184         ac_cv_prog_yacc=:
185     else
186         ac_cv_prog_yacc=$YACC
187     fi
188     rm -fr conftest*
189 ])
190 else
191     ac_cv_prog_yacc=$YACC
192 fi
193 YaccCmd=$ac_cv_prog_yacc
194 AC_SUBST(YaccCmd)
195 ])
196
197 dnl Checking for ar and its arguments + whether we need ranlib.
198 #
199 # ArCmd and RANLIB are AC_SUBST'ed
200 #
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"
205     exit 1;
206 fi
207 if $ArCmd clqs conftest.a >/dev/null 2>/dev/null; then
208     ArCmd="$ArCmd clqs"
209     NeedRanLib=''
210 elif $ArCmd cqs conftest.a >/dev/null 2>/dev/null; then
211     ArCmd="$ArCmd cqs"
212     NeedRanLib=''
213 elif $ArCmd clq conftest.a >/dev/null 2>/dev/null; then
214     ArCmd="$ArCmd clq"
215     NeedRanLib='YES'
216 elif $ArCmd cq conftest.a >/dev/null 2>/dev/null; then
217     ArCmd="$ArCmd cq"
218     NeedRanLib='YES'
219 elif $ArCmd cq conftest.a 2>&1 | grep 'no archive members specified' >/dev/null 2>/dev/null; then
220     ArCmd="$ArCmd cq"
221     NeedRanLib='YES'
222 else
223     echo "I can't figure out how to use your $ArCmd"
224     exit 1
225 fi
226 rm -rf conftest*
227 test -n "$ArCmd" && test -n "$verbose" && echo "        setting ArCmd to $ArCmd"
228 AC_SUBST(ArCmd)
229 if test -z "$NeedRanLib"; then
230     RANLIB=':'
231     test -n "$verbose" && echo "        setting RANLIB to $RANLIB"
232     AC_SUBST(RANLIB)
233 else
234     AC_PROG_RANLIB
235 fi
236 ])
237
238 #
239 dnl AC_SHEBANG_PERL - can we she-bang perl?
240 #
241 AC_DEFUN(AC_SHEBANG_PERL,
242 [AC_CACHE_CHECK([if your perl works in shell scripts], ac_cv_shebang_perl,
243 [echo "#!$PerlCmd"'
244 exit $1;
245 ' > conftest
246 chmod u+x conftest
247 (SHELL=/bin/sh; export SHELL; ./conftest 69 > /dev/null)
248 if test $? -ne 69; then
249    ac_cv_shebang_perl=yes
250 else
251    ac_cv_shebang_perl=no
252 fi
253 rm -f conftest
254 ])])
255
256 #
257 # Extra testing of the result AC_PROG_CC, testing the gcc version no.
258 # *Must* be called after AC_PROG_CC
259 #
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
263     echo ''
264     echo "You would be better off with gcc"
265     echo "Perhaps it is already installed, but not in your PATH?"
266     ac_cv_have_gcc='no'
267 else
268 changequote(, )dnl
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' `"
270 changequote([, ])dnl
271     if test `eval $cmd_string 2>/dev/null` != "1"; then
272         echo ''
273         echo "I'm not sure if your version of gcc will work,"
274         echo "but it's worth a shot, eh?"
275     fi
276     ac_cv_have_gcc='yes'
277 fi
278 ])
279 HaveGcc=`echo $ac_cv_have_gcc | sed 'y/yesno/YESNO/'`
280 AC_SUBST(HaveGcc)
281 ])
282
283 #
284 # AC_PROG_GNUCPP gathers the path to the cpp that the
285 # gcc driver calls upon.
286 #
287 # Substitutes: GNUCPP and RAWCPP (latter is 'GNUCPP -traditional')
288 #
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
292         echo > conftest.c
293         gcc -v -E conftest.c >/dev/null 2>conftest.out
294         # \x5c = backslash
295         echo 'tr/\x5c/\//; /(\S+\/cpp)/ && print "[$]1";' > conftest.pl
296         ac_cv_gnu_cpp="`eval $PerlCmd -n conftest.pl conftest.out`"
297         rm -fr conftest*
298  else
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
304         ac_cv_gnu_cpp = $CPP
305  fi
306 ])
307 GNUCPP=$ac_cv_gnu_cpp
308 RAWCPP="$GNUCPP -traditional"
309 AC_SUBST(GNUCPP)
310 AC_SUBST(RAWCPP)
311 ])
312
313 #
314 # Small feature test for perl version. Assumes PerlCmd
315 # contains path to perl binary
316 #
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
321       echo "
322 ************************************************************************
323 Uh-oh...looks like you have Perl 4.035.
324
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
329 any Info files :-)
330 ************************************************************************
331 "
332    fi
333 else
334    if grep "version 5" conftest.out >/dev/null 2>&1; then
335       :
336    else
337      echo "I'm not sure if your version of perl will work,"
338      echo "but it's worth a shot, eh?"
339    fi
340 fi
341 rm -fr conftest*
342 ])