* Makefile.in, configure.in, chkpwd.c, acconfig.h: support for
[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 AC_ARG_ENABLE(chkpwd, [  --enable-chkpwd         build 'chkpwd' (use this if you have shadow passwords)])
14 AC_ARG_WITH(pam, [  --with-pam              use PAM if present])
15
16 dnl By default, we only build the client (citadel and whobbs) unless we can
17 dnl figure out how to build with POSIX threads.
18 TARGETS=client
19
20 AC_CANONICAL_HOST
21 SO=.so
22 case "$host" in
23         dnl BSDI 3.0 wants relocatable object modules instead of shared libs
24         dnl for dlopen(), and has a wrapper script to link with shared libs.
25         dnl Also has stupid non-reentrant gethostbyaddr() and friends.
26         i?86-*-bsdi*)
27                 test -z "$CC" -a -x /usr/bin/shlicc2 && CC=shlicc2
28                 SO=.mo
29                 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
30         ;;
31         dnl Digital Unix has an odd way to build for pthreads, and we can't
32         dnl build pthreads programs with gcc due to header problems.
33         alpha*-dec-osf*)
34                 test -z "$CC" && CC=cc
35                 SERVER_LDFLAGS=-pthread
36         ;;
37         *-*-cygwin32)
38                 SUFFIX=.exe
39         ;;
40 esac
41
42 dnl Checks for programs.
43 AC_PROG_CC
44
45 dnl Set up system-dependent compiler flags.
46 if test "$GCC" = yes; then
47         CFLAGS="$CFLAGS -Wall -Wstrict-prototypes"
48         case "$host" in
49                 i?86-*-bsdi*)
50                 ;;
51                 mips*-sgi-irix*)
52                         PICFLAGS=-fPIC
53                 ;;
54                 *)
55                         SERVER_LDFLAGS=-rdynamic
56                         PICFLAGS=-fPIC
57                 ;;
58         esac
59 fi
60 AC_PROG_RANLIB
61 AC_PROG_INSTALL
62 missing_dir=`cd $ac_aux_dir && pwd`
63 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
64
65 dnl Checks for libraries.
66
67 dnl libdl, libgdbm, and libcrypt are only used in the server, so the
68 dnl Makefile only passes $(LIBS) to that target. If other programs start
69 dnl requiring additional libraries, we'll have to use other variables, as is
70 dnl done with curses.
71
72 dnl We want to test for crypt() and dlopen() in libc before checking for
73 dnl -lcrypt and -ldl, because some systems (like Irix) have both.
74 AC_CHECK_FUNCS(crypt dlopen)
75
76 if test "$ac_cv_func_dlopen" = no; then
77         AC_CHECK_LIB(dl, dlopen, [LIBS="-ldl $LIBS"
78                 chkpwd_LIBS=-ldl])
79 fi
80
81 dnl Determine the system's authentication capabilities, if autologin is
82 dnl requested. We currently support PAM, standard getpwnam(), and getspnam()
83 dnl (Linux shadow passwords)
84 if test "$enable_autologin" != no; then
85         if test "$with_pam" = yes; then
86                 save_LIBS=$LIBS
87                 AC_CHECK_LIB(pam, pam_start, [chkpwd_LIBS="-lpam $chkpwd_LIBS"
88                         LIBS="-lpam $LIBS"])
89                 AC_CHECK_FUNCS(pam_start)
90                 test "$enable_chkpwd" = yes && LIBS=$save_LIBS
91         fi
92         if test "$ac_cv_func_pam_start" = no -o "$with_pam" != yes; then
93                 AC_CHECK_LIB(shadow, getspnam)
94                 if test "$ac_cv_func_crypt" = no; then
95                         AC_CHECK_LIB(crypt, crypt, [chkpwd_LIBS=-lcrypt
96                                 test "$enable_chkpwd" != yes && \
97                                         LIBS="-lcrypt $LIBS"])
98                 fi
99         fi
100         if test "$ac_cv_func_crypt" = yes -o "$ac_cv_lib_crypt_crypt" = yes -o "$ac_cv_func_pam_start" = yes; then
101                 AC_DEFINE(ENABLE_AUTOLOGIN)
102                 if test "$enable_chkpwd" = yes; then
103                         AC_DEFINE(ENABLE_CHKPWD)
104                         CHKPWD=chkpwd
105                 else
106                         AUTH=auth.ro
107                 fi
108         fi
109 fi
110
111 AC_CHECK_LIB(gdbm, gdbm_open)
112
113 save_LIBS=$LIBS
114 AC_CHECK_LIB(termcap, tgetent, [LIBS="$LIBS -ltermcap"
115         CURSES=-ltermcap])
116 AC_CHECK_LIB(curses, initscr, CURSES="-lcurses $CURSES")
117 LIBS=$save_LIBS
118
119 dnl Check for libpthread(s) if we're not using Digital UNIX. (On which the
120 dnl -pthread flag takes care of this.)
121 if test "$SERVER_LDFLAGS" != -pthread; then
122         AC_CHECK_LIB(pthread, pthread_create)
123         AC_CHECK_LIB(pthreads, pthread_create)
124 fi
125
126 dnl Checks for header files.
127 AC_HEADER_DIRENT
128 AC_HEADER_STDC
129 AC_HEADER_SYS_WAIT
130 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)
131
132 dnl Checks for typedefs, structures, and compiler characteristics.
133 AC_C_CONST
134 AC_TYPE_PID_T
135 AC_TYPE_SIZE_T
136 AC_HEADER_TIME
137 AC_STRUCT_TM
138
139 AC_CACHE_CHECK([for ut_type in struct utmp], ac_cv_struct_ut_type,
140 [AC_TRY_COMPILE([#include <utmp.h>], [struct utmp ut; ut.ut_type;],
141 ac_cv_struct_ut_type=yes, ac_cv_struct_ut_type=no)])
142 if test $ac_cv_struct_ut_type = yes; then
143         AC_DEFINE(HAVE_UT_TYPE)
144 fi
145
146 dnl Checks for library functions.
147 AC_FUNC_GETPGRP
148 AC_PROG_GCC_TRADITIONAL
149 AC_TYPE_SIGNAL
150 AC_FUNC_VPRINTF
151 AC_CHECK_FUNCS(getspnam mkdir mkfifo mktime pthread_cancel rmdir select socket strerror)
152 AC_CHECK_FUNC(pthread_create, TARGETS="client server utils serv_modules")
153 AC_REPLACE_FUNCS(snprintf getutline)
154
155 dnl Done! Now write the Makefile and sysdep.h
156 AC_SUBST(AUTH)
157 AC_SUBST(SO)
158 AC_SUBST(CHKPWD)
159 AC_SUBST(CURSES)
160 AC_SUBST(chkpwd_LIBS)
161 AC_SUBST(TARGETS)
162 AC_SUBST(SERVER_LDFLAGS)
163 AC_SUBST(PICFLAGS)
164 AC_SUBST(SUFFIX)
165 AC_CONFIG_HEADER(sysdep.h)
166 AC_OUTPUT(Makefile weekly)