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 | ||
39423523 DD |
29 | dnl Very limited version of automake's enable-maintainer-mode |
30 | ||
31 | AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) | |
32 | dnl maintainer-mode is disabled by default | |
33 | AC_ARG_ENABLE(maintainer-mode, | |
34 | [ --enable-maintainer-mode | |
35 | enable make rules and dependencies not useful | |
36 | (and sometimes confusing) to the casual installer], | |
37 | maintainer_mode=$enableval, | |
38 | maintainer_mode=no) | |
39 | ||
40 | AC_MSG_RESULT($maintainer_mode) | |
41 | ||
42 | if test "$maintainer_mode" = "yes"; then | |
43 | MAINT='' | |
44 | NOTMAINT='#' | |
45 | else | |
46 | MAINT='#' | |
47 | NOTMAINT='' | |
48 | fi | |
49 | AC_SUBST(MAINT)dnl | |
50 | AC_SUBST(NOTMAINT)dnl | |
51 | ||
fa9f0e33 DD |
52 | # Do we have a single-tree copy of texinfo? Even if we do, we can't |
53 | # rely on it - libiberty is built before texinfo. | |
54 | AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, ) | |
1a78a35a DD |
55 | if test "x$MAKEINFO" = "x"; then |
56 | MAKEINFO="@echo makeinfo missing; true" | |
fa9f0e33 | 57 | BUILD_INFO= |
1a78a35a DD |
58 | else |
59 | BUILD_INFO=info | |
60 | case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in | |
61 | x*\ [[1-3]].* ) | |
62 | MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true" | |
63 | BUILD_INFO= | |
64 | AC_MSG_WARN([ | |
fa9f0e33 | 65 | *** Makeinfo is too old. Info documentation will not be built.]) |
1a78a35a DD |
66 | ;; |
67 | esac | |
68 | fi | |
fa9f0e33 | 69 | AC_SUBST(MAKEINFO) |
39423523 DD |
70 | AC_SUBST(BUILD_INFO) |
71 | ||
72 | AC_CHECK_PROG(PERL, perl, perl, ) | |
73 | if test x"$PERL" = x""; then | |
74 | HAVE_PERL='#' | |
75 | else | |
76 | HAVE_PERL='' | |
77 | fi | |
78 | AC_SUBST(HAVE_PERL) | |
79 | ||
252b5132 RH |
80 | AC_CANONICAL_HOST |
81 | ||
82 | dnl When we start using automake: | |
83 | dnl AM_INIT_AUTOMAKE(libiberty, 1.0) | |
84 | ||
85 | dnl These must be called before AM_PROG_LIBTOOL, because it may want | |
86 | dnl to call AC_CHECK_PROG. | |
87 | AC_CHECK_TOOL(AR, ar) | |
88 | AC_CHECK_TOOL(RANLIB, ranlib, :) | |
89 | ||
252b5132 RH |
90 | LIB_AC_PROG_CC |
91 | ||
92 | AC_ISC_POSIX | |
2ea7befd DD |
93 | AC_C_CONST |
94 | AC_C_INLINE | |
252b5132 RH |
95 | |
96 | dnl When we start using libtool: | |
97 | dnl Default to a non shared library. This may be overridden by the | |
98 | dnl configure option --enable-shared. | |
99 | dnl AM_DISABLE_SHARED | |
100 | ||
101 | dnl When we start using libtool: | |
102 | dnl AM_PROG_LIBTOOL | |
103 | ||
104 | dnl When we start using automake: | |
105 | dnl AM_CONFIG_HEADER(config.h:config.in) | |
106 | AC_CONFIG_HEADER(config.h:config.in) | |
107 | ||
108 | dnl When we start using automake: | |
109 | dnl AM_MAINTAINER_MODE | |
110 | dnl AC_EXEEXT | |
111 | ||
112 | dnl When we start using automake: | |
113 | dnl AM_PROG_INSTALL | |
114 | AC_PROG_INSTALL | |
115 | ||
116 | . ${srcdir}/config.table | |
117 | host_makefile_frag=${frag} | |
118 | AC_SUBST_FILE(host_makefile_frag) | |
119 | ||
120 | # It's OK to check for header files. Although the compiler may not be | |
121 | # able to link anything, it had better be able to at least compile | |
122 | # something. | |
5527febf | 123 | 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 alloca.h) |
252b5132 | 124 | AC_HEADER_SYS_WAIT |
62df2065 | 125 | AC_HEADER_TIME |
252b5132 | 126 | |
7d3ffcaf JL |
127 | libiberty_AC_DECLARE_ERRNO |
128 | ||
15ae9e71 | 129 | AC_CHECK_TYPE(uintptr_t, unsigned long) |
dc579051 | 130 | |
15ae9e71 | 131 | if test $ac_cv_type_uintptr_t = yes |
dc579051 | 132 | then |
24acd898 | 133 | AC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.]) |
dc579051 DD |
134 | fi |
135 | ||
252b5132 RH |
136 | # This is the list of functions which libiberty will provide if they |
137 | # are not available on the host. | |
138 | ||
139 | funcs="asprintf" | |
140 | funcs="$funcs atexit" | |
141 | funcs="$funcs basename" | |
142 | funcs="$funcs bcmp" | |
143 | funcs="$funcs bcopy" | |
c6da642e | 144 | funcs="$funcs bsearch" |
252b5132 RH |
145 | funcs="$funcs bzero" |
146 | funcs="$funcs calloc" | |
147 | funcs="$funcs clock" | |
7b78baae | 148 | funcs="$funcs ffs" |
252b5132 RH |
149 | funcs="$funcs getcwd" |
150 | funcs="$funcs getpagesize" | |
151 | funcs="$funcs index" | |
152 | funcs="$funcs insque" | |
153 | funcs="$funcs memchr" | |
154 | funcs="$funcs memcmp" | |
155 | funcs="$funcs memcpy" | |
156 | funcs="$funcs memmove" | |
157 | funcs="$funcs memset" | |
158 | funcs="$funcs mkstemps" | |
0c0a36a4 | 159 | funcs="$funcs putenv" |
252b5132 RH |
160 | funcs="$funcs random" |
161 | funcs="$funcs rename" | |
162 | funcs="$funcs rindex" | |
0c0a36a4 | 163 | funcs="$funcs setenv" |
252b5132 RH |
164 | funcs="$funcs sigsetmask" |
165 | funcs="$funcs strcasecmp" | |
166 | funcs="$funcs strchr" | |
167 | funcs="$funcs strdup" | |
168 | funcs="$funcs strncasecmp" | |
169 | funcs="$funcs strrchr" | |
170 | funcs="$funcs strstr" | |
171 | funcs="$funcs strtod" | |
172 | funcs="$funcs strtol" | |
173 | funcs="$funcs strtoul" | |
174 | funcs="$funcs tmpnam" | |
175 | funcs="$funcs vasprintf" | |
176 | funcs="$funcs vfprintf" | |
177 | funcs="$funcs vprintf" | |
178 | funcs="$funcs vsprintf" | |
179 | funcs="$funcs waitpid" | |
180 | ||
181 | # Also in the old function.def file: alloca, vfork, getopt. | |
182 | ||
183 | vars="sys_errlist sys_nerr sys_siglist" | |
184 | ||
0c0a36a4 | 185 | checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday" |
252b5132 RH |
186 | |
187 | # These are neither executed nor required, but they help keep | |
188 | # autoheader happy without adding a bunch of text to acconfig.h. | |
189 | if test "x" = "y"; then | |
c6da642e DD |
190 | AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bsearch bzero calloc clock) |
191 | AC_CHECK_FUNCS(getcwd getpagesize index insque mkstemps memchr memcmp memcpy) | |
192 | AC_CHECK_FUNCS(memmove memset putenv random rename rindex sigsetmask) | |
193 | AC_CHECK_FUNCS(strcasecmp setenv strchr strdup strncasecmp strrchr strstr) | |
194 | AC_CHECK_FUNCS(strtod strtol strtoul tmpnam vasprintf vfprintf vprintf) | |
195 | AC_CHECK_FUNCS(vsprintf waitpid getrusage on_exit psignal strerror strsignal) | |
7b78baae | 196 | AC_CHECK_FUNCS(sysconf times sbrk gettimeofday ffs) |
2ea7befd DD |
197 | AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.]) |
198 | AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.]) | |
199 | AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.]) | |
252b5132 RH |
200 | fi |
201 | ||
202 | # For each of these functions, if the host does not provide the | |
203 | # function we want to put FN.o in LIBOBJS, and if the host does | |
30673bf5 | 204 | # provide the function, we want to define HAVE_FN in config.h. |
252b5132 RH |
205 | |
206 | setobjs= | |
0c0a36a4 | 207 | CHECK= |
50d4562d | 208 | target_header_dir= |
252b5132 RH |
209 | if test -n "${with_target_subdir}"; then |
210 | ||
211 | # We are being configured as a target library. AC_REPLACE_FUNCS | |
212 | # may not work correctly, because the compiler may not be able to | |
213 | # link executables. Note that we may still be being configured | |
214 | # native. | |
215 | ||
216 | # If we are being configured for newlib, we know which functions | |
217 | # newlib provide and which ones we will be expected to provide. | |
218 | ||
219 | if test "x${with_newlib}" = "xyes"; then | |
252b5132 RH |
220 | LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o" |
221 | ||
222 | for f in $funcs; do | |
223 | case "$f" in | |
224 | asprintf | basename | insque | random | strdup | vasprintf) | |
225 | ;; | |
226 | *) | |
227 | n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` | |
228 | AC_DEFINE_UNQUOTED($n) | |
229 | ;; | |
230 | esac | |
231 | done | |
232 | ||
233 | # newlib doesnt provide any of the variables in $vars, so we | |
234 | # dont have to check them here. | |
235 | ||
236 | # Of the functions in $checkfuncs, newlib only has strerror. | |
2ea7befd | 237 | AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR) |
252b5132 RH |
238 | |
239 | setobjs=yes | |
240 | ||
241 | fi | |
0c0a36a4 | 242 | |
50d4562d DD |
243 | # We may wish to install the target headers somewhere. |
244 | AC_ARG_ENABLE(install-libiberty, | |
245 | [ --enable-install-libiberty Install headers for end users], | |
246 | enable_install_libiberty=$enableval, | |
247 | enable_install_libiberty=no)dnl | |
248 | ||
249 | # Option parsed, now set things appropriately. | |
250 | case x"$enable_install_libiberty" in | |
251 | xyes|x) | |
252 | target_header_dir=libiberty | |
253 | ;; | |
254 | xno) | |
255 | target_header_dir= | |
256 | ;; | |
257 | *) | |
258 | # This could be sanity-checked in various ways... | |
259 | target_header_dir="${enable_install_libiberty}" | |
260 | ;; | |
261 | esac | |
262 | ||
263 | ||
0c0a36a4 ILT |
264 | else |
265 | ||
266 | # Not a target library, so we set things up to run the test suite. | |
267 | CHECK=check-cplus-dem | |
268 | ||
252b5132 RH |
269 | fi |
270 | ||
0c0a36a4 | 271 | AC_SUBST(CHECK) |
50d4562d | 272 | AC_SUBST(target_header_dir) |
0c0a36a4 | 273 | |
f01b59ed | 274 | case "${host}" in |
bef8b55d | 275 | *-*-cygwin* | *-*-mingw*) |
24acd898 DD |
276 | AC_DEFINE_NOAUTOHEADER(HAVE_SYS_ERRLIST) |
277 | AC_DEFINE_NOAUTOHEADER(HAVE_SYS_NERR) | |
f01b59ed DD |
278 | ;; |
279 | esac | |
280 | ||
252b5132 RH |
281 | if test -z "${setobjs}"; then |
282 | case "${host}" in | |
283 | ||
284 | *-*-vxworks*) | |
285 | # Handle VxWorks configuration specially, since on VxWorks the | |
286 | # libraries are actually on the target board, not in the file | |
287 | # system. | |
288 | LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o" | |
289 | LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o" | |
290 | for f in $funcs; do | |
291 | case "$f" in | |
292 | basename | getpagesize | insque | random | strcasecmp) | |
293 | ;; | |
294 | strncasecmp | strdup | vfork | waitpid | vasprintf) | |
295 | ;; | |
296 | *) | |
297 | n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` | |
298 | AC_DEFINE_UNQUOTED($n) | |
299 | ;; | |
300 | esac | |
301 | done | |
302 | ||
303 | # VxWorks doesn't provide any of the variables in $vars, so we | |
304 | # don't have to check them here. | |
305 | ||
306 | # Of the functions in $checkfuncs, VxWorks only has strerror. | |
2ea7befd | 307 | AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR) |
252b5132 RH |
308 | |
309 | setobjs=yes | |
310 | ;; | |
311 | ||
312 | esac | |
313 | fi | |
314 | ||
315 | if test -z "${setobjs}"; then | |
316 | ||
317 | case "${host}" in | |
318 | ||
319 | *-*-cygwin*) | |
320 | # The Cygwin library actually uses a couple of files from | |
321 | # libiberty when it is built. If we are building a native | |
322 | # Cygwin, and we run the tests, we will appear to have these | |
323 | # files. However, when we go on to build winsup, we will wind up | |
324 | # with a library which does not have the files, since they should | |
325 | # have come from libiberty. | |
326 | ||
327 | # We handle this by removing the functions the winsup library | |
328 | # provides from our shell variables, so that they appear to be | |
329 | # missing. | |
330 | ||
64e3a659 DD |
331 | # DJ - only if we're *building* cygwin, not just building *with* cygwin |
332 | ||
333 | if test -n "${with_target_subdir}" | |
334 | then | |
335 | funcs="`echo $funcs | sed -e 's/random//'`" | |
336 | LIBOBJS="$LIBOBJS random.o" | |
337 | vars="`echo $vars | sed -e 's/sys_siglist//'`" | |
338 | checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`" | |
339 | fi | |
252b5132 RH |
340 | ;; |
341 | ||
342 | *-*-mingw32*) | |
343 | # Under mingw32, sys_nerr and sys_errlist exist, but they are | |
344 | # macros, so the test below won't find them. | |
2ea7befd DD |
345 | libiberty_cv_var_sys_nerr=yes |
346 | libiberty_cv_var_sys_errlist=yes | |
252b5132 RH |
347 | ;; |
348 | ||
349 | *-*-uwin*) | |
350 | # Under some versions of uwin, vfork is notoriously buggy and the test | |
351 | # can hang configure; on other versions, vfork exists just as a stub. | |
352 | # FIXME: This should be removed once vfork in uwin's runtime is fixed. | |
353 | ac_cv_func_vfork_works=no | |
0c0a36a4 ILT |
354 | # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are |
355 | # macros (actually, these are imported from a DLL, but the end effect | |
356 | # is the same), so the test below won't find them. | |
2ea7befd DD |
357 | libiberty_cv_var_sys_nerr=yes |
358 | libiberty_cv_var_sys_errlist=yes | |
252b5132 RH |
359 | ;; |
360 | ||
c0eb281b DD |
361 | *-*-*vms*) |
362 | # Under VMS, vfork works very different than on Unix. The standard test | |
363 | # won't work, and it isn't easily adaptable. It makes more sense to | |
364 | # just force it. | |
365 | ac_cv_func_vfork_works=yes | |
366 | ;; | |
367 | ||
252b5132 RH |
368 | esac |
369 | ||
370 | # We haven't set the list of objects yet. Use the standard autoconf | |
371 | # tests. This will only work if the compiler works. | |
372 | AC_PROG_CC_WORKS | |
373 | AC_REPLACE_FUNCS($funcs) | |
30673bf5 | 374 | libiberty_AC_FUNC_C_ALLOCA |
252b5132 RH |
375 | AC_FUNC_VFORK |
376 | if test $ac_cv_func_vfork_works = no; then | |
377 | LIBOBJS="$LIBOBJS vfork.o" | |
378 | fi | |
24acd898 DD |
379 | # We only need _doprnt if we might use it to implement v*printf. |
380 | if test $ac_cv_func_vprintf != yes \ | |
381 | || test $ac_cv_func_vfprintf != yes \ | |
382 | || test $ac_cv_func_vsprintf != yes; then | |
383 | AC_REPLACE_FUNCS(_doprnt) | |
cc096b71 DD |
384 | else |
385 | AC_CHECK_FUNCS(_doprnt) | |
24acd898 DD |
386 | fi |
387 | ||
252b5132 RH |
388 | for v in $vars; do |
389 | AC_MSG_CHECKING([for $v]) | |
390 | AC_CACHE_VAL(libiberty_cv_var_$v, | |
58b1717a | 391 | [AC_TRY_LINK([int *p;], [extern int $v []; p = &$v;], |
252b5132 RH |
392 | [eval "libiberty_cv_var_$v=yes"], |
393 | [eval "libiberty_cv_var_$v=no"])]) | |
394 | if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then | |
395 | AC_MSG_RESULT(yes) | |
396 | n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` | |
397 | AC_DEFINE_UNQUOTED($n) | |
398 | else | |
399 | AC_MSG_RESULT(no) | |
400 | fi | |
401 | done | |
402 | AC_CHECK_FUNCS($checkfuncs) | |
403 | fi | |
404 | ||
eb383413 L |
405 | libiberty_AC_FUNC_STRNCMP |
406 | ||
252b5132 RH |
407 | # Install a library built with a cross compiler in $(tooldir) rather |
408 | # than $(libdir). | |
409 | if test -z "${with_cross_host}"; then | |
410 | INSTALL_DEST=libdir | |
411 | else | |
412 | INSTALL_DEST=tooldir | |
413 | fi | |
414 | AC_SUBST(INSTALL_DEST) | |
415 | ||
416 | # We need multilib support, but only if configuring for the target. | |
0c0a36a4 | 417 | AC_OUTPUT(Makefile testsuite/Makefile, |
252b5132 RH |
418 | [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h |
419 | if test -n "$CONFIG_FILES"; then | |
420 | if test -n "${with_target_subdir}"; then | |
421 | # FIXME: We shouldn't need to set ac_file | |
422 | ac_file=Makefile | |
423 | . ${libiberty_topdir}/config-ml.in | |
424 | fi | |
425 | fi], | |
426 | srcdir=${srcdir} | |
427 | host=${host} | |
428 | target=${target} | |
429 | with_target_subdir=${with_target_subdir} | |
430 | with_multisubdir=${with_multisubdir} | |
431 | ac_configure_args="--enable-multilib ${ac_configure_args}" | |
432 | CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} | |
433 | libiberty_topdir=${libiberty_topdir} | |
434 | ) |