]>
Commit | Line | Data |
---|---|---|
3affd5f0 | 1 | dnl Process this file with autoconf to produce a configure script |
6599da04 | 2 | |
4ac3cb83 | 3 | AC_PREREQ(2.13) |
3affd5f0 | 4 | AC_INIT(pexecute.c) |
6599da04 | 5 | |
3affd5f0 JL |
6 | dnl We use these options to decide which functions to include. |
7 | AC_ARG_WITH(target-subdir, | |
ca6b370d JL |
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]) | |
3affd5f0 JL |
11 | AC_ARG_WITH(newlib, |
12 | [ --with-newlib Configuring with newlib]) | |
6599da04 | 13 | |
3affd5f0 JL |
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 | ||
3affd5f0 JL |
39 | LIB_AC_PROG_CC |
40 | ||
41 | AC_ISC_POSIX | |
d1209685 ZW |
42 | AC_C_CONST |
43 | AC_C_INLINE | |
3affd5f0 JL |
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 | |
dd8f3ed5 | 59 | dnl AC_EXEEXT |
3affd5f0 JL |
60 | |
61 | dnl When we start using automake: | |
62 | dnl AM_PROG_INSTALL | |
63 | AC_PROG_INSTALL | |
6599da04 JM |
64 | |
65 | . ${srcdir}/config.table | |
66 | host_makefile_frag=${frag} | |
3affd5f0 JL |
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. | |
c6451ce1 | 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) |
a6458d1d | 73 | AC_HEADER_SYS_WAIT |
c6451ce1 | 74 | AC_HEADER_TIME |
6599da04 | 75 | |
3b58c099 MS |
76 | libiberty_AC_DECLARE_ERRNO |
77 | ||
3affd5f0 JL |
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" | |
dac45916 | 86 | funcs="$funcs bsearch" |
3affd5f0 | 87 | funcs="$funcs bzero" |
a9acf741 | 88 | funcs="$funcs calloc" |
3affd5f0 JL |
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" | |
687361c8 | 99 | funcs="$funcs mkstemps" |
9eb4080f | 100 | funcs="$funcs putenv" |
3affd5f0 JL |
101 | funcs="$funcs random" |
102 | funcs="$funcs rename" | |
103 | funcs="$funcs rindex" | |
9eb4080f | 104 | funcs="$funcs setenv" |
3affd5f0 JL |
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 | ||
90e72e20 | 126 | checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday" |
3affd5f0 JL |
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 | |
dac45916 MS |
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) | |
d1209685 ZW |
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.]) | |
6599da04 JM |
141 | fi |
142 | ||
3affd5f0 JL |
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 | |
145 | # provide the function, we want to define HAVE_FN in config.h. Also, | |
146 | # if the host does not provide alloca, we set ALLOCA to alloca.o | |
147 | ||
148 | setobjs= | |
7c72138a | 149 | CHECK= |
3affd5f0 JL |
150 | if test -n "${with_target_subdir}"; then |
151 | ||
ca6b370d | 152 | # We are being configured as a target library. AC_REPLACE_FUNCS |
3affd5f0 | 153 | # may not work correctly, because the compiler may not be able to |
ca6b370d JL |
154 | # link executables. Note that we may still be being configured |
155 | # native. | |
3affd5f0 JL |
156 | |
157 | # If we are being configured for newlib, we know which functions | |
158 | # newlib provide and which ones we will be expected to provide. | |
159 | ||
160 | if test "x${with_newlib}" = "xyes"; then | |
161 | ALLOCA="alloca.o" | |
ca6b370d | 162 | LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o" |
3affd5f0 JL |
163 | |
164 | for f in $funcs; do | |
165 | case "$f" in | |
ca6b370d | 166 | asprintf | basename | insque | random | strdup | vasprintf) |
3affd5f0 JL |
167 | ;; |
168 | *) | |
169 | n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` | |
170 | AC_DEFINE_UNQUOTED($n) | |
171 | ;; | |
172 | esac | |
173 | done | |
174 | ||
175 | # newlib doesnt provide any of the variables in $vars, so we | |
176 | # dont have to check them here. | |
177 | ||
ca6b370d | 178 | # Of the functions in $checkfuncs, newlib only has strerror. |
d1209685 | 179 | AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR) |
3affd5f0 JL |
180 | |
181 | setobjs=yes | |
182 | ||
183 | fi | |
7c72138a TT |
184 | |
185 | else | |
186 | ||
187 | # Not a target library, so we set things up to run the test suite. | |
188 | CHECK=check-cplus-dem | |
189 | ||
3affd5f0 JL |
190 | fi |
191 | ||
7c72138a TT |
192 | AC_SUBST(CHECK) |
193 | ||
3affd5f0 JL |
194 | if test -z "${setobjs}"; then |
195 | case "${host}" in | |
196 | ||
197 | *-*-vxworks*) | |
198 | # Handle VxWorks configuration specially, since on VxWorks the | |
199 | # libraries are actually on the target board, not in the file | |
200 | # system. | |
201 | LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o" | |
202 | LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o" | |
203 | for f in $funcs; do | |
204 | case "$f" in | |
205 | basename | getpagesize | insque | random | strcasecmp) | |
206 | ;; | |
207 | strncasecmp | strdup | vfork | waitpid | vasprintf) | |
208 | ;; | |
209 | *) | |
210 | n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` | |
211 | AC_DEFINE_UNQUOTED($n) | |
212 | ;; | |
213 | esac | |
214 | done | |
215 | ||
216 | # VxWorks doesn't provide any of the variables in $vars, so we | |
217 | # don't have to check them here. | |
218 | ||
219 | # Of the functions in $checkfuncs, VxWorks only has strerror. | |
d1209685 | 220 | AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR) |
3affd5f0 JL |
221 | |
222 | setobjs=yes | |
223 | ;; | |
224 | ||
225 | esac | |
226 | fi | |
227 | ||
228 | if test -z "${setobjs}"; then | |
229 | ||
230 | case "${host}" in | |
231 | ||
dd8f3ed5 GN |
232 | *-*-cygwin*) |
233 | # The Cygwin library actually uses a couple of files from | |
3affd5f0 | 234 | # libiberty when it is built. If we are building a native |
dd8f3ed5 | 235 | # Cygwin, and we run the tests, we will appear to have these |
3affd5f0 JL |
236 | # files. However, when we go on to build winsup, we will wind up |
237 | # with a library which does not have the files, since they should | |
238 | # have come from libiberty. | |
239 | ||
240 | # We handle this by removing the functions the winsup library | |
241 | # provides from our shell variables, so that they appear to be | |
242 | # missing. | |
243 | ||
2f31ed7e DD |
244 | # DJ - only if we're *building* cygwin, not just building *with* cygwin |
245 | ||
246 | if test -n "${with_target_subdir}" | |
247 | then | |
248 | funcs="`echo $funcs | sed -e 's/random//'`" | |
249 | LIBOBJS="$LIBOBJS random.o" | |
250 | vars="`echo $vars | sed -e 's/sys_siglist//'`" | |
251 | checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`" | |
252 | fi | |
3affd5f0 JL |
253 | ;; |
254 | ||
255 | *-*-mingw32*) | |
256 | # Under mingw32, sys_nerr and sys_errlist exist, but they are | |
257 | # macros, so the test below won't find them. | |
d1209685 ZW |
258 | libiberty_cv_var_sys_nerr=yes |
259 | libiberty_cv_var_sys_errlist=yes | |
3affd5f0 JL |
260 | ;; |
261 | ||
89f602a7 MK |
262 | *-*-uwin*) |
263 | # Under some versions of uwin, vfork is notoriously buggy and the test | |
264 | # can hang configure; on other versions, vfork exists just as a stub. | |
265 | # FIXME: This should be removed once vfork in uwin's runtime is fixed. | |
266 | ac_cv_func_vfork_works=no | |
62133b5e MK |
267 | # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are |
268 | # macros (actually, these are imported from a DLL, but the end effect | |
269 | # is the same), so the test below won't find them. | |
d1209685 ZW |
270 | libiberty_cv_var_sys_nerr=yes |
271 | libiberty_cv_var_sys_errlist=yes | |
89f602a7 MK |
272 | ;; |
273 | ||
3affd5f0 JL |
274 | esac |
275 | ||
276 | # We haven't set the list of objects yet. Use the standard autoconf | |
277 | # tests. This will only work if the compiler works. | |
278 | AC_PROG_CC_WORKS | |
279 | AC_REPLACE_FUNCS($funcs) | |
7dd88617 DT |
280 | |
281 | case "${host}" in | |
282 | *-*-interix) | |
283 | # On Interix, it wrongly concludes that the MSVC compiler supports alloca. | |
284 | # (MSVC does on Win32, not on Interix.) | |
285 | # This should be temporary. | |
286 | ||
287 | ac_cv_header_alloca_h=no | |
288 | ac_cv_func_alloca_works=no | |
289 | ALLOCA=alloca.o | |
290 | cat >> confdefs.h <<\EOF | |
291 | #define C_ALLOCA 1 | |
292 | EOF | |
293 | cat >> confdefs.h <<EOF | |
294 | #define STACK_DIRECTION -1 | |
295 | EOF | |
296 | ;; | |
297 | *) | |
298 | AC_FUNC_ALLOCA | |
299 | ;; | |
300 | esac | |
301 | ||
3affd5f0 JL |
302 | AC_FUNC_VFORK |
303 | if test $ac_cv_func_vfork_works = no; then | |
304 | LIBOBJS="$LIBOBJS vfork.o" | |
305 | fi | |
306 | for v in $vars; do | |
307 | AC_MSG_CHECKING([for $v]) | |
308 | AC_CACHE_VAL(libiberty_cv_var_$v, | |
309 | [AC_TRY_LINK([int *p;], [extern int $v; p = &$v;], | |
310 | [eval "libiberty_cv_var_$v=yes"], | |
311 | [eval "libiberty_cv_var_$v=no"])]) | |
312 | if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then | |
313 | AC_MSG_RESULT(yes) | |
314 | n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` | |
315 | AC_DEFINE_UNQUOTED($n) | |
6599da04 | 316 | else |
3affd5f0 | 317 | AC_MSG_RESULT(no) |
6599da04 | 318 | fi |
3affd5f0 JL |
319 | done |
320 | AC_CHECK_FUNCS($checkfuncs) | |
321 | fi | |
322 | ||
a9266bfa KG |
323 | libiberty_AC_FUNC_STRNCMP |
324 | ||
3affd5f0 JL |
325 | # Install a library built with a cross compiler in $(tooldir) rather |
326 | # than $(libdir). | |
ca6b370d | 327 | if test -z "${with_cross_host}"; then |
3affd5f0 JL |
328 | INSTALL_DEST=libdir |
329 | else | |
330 | INSTALL_DEST=tooldir | |
6599da04 | 331 | fi |
3affd5f0 JL |
332 | AC_SUBST(INSTALL_DEST) |
333 | ||
334 | # We need multilib support, but only if configuring for the target. | |
7c72138a | 335 | AC_OUTPUT(Makefile testsuite/Makefile, |
3affd5f0 JL |
336 | [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h |
337 | if test -n "$CONFIG_FILES"; then | |
338 | if test -n "${with_target_subdir}"; then | |
339 | # FIXME: We shouldn't need to set ac_file | |
340 | ac_file=Makefile | |
341 | . ${libiberty_topdir}/config-ml.in | |
342 | fi | |
343 | fi], | |
344 | srcdir=${srcdir} | |
345 | host=${host} | |
346 | target=${target} | |
347 | with_target_subdir=${with_target_subdir} | |
348 | with_multisubdir=${with_multisubdir} | |
349 | ac_configure_args="--enable-multilib ${ac_configure_args}" | |
350 | CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} | |
351 | libiberty_topdir=${libiberty_topdir} | |
352 | ) |