386BSD 0.1 development
[unix-history] / usr / othersrc / public / cvs-1.3 / configure
CommitLineData
8286cffa
WJ
1:
2# Guess values for system-dependent variables and create `Makefile'.
3# Copyright (C) 1991 Free Software Foundation, Inc.
4
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2, or (at your option)
8# any later version.
9
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19# Usage:
20#configure [--srcdir=DIR] [--prefix=DIR] [--host=HOST] [--gas] [--nfp] [TARGET]
21#All args except --srcdir=DIR, --prefix=DIR, and --exec_prefix=DIR are ignored.
22
23# @(#)configure 1.26 92/04/10
24
25trap 'rm -f conftest* core* uttest; exit 1' 1 2 3 15
26
27# Uncomment out the next line if your sh aborts if an unset variable
28# is referenced; some popular systems do not understand +u and most
29# bourne shells should already have this set as the default...
30#set +u
31
32# Make sure we don't find the System V /etc/install.
33PATH=`echo $PATH|sed '
34s,^:,|,
35s,:$,|,
36s,:/usr/etc\([:|]\),\1,g
37s,:/usr/etc$,,g
38s,\([:|]\)/usr/etc:,\1,g
39s,^/usr/etc:,,g
40s,:/usr/sbin\([:|]\),\1,g
41s,:/usr/sbin$,,g
42s,\([:|]\)/usr/sbin:,\1,g
43s,^/usr/sbin:,,g
44s,:/etc\([:|]\),\1,g
45s,:/etc$,,g
46s,\([:|]\)/etc:,\1,g
47s,^/etc:,,g
48s,|,:,g'`
49
50# A filename unique to this package, relative to the directory that
51# configure is in, which we can look for to find out if srcdir is correct.
52unique_file=src/update.c
53
54# Default destination directory is /usr/local
55# Binaries go in "bin", libraries in "lib", manual pages in "man".
56prefix=/usr/local
57
58for arg in $*; do
59 # Handle --srcdir with a space before the argument.
60 if [ x$next_srcdir = xyes ]; then srcdir=$arg; next_srcdir=
61 # Handle --prefix with a space before the argument.
62 elif [ x$next_prefix = xyes ]; then prefix=$arg; next_prefix=
63 # Handle --exec_prefix with a space before the argument.
64 elif [ x$next_exec_prefix = xyes ]; then exec_prefix=$arg; next_prefix=
65 # Handle --host with a space before the argument.
66 elif [ x$next_host = xyes ]; then next_host=
67 else
68 case $arg in
69 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=* | --s=*)
70 srcdir=`echo $arg | sed 's/^[-a-z]*=//'` ;;
71 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr | --s)
72 next_srcdir=yes ;;
73 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
74 prefix=`echo $arg | sed 's/^[-a-z]*=//'` ;;
75 -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
76 next_prefix=yes ;;
77 -exec_prefix=* | --exec_prefix=* | --exec_prefi=* | --exec_pref=* | --exec_pre=* | --exec_pr=* | --exec_p=* | --exec_=* | --exec=* | --exe=* | --ex=* | --e=*)
78 exec_prefix=`echo $arg | sed 's/^[-a-z_]*=//'` ;;
79 -exec_prefix | --exec_prefix | --exec_prefi | --exec_pref | --exec_pre | --exec_pr | --exec_p | --exec_ | --exec | --exe | --ex | --e)
80 next_exec_prefix=yes ;;
81 -host=* | --host=* | --hos=* | --ho=* | --h=*) ;;
82 -host | --host | --hos | --ho | --h)
83 next_host=yes ;;
84 -gas | --gas | --ga | --g) ;;
85 -nfp | --nfp | --nf | --n) ;;
86 *) ;;
87 esac
88 fi
89done
90
91if [ -z "${exec_prefix}" ] ; then exec_prefix=${prefix} ; fi
92
93vpsub='s@\$\([-./a-zA-Z0-9]*\)<@\1@g'
94# Find the source files, if location was not specified.
95if [ x$srcdir = x ]; then
96 srcdirdefaulted=yes; srcdir=.
97 if [ ! -r $unique_file ]; then srcdir=`pwd`/..; fi
98fi
99if [ $srcdir != . ]; then
100 VPATH='VPATH = $(srcdir)'
101 vpsub='s@\$\([-./a-zA-Z0-9]*\)<@\$<@g'
102fi
103
104if [ ! -r $srcdir/$unique_file ]; then
105 if [ x$srcdirdefaulted = xyes ]; then
106 echo "$0: Can not find sources in \`.' or \`..'." 1>&2
107 else
108 echo "$0: Can not find sources in \`${srcdir}'." 1>&2
109 fi
110 exit 1
111fi
112
113if grep '^#.*define.*MY_NDBM' ${srcdir}/src/config.h >/dev/null 2>/dev/null; then :
114 CC1=gcc
115 CC2=cc
116else
117 CC1=cc
118 CC2=gcc
119fi
120
121if test "$RANDOM" = "$RANDOM"; then
122 # Plain old Bourne shell.
123 if test -z "$CC"; then
124 echo checking for cc/gcc
125 test -n "`$CC1 / 2>&1`" && CC="$CC1"
126 if test -z "$CC"; then
127 test -n "`$CC2 2>&1`" && CC="$CC2"
128 fi
129 fi
130
131 echo checking for install
132 if test -z "$INSTALL" && test -n "`install 2>&1`"; then
133 INSTALL="install -c"
134 INSTALLDATA="install -c -m 644"
135 fi
136
137 echo checking for ranlib
138 test -z "$RANLIB" && test -n "`ranlib conftest 2>&1`" && RANLIB=ranlib
139 rm -f conftest*
140
141 echo checking for bison/yacc
142 test -z "$YACC" && test -n "`bison 2>&1`" && YACC="bison -y"
143else
144 # ksh, bash or zsh. ksh and zsh write "command not found" to stderr.
145 if test -z "$CC"; then
146 echo checking for cc/gcc
147 type $CC1 && CC="$CC1"
148 test -z "$CC" && type $CC2 && CC="$CC2"
149 fi
150
151 echo checking for install
152 if test -z "$INSTALL" && type install; then
153 INSTALL="install -c"
154 INSTALLDATA="install -c -m 644"
155 fi
156
157 echo checking for ranlib
158 test -z "$RANLIB" && type ranlib && RANLIB=ranlib
159
160 echo checking for bison/yacc
161 test -z "$YACC" && type bison && YACC="bison -y"
162fi
163
164CC=${CC-cc}
165INSTALL=${INSTALL-cp}
166INSTALLDATA=${INSTALLDATA-cp}
167RANLIB=${RANLIB-echo}
168YACC=${YACC-yacc}
169
170rm -f conftest*
171compile='$CC $DEFS $TDEFS conftest.c -o conftest $TLIBS $LIBS >/dev/null 2>&1'
172
173# Check for various header files.
174
175echo checking for Minix
176if test -d /usr/include/minix; then
177 DEFS="$DEFS -UUSG -D_POSIX_SOURCE -D_POSIX_1_SOURCE=2 -D_POSIX_C_SOURCE=2 -D_MINIX"
178else
179 echo checking for BSD string and memory functions
180 echo "
181#include <strings.h>
182main() { exit(0); } t() { rindex(0, 0); bzero(0, 0); }" > conftest.c
183 eval $compile
184 if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then :
185 else DEFS="$DEFS -DUSG"
186 fi
187 rm -f conftest*
188fi
189
190echo checking signal handler return type
191echo "
192#include <sys/types.h>
193#include <signal.h>
194void foo() { exit(0); }
195main() { exit(0); } t() { signal(SIGINT, foo); kill(getpid(), SIGINT); }" > conftest.c
196eval $compile
197if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then :
198 else DEFS="$DEFS -DSIGTYPE=int"
199fi
200rm -f conftest*
201
202echo checking for directory library header
203echo '
204#include <sys/types.h>
205#ifdef DIRENT
206#include <dirent.h>
207#ifdef direct
208#undef direct
209#endif
210#define direct dirent
211#else
212#ifdef SYSNDIR
213#include <sys/ndir.h>
214#else
215#ifdef NDIR
216#include <ndir.h>
217#else /* must be BSD */
218#include <sys/dir.h>
219#endif
220#endif
221#endif
222main() { DIR *d = opendir(".");
223 struct direct *e;
224 while ((e = readdir(d)))
225 if (strcmp(e->d_name, "conftestfile") == 0)
226 exit(0);
227 exit(1);
228}' > conftest.c
229> conftestfile
230TDEFS=-DDIRENT
231eval $compile
232TDEFS=
233if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then
234 DEFS="$DEFS -DDIRENT"
235else
236 rm -f conftest
237 TDEFS=-DDIRENT
238 TLIBS=-ldir
239 eval $compile
240 TDEFS=
241 TLIBS=
242 if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then
243 DEFS="$DEFS -DDIRENT"
244 LIBS="-ldir $LIBS"
245 else
246 rm -f conftest
247 TDEFS=-DSYSNDIR
248 eval $compile
249 TDEFS=
250 if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then
251 DEFS="$DEFS -DSYSNDIR"
252 else
253 rm -f conftest
254 TDEFS=-DSYSNDIR
255 TLIBS=-lx
256 eval $compile
257 TDEFS=
258 TLIBS=
259 if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then
260 DEFS="$DEFS -DSYSNDIR"
261 LIBS="$LIBS -lx"
262 else
263 rm -f conftest
264 TDEFS=-DNDIR
265 eval $compile
266 TDEFS=
267 if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then
268 DEFS="$DEFS -DNDIR"
269 else
270 eval $compile
271 if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then :
272 else
273 echo >&2 "configure: opendir() is missing; cannot continue"
274 rm -f conftest*
275 exit 1
276 fi
277 fi
278 fi
279 fi
280 fi
281fi
282rm -f foo conftest*
283
284echo checking for ANSI C header files
285echo "#include <stddef.h>
286#include <stdlib.h>
287#include <string.h>
288main() { exit(0); }" > conftest.c
289eval $compile
290if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then
291 DEFS="$DEFS -DSTDC_HEADERS"
292fi
293rm -f conftest*
294
295echo checking for POSIX.1 header files
296echo "#include <unistd.h>
297main() {
298#ifdef _POSIX_VERSION
299exit(0);
300#else
301exit(1);
302#endif
303}" > conftest.c
304eval $compile
305if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then
306 DEFS="$DEFS -DPOSIX"
307fi
308rm -f conftest*
309
310echo checking for uid_t in sys/types.h
311echo "#include <sys/types.h>
312main() { exit(0); } t() { uid_t x; }" > conftest.c
313eval $compile
314if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then :
315else
316 DEFS="$DEFS -Duid_t=int -Dgid_t=int"
317fi
318rm -f conftest*
319
320echo checking for mode_t in sys/types.h
321echo "#include <sys/types.h>
322main() { exit(0); } t() { mode_t x; }" > conftest.c
323eval $compile
324if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then :
325else
326 DEFS="$DEFS -Dmode_t=int"
327fi
328rm -f conftest*
329
330echo checking for size_t in sys/types.h
331echo "#include <sys/types.h>
332main() { exit(0); } t() { size_t x; }" > conftest.c
333eval $compile
334if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then :
335else
336 DEFS="$DEFS -Dsize_t=unsigned"
337fi
338rm -f conftest*
339
340echo checking for unsigned characters
341echo 'main() { char c = 255; exit(c < 0); }' > conftest.c
342eval $compile
343if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then
344 DEFS="$DEFS -D__CHAR_UNSIGNED__"
345fi
346rm -f conftest*
347
348echo checking whether time.h has struct tm
349echo '#include <sys/types.h>
350#include <time.h>
351main() { struct tm *tp; exit(0); }' > conftest.c
352eval $compile
353if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then :
354 else DEFS="$DEFS -DTM_IN_SYS_TIME"
355fi
356rm -f conftest*
357
358# Check whether various functions exist.
359
360# Functions we provide replacements for.
361for func in fnmatch getwd mkdir rename strdup
362do
363 echo checking for $func
364 echo "main() { exit(0); } t() { ${func}(); }" > conftest.c
365 eval $compile
366 if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then :
367 else LIBOBJS="$LIBOBJS ${func}.o"
368 fi
369 rm -f conftest*
370done
371
372func=gethostname
373echo checking for $func
374echo "main() { exit(0); } t() { ${func}(); }" > conftest.c
375eval $compile
376if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then :
377 else LIBOBJS="$LIBOBJS hostname.o"
378fi
379rm -f conftest*
380
381func=re_exec
382echo checking for $func
383echo "main() { exit(0); } t() { ${func}(); }" > conftest.c
384eval $compile
385if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then :
386 else LIBOBJS="$LIBOBJS regex.o"
387fi
388rm -f conftest*
389
390func=dup2
391echo checking for $func
392echo "main() { exit(0); } t() { ${func}(); }" > conftest.c
393eval $compile
394if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then :
395 else LIBOBJS="$LIBOBJS dup2.o"
396fi
397rm -f conftest*
398
399# Functions whose absence we work around.
400for func in fchmod fsync ftime mkfifo putenv strerror setvbuf vfork vprintf
401do
402 echo checking for $func
403 echo "main() { exit(0); } t() { ${func}(); }" > conftest.c
404 eval $compile
405 if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then :
406 else DEFS="$DEFS -D`echo $func|tr '[a-z]' '[A-Z]'`_MISSING"
407 fi
408 rm -f conftest*
409done
410
411echo checking for timeb.h header file
412echo '
413#include <stdio.h>
414#include <sys/types.h>
415#ifdef TM_IN_SYS_TIME
416#include <sys/time.h>
417#else
418#include <time.h>
419#endif
420#include <sys/timeb.h>
421main() { exit(0); } t() { struct timeb tb; printf("%d", sizeof(tb)); }' > conftest.c
422eval $compile
423if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then :
424else
425 DEFS="$DEFS -DTIMEB_H_MISSING"
426fi
427rm -f conftest*
428
429case "$DEFS" in
430*VPRINTF_MISSING*)
431 func=_doprnt
432 echo checking for $func
433 echo "main() { exit(0); } t() { ${func}(); }" > conftest.c
434 eval $compile
435 if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then :
436 else DEFS="$DEFS -DDOPRNT_MISSING"
437 fi
438 rm -f conftest*
439 ;;
440esac
441
442case "$DEFS" in
443*FTIME_MISSING*)
444 echo checking for timezone
445 echo "main() { extern char *timezone(); printf(\"%s\",timezone(0,0)); exit(0); }" > conftest.c
446 eval $compile
447 if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then
448 DEFS="$DEFS -DHAVE_TIMEZONE"
449 fi
450 rm -f conftest* core*
451 ;;
452esac
453
454case "$DEFS" in
455*POSIX*)
456 ;;
457*)
458 echo checking for BSD signals
459 echo "
460#include <signal.h>
461main() { exit(0); } t() { sigvec(); sigblock(); }" > conftest.c
462 eval $compile
463 if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then
464 DEFS="$DEFS -DBSD_SIGNALS"
465 fi
466 rm -f conftest*
467 ;;
468esac
469
470func=ftruncate
471echo checking for $func
472echo "main() { exit(0); } t() { ${func}(); }" > conftest.c
473eval $compile
474if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then :
475else
476 rm -f conftest*
477 echo "
478#include <sys/types.h>
479#include <fcntl.h>
480main() { exit(0); }
481#if !defined(F_CHSIZE) && !defined(F_FREESP)
482t() { chsize(); }
483#endif
484" > conftest.c
485 eval $compile
486 if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then
487 LIBOBJS="$LIBOBJS ${func}.o"
488 else DEFS="$DEFS -D`echo $func|tr '[a-z]' '[A-Z]'`_MISSING"
489 fi
490fi
491rm -f conftest*
492
493# Check other misc. things.
494
495echo checking utime with null argument
496rm -f uttest; > uttest
497# Sequent interprets utime(file, 0) to mean use start of epoch. Wrong.
498echo '#include <sys/types.h>
499#include <sys/stat.h>
500main() {
501struct stat s, t;
502exit(!(stat ("uttest", &s) == 0 && utime("uttest", (long *)0) == 0
503&& stat("uttest", &t) == 0 && t.st_mtime - s.st_mtime < 120));
504}' > conftest.c
505eval $compile
506test -s conftest && (./conftest) >/dev/null 2>/dev/null || DEFS="$DEFS -DUTIME_NULL_MISSING"
507rm -f conftest* core* uttest
508
509case "$LIBOBJS" in
510*rename.o*)
511 LIBPROGS="$LIBPROGS mvdir"
512 DEFS="$DEFS -DMVDIR="'\\"$(libdir)/mvdir\\"'
513 ;;
514esac
515
516echo checking how to get alloca
517echo '
518#ifdef __GNUC__
519#define alloca __builtin_alloca
520#else
521#ifdef sparc
522#include <alloca.h>
523#else
524#ifdef _AIX
525 #pragma alloca
526#else
527char *alloca ();
528#endif
529#endif
530#endif
531main() { char *p = (char *) alloca(1); exit(0); }' > conftest.c
532eval $compile
533if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then :
534else
535 # I've had some problems with this stuff. If you need -lPW for some
536 # reason, try uncommenting the lines below
537 # rm -f conftest*
538 # echo 'char *alloca();
539 #main() { char *p = alloca(1); exit(0); }' > conftest.c
540 # eval $compile -lPW
541 # if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then LIBS="$LIBS -lPW"
542 # else
543 LIBOBJS="$LIBOBJS alloca.o"
544 # fi
545fi
546rm -f conftest*
547
548if grep '^#.*define.*MY_NDBM' ${srcdir}/src/config.h >/dev/null 2>/dev/null; then :
549else
550 echo checking for ndbm support
551 echo '#include <ndbm.h>
552 main() { exit(0); } t() { dbm_open(0); dbm_close(0); }' > conftest.c
553 eval $compile
554 if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then :
555 else
556 TLIBS=-lgdbm
557 eval $compile
558 TLIBS=
559 if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then
560 LIBS="$LIBS -lgdbm"
561 else
562 TDEFS="-I${prefix}/include"
563 TLIBS="-L${prefix}/lib -lgdbm"
564 eval $compile
565 TDEFS=
566 TLIBS=
567 if test -s conftest && (./conftest) >/dev/null 2>/dev/null; then
568 DEFS="$DEFS -I${prefix}/include"
569 LIBS="$LIBS -L${prefix}/lib -lgdbm"
570 else
571 echo 'configure: Warning: you will likely have to install GNU dbm'
572 echo ' (including the <ndbm.h> header file)'
573 echo ' and re-run this configure script'
574 fi
575 fi
576 fi
577 rm -f conftest*
578fi
579
580echo checking for $CC -g -O combination
581echo "main() { exit(0); }" > conftest.c
582if test -n "`$CC -g -O -o conftest conftest.c 2>&1`"; then
583 if test -n "`$CC -g -o conftest conftest.c 2>&1`"; then
584 CDEBUG=
585 else
586 CDEBUG="-g"
587 fi
588else
589 CDEBUG="-g -O"
590fi
591rm -f conftest*
592
593trap 'rm -f Makefile lib/Makefile src/Makefile man/Makefile doc/Makefile examples/Makefile contrib/Makefile config.status conftest*; exit 1' 1 2 3 15
594
595for dir in . lib src man doc examples contrib
596do
597 test -d $dir || mkdir $dir
598 if test "$srcdir" = "."; then
599 xsrcdir="."
600 includeopt=
601 else
602 case $srcdir in
603 /*)
604 xsrcdir=$srcdir/$dir
605 includeopt="-I$srcdir/lib"
606 ;;
607 *)
608 xsrcdir=../$srcdir/$dir
609 includeopt="-I../$srcdir/lib"
610 ;;
611 esac
612 if test "$dir" = "."; then
613 xsrcdir=$srcdir
614 fi
615 fi
616 echo '# Generated automatically from Makefile.in by configure.' > $dir/Makefile
617 sed -e "
618$vpsub
619s,@srcdir@,$xsrcdir,
620s,@prefix@,$prefix,
621s,@exec_prefix@,$exec_prefix,
622s,@includeopt@,$includeopt,
623s,@VPATH@,$VPATH,
624s,@CC@,$CC,
625s,@RANLIB@,$RANLIB,
626s,@YACC@,$YACC,
627s,@INSTALL@,$INSTALL,
628s,@INSTALLDATA@,$INSTALLDATA,
629s,@DEFS@,$DEFS,
630s,@LIBS@,$LIBS,
631s,@LIBPROGS@,$LIBPROGS,
632s,@LIBOBJS@,$LIBOBJS,
633s,@CDEBUG@,$CDEBUG,
634" $srcdir/$dir/Makefile.in >> $dir/Makefile
635done
636
637echo "srcdir = $srcdir
638prefix = $prefix
639exec_prefix = $exec_prefix
640includeopt = $includeopt
641VPATH = $VPATH
642CC = $CC
643RANLIB = $RANLIB
644YACC = $YACC
645INSTALL = $INSTALL
646INSTALLDATA = $INSTALLDATA
647DEFS = $DEFS
648LIBS = $LIBS
649LIBPROGS = $LIBPROGS
650LIBOBJS = $LIBOBJS
651CDEBUG = $CDEBUG" > config.status