]> code.citadel.org Git - citadel.git/blob - citadel/configure.in
* Makefile.in, configure.in: link netproc with gdbm
[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, [  --disable-chkpwd        don't build 'chkpwd'])
14 AC_ARG_WITH(pam, [  --with-pam              use PAM if present (see PAM.txt before you try this)])
15 AC_ARG_WITH(kthread, [  --with-kthread          use kernel threads (on FreeBSD) (not recommended yet)])
16
17 dnl By default, we only build the client (citadel and whobbs) unless we can
18 dnl figure out how to build with POSIX threads.
19 TARGETS=client
20
21 AC_CANONICAL_HOST
22 SO=.so
23 PTHREAD_DEFS=-D_REENTRANT
24 LINK_SHARED='$(CC) -shared'
25 case "$host" in
26         dnl BSDI 3.0 wants relocatable object modules instead of shared libs
27         dnl for dlopen(), and has a wrapper script to link with shared libs.
28         dnl Also has stupid non-reentrant gethostbyaddr() and friends.
29         *-*-bsdi[123]*)
30                 test -z "$CC" -a -x /usr/bin/shlicc2 && CC=shlicc2
31                 SO=.mo
32                 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
33         ;;
34         *-*-bsdi*)
35                 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
36         ;;
37         dnl Digital Unix has an odd way to build for pthreads, and we can't
38         dnl build pthreads programs with gcc due to header problems.
39         alpha*-dec-osf*)
40                 test -z "$CC" && CC=cc
41                 PTHREAD_DEFS=-pthread
42                 SERVER_LDFLAGS=-pthread
43                 check_pthread=no
44         ;;
45         dnl FreeBSD is similar to Digital UNIX:
46         *-*-freebsd*)
47                 if test "$with_kthread" = yes; then
48                         SERVER_LDFLAGS=-kthread
49                 else
50                         SERVER_LDFLAGS=-pthread
51                 fi
52                 check_pthread=no
53                 PTHREAD_DEFS=-D_THREAD_SAFE
54         ;;
55         *-*-openbsd*)
56                 SERVER_LDFLAGS=-pthread
57                 check_pthread=no
58                 PTHREAD_DEFS=-pthread
59                 LINK_SHARED="ld -x -Bshareable"
60         ;;
61 esac
62
63 dnl Checks for programs.
64 AC_PROG_CC
65
66 dnl Set up system-dependent compiler flags.
67 if test "$GCC" = yes; then
68         CFLAGS="$CFLAGS -Wall -Wstrict-prototypes"
69         case "$host" in
70                 *-*-bsdi[123]*)
71                 ;;
72                 mips*-sgi-irix*)
73                         PICFLAGS=-fPIC
74                 ;;
75                 *)
76                         SERVER_LDFLAGS="$SERVER_LDFLAGS -rdynamic"
77                         PICFLAGS=-fPIC
78                 ;;
79         esac
80 fi
81 AC_PROG_RANLIB
82 AC_PROG_INSTALL
83 missing_dir=`cd $ac_aux_dir && pwd`
84 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
85
86 dnl Checks for system services.
87 AC_EXEEXT
88
89 dnl Checks for libraries.
90
91 dnl libdl, libgdbm, and libcrypt are only used in the server, so the
92 dnl Makefile only passes $(LIBS) to that target. If other programs start
93 dnl requiring additional libraries, we'll have to use other variables, as is
94 dnl done with curses.
95
96 dnl We want to test for the following in libc before checking for their
97 dnl respective libraries, because some systems (like Irix) have both, and the
98 dnl non-libc versions may be broken.
99 AC_CHECK_FUNCS(crypt dlopen gethostbyname connect)
100
101 if test "$ac_cv_func_gethostbyname" = no; then
102         AC_CHECK_LIB(nsl, gethostbyname, NETLIBS="-lnsl $NETLIBS")
103 fi
104
105 if test "$ac_cv_func_connect" = no; then
106         AC_CHECK_LIB(socket, connect, NETLIBS="-lsocket $NETLIBS",, $NETLIBS)
107 fi
108
109 if test "$ac_cv_func_dlopen" = no; then
110         AC_CHECK_LIB(dl, dlopen, [LIBS="-ldl $LIBS"
111                 chkpwd_LIBS=-ldl])
112 fi
113
114 dnl Determine the system's authentication capabilities, if autologin is
115 dnl requested. We currently support PAM, standard getpwnam(), and getspnam()
116 dnl (Linux shadow passwords)
117 if test "$enable_autologin" != no; then
118         if test "$with_pam" = yes; then
119                 save_LIBS=$LIBS
120                 AC_CHECK_LIB(pam, pam_start, [chkpwd_LIBS="-lpam $chkpwd_LIBS"
121                         LIBS="-lpam $LIBS"])
122                 AC_CHECK_FUNCS(pam_start)
123                 test "$enable_chkpwd" != no && LIBS=$save_LIBS
124         fi
125         if test "$ac_cv_func_pam_start" = no -o "$with_pam" != yes; then
126                 AC_CHECK_LIB(shadow, getspnam)
127                 if test "$ac_cv_func_crypt" = no; then
128                         AC_CHECK_LIB(crypt, crypt, [chkpwd_LIBS=-lcrypt
129                                 test "$enable_chkpwd" = no && \
130                                         LIBS="-lcrypt $LIBS"])
131                 fi
132         fi
133         if test "$ac_cv_func_crypt" = yes -o "$ac_cv_lib_crypt_crypt" = yes -o "$ac_cv_func_pam_start" = yes; then
134                 AC_DEFINE(ENABLE_AUTOLOGIN)
135                 if test "$enable_chkpwd" != no; then
136                         AC_DEFINE(ENABLE_CHKPWD)
137                         CHKPWD=chkpwd
138                 else
139                         AUTH=auth.ro
140                 fi
141         fi
142 fi
143
144 test -f /usr/local/lib/libgdbm.a && LDFLAGS="$LDFLAGS -L/usr/local/lib"
145 AC_CHECK_LIB(gdbm, gdbm_open, GDBM="$GDBM -lgdbm")
146
147 save_LIBS=$LIBS
148 AC_CHECK_LIB(termcap, tgetent, [LIBS="$LIBS -ltermcap"
149         CURSES=-ltermcap])
150 AC_CHECK_LIB(curses, initscr, CURSES="-lcurses $CURSES", [
151         AC_CHECK_LIB(ncurses, initscr, CURSES="-lncurses")])
152 LIBS=$save_LIBS
153
154 dnl Check for libpthread(s) if we're not using Digital UNIX or FreeBSD. (On
155 dnl which the -pthread flag takes care of this.)
156 if test "$check_pthread" != no; then
157         AC_CHECK_LIB(pthread, pthread_create)
158         AC_CHECK_LIB(pthreads, pthread_create)
159 fi
160
161 dnl Checks for header files.
162 AC_HEADER_DIRENT
163 AC_HEADER_STDC
164 AC_HEADER_SYS_WAIT
165 test -f /usr/local/include/gdbm.h && CPPFLAGS="$CPPFLAGS -I/usr/local/include"
166 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 gdbm.h utmp.h paths.h)
167
168 dnl some systems require -pthread, -D_REENTRANT, etc to be passed to cc if we
169 dnl include pthread.h:
170 save_CPPFLAGS=$CPPFLAGS
171 CPPFLAGS="$CPPFLAGS $PTHREAD_DEFS"
172 AC_CHECK_HEADERS(pthread.h)
173 CPPFLAGS=$save_CPPFLAGS
174
175 dnl Checks for typedefs, structures, and compiler characteristics.
176 AC_C_CONST
177 AC_TYPE_PID_T
178 AC_TYPE_SIZE_T
179 AC_HEADER_TIME
180 AC_STRUCT_TM
181
182 AC_CACHE_CHECK([for ut_type in struct utmp], ac_cv_struct_ut_type,
183 [AC_TRY_COMPILE([#include <utmp.h>], [struct utmp ut; ut.ut_type;],
184 ac_cv_struct_ut_type=yes, ac_cv_struct_ut_type=no)])
185 if test $ac_cv_struct_ut_type = yes; then
186         AC_DEFINE(HAVE_UT_TYPE)
187 fi
188
189 AC_CACHE_CHECK([for ut_host in struct utmp], ac_cv_struct_ut_host,
190 [AC_TRY_COMPILE([#include <utmp.h>], [struct utmp ut; ut.ut_host;],
191 ac_cv_struct_ut_host=yes, ac_cv_struct_ut_host=no)])
192 if test $ac_cv_struct_ut_host = yes; then
193         AC_DEFINE(HAVE_UT_HOST)
194 fi
195
196 dnl Checks for library functions.
197 AC_FUNC_GETPGRP
198 AC_PROG_GCC_TRADITIONAL
199 AC_TYPE_SIGNAL
200 AC_FUNC_VPRINTF
201 AC_CHECK_FUNCS(getspnam mkdir mkfifo mktime rmdir select socket strerror)
202
203 dnl Now check for pthreads -- set up variables so that the compiler will be run
204 dnl with proper flags for pthread programs
205 save_LDFLAGS=$LDFLAGS
206 LDFLAGS="$LDFLAGS $SERVER_LDFLAGS"
207
208 dnl On some platforms, AC_CHECK_FUNC[S] doesn't work for pthreads programs;
209 dnl we need to include pthread.h
210 dnl AC_CHECK_FUNCS(pthread_cancel)
211
212 AC_CACHE_CHECK([for pthread_cancel], ac_cv_func_pthread_cancel,
213 [AC_TRY_LINK([#include <pthread.h>],
214 [       pthread_t thread;
215
216         /* The GNU C library defines this for functions which it implements
217            to always fail with ENOSYS.  Some functions are actually named
218            something starting with __ and the normal name is an alias.  */
219 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
220         choke me
221 #else
222         pthread_cancel(thread);
223 #endif],
224 ac_cv_func_pthread_cancel=yes, ac_cv_func_pthread_cancel=no)])
225 if test "$ac_cv_func_pthread_cancel" = yes; then
226         AC_DEFINE(HAVE_PTHREAD_CANCEL)
227 fi
228
229 dnl AC_CHECK_FUNC(pthread_create, TARGETS="client server utils serv_modules")
230
231 AC_CACHE_CHECK([for pthread_create], ac_cv_func_pthread_create,
232 [AC_TRY_LINK([#include <pthread.h>],
233 [       /* The GNU C library defines this for functions which it implements
234            to always fail with ENOSYS.  Some functions are actually named
235            something starting with __ and the normal name is an alias.  */
236 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
237         choke me
238 #else
239         pthread_create(NULL, NULL, NULL, NULL);
240 #endif],
241 ac_cv_func_pthread_create=yes, ac_cv_func_pthread_create=no)])
242 if test "$ac_cv_func_pthread_create" = yes; then
243         TARGETS="client server utils serv_modules"
244 fi
245
246 dnl Now restore the old ldflags so we don't pass the wrong stuff to makefile
247 LDFLAGS=$save_LDFLAGS
248
249 AC_REPLACE_FUNCS(snprintf getutline)
250
251 dnl Done! Now write the Makefile and sysdep.h
252 AC_SUBST(AUTH)
253 AC_SUBST(SO)
254 AC_SUBST(CHKPWD)
255 AC_SUBST(CURSES)
256 AC_SUBST(GDBM)
257 AC_SUBST(NETLIBS)
258 AC_SUBST(chkpwd_LIBS)
259 AC_SUBST(TARGETS)
260 AC_SUBST(SERVER_LDFLAGS)
261 AC_SUBST(PICFLAGS)
262 AC_SUBST(LINK_SHARED)
263 AC_SUBST(PTHREAD_DEFS)
264 AC_CONFIG_HEADER(sysdep.h)
265 AC_OUTPUT(Makefile weekly)