Commit | Line | Data |
---|---|---|
252b5132 RH |
1 | dnl Process this file with autoconf to produce a configure script |
2 | ||
0c0a36a4 | 3 | AC_PREREQ(2.13) |
252b5132 RH |
4 | AC_INIT(pexecute.c) |
5 | ||
6 | dnl We use these options to decide which functions to include. | |
7 | AC_ARG_WITH(target-subdir, | |
8 | [ --with-target-subdir=SUBDIR Configuring in a subdirectory]) | |
9 | AC_ARG_WITH(cross-host, | |
10 | [ --with-cross-host=HOST Configuring with a cross compiler]) | |
11 | AC_ARG_WITH(newlib, | |
12 | [ --with-newlib Configuring with newlib]) | |
13 | ||
14 | if test "${srcdir}" = "."; then | |
15 | if test -z "${with_target_subdir}"; then | |
16 | libiberty_topdir="${srcdir}/.." | |
17 | else | |
18 | if test "${with_target_subdir}" != "."; then | |
19 | libiberty_topdir="${srcdir}/${with_multisrctop}../.." | |
20 | else | |
21 | libiberty_topdir="${srcdir}/${with_multisrctop}.." | |
22 | fi | |
23 | fi | |
24 | else | |
25 | libiberty_topdir="${srcdir}/.." | |
26 | fi | |
27 | AC_CONFIG_AUX_DIR($libiberty_topdir) | |
28 | ||
29 | AC_CANONICAL_HOST | |
30 | ||
31 | dnl When we start using automake: | |
32 | dnl AM_INIT_AUTOMAKE(libiberty, 1.0) | |
33 | ||
34 | dnl These must be called before AM_PROG_LIBTOOL, because it may want | |
35 | dnl to call AC_CHECK_PROG. | |
36 | AC_CHECK_TOOL(AR, ar) | |
37 | AC_CHECK_TOOL(RANLIB, ranlib, :) | |
38 | ||
252b5132 RH |
39 | LIB_AC_PROG_CC |
40 | ||
41 | AC_ISC_POSIX | |
2ea7befd DD |
42 | AC_C_CONST |
43 | AC_C_INLINE | |
252b5132 RH |
44 | |
45 | dnl When we start using libtool: | |
46 | dnl Default to a non shared library. This may be overridden by the | |
47 | dnl configure option --enable-shared. | |
48 | dnl AM_DISABLE_SHARED | |
49 | ||
50 | dnl When we start using libtool: | |
51 | dnl AM_PROG_LIBTOOL | |
52 | ||
53 | dnl When we start using automake: | |
54 | dnl AM_CONFIG_HEADER(config.h:config.in) | |
55 | AC_CONFIG_HEADER(config.h:config.in) | |
56 | ||
57 | dnl When we start using automake: | |
58 | dnl AM_MAINTAINER_MODE | |
59 | dnl AC_EXEEXT | |
60 | ||
61 | dnl When we start using automake: | |
62 | dnl AM_PROG_INSTALL | |
63 | AC_PROG_INSTALL | |
64 | ||
65 | . ${srcdir}/config.table | |
66 | host_makefile_frag=${frag} | |
67 | AC_SUBST_FILE(host_makefile_frag) | |
68 | ||
69 | # It's OK to check for header files. Although the compiler may not be | |
70 | # able to link anything, it had better be able to at least compile | |
71 | # something. | |
62df2065 | 72 | AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h) |
252b5132 | 73 | AC_HEADER_SYS_WAIT |
62df2065 | 74 | AC_HEADER_TIME |
252b5132 | 75 | |
7d3ffcaf JL |
76 | libiberty_AC_DECLARE_ERRNO |
77 | ||
252b5132 RH |
78 | # This is the list of functions which libiberty will provide if they |
79 | # are not available on the host. | |
80 | ||
81 | funcs="asprintf" | |
82 | funcs="$funcs atexit" | |
83 | funcs="$funcs basename" | |
84 | funcs="$funcs bcmp" | |
85 | funcs="$funcs bcopy" | |
c6da642e | 86 | funcs="$funcs bsearch" |
252b5132 RH |
87 | funcs="$funcs bzero" |
88 | funcs="$funcs calloc" | |
89 | funcs="$funcs clock" | |
90 | funcs="$funcs getcwd" | |
91 | funcs="$funcs getpagesize" | |
92 | funcs="$funcs index" | |
93 | funcs="$funcs insque" | |
94 | funcs="$funcs memchr" | |
95 | funcs="$funcs memcmp" | |
96 | funcs="$funcs memcpy" | |
97 | funcs="$funcs memmove" | |
98 | funcs="$funcs memset" | |
99 | funcs="$funcs mkstemps" | |
0c0a36a4 | 100 | funcs="$funcs putenv" |
252b5132 RH |
101 | funcs="$funcs random" |
102 | funcs="$funcs rename" | |
103 | funcs="$funcs rindex" | |
0c0a36a4 | 104 | funcs="$funcs setenv" |
252b5132 RH |
105 | funcs="$funcs sigsetmask" |
106 | funcs="$funcs strcasecmp" | |
107 | funcs="$funcs strchr" | |
108 | funcs="$funcs strdup" | |
109 | funcs="$funcs strncasecmp" | |
110 | funcs="$funcs strrchr" | |
111 | funcs="$funcs strstr" | |
112 | funcs="$funcs strtod" | |
113 | funcs="$funcs strtol" | |
114 | funcs="$funcs strtoul" | |
115 | funcs="$funcs tmpnam" | |
116 | funcs="$funcs vasprintf" | |
117 | funcs="$funcs vfprintf" | |
118 | funcs="$funcs vprintf" | |
119 | funcs="$funcs vsprintf" | |
120 | funcs="$funcs waitpid" | |
121 | ||
122 | # Also in the old function.def file: alloca, vfork, getopt. | |
123 | ||
124 | vars="sys_errlist sys_nerr sys_siglist" | |
125 | ||
0c0a36a4 | 126 | checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday" |
252b5132 RH |
127 | |
128 | # These are neither executed nor required, but they help keep | |
129 | # autoheader happy without adding a bunch of text to acconfig.h. | |
130 | if test "x" = "y"; then | |
c6da642e DD |
131 | AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bsearch bzero calloc clock) |
132 | AC_CHECK_FUNCS(getcwd getpagesize index insque mkstemps memchr memcmp memcpy) | |
133 | AC_CHECK_FUNCS(memmove memset putenv random rename rindex sigsetmask) | |
134 | AC_CHECK_FUNCS(strcasecmp setenv strchr strdup strncasecmp strrchr strstr) | |
135 | AC_CHECK_FUNCS(strtod strtol strtoul tmpnam vasprintf vfprintf vprintf) | |
136 | AC_CHECK_FUNCS(vsprintf waitpid getrusage on_exit psignal strerror strsignal) | |
137 | AC_CHECK_FUNCS(sysconf times sbrk gettimeofday) | |
2ea7befd DD |
138 | AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.]) |
139 | AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.]) | |
140 | AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.]) | |
252b5132 RH |
141 | fi |
142 | ||
143 | # For each of these functions, if the host does not provide the | |
144 | # function we want to put FN.o in LIBOBJS, and if the host does | |
30673bf5 | 145 | # provide the function, we want to define HAVE_FN in config.h. |
252b5132 RH |
146 | |
147 | setobjs= | |
0c0a36a4 | 148 | CHECK= |
252b5132 RH |
149 | if test -n "${with_target_subdir}"; then |
150 | ||
151 | # We are being configured as a target library. AC_REPLACE_FUNCS | |
152 | # may not work correctly, because the compiler may not be able to | |
153 | # link executables. Note that we may still be being configured | |
154 | # native. | |
155 | ||
156 | # If we are being configured for newlib, we know which functions | |
157 | # newlib provide and which ones we will be expected to provide. | |
158 | ||
159 | if test "x${with_newlib}" = "xyes"; then | |
252b5132 RH |
160 | LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o" |
161 | ||
162 | for f in $funcs; do | |
163 | case "$f" in | |
164 | asprintf | basename | insque | random | strdup | vasprintf) | |
165 | ;; | |
166 | *) | |
167 | n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` | |
168 | AC_DEFINE_UNQUOTED($n) | |
169 | ;; | |
170 | esac | |
171 | done | |
172 | ||
173 | # newlib doesnt provide any of the variables in $vars, so we | |
174 | # dont have to check them here. | |
175 | ||
176 | # Of the functions in $checkfuncs, newlib only has strerror. | |
2ea7befd | 177 | AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR) |
252b5132 RH |
178 | |
179 | setobjs=yes | |
180 | ||
181 | fi | |
0c0a36a4 ILT |
182 | |
183 | else | |
184 | ||
185 | # Not a target library, so we set things up to run the test suite. | |
186 | CHECK=check-cplus-dem | |
187 | ||
252b5132 RH |
188 | fi |
189 | ||
0c0a36a4 ILT |
190 | AC_SUBST(CHECK) |
191 | ||
252b5132 RH |
192 | if test -z "${setobjs}"; then |
193 | case "${host}" in | |
194 | ||
195 | *-*-vxworks*) | |
196 | # Handle VxWorks configuration specially, since on VxWorks the | |
197 | # libraries are actually on the target board, not in the file | |
198 | # system. | |
199 | LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o" | |
200 | LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o" | |
201 | for f in $funcs; do | |
202 | case "$f" in | |
203 | basename | getpagesize | insque | random | strcasecmp) | |
204 | ;; | |
205 | strncasecmp | strdup | vfork | waitpid | vasprintf) | |
206 | ;; | |
207 | *) | |
208 | n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` | |
209 | AC_DEFINE_UNQUOTED($n) | |
210 | ;; | |
211 | esac | |
212 | done | |
213 | ||
214 | # VxWorks doesn't provide any of the variables in $vars, so we | |
215 | # don't have to check them here. | |
216 | ||
217 | # Of the functions in $checkfuncs, VxWorks only has strerror. | |
2ea7befd | 218 | AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR) |
252b5132 RH |
219 | |
220 | setobjs=yes | |
221 | ;; | |
222 | ||
223 | esac | |
224 | fi | |
225 | ||
226 | if test -z "${setobjs}"; then | |
227 | ||
228 | case "${host}" in | |
229 | ||
230 | *-*-cygwin*) | |
231 | # The Cygwin library actually uses a couple of files from | |
232 | # libiberty when it is built. If we are building a native | |
233 | # Cygwin, and we run the tests, we will appear to have these | |
234 | # files. However, when we go on to build winsup, we will wind up | |
235 | # with a library which does not have the files, since they should | |
236 | # have come from libiberty. | |
237 | ||
238 | # We handle this by removing the functions the winsup library | |
239 | # provides from our shell variables, so that they appear to be | |
240 | # missing. | |
241 | ||
64e3a659 DD |
242 | # DJ - only if we're *building* cygwin, not just building *with* cygwin |
243 | ||
244 | if test -n "${with_target_subdir}" | |
245 | then | |
246 | funcs="`echo $funcs | sed -e 's/random//'`" | |
247 | LIBOBJS="$LIBOBJS random.o" | |
248 | vars="`echo $vars | sed -e 's/sys_siglist//'`" | |
249 | checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`" | |
250 | fi | |
252b5132 RH |
251 | ;; |
252 | ||
253 | *-*-mingw32*) | |
254 | # Under mingw32, sys_nerr and sys_errlist exist, but they are | |
255 | # macros, so the test below won't find them. | |
2ea7befd DD |
256 | libiberty_cv_var_sys_nerr=yes |
257 | libiberty_cv_var_sys_errlist=yes | |
252b5132 RH |
258 | ;; |
259 | ||
260 | *-*-uwin*) | |
261 | # Under some versions of uwin, vfork is notoriously buggy and the test | |
262 | # can hang configure; on other versions, vfork exists just as a stub. | |
263 | # FIXME: This should be removed once vfork in uwin's runtime is fixed. | |
264 | ac_cv_func_vfork_works=no | |
0c0a36a4 ILT |
265 | # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are |
266 | # macros (actually, these are imported from a DLL, but the end effect | |
267 | # is the same), so the test below won't find them. | |
2ea7befd DD |
268 | libiberty_cv_var_sys_nerr=yes |
269 | libiberty_cv_var_sys_errlist=yes | |
252b5132 RH |
270 | ;; |
271 | ||
272 | esac | |
273 | ||
274 | # We haven't set the list of objects yet. Use the standard autoconf | |
275 | # tests. This will only work if the compiler works. | |
276 | AC_PROG_CC_WORKS | |
277 | AC_REPLACE_FUNCS($funcs) | |
30673bf5 | 278 | libiberty_AC_FUNC_C_ALLOCA |
252b5132 RH |
279 | AC_FUNC_VFORK |
280 | if test $ac_cv_func_vfork_works = no; then | |
281 | LIBOBJS="$LIBOBJS vfork.o" | |
282 | fi | |
283 | for v in $vars; do | |
284 | AC_MSG_CHECKING([for $v]) | |
285 | AC_CACHE_VAL(libiberty_cv_var_$v, | |
286 | [AC_TRY_LINK([int *p;], [extern int $v; p = &$v;], | |
287 | [eval "libiberty_cv_var_$v=yes"], | |
288 | [eval "libiberty_cv_var_$v=no"])]) | |
289 | if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then | |
290 | AC_MSG_RESULT(yes) | |
291 | n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` | |
292 | AC_DEFINE_UNQUOTED($n) | |
293 | else | |
294 | AC_MSG_RESULT(no) | |
295 | fi | |
296 | done | |
297 | AC_CHECK_FUNCS($checkfuncs) | |
298 | fi | |
299 | ||
eb383413 L |
300 | libiberty_AC_FUNC_STRNCMP |
301 | ||
252b5132 RH |
302 | # Install a library built with a cross compiler in $(tooldir) rather |
303 | # than $(libdir). | |
304 | if test -z "${with_cross_host}"; then | |
305 | INSTALL_DEST=libdir | |
306 | else | |
307 | INSTALL_DEST=tooldir | |
308 | fi | |
309 | AC_SUBST(INSTALL_DEST) | |
310 | ||
311 | # We need multilib support, but only if configuring for the target. | |
0c0a36a4 | 312 | AC_OUTPUT(Makefile testsuite/Makefile, |
252b5132 RH |
313 | [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h |
314 | if test -n "$CONFIG_FILES"; then | |
315 | if test -n "${with_target_subdir}"; then | |
316 | # FIXME: We shouldn't need to set ac_file | |
317 | ac_file=Makefile | |
318 | . ${libiberty_topdir}/config-ml.in | |
319 | fi | |
320 | fi], | |
321 | srcdir=${srcdir} | |
322 | host=${host} | |
323 | target=${target} | |
324 | with_target_subdir=${with_target_subdir} | |
325 | with_multisubdir=${with_multisubdir} | |
326 | ac_configure_args="--enable-multilib ${ac_configure_args}" | |
327 | CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} | |
328 | libiberty_topdir=${libiberty_topdir} | |
329 | ) |