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