]> git.saurik.com Git - bison.git/blob - acinclude.m4
# ignore "intl" directory, as it is no longer in source control.
[bison.git] / acinclude.m4
1 dnl BISON_DEFINE_FILE(VARNAME, FILE)
2 dnl Defines (with AC_DEFINE) VARNAME to the expansion of the FILE
3 dnl variable, expanding ${prefix} and such.
4 dnl Example: BISON_DEFINE_FILE(DATADIR, datadir)
5 dnl By Alexandre Oliva <oliva@dcc.unicamp.br>
6 AC_DEFUN(BISON_DEFINE_FILE, [
7 ac_expanded=`(
8 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
9 test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
10 eval echo \""[$]$2"\"
11 )`
12 AC_DEFINE_UNQUOTED($1, "$ac_expanded")
13 ])
14
15 dnl See whether we need a declaration for a function.
16 dnl BISON_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES])
17 AC_DEFUN(BISON_NEED_DECLARATION,
18 [AC_MSG_CHECKING([whether $1 must be declared])
19 AC_CACHE_VAL(bison_cv_decl_needed_$1,
20 [AC_TRY_COMPILE([
21 #include <stdio.h>
22 #ifdef HAVE_STRING_H
23 #include <string.h>
24 #else
25 #ifdef HAVE_STRINGS_H
26 #include <strings.h>
27 #endif
28 #endif
29 #ifdef HAVE_STDLIB_H
30 #include <stdlib.h>
31 #endif
32 #ifdef HAVE_UNISTD_H
33 #include <unistd.h>
34 #endif
35 #ifndef HAVE_RINDEX
36 #define rindex strrchr
37 #endif
38 #ifndef HAVE_INDEX
39 #define index strchr
40 #endif
41 $2],
42 [char *(*pfn) = (char *(*)) $1],
43 eval "bison_cv_decl_needed_$1=no", eval "bison_cv_decl_needed_$1=yes")])
44 if eval "test \"`echo '$bison_cv_decl_needed_'$1`\" = yes"; then
45 AC_MSG_RESULT(yes)
46 bison_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
47 AC_DEFINE_UNQUOTED($bison_tr_decl)
48 else
49 AC_MSG_RESULT(no)
50 fi
51 ])dnl
52
53 dnl Check multiple functions to see whether each needs a declaration.
54 dnl BISON_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES])
55 AC_DEFUN(BISON_NEED_DECLARATIONS,
56 [for ac_func in $1
57 do
58 BISON_NEED_DECLARATION($ac_func, $2)
59 done
60 ])