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