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