]> code.citadel.org Git - citadel.git/blob - citadel/configure.in
added --with-db and --with-gdbm options to configure
[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
15 AC_ARG_ENABLE(threaded-client, [  --disable-threaded-client
16                           disable multithreaded client])
17
18 AC_ARG_WITH(pam, [  --with-pam              use PAM if present (see PAM.txt before you try this)])
19 AC_ARG_WITH(kthread, [  --with-kthread          use kernel threads (on FreeBSD) (not recommended yet)])
20 AC_ARG_WITH(gdbm, [  --with-gdbm[=DIR]       use GDBM [DIR=/usr/local]])
21 AC_ARG_WITH(db, [  --with-db[=DIR]         use Sleepycat DB 3.1 [DIR=/usr/local/BerkeleyDB.3.1]])
22
23 if test "x$with_gdbm" != xno -a "x$with_gdbm" != xyeso -a "$with_gdbm"; then
24         db_dir="$with_gdbm"
25         with_gdbm=yes
26 else
27         test -f /usr/local/lib/libgdbm.a -o -f /usr/local/lib/libgdbm.so && db_dir=/usr/local
28 fi
29
30 if test "x$with_db" != xno -a "x$with_db" != xyes -a "$with_db"; then
31         db_dir="$with_db"
32         with_db=yes
33 else
34         test -d /usr/local/BerkeleyDB.3.1 && db_dir=/usr/local/BerkeleyDB.3.1
35 fi
36
37 if test "x$with_gdbm" = xyes -a "x$with_db" = xyes; then
38         AC_MSG_ERROR(can't enable both gdbm and db)
39 fi
40
41 dnl By default, we only build the client (citadel and whobbs) unless we can
42 dnl figure out how to build with POSIX threads.
43 TARGETS=client
44
45 AC_CANONICAL_HOST
46 SO=.so
47 PTHREAD_DEFS=-D_REENTRANT
48 LINK_SHARED='$(CC) -shared -fPIC'
49 case "$host" in
50         dnl BSDI 3.0 wants relocatable object modules instead of shared libs
51         dnl for dlopen(), and has a wrapper script to link with shared libs.
52         dnl Also has stupid non-reentrant gethostbyaddr() and friends.
53         *-*-bsdi[123]*)
54                 test -z "$CC" -a -x /usr/bin/shlicc2 && CC=shlicc2
55                 SO=.mo
56                 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
57         ;;
58         *-*-bsdi*)
59                 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
60         ;;
61         dnl Digital Unix has an odd way to build for pthreads, and we can't
62         dnl build pthreads programs with gcc due to header problems.
63         alpha*-dec-osf*)
64                 test -z "$CC" && CC=cc
65                 PTHREAD_DEFS=-pthread
66                 PTHREAD_LIBS=-pthread
67                 check_pthread=no
68         ;;
69         dnl FreeBSD is similar to Digital UNIX:
70         *-*-freebsd*)
71                 if test "$with_kthread" = yes; then
72                         PTHREAD_LIBS=-kthread
73                 else
74                         PTHREAD_LIBS=-pthread
75                 fi
76                 check_pthread=no
77                 PTHREAD_DEFS=-D_THREAD_SAFE
78         ;;
79         *-*-openbsd*)
80                 PTHREAD_LIBS=-pthread
81                 check_pthread=no
82                 PTHREAD_DEFS=-pthread
83                 LINK_SHARED="ld -x -Bshareable"
84         ;;
85         *-*-solaris*)
86                 PTHREAD_DEFS="-D_REENTRANT -D_PTHREADS"
87         ;;
88 esac
89
90 dnl Checks for programs.
91 AC_PROG_CC
92
93 dnl Set up system-dependent compiler flags.
94 if test "$GCC" = yes; then
95         case "$host" in
96                 *-*-bsdi[123]*)
97                         CFLAGS="$CFLAGS -Wall -Wstrict-prototypes"
98                 ;;
99                 mips*-sgi-irix*)
100                         CFLAGS="$CFLAGS -Wall -Wstrict-prototypes"
101                         PICFLAGS=-fPIC
102                 ;;
103                 *-*-solaris*)
104                         CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
105                         PICFLAGS=-fPIC
106                 ;;
107                 *-*-hpux*)
108                         SERVER_LDFLAGS="$SERVER_LDFLAGS -Wl,-E"
109                         PICFLAGS=-fPIC
110                 ;;
111                 *)
112                         CFLAGS="$CFLAGS -Wall -Wstrict-prototypes"
113                         SERVER_LDFLAGS="$SERVER_LDFLAGS -rdynamic"
114                         PICFLAGS=-fPIC
115                 ;;
116         esac
117 fi
118 AC_PROG_RANLIB
119 AC_PROG_INSTALL
120 AC_PROG_YACC
121 missing_dir=`cd $ac_aux_dir && pwd`
122 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
123
124 dnl Checks for system services.
125 AC_EXEEXT
126
127 dnl Checks for libraries.
128
129 dnl libdl, libgdbm, and libcrypt are only used in the server, so the
130 dnl Makefile only passes $(LIBS) to that target. If other programs start
131 dnl requiring additional libraries, we'll have to use other variables, as is
132 dnl done with curses.
133
134 dnl We want to test for the following in libc before checking for their
135 dnl respective libraries, because some systems (like Irix) have both, and the
136 dnl non-libc versions may be broken.
137 AC_CHECK_FUNCS(crypt dlopen gethostbyname connect)
138
139 if test "$ac_cv_func_gethostbyname" = no; then
140         AC_CHECK_LIB(nsl, gethostbyname, NETLIBS="-lnsl $NETLIBS")
141 fi
142
143 if test "$ac_cv_func_connect" = no; then
144         AC_CHECK_LIB(socket, connect, NETLIBS="-lsocket $NETLIBS",, $NETLIBS)
145 fi
146
147 if test "$ac_cv_func_dlopen" = no; then
148         AC_CHECK_LIB(dl, dlopen, [LIBS="-ldl $LIBS"
149                 test "$with_pam" = yes && chkpwd_LIBS="-ldl $chkpwd_LIBS"])
150 fi
151
152 dnl Check for HP/UX dyanmic loader. This should only be in -ldld.
153 AC_CHECK_LIB(dld, shl_load, LIBS="-ldld $LIBS")
154
155 dnl Determine the system's authentication capabilities, if autologin is
156 dnl requested. We currently support PAM, standard getpwnam(), and getspnam()
157 dnl (Linux shadow passwords)
158 if test "$enable_autologin" != no; then
159         if test "$with_pam" = yes; then
160                 save_LIBS=$LIBS
161                 AC_CHECK_LIB(pam, pam_start, [chkpwd_LIBS="-lpam $chkpwd_LIBS"
162                         LIBS="-lpam $LIBS"])
163                 AC_CHECK_FUNCS(pam_start)
164                 test "$enable_chkpwd" != no && LIBS=$save_LIBS
165         fi
166         if test "$ac_cv_func_pam_start" = no -o "$with_pam" != yes; then
167                 save_LIBS=$LIBS
168                 AC_SEARCH_LIBS(getspnam, shadow, [
169                         if test "$ac_cv_search_getspnam" = -lshadow; then
170                                 chkpwd_LIBS="-lshadow $chkpwd_LIBS"
171                         fi])
172                 test "$enable_chkpwd" != no && LIBS=$save_LIBS
173                 if test "$ac_cv_func_crypt" = no; then
174                         AC_CHECK_LIB(crypt, crypt, [
175                                 chkpwd_LIBS="-lcrypt $chkpwd_LIBS"
176                                 test "$enable_chkpwd" = no && \
177                                         LIBS="-lcrypt $LIBS"])
178                 fi
179         fi
180         if test "$ac_cv_func_crypt" = yes -o "$ac_cv_lib_crypt_crypt" = yes -o "$ac_cv_func_pam_start" = yes; then
181                 AC_DEFINE(ENABLE_AUTOLOGIN)
182                 if test "$enable_chkpwd" != no; then
183                         AC_DEFINE(ENABLE_CHKPWD)
184                         CHKPWD=chkpwd
185                 else
186                         AUTH=auth.ro
187                 fi
188         fi
189 fi
190
191 test "$db_dir" && LDFLAGS="$LDFLAGS -L$db_dir/lib"
192 if test "x$with_gdbm" != xno -a "x$with_db" != xyes; then
193         AC_CHECK_LIB(gdbm, gdbm_open,
194                 [GDBM="$GDBM -lgdbm"
195                 DATABASE=database.c
196                 with_db=no])
197 fi
198
199 if test "x$with_db" != xno -a "x$with_gdbm" != xyes; then
200         AC_CHECK_LIB(db, db_env_create,
201                 [GDBM="$GDBM -ldb"
202                 DATABASE=database_sleepycat.c
203                 with_gdbm=no])
204 fi
205
206 test -f /usr/local/lib/libresolv.a && LDFLAGS="$LDFLAGS -L/usr/local/lib"
207 AC_CHECK_LIB(resolv, res_query, RESOLV="$RESOLV -lresolv")
208
209 save_LIBS=$LIBS
210 LIBS=$CURSES
211 AC_SEARCH_LIBS(tgetent, [curses termcap])
212 AC_SEARCH_LIBS(initscr, [curses ncurses])
213 CURSES=$LIBS
214 LIBS=$save_LIBS
215
216 dnl Check for libpthread(s) if we're not using Digital UNIX or FreeBSD. (On
217 dnl which the -pthread flag takes care of this.)
218 if test "$check_pthread" != no; then
219         AC_CHECK_LIB(pthread, pthread_create,
220                 PTHREAD_LIBS="-lpthread $PTHREAD_LIBS")
221         AC_CHECK_LIB(pthreads, pthread_create,
222                 PTHREAD_LIBS="-lpthreads $PTHREAD_LIBS")
223 fi
224
225 dnl Checks for header files.
226 AC_HEADER_DIRENT
227 AC_HEADER_STDC
228 AC_HEADER_SYS_WAIT
229 test "$db_dir" && CPPFLAGS="$CPPFLAGS -I$db_dir/include"
230 AC_CHECK_HEADERS(curses.h dl.h dlfcn.h fcntl.h limits.h termios.h strings.h sys/ioctl.h sys/select.h sys/time.h syslog.h unistd.h utmp.h utmpx.h paths.h)
231
232 dnl some systems require -pthread, -D_REENTRANT, etc to be passed to cc if we
233 dnl include pthread.h:
234 save_CPPFLAGS=$CPPFLAGS
235 CPPFLAGS="$CPPFLAGS $PTHREAD_DEFS"
236 AC_CHECK_HEADERS(pthread.h)
237 CPPFLAGS=$save_CPPFLAGS
238
239 dnl Checks for typedefs, structures, and compiler characteristics.
240 AC_C_CONST
241 AC_TYPE_PID_T
242 AC_TYPE_SIZE_T
243 AC_HEADER_TIME
244 AC_STRUCT_TM
245
246 dnl Check the size of various builtin types; see typesize.h (error)
247 AC_CHECK_SIZEOF(char, 0)
248 AC_CHECK_SIZEOF(short, 0)
249 AC_CHECK_SIZEOF(int, 0)
250 AC_CHECK_SIZEOF(long, 0)
251 dnl AC_CHECK_SIZEOF(long long, 0)
252
253 AC_CACHE_CHECK([for ut_type in struct utmp], ac_cv_struct_ut_type,
254 [AC_TRY_COMPILE([#include <sys/types.h>
255 #include <utmp.h>], [struct utmp ut; ut.ut_type;],
256 ac_cv_struct_ut_type=yes, ac_cv_struct_ut_type=no)])
257 if test $ac_cv_struct_ut_type = yes; then
258         AC_DEFINE(HAVE_UT_TYPE)
259 fi
260
261 AC_CACHE_CHECK([for ut_host in struct utmp], ac_cv_struct_ut_host,
262 [AC_TRY_COMPILE([#include <sys/types.h>
263 #include <utmp.h>], [struct utmp ut; ut.ut_host;],
264 ac_cv_struct_ut_host=yes, ac_cv_struct_ut_host=no)])
265 if test $ac_cv_struct_ut_host = yes; then
266         AC_DEFINE(HAVE_UT_HOST)
267 fi
268
269 dnl Checks for library functions.
270 AC_FUNC_GETPGRP
271 AC_PROG_GCC_TRADITIONAL
272 AC_TYPE_SIGNAL
273 AC_FUNC_VPRINTF
274 AC_CHECK_FUNCS(getspnam getutxline mkdir mkfifo mktime rmdir select socket strerror strcasecmp strncasecmp)
275
276 dnl Now check for pthreads -- set up variables so that the compiler will be run
277 dnl with proper flags for pthread programs
278 save_LDFLAGS=$LDFLAGS
279 LDFLAGS="$LDFLAGS $SERVER_LDFLAGS"
280 save_LIBS=$LIBS
281 LIBS="$PTHREAD_LIBS $LIBS"
282
283 dnl On some platforms, AC_CHECK_FUNC[S] doesn't work for pthreads programs;
284 dnl we need to include pthread.h
285 dnl AC_CHECK_FUNCS(pthread_cancel)
286
287 AC_CACHE_CHECK([for pthread_cancel], ac_cv_func_pthread_cancel,
288 [AC_TRY_LINK([#include <pthread.h>],
289 [       pthread_t thread;
290
291         /* The GNU C library defines this for functions which it implements
292            to always fail with ENOSYS.  Some functions are actually named
293            something starting with __ and the normal name is an alias.  */
294 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
295         choke me
296 #else
297         pthread_cancel(thread);
298 #endif],
299 ac_cv_func_pthread_cancel=yes, ac_cv_func_pthread_cancel=no)])
300 if test "$ac_cv_func_pthread_cancel" = yes; then
301         AC_DEFINE(HAVE_PTHREAD_CANCEL)
302 fi
303
304 dnl AC_CHECK_FUNC(pthread_create, TARGETS="client server utils serv_modules")
305
306 AC_CACHE_CHECK([for pthread_create], ac_cv_func_pthread_create,
307 [AC_TRY_LINK([#include <pthread.h>],
308 [       /* The GNU C library defines this for functions which it implements
309            to always fail with ENOSYS.  Some functions are actually named
310            something starting with __ and the normal name is an alias.  */
311 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
312         choke me
313 #else
314         pthread_create(NULL, NULL, NULL, NULL);
315 #endif],
316 ac_cv_func_pthread_create=yes, ac_cv_func_pthread_create=no)])
317 if test "$ac_cv_func_pthread_create" = yes; then
318         TARGETS="client server utils serv_modules"
319         if test "x$enable_threaded_client" != xno; then
320                 AC_DEFINE(THREADED_CLIENT)
321                 CLIENT_PTLIBS=$PTHREAD_LIBS
322                 CL_LIBOBJS='$(LIBOBJS:.o=.ro)'
323                 CX=.ro
324         fi
325 fi
326
327 if test "x$CX" != x.ro; then
328         CL_LIBOBJS='$(LIBOBJS)'
329         CX=.o
330 fi
331
332 dnl Now restore the old ldflags so we don't pass the wrong stuff to makefile
333 LDFLAGS=$save_LDFLAGS
334 LIBS=$save_LIBS
335
336 AC_REPLACE_FUNCS(snprintf getutline)
337
338 dnl Done! Now write the Makefile and sysdep.h
339 AC_SUBST(AUTH)
340 AC_SUBST(SO)
341 AC_SUBST(CHKPWD)
342 AC_SUBST(CURSES)
343 AC_SUBST(GDBM)
344 AC_SUBST(RESOLV)
345 AC_SUBST(NETLIBS)
346 AC_SUBST(chkpwd_LIBS)
347 AC_SUBST(TARGETS)
348 AC_SUBST(SERVER_LDFLAGS)
349 AC_SUBST(PICFLAGS)
350 AC_SUBST(LINK_SHARED)
351 AC_SUBST(PTHREAD_DEFS)
352 AC_SUBST(PTHREAD_LIBS)
353 AC_SUBST(CLIENT_PTLIBS)
354 AC_SUBST(CL_LIBOBJS)
355 AC_SUBST(CX)
356 AC_SUBST(DATABASE)
357 AC_CONFIG_HEADER(sysdep.h)
358 AC_OUTPUT(Makefile weekly)