Cache a result.
[gnulib.git] / m4 / alloca.m4
1 # alloca.m4 serial 6
2 dnl Copyright (C) 2002-2004, 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_DEFUN([gl_FUNC_ALLOCA],
8 [
9   dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
10   AC_REQUIRE([AC_PROG_CPP])
11   AC_REQUIRE([AC_PROG_EGREP])
12
13   AC_REQUIRE([AC_FUNC_ALLOCA])
14   if test $ac_cv_func_alloca_works = no; then
15     gl_PREREQ_ALLOCA
16   fi
17
18   # Define an additional variable used in the Makefile substitution.
19   if test $ac_cv_working_alloca_h = yes; then
20     AC_CACHE_VAL([gl_cv_rpl_alloca], [
21       AC_EGREP_CPP([Need own alloca], [
22 #if defined __GNUC__ || defined _AIX || defined _MSC_VER
23           Need own alloca
24 #endif
25         ], [gl_cv_rpl_alloca=yes], [gl_cv_rpl_alloca=no])
26     ])
27     if test $gl_cv_rpl_alloca = yes; then
28       AC_DEFINE([HAVE_ALLOCA], 1,
29         [Define to 1 if you have `alloca' after including <alloca.h>,
30          a header that may be supplied by this distribution.])
31       ALLOCA_H=alloca.h
32     else
33       ALLOCA_H=
34     fi
35   else
36     ALLOCA_H=alloca.h
37   fi
38   AC_SUBST([ALLOCA_H])
39
40   AC_DEFINE(HAVE_ALLOCA_H, 1,
41     [Define HAVE_ALLOCA_H for backward compatibility with older code
42      that includes <alloca.h> only if HAVE_ALLOCA_H is defined.])
43 ])
44
45 # Prerequisites of lib/alloca.c.
46 # STACK_DIRECTION is already handled by AC_FUNC_ALLOCA.
47 AC_DEFUN([gl_PREREQ_ALLOCA], [:])