fixes for BSDI. see ChangeLog.
[citadel.git] / citadel / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 dnl $Id$
3 AC_PREREQ(2.13)
4 AC_INIT(citserver.c)
5 AC_PREFIX_DEFAULT(/usr/local/citadel)
6 if test "$prefix" = NONE; then
7         AC_DEFINE_UNQUOTED(BBSDIR, "$ac_default_prefix")
8 else
9         AC_DEFINE_UNQUOTED(BBSDIR, "$prefix")
10 fi
11
12 AC_ARG_ENABLE(autologin, [  --disable-autologin     disable autologin (default is enabled if possible)])
13
14 dnl By default, we only build the client (citadel and whobbs) unless we can
15 dnl figure out how to build with POSIX threads.
16 TARGETS=client
17
18 AC_CANONICAL_HOST
19 SO=.so
20 case "$host" in
21         dnl BSDI 3.0 wants relocatable object modules instead of shared libs
22         dnl for dlopen(), and has a wrapper script to link with shared libs
23         i?86-*-bsdi*)
24                 test -z "$CC" -a -x /usr/bin/shlicc2 && CC=shlicc2
25                 SO=.mo
26         ;;
27         dnl Digital Unix has an odd way to build pthreads, and we can't build
28         dnl pthreads programs with gcc due to header problems.
29         alpha*-dec-osf*)
30                 test -z "$CC" && CC=cc
31                 SERVER_LDFLAGS=-pthread
32         ;;
33         *-*-cygwin32)
34                 SUFFIX=.exe
35         ;;
36 esac
37
38 dnl Checks for programs.
39 AC_PROG_CC
40
41 dnl Set up system-dependent compiler flags.
42 if test "$GCC" = yes; then
43         CFLAGS="$CFLAGS -Wall -Wstrict-prototypes"
44         case "$host" in
45                 i?86-*-bsdi*)
46                 ;;
47                 mips*-sgi-irix*)
48                         PICFLAGS=-fPIC
49                 ;;
50                 *)
51                         SERVER_LDFLAGS=-rdynamic
52                         PICFLAGS=-fPIC
53                 ;;
54         esac
55 fi
56 AC_PROG_RANLIB
57 AC_PROG_INSTALL
58 missing_dir=`cd $ac_aux_dir && pwd`
59 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
60
61 dnl Checks for libraries.
62
63 dnl libdl, libgdbm, and libcrypt are only used in the server, so the
64 dnl Makefile only passes $(LIBS) to that target. If other programs start
65 dnl requiring additional libraries, we'll have to use other variables, as is
66 dnl done with curses.
67
68 dnl We want to test for crypt() and dlopen() in libc before checking for
69 dnl -lcrypt and -ldl, because some systems (like Irix) have both.
70 AC_CHECK_FUNCS(crypt dlopen)
71
72 dnl We only need crypt() if we're using autologin. FIXME: implement shadow
73 dnl passwords and/or PAM...
74 if test "$enable_autologin" != no -a "$ac_cv_func_crypt" = no; then
75         AC_CHECK_LIB(crypt, crypt)
76 fi
77
78 dnl Enable autologin if the feature is requested (which is the default) and
79 dnl a crypt() functin is available.
80 if test "$enable_autologin" != no -a \( "$ac_cv_func_crypt" = yes -o "$ac_cv_lib_crypt_crypt" = yes \); then
81         AC_DEFINE(ENABLE_AUTOLOGIN)
82 fi
83
84 if test "$ac_cv_func_dlopen" = no; then
85         AC_CHECK_LIB(dl, dlopen)
86 fi
87
88 AC_CHECK_LIB(gdbm, gdbm_open)
89
90 save_LIBS=$LIBS
91 AC_CHECK_LIB(termcap, tgetent, [LIBS="$LIBS -ltermcap"
92         CURSES=-ltermcap])
93 AC_CHECK_LIB(curses, initscr, CURSES="-lcurses $CURSES")
94 LIBS=$save_LIBS
95
96 dnl Check for libpthread(s) if we're not using Digital UNIX. (On which the
97 dnl -pthread flag takes care of this.)
98 if test "$SERVER_LDFLAGS" != -pthread; then
99         AC_CHECK_LIB(pthread, pthread_create)
100         AC_CHECK_LIB(pthreads, pthread_create)
101 fi
102
103 dnl Checks for header files.
104 AC_HEADER_DIRENT
105 AC_HEADER_STDC
106 AC_HEADER_SYS_WAIT
107 AC_CHECK_HEADERS(curses.h fcntl.h limits.h termios.h strings.h sys/ioctl.h sys/select.h sys/time.h syslog.h unistd.h pthread.h gdbm.h utmp.h)
108
109 dnl Checks for typedefs, structures, and compiler characteristics.
110 AC_C_CONST
111 AC_TYPE_PID_T
112 AC_TYPE_SIZE_T
113 AC_HEADER_TIME
114 AC_STRUCT_TM
115
116 AC_CACHE_CHECK([for ut_type in struct utmp], ac_cv_struct_ut_type,
117 [AC_TRY_COMPILE([#include <utmp.h>], [struct utmp ut; ut.ut_type;],
118 ac_cv_struct_ut_type=yes, ac_cv_struct_ut_type=no)])
119 if test $ac_cv_struct_ut_type = yes; then
120         AC_DEFINE(HAVE_UT_TYPE)
121 fi
122
123 dnl Checks for library functions.
124 AC_FUNC_GETPGRP
125 AC_PROG_GCC_TRADITIONAL
126 AC_TYPE_SIGNAL
127 AC_FUNC_VPRINTF
128 AC_CHECK_FUNCS(mkdir mkfifo mktime pthread_cancel rmdir select socket strerror)
129 AC_CHECK_FUNC(pthread_create, TARGETS="client server utils serv_modules")
130 AC_REPLACE_FUNCS(snprintf getutline)
131
132 dnl Done! Now write the Makefile and sysdep.h
133 AC_SUBST(SO)
134 AC_SUBST(CURSES)
135 AC_SUBST(TARGETS)
136 AC_SUBST(SERVER_LDFLAGS)
137 AC_SUBST(PICFLAGS)
138 AC_SUBST(SUFFIX)
139 AC_CONFIG_HEADER(sysdep.h)
140 AC_OUTPUT(Makefile weekly)