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