aclocal.m4 revision 50397
1dnl See whether we need a declaration for a function.
2dnl GCC_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES])
3AC_DEFUN(GCC_NEED_DECLARATION,
4[AC_MSG_CHECKING([whether $1 must be declared])
5AC_CACHE_VAL(gcc_cv_decl_needed_$1,
6[AC_TRY_COMPILE([
7#include <stdio.h>
8#ifdef HAVE_STRING_H
9#include <string.h>
10#else
11#ifdef HAVE_STRINGS_H
12#include <strings.h>
13#endif
14#endif
15#ifdef HAVE_STDLIB_H
16#include <stdlib.h>
17#endif
18#ifdef HAVE_UNISTD_H
19#include <unistd.h>
20#endif
21#ifndef HAVE_RINDEX
22#define rindex strrchr
23#endif
24#ifndef HAVE_INDEX
25#define index strchr
26#endif
27$2],
28[char *(*pfn) = (char *(*)) $1],
29eval "gcc_cv_decl_needed_$1=no", eval "gcc_cv_decl_needed_$1=yes")])
30if eval "test \"`echo '$gcc_cv_decl_needed_'$1`\" = yes"; then
31  AC_MSG_RESULT(yes)
32  gcc_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
33  AC_DEFINE_UNQUOTED($gcc_tr_decl)
34else
35  AC_MSG_RESULT(no)
36fi
37])dnl
38
39dnl Check multiple functions to see whether each needs a declaration.
40dnl GCC_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES])
41AC_DEFUN(GCC_NEED_DECLARATIONS,
42[for ac_func in $1
43do
44GCC_NEED_DECLARATION($ac_func, $2)
45done
46])
47
48dnl Check if we have vprintf and possibly _doprnt.
49dnl Note autoconf checks for vprintf even though we care about vfprintf.
50AC_DEFUN(GCC_FUNC_VFPRINTF_DOPRNT,
51[AC_FUNC_VPRINTF
52vfprintf=
53doprint=
54if test $ac_cv_func_vprintf != yes ; then
55  vfprintf=vfprintf.o
56  if test $ac_cv_func__doprnt != yes ; then
57    doprint=doprint.o
58  fi
59fi
60AC_SUBST(vfprintf)
61AC_SUBST(doprint)
62])    
63
64dnl See if the printf functions in libc support %p in format strings.
65AC_DEFUN(GCC_FUNC_PRINTF_PTR,
66[AC_CACHE_CHECK(whether the printf functions support %p,
67  gcc_cv_func_printf_ptr,
68[AC_TRY_RUN([#include <stdio.h>
69
70main()
71{
72  char buf[64];
73  char *p = buf, *q = NULL;
74  sprintf(buf, "%p", p);
75  sscanf(buf, "%p", &q);
76  exit (p != q);
77}], gcc_cv_func_printf_ptr=yes, gcc_cv_func_printf_ptr=no,
78	gcc_cv_func_printf_ptr=no)
79rm -f core core.* *.core])
80if test $gcc_cv_func_printf_ptr = yes ; then
81  AC_DEFINE(HAVE_PRINTF_PTR)
82fi
83])
84
85dnl See if symbolic links work and if not, try to substitute either hard links or simple copy.
86AC_DEFUN(GCC_PROG_LN_S,
87[AC_MSG_CHECKING(whether ln -s works)
88AC_CACHE_VAL(gcc_cv_prog_LN_S,
89[rm -f conftestdata_t
90echo >conftestdata_f
91if ln -s conftestdata_f conftestdata_t 2>/dev/null
92then
93  gcc_cv_prog_LN_S="ln -s"
94else
95  if ln conftestdata_f conftestdata_t 2>/dev/null
96  then
97    gcc_cv_prog_LN_S=ln
98  else
99    gcc_cv_prog_LN_S=cp
100  fi
101fi
102rm -f conftestdata_f conftestdata_t
103])dnl
104LN_S="$gcc_cv_prog_LN_S"
105if test "$gcc_cv_prog_LN_S" = "ln -s"; then
106  AC_MSG_RESULT(yes)
107else
108  if test "$gcc_cv_prog_LN_S" = "ln"; then
109    AC_MSG_RESULT([no, using ln])
110  else
111    AC_MSG_RESULT([no, and neither does ln, so using cp])
112  fi
113fi
114AC_SUBST(LN_S)dnl
115])
116
117dnl See if hard links work and if not, try to substitute either symbolic links or simple copy.
118AC_DEFUN(GCC_PROG_LN,
119[AC_MSG_CHECKING(whether ln works)
120AC_CACHE_VAL(gcc_cv_prog_LN,
121[rm -f conftestdata_t
122echo >conftestdata_f
123if ln conftestdata_f conftestdata_t 2>/dev/null
124then
125  gcc_cv_prog_LN="ln"
126else
127  if ln -s conftestdata_f conftestdata_t 2>/dev/null
128  then
129    gcc_cv_prog_LN="ln -s"
130  else
131    gcc_cv_prog_LN=cp
132  fi
133fi
134rm -f conftestdata_f conftestdata_t
135])dnl
136LN="$gcc_cv_prog_LN"
137if test "$gcc_cv_prog_LN" = "ln"; then
138  AC_MSG_RESULT(yes)
139else
140  if test "$gcc_cv_prog_LN" = "ln -s"; then
141    AC_MSG_RESULT([no, using ln -s])
142  else
143    AC_MSG_RESULT([no, and neither does ln -s, so using cp])
144  fi
145fi
146AC_SUBST(LN)dnl
147])
148
149dnl See whether the stage1 host compiler accepts the volatile keyword.
150AC_DEFUN(GCC_C_VOLATILE,
151[AC_CACHE_CHECK([for volatile], gcc_cv_c_volatile,
152[AC_TRY_COMPILE(, [volatile int foo;],
153        gcc_cv_c_volatile=yes, gcc_cv_c_volatile=no)])
154if test $gcc_cv_c_volatile = yes ; then
155  AC_DEFINE(HAVE_VOLATILE)
156fi
157])
158
159AC_DEFUN(EGCS_PROG_INSTALL,
160[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
161# Find a good install program.  We prefer a C program (faster),
162# so one script is as good as another.  But avoid the broken or
163# incompatible versions:
164# SysV /etc/install, /usr/sbin/install
165# SunOS /usr/etc/install
166# IRIX /sbin/install
167# AIX /bin/install
168# AFS /usr/afsws/bin/install, which mishandles nonexistent args
169# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
170# ./install, which can be erroneously created by make from ./install.sh.
171AC_MSG_CHECKING(for a BSD compatible install)
172if test -z "$INSTALL"; then
173AC_CACHE_VAL(ac_cv_path_install,
174[  IFS="${IFS= 	}"; ac_save_IFS="$IFS"; IFS="${IFS}:"
175  for ac_dir in $PATH; do
176    # Account for people who put trailing slashes in PATH elements.
177    case "$ac_dir/" in
178    /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
179    *)
180      # OSF1 and SCO ODT 3.0 have their own names for install.
181      for ac_prog in ginstall scoinst install; do
182        if test -f $ac_dir/$ac_prog; then
183	  if test $ac_prog = install &&
184            grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
185	    # AIX install.  It has an incompatible calling convention.
186	    # OSF/1 installbsd also uses dspmsg, but is usable.
187	    :
188	  else
189	    ac_cv_path_install="$ac_dir/$ac_prog -c"
190	    break 2
191	  fi
192	fi
193      done
194      ;;
195    esac
196  done
197  IFS="$ac_save_IFS"
198])dnl
199  if test "${ac_cv_path_install+set}" = set; then
200    INSTALL="$ac_cv_path_install"
201  else
202    # As a last resort, use the slow shell script.  We don't cache a
203    # path for INSTALL within a source directory, because that will
204    # break other packages using the cache if that directory is
205    # removed, or if the path is relative.
206    INSTALL="$ac_install_sh"
207  fi
208fi
209dnl We do special magic for INSTALL instead of AC_SUBST, to get
210dnl relative paths right.
211AC_MSG_RESULT($INSTALL)
212AC_SUBST(INSTALL)dnl
213
214# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
215# It thinks the first close brace ends the variable substitution.
216test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
217AC_SUBST(INSTALL_PROGRAM)dnl
218
219test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
220AC_SUBST(INSTALL_DATA)dnl
221])
222