Imported from ../bash-2.0.tar.gz.
[platform/upstream/bash.git] / configure.in
1 dnl
2 dnl Configure script for bash-2.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 dnl checks for version info
8 AC_REVISION([for Bash 2.0, version 1.14, from autoconf version] AC_ACVERSION)dnl
9
10 AC_INIT(shell.h)
11 AC_CONFIG_HEADER(config.h)
12
13 dnl make sure we are using a recent autoconf version
14 AC_PREREQ(2.8)
15
16 dnl where to find install.sh, config.sub, and config.guess
17 AC_CONFIG_AUX_DIR(./support)
18
19 dnl canonicalize the host and os so we can do some tricky things before
20 dnl parsing options
21 AC_CANONICAL_HOST
22
23 dnl configure defaults
24 opt_gnu_malloc=yes
25 opt_glibc_malloc=no
26 opt_purify=no
27 opt_afs=no
28
29 dnl some systems should be configured without gnu malloc by default
30 dnl and some need a special compiler or loader
31 dnl look in the NOTES file for more
32 case "${host_cpu}-${host_os}" in
33 alpha-*)        opt_gnu_malloc=no ;;    # alpha running osf/1 or linux
34 *cray*-*)       opt_gnu_malloc=no ;;    # Crays
35 *-osf1*)        opt_gnu_malloc=no ;;    # other osf/1 machines
36 sparc-svr4*)    opt_gnu_malloc=no ;;    # sparc SVR4, SVR4.2
37 sparc-netbsd*)  opt_gnu_malloc=no ;;    # needs 8-byte alignment
38 sparc-linux*)   opt_gnu_malloc=no ;;    # sparc running linux; requires ELF
39 *-aix*)         opt_gnu_malloc=no ;;    # AIX machines
40 *-nextstep*)    opt_gnu_malloc=no ;;    # NeXT machines running NeXTstep
41 *-dgux*)        opt_gnu_malloc=no ;;    # DG/UX machines
42 *-qnx)          opt_gnu_malloc=no ;;    # QNX 4.2
43 *-bsdi2.1)      opt_gnu_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins
44 esac
45
46 dnl arguments to configure
47 dnl packages
48 AC_ARG_WITH(gnu-malloc, --with-gnu-malloc       use the GNU version of malloc,opt_gnu_malloc=$withval)
49 AC_ARG_WITH(glibc-malloc, --with-glibc-malloc   use the GNU C library version of malloc,opt_glibc_malloc=$withval)
50 AC_ARG_WITH(purify, --with-purify               configure to postprocess with purify, opt_purify=$withval)
51 AC_ARG_WITH(afs, --with-afs             if you are running AFS, opt_afs=$withval)
52
53 dnl test for glibc malloc first because it can override the default
54 if test "$opt_glibc_malloc" = yes; then 
55         MALLOC=gmalloc.o MALLOC_SRC='$(ALLOC_LIBSRC)/gmalloc.c'
56 elif test "$opt_gnu_malloc" = yes; then
57         MALLOC=malloc.o MALLOC_SRC='$(ALLOC_LIBSRC)/malloc.c'
58 else
59         MALLOC= MALLOC_SRC=
60 fi
61
62 if test "$opt_purify" = yes; then
63         PURIFY=purify
64 else
65         PURIFY=
66 fi
67
68 if test "$opt_afs" = yes; then
69         AC_DEFINE(AFS)
70 fi
71
72 dnl optional shell features in config.h.in
73 opt_minimal_config=no
74
75 opt_job_control=yes
76 opt_alias=yes
77 opt_readline=yes
78 opt_history=yes
79 opt_bang_history=yes
80 opt_dirstack=yes
81 opt_restricted=yes
82 opt_process_subst=yes
83 opt_prompt_decoding=yes
84 opt_select=yes
85 opt_help=yes
86 opt_array_variables=yes
87 opt_dparen_arith=yes
88 opt_brace_expansion=yes
89 opt_disabled_builtins=no
90 opt_command_timing=yes
91 opt_usg_echo=no
92
93 dnl argument parsing for optional features
94 AC_ARG_ENABLE(minimal-config, --enable-minimal-config   a minimal sh-like configuration, opt_minimal_config=$enableval)
95
96 dnl a minimal configuration turns everything off, but features can be
97 dnl added individually
98 if test $opt_minimal_config = yes; then
99         opt_job_control=no opt_alias=no opt_readline=no
100         opt_history=no opt_bang_history=no opt_dirstack=no
101         opt_restricted=no opt_process_subst=no opt_prompt_decoding=no
102         opt_select=no opt_help=no opt_array_variables=no opt_dparen_arith=no
103         opt_brace_expansion=no opt_disabled_builtins=no opt_command_timing=no
104 fi
105
106 AC_ARG_ENABLE(job-control, --enable-job-control enable job control features, opt_job_control=$enableval)
107 AC_ARG_ENABLE(alias, --enable-alias             enable shell aliases, opt_alias=$enableval)
108 AC_ARG_ENABLE(readline, --enable-readline       turn on command line editing, opt_readline=$enableval)
109 AC_ARG_ENABLE(history, --enable-history turn on command history, opt_history=$enableval)
110 AC_ARG_ENABLE(bang-history, --enable-bang-history       turn on csh-style history substitution, opt_bang_history=$enableval)
111 AC_ARG_ENABLE(directory-stack, --enable-directory-stack enable builtins pushd/popd/dirs, opt_dirstack=$enableval)
112 AC_ARG_ENABLE(restricted, --enable-restricted   enable a restricted shell, opt_restricted=$enableval)
113 AC_ARG_ENABLE(process-substitution, --enable-process-substitution       enable process substitution, opt_process_subst=$enableval)
114 AC_ARG_ENABLE(prompt-string-decoding, --enable-prompt-string-decoding   turn on escape character decoding in prompts, opt_prompt_decoding=$enableval)
115 AC_ARG_ENABLE(select, --enable-select           include select command, opt_select=$enableval)
116 AC_ARG_ENABLE(help-builtin, --enable-help-builtin       include the help builtin, opt_help=$enableval)
117 AC_ARG_ENABLE(array-variables, --enable-array-variables include shell array variables, opt_array_variables=$enableval)
118 AC_ARG_ENABLE(dparen-arithmetic, [--enable-dparen-arithmetic    include ((...)) command], opt_dparen_arith=$enableval)
119 AC_ARG_ENABLE(brace-expansion, --enable-brace-expansion include brace expansion, opt_brace_expansion=$enableval)
120 AC_ARG_ENABLE(disabled-builtins, --enable-disabled-builtins     allow disabled builtins to still be invoked, opt_disabled_builtins=$enableval)
121 AC_ARG_ENABLE(command-timing, --enable-command-timing   enable the time reserved word and command timing, opt_command_timing=$enableval)
122 AC_ARG_ENABLE(usg-echo-default, --enable-usg-echo-default       make the echo builtin expand escape sequences by default, opt_usg_echo=$enableval)
123
124 dnl opt_job_control is handled later, after BASH_JOB_CONTROL_MISSING runs
125
126 if test $opt_alias = yes; then
127 AC_DEFINE(ALIAS)
128 fi
129 if test $opt_readline = yes; then
130 AC_DEFINE(READLINE)
131 READLINE_LIB=-lreadline
132 READLINE_DEP='$(READLINE_LIBRARY)'
133 else
134 READLINE_LIB= READLINE_DEP=
135 fi
136 if test $opt_history = yes; then
137 AC_DEFINE(HISTORY)
138 HISTORY_LIB=-lhistory
139 HISTORY_DEP='$(HISTORY_LIBRARY)'
140 else
141 HISTORY_LIB= HISTORY_DEP=
142 fi
143 if test $opt_bang_history = yes; then
144 AC_DEFINE(BANG_HISTORY)
145 HISTORY_LIB=-lhistory
146 HISTORY_DEP='$(HISTORY_LIBRARY)'
147 else
148 HISTORY_LIB= HISTORY_DEP=
149 fi
150 if test $opt_dirstack = yes; then
151 AC_DEFINE(PUSHD_AND_POPD)
152 fi
153 if test $opt_restricted = yes; then
154 AC_DEFINE(RESTRICTED_SHELL)
155 fi
156 if test $opt_process_subst = yes; then
157 AC_DEFINE(PROCESS_SUBSTITUTION)
158 fi
159 if test $opt_prompt_decoding = yes; then
160 AC_DEFINE(PROMPT_STRING_DECODE)
161 fi
162 if test $opt_select = yes; then
163 AC_DEFINE(SELECT_COMMAND)
164 fi
165 if test $opt_help = yes; then
166 AC_DEFINE(HELP_BUILTIN)
167 fi
168 if test $opt_array_variables = yes; then
169 AC_DEFINE(ARRAY_VARS)
170 fi
171 if test $opt_dparen_arith = yes; then
172 AC_DEFINE(DPAREN_ARITHMETIC)
173 fi
174 if test $opt_brace_expansion = yes; then
175 AC_DEFINE(BRACE_EXPANSION)
176 fi
177 if test $opt_disabled_builtins = yes; then
178 AC_DEFINE(DISABLED_BUILTINS)
179 fi
180 if test $opt_command_timing = yes; then
181 AC_DEFINE(COMMAND_TIMING)
182 fi
183 if test $opt_usg_echo = yes ; then
184 AC_DEFINE(DEFAULT_ECHO_TO_USG)
185 fi
186
187 dnl now substitute in the values generated by arguments
188 AC_SUBST(PURIFY)
189 AC_SUBST(MALLOC)
190 AC_SUBST(MALLOC_SRC)
191 AC_SUBST(READLINE_LIB)
192 AC_SUBST(READLINE_DEP)
193 AC_SUBST(HISTORY_LIB)
194 AC_SUBST(HISTORY_DEP)
195
196 echo "Beginning configuration for bash-2.0"
197
198 dnl compilation checks
199 AC_PROG_CC
200 AC_ISC_POSIX
201 AC_MINIX
202
203 dnl See whether cc works at all
204 BASH_CC_WORKS
205
206 dnl We want these before the checks, so the checks can modify their values.
207 test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1
208
209 dnl If we're using gcc and the user hasn't specified CFLAGS, add -O2 to CFLAGS.
210 test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O2"
211
212 AC_SUBST(CFLAGS)
213 AC_SUBST(CPPFLAGS)
214 AC_SUBST(LDFLAGS)
215
216 AC_PROG_GCC_TRADITIONAL
217
218 dnl programs needed by the build and install process
219 AC_PROG_INSTALL
220 AC_CHECK_PROG(AR, ar, ar)
221 AC_PROG_RANLIB
222 AC_PROG_YACC
223 AC_PROG_MAKE_SET
224
225 dnl special checks for libc functions
226 AC_FUNC_ALLOCA
227 AC_FUNC_GETPGRP
228 AC_FUNC_SETVBUF_REVERSED
229 AC_FUNC_VPRINTF
230 AC_FUNC_WAIT3
231 AC_FUNC_STRCOLL
232
233 dnl if vprintf is not in libc, see if it's defined in stdio.h
234 if test "$ac_cv_func_vprintf" = no; then
235     AC_MSG_CHECKING(for declaration of vprintf in stdio.h)
236     AC_EGREP_HEADER([[int[      ]*vprintf[^a-zA-Z0-9]]],stdio.h,ac_cv_func_vprintf=yes)
237     AC_MSG_RESULT($ac_cv_func_vprintf)
238     if test $ac_cv_func_vprintf = yes; then
239         AC_DEFINE(HAVE_VPRINTF)
240     fi
241 fi
242
243 dnl signal stuff
244 AC_RETSIGTYPE
245
246 dnl checks for certain version-specific system calls and libc functions
247 AC_CHECK_FUNC(__setostype, AC_DEFINE(HAVE_SETOSTYPE))
248 AC_CHECK_FUNC(wait3, AC_DEFINE(HAVE_WAIT3))
249
250 dnl checks for missing libc functions
251 AC_CHECK_FUNC(mkfifo,AC_DEFINE(HAVE_MKFIFO),AC_DEFINE(MKFIFO_MISSING))
252
253 dnl checks for system calls
254 AC_CHECK_FUNCS(dup2 select getdtablesize getgroups gethostname \
255                 setdtablesize getpagesize killpg lstat getpeername \
256                 getrlimit getrusage gettimeofday waitpid tcgetpgrp)
257
258 dnl checks for c library functions
259 AC_CHECK_FUNCS(bcopy bzero confstr getcwd strcasecmp setenv putenv \
260                 setlinebuf setlocale strchr strerror tcgetattr uname \
261                 sysconf ulimit times tzset siginterrupt memmove)
262
263 dnl checks for locale functions
264 AC_CHECK_HEADERS(libintl.h)
265 AC_CHECK_FUNCS(gettext textdomain bindtextdomain)
266
267 dnl check for GNU libintl if gettext/textdomain/bindtextdomain
268 dnl are not found in libc
269 if test "$ac_cv_func_bindtextdomain" = "no"; then
270     AC_CHECK_LIB(intl,bindtextdomain)
271     if test "$ac_cv_lib_intl" = "yes"; then
272         AC_CHECK_FUNCS(gettext textdomain bindtextdomain)
273     fi
274 fi
275
276 dnl checks for the dynamic loading library functions in libc and libdl
277 AC_CHECK_LIB(dl, dlopen)
278 AC_CHECK_FUNCS(dlopen dlclose dlsym)
279
280 dnl this defines SYS_SIGLIST_DECLARED
281 AC_DECL_SYS_SIGLIST
282
283 dnl header files
284 AC_HEADER_DIRENT
285 AC_HEADER_TIME
286
287 AC_CHECK_HEADERS(unistd.h stdlib.h stdarg.h varargs.h limits.h string.h \
288                  memory.h locale.h termcap.h termio.h termios.h)
289 AC_CHECK_HEADERS(sys/ptem.h sys/pte.h sys/stream.h sys/select.h sys/file.h \
290                  sys/resource.h sys/param.h sys/socket.h \
291                  sys/time.h sys/times.h sys/wait.h)
292
293 dnl libraries
294 dnl this is reportedly no longer necessary for irix[56].?
295 dnl AC_CHECK_LIB(sun, getpwent)
296 BASH_CHECK_SOCKLIB
297
298 dnl system types
299 AC_TYPE_GETGROUPS
300 AC_TYPE_OFF_T
301 AC_TYPE_MODE_T
302 AC_TYPE_UID_T
303 AC_TYPE_PID_T
304 AC_TYPE_SIZE_T
305 AC_CHECK_TYPE(time_t, long)
306
307 AC_TYPE_SIGNAL
308
309 dnl structures
310 AC_HEADER_STAT
311 AC_HEADER_EGREP(struct timeval, sys/time.h, bash_cv_struct_timeval=yes, )
312 if test -z "$bash_cv_struct_timeval"; then
313 AC_HEADER_EGREP(struct timeval, time.h, bash_cv_struct_timeval=yes, bash_cv_struct_timeval=no)
314 fi
315 if test $bash_cv_struct_timeval = yes; then
316 AC_DEFINE(HAVE_TIMEVAL)
317 fi
318
319 dnl C compiler characteristics
320 AC_C_BIGENDIAN
321
322 dnl system services
323 AC_SYS_INTERPRETER
324 if test $ac_cv_sys_interpreter = yes; then
325 AC_DEFINE(HAVE_HASH_BANG_EXEC)
326 fi
327 dnl we use NO_READ_RESTART_ON_SIGNAL
328 AC_SYS_RESTARTABLE_SYSCALLS
329
330 dnl Miscellaneous Bash tests
331 if test "$ac_cv_func_lstat" = "no"; then
332 BASH_FUNC_LSTAT
333 fi
334
335 BASH_DUP2_CLOEXEC_CHECK
336 BASH_PGRP_SYNC
337 BASH_SYS_ERRLIST
338 BASH_SYS_SIGLIST
339 BASH_UNDER_SYS_SIGLIST
340 BASH_SIGNAL_CHECK
341 BASH_TYPE_SIGHANDLER
342 BASH_CHECK_TYPE(clock_t, [#include <sys/times.h>], long)
343 BASH_CHECK_TYPE(sigset_t, [#include <signal.h>], int)
344 BASH_CHECK_TYPE(quad_t, , long, HAVE_QUAD_T)
345 BASH_RLIMIT_TYPE
346 BASH_STRUCT_TERMIOS_LDISC
347 BASH_STRUCT_TERMIO_LDISC
348 BASH_STRUCT_DIRENT_D_INO
349 BASH_FUNC_STRSIGNAL
350 BASH_FUNC_OPENDIR_CHECK
351 BASH_FUNC_PRINTF
352 BASH_FUNC_ULIMIT_MAXFDS
353 BASH_FUNC_GETENV
354 BASH_FUNC_GETCWD
355 BASH_FUNC_SBRK_DECLARED
356 BASH_FUNC_POSIX_SETJMP
357 BASH_REINSTALL_SIGHANDLERS
358 BASH_JOB_CONTROL_MISSING
359 BASH_SYS_NAMED_PIPES
360 BASH_HAVE_TIOCGWINSZ
361 BASH_HAVE_TIOCSTAT
362 BASH_HAVE_FIONREAD
363 BASH_CHECK_GETPW_FUNCS
364 BASH_CHECK_DEV_FD
365
366 case "$host_os" in
367 hpux*)  BASH_KERNEL_RLIMIT_CHECK ;;
368 esac
369
370 if test "$opt_readline" = yes; then
371 BASH_CHECK_LIB_TERMCAP
372 fi
373 AC_SUBST(TERMCAP_LIB)
374 AC_SUBST(TERMCAP_DEP)
375
376 dnl special checks
377 BASH_DEFAULT_MAIL_DIR
378
379 if test "$bash_cv_job_control_missing" = missing; then
380         opt_job_control=no
381 fi
382
383 if test "$opt_job_control" = yes; then
384 AC_DEFINE(JOB_CONTROL)
385 JOBS_O=jobs.o
386 else
387 JOBS_O=nojobs.o
388 fi
389
390 AC_SUBST(JOBS_O)
391
392 dnl use this section to possibly define more cpp variables, specify local
393 dnl libraries, and specify any additional local cc flags
394 dnl
395 dnl this should really go away someday
396
397 case "$host_os" in
398 sysv4.2)        AC_DEFINE(SVR4_2)
399                 AC_DEFINE(SVR4) ;;
400 sysv4*)         AC_DEFINE(SVR4) ;;
401 hpux*)          LOCAL_CFLAGS=-DHPUX ;;
402 dgux*)          LOCAL_CFLAGS=-D_DGUX_SOURCE; LOCAL_LIBS=-ldgc ;;
403 isc*)           LOCAL_CFLAGS=-Disc386;;
404 sco3.2v5*)      LOCAL_CFLAGS="-DWAITPID_BROKEN -DNO_MEMSCRAMBLE -DPATH_MAX=1024" ;;
405 sco3.2v4*)      LOCAL_CFLAGS="-DMUST_UNBLOCK_CHLD -DNO_MEMSCRAMBLE -DPATH_MAX=1024" ;;
406 sco3.2*)        LOCAL_CFLAGS=-DMUST_UNBLOCK_CHLD ;;
407 sunos4*)        LOCAL_CFLAGS=-DSunOS4;;
408 linux*)         LOCAL_LDFLAGS=-rdynamic ;;      # allow dynamic loading
409 aix4.2*)        LOCAL_LDFLAGS="-bexpall -brtl";;# allow dynamic loading
410 esac
411
412 case "$host_cpu" in
413 *cray*)         LOCAL_CFLAGS="-DCRAY" ;; # shell var so config.h can use it
414 esac
415
416 case "$host_cpu-$host_os" in
417 ibmrt-*bsd4*)   LOCAL_CFLAGS="-ma -U__STDC__" ;;
418 esac
419
420 case "$host_cpu-$host_vendor-$host_os" in
421 m88k-motorola-sysv3)    LOCAL_CFLAGS=-DWAITPID_BROKEN ;;
422 mips-pyramid-sysv4)     LOCAL_CFLAGS=-Xa ;;
423 esac
424
425 # try to create a directory tree if the source is elsewhere
426 # this should be packaged into a script accessible via ${srcdir}/support
427 case "$srcdir" in
428 .)      ;;
429 *)      for d in doc tests support lib ; do     # dirs
430                 test -d $d || mkdir $d
431         done
432         for ld in readline glob tilde malloc termcap; do        # libdirs
433                 test -d lib/$ld || mkdir lib/$ld
434         done
435         ;;
436 esac
437
438 BUILD_DIR=`pwd`
439
440 AC_SUBST(incdir)
441 AC_SUBST(BUILD_DIR)
442
443 AC_SUBST(YACC)
444 AC_SUBST(AR)
445
446 AC_SUBST(host_cpu)
447 AC_SUBST(host_os)
448
449 AC_SUBST(LOCAL_LIBS)
450 AC_SUBST(LOCAL_CFLAGS)
451 AC_SUBST(LOCAL_LDFLAGS)
452
453 AC_SUBST(ALLOCA_SOURCE)
454 AC_SUBST(ALLOCA_OBJECT)
455
456 AC_OUTPUT([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
457           lib/malloc/Makefile lib/termcap/Makefile lib/tilde/Makefile \
458           doc/Makefile],
459 [
460 # Makefile uses this timestamp file to record whether config.h is up to date.
461 echo timestamp > stamp-h
462 ])