bb80193fea140ed2c44b4ebe5ceffbb60d9e0993
[platform/upstream/bash.git] / configure.in
1 dnl
2 dnl Configure script for bash-2.05
3 dnl
4 dnl report bugs to chet@po.cwru.edu
5 dnl
6 dnl Process this file with autoconf to produce a configure script.
7
8 # Copyright (C) 1987-2001 Free Software Foundation, Inc.
9
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2, or (at your option)
13 # any later version.
14
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 # 02111-1307, USA.
24
25 AC_REVISION([for Bash 2.05a, version 2.128, from autoconf version] AC_ACVERSION)dnl
26
27 AC_INIT(bash, 2.05a, bug-bash@gnu.org)
28
29 dnl make sure we are using a recent autoconf version
30 AC_PREREQ(2.50)
31
32 AC_CONFIG_SRCDIR(shell.h)
33 dnl where to find install.sh, config.sub, and config.guess
34 AC_CONFIG_AUX_DIR(./support)
35 AC_CONFIG_HEADERS(config.h)
36
37 dnl checks for version info
38 BASHVERS=2.05a
39
40 dnl canonicalize the host and os so we can do some tricky things before
41 dnl parsing options
42 AC_CANONICAL_HOST
43
44 dnl configure defaults
45 opt_bash_malloc=yes
46 opt_purify=no
47 opt_purecov=no
48 opt_afs=no
49 opt_curses=no
50 opt_with_installed_readline=no
51
52 #htmldir=
53
54 dnl some systems should be configured without the bash malloc by default
55 dnl and some need a special compiler or loader
56 dnl look in the NOTES file for more
57 case "${host_cpu}-${host_os}" in
58 alpha*-*)       opt_bash_malloc=no ;;   # alpha running osf/1 or linux
59 *[[Cc]]ray*-*)  opt_bash_malloc=no ;;   # Crays
60 *-osf1*)        opt_bash_malloc=no ;;   # other osf/1 machines
61 sparc-svr4*)    opt_bash_malloc=no ;;   # sparc SVR4, SVR4.2
62 sparc-netbsd*)  opt_bash_malloc=no ;;   # needs 8-byte alignment
63 mips-irix6*)    opt_bash_malloc=no ;;   # needs 8-byte alignment
64 m68k-sysv)      opt_bash_malloc=no ;;   # fixes file descriptor leak in closedir
65 sparc-linux*)   opt_bash_malloc=no ;;   # sparc running linux; requires ELF
66 #*-freebsd*)    opt_bash_malloc=no ;;   # they claim it's better
67 *-openbsd*)     opt_bash_malloc=no ;;   # they claim it needs eight-bit alignment
68 *-aix*)         opt_bash_malloc=no ;;   # AIX machines
69 *-nextstep*)    opt_bash_malloc=no ;;   # NeXT machines running NeXTstep
70 *-macos*)       opt_bash_malloc=no ;;   # Apple MacOS X
71 *-rhapsody*)    opt_bash_malloc=no ;;   # Apple Rhapsody (MacOS X)
72 *-darwin*)      opt_bash_malloc=no ;;   # Apple Darwin (MacOS X)
73 *-dgux*)        opt_bash_malloc=no ;;   # DG/UX machines
74 *-qnx*)         opt_bash_malloc=no ;;   # QNX 4.2
75 *-machten4)     opt_bash_malloc=no ;;   # MachTen 4.x
76 *-bsdi2.1|*-bsdi3.?)    opt_bash_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins
77 *-beos*)        opt_bash_malloc=no ;;   # they say it's suitable
78 *-cygwin*)      opt_bash_malloc=no ;;   # Cygnus's CYGWIN environment
79 *-opennt*|*-interix*)   opt_bash_malloc=no ;;   # Interix, now owned by Microsoft
80 esac
81
82 dnl arguments to configure
83 dnl packages
84 AC_ARG_WITH(afs, --with-afs             if you are running AFS, opt_afs=$withval)
85 AC_ARG_WITH(bash-malloc, --with-bash-malloc     use the Bash version of malloc,opt_bash_malloc=$withval)
86 AC_ARG_WITH(curses, --with-curses               use the curses library instead of the termcap library,opt_curses=$withval)
87 AC_ARG_WITH(gnu-malloc, --with-gnu-malloc       synonym for --with-bash-malloc,opt_bash_malloc=$withval)
88 AC_ARG_WITH(installed-readline, --with-installed-readline       use a version of the readline library that is already installed, opt_with_installed_readline=$withval)
89 AC_ARG_WITH(purecov, --with-purecov             configure to postprocess with pure coverage, opt_purecov=$withval)
90 AC_ARG_WITH(purify, --with-purify               configure to postprocess with purify, opt_purify=$withval)
91
92 if test "$opt_bash_malloc" = yes; then
93         MALLOC_TARGET=malloc
94         MALLOC_SRC=malloc.c
95
96         MALLOC_LIB='-lmalloc'
97         MALLOC_LIBRARY='$(ALLOC_LIBDIR)/libmalloc.a'
98         MALLOC_LDFLAGS='-L$(ALLOC_LIBDIR)'
99         MALLOC_DEP='$(MALLOC_LIBRARY)'
100
101         AC_DEFINE(USING_BASH_MALLOC)
102 else
103         MALLOC_LIB=
104         MALLOC_LIBRARY=
105         MALLOC_LDFLAGS=
106         MALLOC_DEP=     
107 fi
108
109 if test "$opt_purify" = yes; then
110         PURIFY="purify "
111 else
112         PURIFY=
113 fi
114
115 if test "$opt_purecov" = yes; then
116         PURIFY="${PURIFY}purecov"
117 fi
118
119 if test "$opt_afs" = yes; then
120         AC_DEFINE(AFS)
121 fi
122
123 if test "$opt_curses" = yes; then
124         prefer_curses=yes
125 fi
126
127 dnl optional shell features in config.h.in
128 opt_minimal_config=no
129
130 opt_job_control=yes
131 opt_alias=yes
132 opt_readline=yes
133 opt_history=yes
134 opt_bang_history=yes
135 opt_dirstack=yes
136 opt_restricted=yes
137 opt_process_subst=yes
138 opt_prompt_decoding=yes
139 opt_select=yes
140 opt_help=yes
141 opt_array_variables=yes
142 opt_dparen_arith=yes
143 opt_extended_glob=yes
144 opt_brace_expansion=yes
145 opt_disabled_builtins=no
146 opt_command_timing=yes
147 opt_xpg_echo=no
148 opt_cond_command=yes
149 opt_arith_for_command=yes
150 opt_net_redirs=yes
151 opt_progcomp=yes
152 opt_largefile=yes
153
154 dnl options that affect how bash is compiled and linked
155 opt_static_link=no
156 opt_profiling=no
157
158 dnl argument parsing for optional features
159 AC_ARG_ENABLE(minimal-config, --enable-minimal-config   a minimal sh-like configuration, opt_minimal_config=$enableval)
160
161 dnl a minimal configuration turns everything off, but features can be
162 dnl added individually
163 if test $opt_minimal_config = yes; then
164         opt_job_control=no opt_alias=no opt_readline=no
165         opt_history=no opt_bang_history=no opt_dirstack=no
166         opt_restricted=no opt_process_subst=no opt_prompt_decoding=no
167         opt_select=no opt_help=no opt_array_variables=no opt_dparen_arith=no
168         opt_brace_expansion=no opt_disabled_builtins=no opt_command_timing=no
169         opt_extended_glob=no opt_cond_command=no opt_arith_for_command=no
170         opt_net_redirs=no opt_progcomp=no
171 fi
172
173 AC_ARG_ENABLE(alias, --enable-alias             enable shell aliases, opt_alias=$enableval)
174 AC_ARG_ENABLE(arith-for-command, --enable-arith-for-command     enable arithmetic for command, opt_arith_for_command=$enableval)
175 AC_ARG_ENABLE(array-variables, --enable-array-variables include shell array variables, opt_array_variables=$enableval)
176 AC_ARG_ENABLE(bang-history, --enable-bang-history       turn on csh-style history substitution, opt_bang_history=$enableval)
177 AC_ARG_ENABLE(brace-expansion, --enable-brace-expansion include brace expansion, opt_brace_expansion=$enableval)
178 AC_ARG_ENABLE(command-timing, --enable-command-timing   enable the time reserved word and command timing, opt_command_timing=$enableval)
179 AC_ARG_ENABLE(cond-command, --enable-cond-command       enable the conditional command, opt_cond_command=$enableval)
180 AC_ARG_ENABLE(directory-stack, --enable-directory-stack enable builtins pushd/popd/dirs, opt_dirstack=$enableval)
181 AC_ARG_ENABLE(disabled-builtins, --enable-disabled-builtins     allow disabled builtins to still be invoked, opt_disabled_builtins=$enableval)
182 AC_ARG_ENABLE(dparen-arithmetic, [--enable-dparen-arithmetic    include ((...)) command], opt_dparen_arith=$enableval)
183 AC_ARG_ENABLE(extended-glob, --enable-extended-glob     include ksh-style extended pattern matching, opt_extended_glob=$enableval)
184 AC_ARG_ENABLE(help-builtin, --enable-help-builtin       include the help builtin, opt_help=$enableval)
185 AC_ARG_ENABLE(history, --enable-history turn on command history, opt_history=$enableval)
186 AC_ARG_ENABLE(job-control, --enable-job-control enable job control features, opt_job_control=$enableval)
187 AC_ARG_ENABLE(largefile, --enable-largefile     enable support for large files, opt_largefile=$enableval)
188 AC_ARG_ENABLE(net-redirections, --enable-net-redirections       enable /dev/tcp/host/port redirection, opt_net_redirs=$enableval)
189 AC_ARG_ENABLE(process-substitution, --enable-process-substitution       enable process substitution, opt_process_subst=$enableval)
190 AC_ARG_ENABLE(progcomp, --enable-progcomp       enable programmable completion and the complete builtin, opt_progcomp=$enableval)
191 AC_ARG_ENABLE(prompt-string-decoding, --enable-prompt-string-decoding   turn on escape character decoding in prompts, opt_prompt_decoding=$enableval)
192 AC_ARG_ENABLE(readline, --enable-readline       turn on command line editing, opt_readline=$enableval)
193 AC_ARG_ENABLE(restricted, --enable-restricted   enable a restricted shell, opt_restricted=$enableval)
194 AC_ARG_ENABLE(select, --enable-select           include select command, opt_select=$enableval)
195 AC_ARG_ENABLE(usg-echo-default, --enable-usg-echo-default       a synonym for --enable-xpg-echo-default, opt_xpg_echo=$enableval)
196 AC_ARG_ENABLE(xpg-echo-default, --enable-xpg-echo-default       make the echo builtin expand escape sequences by default, opt_xpg_echo=$enableval)
197
198 dnl options that alter how bash is compiled and linked
199 AC_ARG_ENABLE(profiling, --enable-profiling             allow profiling with gprof, opt_profiling=$enableval)
200 AC_ARG_ENABLE(static-link, --enable-static-link         [link bash statically, for use as a root shell], opt_static_link=$enableval)
201
202 dnl opt_job_control is handled later, after BASH_JOB_CONTROL_MISSING runs
203
204 dnl opt_readline and opt_history are handled later, because AC_PROG_CC needs
205 dnl to be run before we can check the version of an already-installed readline
206 dnl library
207
208 if test $opt_alias = yes; then
209 AC_DEFINE(ALIAS)
210 fi
211 if test $opt_dirstack = yes; then
212 AC_DEFINE(PUSHD_AND_POPD)
213 fi
214 if test $opt_restricted = yes; then
215 AC_DEFINE(RESTRICTED_SHELL)
216 fi
217 if test $opt_process_subst = yes; then
218 AC_DEFINE(PROCESS_SUBSTITUTION)
219 fi
220 if test $opt_prompt_decoding = yes; then
221 AC_DEFINE(PROMPT_STRING_DECODE)
222 fi
223 if test $opt_select = yes; then
224 AC_DEFINE(SELECT_COMMAND)
225 fi
226 if test $opt_help = yes; then
227 AC_DEFINE(HELP_BUILTIN)
228 fi
229 if test $opt_array_variables = yes; then
230 AC_DEFINE(ARRAY_VARS)
231 fi
232 if test $opt_dparen_arith = yes; then
233 AC_DEFINE(DPAREN_ARITHMETIC)
234 fi
235 if test $opt_brace_expansion = yes; then
236 AC_DEFINE(BRACE_EXPANSION)
237 fi
238 if test $opt_disabled_builtins = yes; then
239 AC_DEFINE(DISABLED_BUILTINS)
240 fi
241 if test $opt_command_timing = yes; then
242 AC_DEFINE(COMMAND_TIMING)
243 fi
244 if test $opt_xpg_echo = yes ; then
245 AC_DEFINE(DEFAULT_ECHO_TO_XPG)
246 fi
247 if test $opt_extended_glob = yes ; then
248 AC_DEFINE(EXTENDED_GLOB)
249 fi
250 if test $opt_cond_command = yes ; then
251 AC_DEFINE(COND_COMMAND)
252 fi
253 if test $opt_arith_for_command = yes; then
254 AC_DEFINE(ARITH_FOR_COMMAND)
255 fi
256 if test $opt_net_redirs = yes; then
257 AC_DEFINE(NETWORK_REDIRECTIONS)
258 fi
259 if test $opt_progcomp = yes; then
260 AC_DEFINE(PROGRAMMABLE_COMPLETION)
261 fi
262
263 if test "$opt_minimal_config" = yes; then
264         TESTSCRIPT=run-minimal
265 else
266         TESTSCRIPT=run-all
267 fi
268
269 dnl now substitute in the values generated by arguments
270 AC_SUBST(TESTSCRIPT)
271 AC_SUBST(PURIFY)
272 AC_SUBST(MALLOC_TARGET)
273 AC_SUBST(MALLOC_SRC)
274
275 AC_SUBST(MALLOC_LIB)
276 AC_SUBST(MALLOC_LIBRARY)
277 AC_SUBST(MALLOC_LDFLAGS)
278 AC_SUBST(MALLOC_DEP)
279
280 AC_SUBST(htmldir)
281
282 echo ""
283 echo "Beginning configuration for bash-$BASHVERS for ${host_cpu}-${host_vendor}-${host_os}"
284 echo ""
285
286 dnl compilation checks
287 dnl AC_PROG_CC sets $cross_compiling to `yes' if cross-compiling for a
288 dnl different environment
289 AC_PROG_CC
290
291 dnl test for Unix variants
292 AC_ISC_POSIX
293 AC_MINIX
294
295 dnl test for non-Unix variants
296 AC_CYGWIN
297 AC_MINGW32
298
299 AC_SYS_LARGEFILE
300
301 dnl BEGIN changes for cross-building for cygwin and BeOS
302
303 SIGNAMES_H=lsignames.h
304
305 dnl load up the cross-building cache file -- add more cases and cache
306 dnl files as necessary
307
308 dnl Note that host and target machine are the same, and different than the
309 dnl build machine.
310 dnl Set SIGNAMES_H based on whether or not we're cross-compiling.
311
312 if test "x$cross_compiling" = "xyes"; then
313     case "${host}" in
314     *-cygwin*)
315         cross_cache=${srcdir}/cross-build/cygwin32.cache
316         SIGNAMES_H='$(srcdir)/cross-build/win32sig.h'
317         ;;
318     i[[3456]]86-*-beos*)
319         cross_cache=${srcdir}/cross-build/x86-beos.cache
320         SIGNAMES_H='${srcdir}/cross-build/beos-sig.h'
321         ;;
322     *)  echo "configure: cross-compiling for $host is not supported" >&2
323         ;;
324     esac
325     if test -n "${cross_cache}" && test -r "${cross_cache}"; then
326         echo "loading cross-build cache file ${cross_cache}"
327         . ${cross_cache}
328     fi
329     unset cross_cache
330 fi
331 AC_SUBST(SIGNAMES_H)
332
333 if test -z "$CC_FOR_BUILD"; then
334     if test "x$cross_compiling" = "xno"; then
335         CC_FOR_BUILD='$(CC)'
336     else
337         CC_FOR_BUILD=gcc
338     fi
339 fi
340 AC_SUBST(CC_FOR_BUILD)
341
342 dnl END changes for cross-building
343
344 dnl We want these before the checks, so the checks can modify their values.
345 test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1
346
347 dnl If we're using gcc and the user hasn't specified CFLAGS, add -O2 to CFLAGS.
348 test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O2"
349
350 dnl handle options that alter how bash is compiled and linked
351 dnl these must come after the test for cc/gcc
352 if test "$opt_profiling" = "yes"; then
353         PROFILE_FLAGS=-pg
354         case "$host_os" in
355         solaris2*)      ;;
356         *)              opt_static_link=yes ;;
357         esac
358 fi
359
360 if test "$opt_static_link" = yes; then
361         # if we're using gcc, add `-static' to LDFLAGS, except on Solaris >= 2
362         if test -n "$GCC" || test "$ac_cv_prog_gcc" = "yes"; then
363                 STATIC_LD="-static" 
364                 case "$host_os" in
365                 solaris2*)      ;;
366                 *)              LDFLAGS="$LDFLAGS -static" ;;   # XXX experimental
367                 esac
368         fi
369 fi
370
371 AC_SUBST(CFLAGS)
372 AC_SUBST(CPPFLAGS)
373 AC_SUBST(LDFLAGS)
374 AC_SUBST(STATIC_LD)
375
376 AC_PROG_GCC_TRADITIONAL
377
378 dnl BEGIN READLINE and HISTORY LIBRARY SECTION
379 dnl prepare to allow bash to be linked against an already-installed readline
380
381 dnl first test that the readline version is new enough to link bash against
382 if test "$opt_readline" = yes && test "$opt_with_installed_readline" != "no"
383 then
384 echo opt_with_installed_readline = $opt_with_installed_readline
385         # If the user specified --with-installed-readline=PREFIX and PREFIX
386         # is not `yes', set ac_cv_rl_prefix to PREFIX
387         test $opt_with_installed_readline != "yes" && ac_cv_rl_prefix=$opt_with_installed_readline
388
389         RL_LIB_READLINE_VERSION
390
391         case "$ac_cv_rl_version" in
392         4.[[2-9]]*|5*|6*|7*|8*|9*)      ;;
393         *)      opt_with_installed_readline=no 
394                 AC_MSG_WARN(installed readline library is too old to be linked with bash)
395                 AC_MSG_WARN(using private bash version)
396                 ;;
397         esac
398 fi
399
400 if test $opt_readline = yes; then
401         AC_DEFINE(READLINE)
402         READLINE_LIB=-lreadline
403         if test "$opt_with_installed_readline" != "no" ; then
404                 case "$RL_INCLUDEDIR" in
405                 /usr/include)   ;;
406                 *)              RL_INCLUDE='-I${RL_INCLUDEDIR}'
407                 esac
408                 READLINE_DEP=
409         else
410                 RL_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
411                 READLINE_DEP='$(READLINE_LIBRARY)'
412         fi
413 else
414         RL_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
415         READLINE_LIB= READLINE_DEP=
416 fi
417 if test $opt_history = yes || test $opt_bang_history = yes; then
418         if test $opt_history = yes; then
419                 AC_DEFINE(HISTORY)
420         fi
421         if test $opt_bang_history = yes; then
422                 AC_DEFINE(BANG_HISTORY)
423         fi
424         HISTORY_LIB=-lhistory
425         if test "$opt_with_installed_readline" != "no"; then
426                 HIST_LIBDIR=$RL_LIBDIR
427                 HISTORY_DEP=
428                 case "$RL_INCLUDEDIR" in
429                 /usr/include)   ;;
430                 *)              RL_INCLUDE='-I${RL_INCLUDEDIR}'
431                 esac
432         else
433                 HIST_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
434                 HISTORY_DEP='$(HISTORY_LIBRARY)'
435         fi
436 else
437         HIST_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
438         HISTORY_LIB= HISTORY_DEP=
439 fi
440 AC_SUBST(READLINE_LIB)
441 AC_SUBST(READLINE_DEP)
442 AC_SUBST(RL_LIBDIR)
443 AC_SUBST(RL_INCLUDEDIR)
444 AC_SUBST(RL_INCLUDE)
445 AC_SUBST(HISTORY_LIB)
446 AC_SUBST(HISTORY_DEP)
447 AC_SUBST(HIST_LIBDIR)
448
449 dnl END READLINE and HISTORY LIBRARY SECTION
450
451 dnl programs needed by the build and install process
452 AC_PROG_INSTALL
453 AC_CHECK_PROG(AR, ar, , ar)
454 dnl Set default for ARFLAGS, since autoconf does not have a macro for it.
455 dnl This allows people to set it when running configure or make
456 test -n "$ARFLAGS" || ARFLAGS="cr"
457 AC_PROG_RANLIB
458 AC_PROG_YACC
459 AC_PROG_MAKE_SET
460
461 case "$host_os" in
462 opennt*|interix*)       MAKE_SHELL="$INTERIX_ROOT/bin/sh" ;;
463 *)                      MAKE_SHELL=/bin/sh ;;
464 esac
465 AC_SUBST(MAKE_SHELL)
466
467 dnl Turn on any extensions available in the GNU C library.
468 AC_DEFINE(_GNU_SOURCE, 1)
469
470 dnl C compiler characteristics
471 AC_C_CONST
472 AC_C_INLINE
473 AC_C_BIGENDIAN
474 AC_C_STRINGIZE
475 AC_C_LONG_DOUBLE
476 AC_C_PROTOTYPES
477 AC_C_CHAR_UNSIGNED
478
479 dnl header files
480 AC_HEADER_DIRENT
481 AC_HEADER_TIME
482
483 BASH_HEADER_INTTYPES
484
485 AC_CHECK_HEADERS(unistd.h stdlib.h stdarg.h varargs.h limits.h string.h \
486                  memory.h locale.h termcap.h termio.h termios.h dlfcn.h \
487                  stddef.h stdint.h netdb.h grp.h strings.h)
488 AC_CHECK_HEADERS(sys/ptem.h sys/pte.h sys/stream.h sys/select.h sys/file.h \
489                  sys/resource.h sys/param.h sys/socket.h \
490                  sys/time.h sys/times.h sys/wait.h)
491 AC_CHECK_HEADERS(netinet/in.h arpa/inet.h)
492
493 dnl special checks for libc functions
494 AC_FUNC_ALLOCA
495 AC_FUNC_GETPGRP
496 AC_FUNC_SETVBUF_REVERSED
497 AC_FUNC_VPRINTF
498 AC_FUNC_STRCOLL
499
500 dnl if we're not using the bash malloc but require the C alloca, set things
501 dnl up to build a libmalloc.a containing only alloca.o
502
503 if test "$ac_cv_func_alloca_works" = "no" && test "$opt_bash_malloc" = "no"; then
504         MALLOC_TARGET=alloca
505         MALLOC_SRC=alloca.c
506
507         MALLOC_LIB='-lmalloc'
508         MALLOC_LIBRARY='$(ALLOC_LIBDIR)/libmalloc.a'
509         MALLOC_LDFLAGS='-L$(ALLOC_LIBDIR)'
510         MALLOC_DEP='$(MALLOC_LIBRARY)'
511 fi
512
513 dnl if vprintf is not in libc, see if it's defined in stdio.h
514 if test "$ac_cv_func_vprintf" = no; then
515     AC_MSG_CHECKING(for declaration of vprintf in stdio.h)
516     AC_EGREP_HEADER([[int[      ]*vprintf[^a-zA-Z0-9]]],stdio.h,ac_cv_func_vprintf=yes)
517     AC_MSG_RESULT($ac_cv_func_vprintf)
518     if test $ac_cv_func_vprintf = yes; then
519         AC_DEFINE(HAVE_VPRINTF)
520     fi
521 fi
522
523 if test "$ac_cv_func_vprintf" = no && test "$ac_cv_func__doprnt" = "yes"; then
524   AC_LIBOBJ(vprint)
525 fi
526
527 dnl signal stuff
528 AC_TYPE_SIGNAL
529
530 dnl checks for certain version-specific system calls and libc functions
531 AC_CHECK_FUNC(__setostype, AC_DEFINE(HAVE_SETOSTYPE))
532 AC_CHECK_FUNC(wait3, AC_DEFINE(HAVE_WAIT3))
533
534 dnl checks for missing libc functions
535 AC_CHECK_FUNC(mkfifo,AC_DEFINE(HAVE_MKFIFO),AC_DEFINE(MKFIFO_MISSING))
536
537 dnl checks for system calls
538 AC_CHECK_FUNCS(dup2 select getdtablesize getgroups gethostname \
539                 setdtablesize getpagesize killpg lstat getpeername sbrk \
540                 getrlimit getrusage gettimeofday waitpid tcgetpgrp \
541                 readlink)
542 AC_REPLACE_FUNCS(rename)
543
544 dnl checks for c library functions
545 AC_CHECK_FUNCS(bcopy bzero confstr sysconf pathconf setenv putenv \
546                 setlinebuf setvbuf setlocale strchr tcgetattr uname \
547                 ulimit tzset siginterrupt memmove ttyname times \
548                 getaddrinfo gethostbyname getservbyname inet_aton \
549                 vsnprintf snprintf vasprintf asprintf fnmatch)
550 AC_CHECK_FUNCS(isascii isblank isgraph isprint isspace isxdigit)
551 AC_REPLACE_FUNCS(getcwd strcasecmp strerror strpbrk strtod)
552 AC_REPLACE_FUNCS(strtol strtoul strtoll strtoull strtoimax strtoumax)
553
554 AC_CHECK_DECLS([strtold])
555 AC_CHECK_DECLS([confstr])
556 AC_CHECK_DECLS([sbrk])
557 AC_CHECK_DECLS([printf])
558 AC_CHECK_DECLS([strsignal])
559
560 BASH_CHECK_DECL(strtoimax)
561 BASH_CHECK_DECL(strtol)
562 BASH_CHECK_DECL(strtoll)
563 BASH_CHECK_DECL(strtoul)
564 BASH_CHECK_DECL(strtoull)
565 BASH_CHECK_DECL(strtoumax)
566
567 dnl checks for locale functions
568 AC_CHECK_HEADERS(libintl.h)
569 AC_CHECK_FUNCS(gettext textdomain bindtextdomain)
570
571 dnl check for GNU libintl if gettext/textdomain/bindtextdomain
572 dnl are not found in libc
573 if test "$ac_cv_func_bindtextdomain" = "no"; then
574     AC_CHECK_LIB(intl,bindtextdomain)
575     if test "$ac_cv_lib_intl" = "yes"; then
576         AC_CHECK_FUNCS(gettext textdomain bindtextdomain)
577     fi
578 fi
579
580 dnl checks for the dynamic loading library functions in libc and libdl
581 if test "$opt_static_link" != yes; then
582 AC_CHECK_LIB(dl, dlopen)
583 AC_CHECK_FUNCS(dlopen dlclose dlsym)
584 fi
585
586 dnl this defines SYS_SIGLIST_DECLARED
587 AC_DECL_SYS_SIGLIST
588
589 dnl network functions -- check for inet_aton again
590 if test "$ac_cv_func_inet_aton" != 'yes'; then
591 BASH_FUNC_INET_ATON
592 fi
593
594 dnl libraries
595 dnl this is reportedly no longer necessary for irix[56].?
596 case "$host_os" in
597 irix4*) AC_CHECK_LIB(sun, getpwent) ;;
598 esac
599
600 dnl check for getpeername in the socket library only if it's not in libc
601 if test "$ac_cv_func_getpeername" = no; then
602         BASH_CHECK_LIB_SOCKET
603 fi
604 dnl check for gethostbyname in socket libraries if it's not in libc
605 if test "$ac_cv_func_gethostbyname" = no; then
606         BASH_FUNC_GETHOSTBYNAME
607 fi
608
609 dnl system types
610 AC_TYPE_GETGROUPS
611 AC_TYPE_OFF_T
612 AC_TYPE_MODE_T
613 AC_TYPE_UID_T
614 AC_TYPE_PID_T
615 AC_TYPE_SIZE_T
616 AC_CHECK_TYPE(ssize_t, int)
617 AC_CHECK_TYPE(time_t, long)
618
619 BASH_TYPE_LONG_LONG
620 BASH_TYPE_UNSIGNED_LONG_LONG
621
622 AC_TYPE_SIGNAL
623
624 AC_CHECK_SIZEOF(char, 1)
625 AC_CHECK_SIZEOF(short, 2)
626 AC_CHECK_SIZEOF(int, 4)
627 AC_CHECK_SIZEOF(long, 4)
628 AC_CHECK_SIZEOF(char *, 4)
629 AC_CHECK_SIZEOF(double, 8)
630 AC_CHECK_SIZEOF([long long], 8)
631
632 AC_CHECK_TYPE(u_int, [unsigned int])
633 AC_CHECK_TYPE(u_long, [unsigned long])
634
635 BASH_TYPE_BITS16_T
636 BASH_TYPE_U_BITS16_T
637 BASH_TYPE_BITS32_T
638 BASH_TYPE_U_BITS32_T
639 BASH_TYPE_BITS64_T
640
641 BASH_TYPE_PTRDIFF_T
642
643 dnl structures
644 AC_HEADER_STAT
645
646 dnl system services
647 AC_SYS_INTERPRETER
648 if test $ac_cv_sys_interpreter = yes; then
649 AC_DEFINE(HAVE_HASH_BANG_EXEC)
650 fi
651
652 dnl Miscellaneous Bash tests
653 if test "$ac_cv_func_lstat" = "no"; then
654 BASH_FUNC_LSTAT
655 fi
656
657 dnl behavior of system calls and library functions
658 BASH_FUNC_DUP2_CLOEXEC_CHECK
659 BASH_SYS_PGRP_SYNC
660 BASH_SYS_SIGNAL_VINTAGE
661
662 dnl checking for the presence of certain library symbols
663 BASH_SYS_ERRLIST
664 BASH_SYS_SIGLIST
665 BASH_UNDER_SYS_SIGLIST
666
667 dnl various system types
668 BASH_TYPE_SIGHANDLER
669 BASH_CHECK_TYPE(clock_t, [#include <sys/times.h>], long)
670 BASH_CHECK_TYPE(sigset_t, [#include <signal.h>], int)
671 BASH_CHECK_TYPE(quad_t, , long, HAVE_QUAD_T)
672 BASH_CHECK_TYPE(intmax_t, , $bash_cv_type_long_long)
673 BASH_CHECK_TYPE(uintmax_t, , $bash_cv_type_unsigned_long_long)
674 if test "$ac_cv_header_sys_socket_h" = "yes"; then
675 BASH_CHECK_TYPE(socklen_t, [#include <sys/socket.h>], int, HAVE_SOCKLEN_T)
676 fi
677 BASH_TYPE_RLIMIT
678
679 dnl presence and contents of structures used by system calls
680 BASH_STRUCT_TERMIOS_LDISC
681 BASH_STRUCT_TERMIO_LDISC
682 BASH_STRUCT_DIRENT_D_INO
683 BASH_STRUCT_DIRENT_D_FILENO
684 BASH_STRUCT_WINSIZE
685 BASH_STRUCT_TIMEVAL
686 AC_CHECK_MEMBERS([struct stat.st_blocks])
687
688 dnl presence and behavior of C library functions
689 BASH_FUNC_STRSIGNAL
690 BASH_FUNC_OPENDIR_CHECK
691 BASH_FUNC_ULIMIT_MAXFDS
692 BASH_FUNC_GETENV
693 if test "$ac_func_getcwd" = "yes"; then
694 BASH_FUNC_GETCWD
695 fi
696 BASH_FUNC_POSIX_SETJMP
697 BASH_FUNC_STRCOLL
698
699 dnl I have removed this check.  The existing libc FNM_EXTMATCH implementation
700 dnl (glibc-2.2.4) disagrees with bash on the matching of incorrectly-formed
701 dnl patterns (bash treats them as strings or characters to be matched without
702 dnl any special meaning) and has one outright bug:  a[X-]b should match
703 dnl both a-b and aXb.
704 dnl
705 dnl Once Ulrich and I get together on this, the check can return
706 dnl
707 dnl chet 10/31/2001
708 dnl
709 dnl BASH_FUNC_FNMATCH_EXTMATCH
710
711 BASH_FUNC_PRINTF_A_FORMAT
712
713 dnl presence and behavior of OS functions
714 BASH_SYS_REINSTALL_SIGHANDLERS
715 BASH_SYS_JOB_CONTROL_MISSING
716 BASH_SYS_NAMED_PIPES
717
718 dnl presence of certain CPP defines
719 AC_HEADER_TIOCGWINSZ
720 BASH_HAVE_TIOCSTAT
721 BASH_HAVE_FIONREAD
722
723 dnl miscellaneous
724 BASH_CHECK_SPEED_T
725 BASH_CHECK_GETPW_FUNCS
726 BASH_CHECK_RTSIGS
727 BASH_CHECK_SYS_SIGLIST
728
729 dnl special checks
730 case "$host_os" in
731 hpux*)  BASH_CHECK_KERNEL_RLIMIT ;;
732 esac
733
734 if test "$opt_readline" = yes; then
735 dnl yuck
736 case "$host_os" in
737 aix*)   prefer_curses=yes ;;
738 esac
739 BASH_CHECK_LIB_TERMCAP
740 fi
741 AC_SUBST(TERMCAP_LIB)
742 AC_SUBST(TERMCAP_DEP)
743
744 BASH_CHECK_DEV_FD
745 BASH_CHECK_DEV_STDIN
746 BASH_SYS_DEFAULT_MAIL_DIR
747
748 if test "$bash_cv_job_control_missing" = missing; then
749         opt_job_control=no
750 fi
751
752 if test "$opt_job_control" = yes; then
753 AC_DEFINE(JOB_CONTROL)
754 JOBS_O=jobs.o
755 else
756 JOBS_O=nojobs.o
757 fi
758
759 AC_SUBST(JOBS_O)
760
761 dnl Defines that we want to propagate to the Makefiles in subdirectories,
762 dnl like glob and readline
763
764 LOCAL_DEFS=-DSHELL
765
766 dnl use this section to possibly define more cpp variables, specify local
767 dnl libraries, and specify any additional local cc flags
768 dnl
769 dnl this should really go away someday
770
771 case "${host_os}" in
772 sysv4.2*)       AC_DEFINE(SVR4_2)
773                 AC_DEFINE(SVR4) ;;
774 sysv4*)         AC_DEFINE(SVR4) ;;
775 sysv5*)         AC_DEFINE(SVR5) ;;
776 hpux9*)         LOCAL_CFLAGS="-DHPUX9 -DHPUX" ;;
777 hpux*)          LOCAL_CFLAGS=-DHPUX ;;
778 dgux*)          LOCAL_CFLAGS=-D_DGUX_SOURCE; LOCAL_LIBS=-ldgc ;;
779 isc*)           LOCAL_CFLAGS=-Disc386 ;;
780 rhapsody*)      LOCAL_CFLAGS=-DRHAPSODY ;;
781 darwin*)        LOCAL_CFLAGS=-DMACOSX ;;
782 sco3.2v5*)      LOCAL_CFLAGS="-b elf -DWAITPID_BROKEN -DNO_MEMSCRAMBLE -DPATH_MAX=1024" ;;
783 sco3.2v4*)      LOCAL_CFLAGS="-DMUST_UNBLOCK_CHLD -DNO_MEMSCRAMBLE -DPATH_MAX=1024" ;;
784 sco3.2*)        LOCAL_CFLAGS=-DMUST_UNBLOCK_CHLD ;;
785 sunos4*)        LOCAL_CFLAGS=-DSunOS4 ;;
786 solaris2.5*)    LOCAL_CFLAGS=-DSunOS5 ;;
787 lynxos*)        LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
788 linux*)         LOCAL_LDFLAGS=-rdynamic ;;       # allow dynamic loading
789 *qnx*)          LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s -lunix -lncurses" ;;
790 powerux*)       LOCAL_LIBS="-lgen" ;;
791 cygwin*)        LOCAL_LIBS="-luser32" ;;
792 opennt*|interix*) LOCAL_CFLAGS="-DNO_MAIN_ENV_ARG -DBROKEN_DIRENT_D_INO" ;;
793 esac
794
795 dnl Stanza for OS/compiler pair-specific flags
796 case "${host_os}-${CC}" in
797 aix4.2*-*gcc*)  LOCAL_LDFLAGS="-Xlinker -bexpall -Xlinker -brtl" ;;
798 aix4.2*)        LOCAL_LDFLAGS="-bexpall -brtl" ;;
799 bsdi4*-*gcc*)   LOCAL_LDFLAGS="-rdynamic" ;;    # allow dynamic loading, like Linux
800 esac
801
802 dnl FreeBSD-3.x can have either a.out or ELF
803 case "${host_os}" in
804 freebsd[[3-9]]*)
805                 if test -x /usr/bin/objformat && test "`/usr/bin/objformat`" = "elf" ; then
806                         LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
807                 fi ;;
808 freebsdelf*)    LOCAL_LDFLAGS=-rdynamic ;;      # allow dynamic loading
809 esac
810
811 case "$host_cpu" in
812 *cray*)         LOCAL_CFLAGS="-DCRAY" ;; # shell var so config.h can use it
813 esac
814
815 case "$host_cpu-$host_os" in
816 ibmrt-*bsd4*)   LOCAL_CFLAGS="-ma -U__STDC__" ;;
817 esac
818
819 case "$host_cpu-$host_vendor-$host_os" in
820 m88k-motorola-sysv3)    LOCAL_CFLAGS=-DWAITPID_BROKEN ;;
821 mips-pyramid-sysv4)     LOCAL_CFLAGS=-Xa ;;
822 esac
823
824 #
825 # Shared object configuration section.  These values are generated by
826 # ${srcdir}/support/shobj-conf
827 #
828 if test "$ac_cv_func_dlopen" = "yes" && test -f ${srcdir}/support/shobj-conf
829 then
830         AC_MSG_CHECKING(shared object configuration for loadable builtins)
831         eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c "${host_cpu}" -o "${host_os}" -v "${host_vendor}"`
832         AC_SUBST(SHOBJ_CC)
833         AC_SUBST(SHOBJ_CFLAGS)
834         AC_SUBST(SHOBJ_LD)
835         AC_SUBST(SHOBJ_LDFLAGS)
836         AC_SUBST(SHOBJ_XLDFLAGS)
837         AC_SUBST(SHOBJ_LIBS)
838         AC_SUBST(SHOBJ_STATUS)
839         AC_MSG_RESULT($SHOBJ_STATUS)
840 fi
841
842 # try to create a directory tree if the source is elsewhere
843 # this should be packaged into a script accessible via ${srcdir}/support
844 case "$srcdir" in
845 .)      ;;
846 *)      for d in doc tests support lib examples; do     # dirs
847                 test -d $d || mkdir $d
848         done
849         for ld in readline glob tilde malloc sh termcap; do     # libdirs
850                 test -d lib/$ld || mkdir lib/$ld
851         done
852         test -d examples/loadables || mkdir examples/loadables  # loadable builtins
853         test -d examples/loadables/perl || mkdir examples/loadables/perl
854         ;;
855 esac
856
857 BUILD_DIR=`pwd`
858
859 AC_SUBST(PROFILE_FLAGS)
860
861 AC_SUBST(incdir)
862 AC_SUBST(BUILD_DIR)
863
864 AC_SUBST(YACC)
865 AC_SUBST(AR)
866 AC_SUBST(ARFLAGS)
867
868 AC_SUBST(BASHVERS)
869
870 AC_SUBST(host_cpu)
871 AC_SUBST(host_vendor)
872 AC_SUBST(host_os)
873
874 AC_SUBST(LOCAL_LIBS)
875 AC_SUBST(LOCAL_CFLAGS)
876 AC_SUBST(LOCAL_LDFLAGS)
877 AC_SUBST(LOCAL_DEFS)
878
879 #AC_SUBST(ALLOCA_SOURCE)
880 #AC_SUBST(ALLOCA_OBJECT)
881
882 AC_OUTPUT([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
883           lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile \
884           lib/tilde/Makefile doc/Makefile support/Makefile \
885           examples/loadables/Makefile examples/loadables/perl/Makefile],
886 [
887 # Makefile uses this timestamp file to record whether config.h is up to date.
888 echo timestamp > stamp-h
889 ])