OSDN Git Service

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