1 dnl Process this file with autoconf to produce a configure script.
4 AC_INIT([Citadel/UX], [5.80], [http://uncensored.citadel.org/])
5 AC_REVISION([$Revision$])
6 AC_CONFIG_SRCDIR([citserver.c])
7 AC_PREFIX_DEFAULT(/usr/local/citadel)
8 if test "$prefix" = NONE; then
9 AC_DEFINE_UNQUOTED(BBSDIR, "$ac_default_prefix")
11 AC_DEFINE_UNQUOTED(BBSDIR, "$prefix")
14 AC_ARG_ENABLE(autologin, [ --disable-autologin disable autologin (default is enabled if possible)])
15 AC_ARG_ENABLE(chkpwd, [ --disable-chkpwd don't build 'chkpwd'])
17 AC_ARG_ENABLE(threaded-client, [ --disable-threaded-client
18 disable multithreaded client])
20 AC_ARG_WITH(pam, [ --with-pam use PAM if present (see PAM.txt before you try this)])
21 AC_ARG_WITH(kthread, [ --with-kthread use kernel threads (on FreeBSD) (not recommended yet)])
22 AC_ARG_WITH(gdbm, [ --with-gdbm@<:@=DIR@:>@ use GDBM @<:@DIR=/usr/local@:>@])
23 AC_ARG_WITH(db, [ --with-db@<:@=DIR@:>@ use Sleepycat DB 3.x @<:@DIR=/usr/local/BerkeleyDB.3.@<:@123@:>@@:>@])
25 if test "x$with_gdbm" != xno -a "x$with_gdbm" != xyes -a "$with_gdbm"; then
29 test -f /usr/local/lib/libgdbm.a -o -f /usr/local/lib/libgdbm.so && db_dir=/usr/local
32 if test "x$with_db" != xno -a "x$with_db" != xyes -a "$with_db"; then
36 test -d /usr/local/BerkeleyDB.3.1 && db_dir=/usr/local/BerkeleyDB.3.1
37 test -d /usr/local/BerkeleyDB.3.2 && db_dir=/usr/local/BerkeleyDB.3.2
38 test -d /usr/local/BerkeleyDB.3.3 && db_dir=/usr/local/BerkeleyDB.3.3
41 if test "x$with_gdbm" = xyes -a "x$with_db" = xyes; then
42 AC_MSG_ERROR(can't enable both gdbm and db)
45 dnl By default, we only build the client (citadel and whobbs) unless we can
46 dnl figure out how to build with POSIX threads.
50 PTHREAD_DEFS=-D_REENTRANT
52 dnl BSDI 3.0 wants relocatable object modules instead of shared libs
53 dnl for dlopen(), and has a wrapper script to link with shared libs.
54 dnl Also has stupid non-reentrant gethostbyaddr() and friends.
56 test -z "$CC" -a -x /usr/bin/shlicc2 && CC=shlicc2
57 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
60 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
62 dnl Digital Unix has an odd way to build for pthreads, and we can't
63 dnl build pthreads programs with gcc due to header problems.
65 test -z "$CC" && CC=cc
70 dnl FreeBSD is similar to Digital UNIX:
72 if test "$with_kthread" = yes; then
78 PTHREAD_DEFS=-D_THREAD_SAFE
86 PTHREAD_DEFS="-D_REENTRANT -D_PTHREADS"
90 dnl Checks for programs.
93 dnl Set up system-dependent compiler flags.
94 if test "$GCC" = yes; then
97 CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
100 CFLAGS="$CFLAGS -Wall -Wstrict-prototypes"
108 AC_SUBST(LIBTOOL_DEPS)
111 missing_dir=`cd $ac_aux_dir && pwd`
112 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
114 dnl Checks for system services.
116 dnl Checks for libraries.
118 dnl libdl, libgdbm, and libcrypt are only used in the server, so the
119 dnl Makefile only passes $(LIBS) to that target. If other programs start
120 dnl requiring additional libraries, we'll have to use other variables, as is
121 dnl done with curses.
123 dnl We want to test for the following in libc before checking for their
124 dnl respective libraries, because some systems (like Irix) have both, and the
125 dnl non-libc versions may be broken.
126 AC_CHECK_FUNCS(crypt dlopen gethostbyname connect)
128 if test "$ac_cv_func_gethostbyname" = no; then
129 AC_CHECK_LIB(nsl, gethostbyname, NETLIBS="-lnsl $NETLIBS")
132 if test "$ac_cv_func_connect" = no; then
133 AC_CHECK_LIB(socket, connect, NETLIBS="-lsocket $NETLIBS",, $NETLIBS)
136 if test "$ac_cv_func_dlopen" = no; then
137 AC_CHECK_LIB(dl, dlopen, [LIBS="-ldl $LIBS"
138 test "$with_pam" = yes && chkpwd_LIBS="-ldl $chkpwd_LIBS"])
141 dnl Check for HP/UX dyanmic loader. This should only be in -ldld.
142 AC_CHECK_LIB(dld, shl_load, LIBS="-ldld $LIBS")
144 dnl Check for Solaris realtime support
145 AC_CHECK_LIB(rt, sched_yield)
147 dnl Determine the system's authentication capabilities, if autologin is
148 dnl requested. We currently support PAM, standard getpwnam(), and getspnam()
149 dnl (Linux shadow passwords)
150 if test "$enable_autologin" != no; then
151 if test "$with_pam" = yes; then
153 AC_CHECK_LIB(pam, pam_start, [chkpwd_LIBS="-lpam $chkpwd_LIBS"
155 AC_CHECK_FUNCS(pam_start)
156 test "$enable_chkpwd" != no && LIBS=$save_LIBS
158 if test "$ac_cv_func_pam_start" = no -o "$with_pam" != yes; then
160 AC_SEARCH_LIBS(getspnam, shadow, [
161 if test "$ac_cv_search_getspnam" = -lshadow; then
162 chkpwd_LIBS="-lshadow $chkpwd_LIBS"
164 test "$enable_chkpwd" != no && LIBS=$save_LIBS
165 if test "$ac_cv_func_crypt" = no; then
166 AC_CHECK_LIB(crypt, crypt, [
167 chkpwd_LIBS="-lcrypt $chkpwd_LIBS"
168 test "$enable_chkpwd" = no && \
169 LIBS="-lcrypt $LIBS"])
172 if test "$ac_cv_func_crypt" = yes -o "$ac_cv_lib_crypt_crypt" = yes -o "$ac_cv_func_pam_start" = yes; then
173 AC_DEFINE(ENABLE_AUTOLOGIN)
174 if test "$enable_chkpwd" != no; then
175 AC_DEFINE(ENABLE_CHKPWD)
183 test "$db_dir" && LDFLAGS="$LDFLAGS -L$db_dir/lib"
184 if test "x$with_db" != xno -a "x$with_gdbm" != xyes; then
185 AC_CHECK_LIB(db, db_env_create,
187 DATABASE=database_sleepycat.c
188 with_gdbm=no], [], [$NETLIBS])
191 if test "x$with_gdbm" != xno -a "x$with_db" != xyes; then
192 AC_CHECK_LIB(gdbm, gdbm_open,
198 test -f /usr/local/lib/libresolv.a && LDFLAGS="$LDFLAGS -L/usr/local/lib"
199 AC_CHECK_LIB(resolv, res_query, RESOLV="$RESOLV -lresolv")
203 AC_SEARCH_LIBS(tgetent, [curses termcap])
204 AC_SEARCH_LIBS(initscr, [curses ncurses])
208 dnl Check for libpthread(s) if we're not using Digital UNIX or FreeBSD. (On
209 dnl which the -pthread flag takes care of this.)
210 if test "$check_pthread" != no; then
211 AC_CHECK_LIB(pthread, pthread_create,
212 PTHREAD_LIBS="-lpthread $PTHREAD_LIBS")
213 AC_CHECK_LIB(pthreads, pthread_create,
214 PTHREAD_LIBS="-lpthreads $PTHREAD_LIBS")
217 dnl Checks for header files.
221 test "$db_dir" && CPPFLAGS="$CPPFLAGS -I$db_dir/include" || test -d /usr/include/db3 && CPPFLAGS="$CPPFLAGS -I/usr/include/db3"
222 AC_CHECK_HEADERS(curses.h dl.h fcntl.h limits.h termios.h sys/ioctl.h sys/select.h sys/time.h syslog.h unistd.h utmp.h utmpx.h paths.h)
224 AC_CHECK_HEADER(resolv.h, [SMTP=modules/libsmtp.la; DOMAIN=domain.c])
228 dnl some systems require -pthread, -D_REENTRANT, etc to be passed to cc if we
229 dnl include pthread.h:
230 save_CPPFLAGS=$CPPFLAGS
231 CPPFLAGS="$CPPFLAGS $PTHREAD_DEFS"
232 AC_CHECK_HEADERS(pthread.h)
233 CPPFLAGS=$save_CPPFLAGS
235 dnl Checks for typedefs, structures, and compiler characteristics.
242 dnl Check the size of various builtin types; see typesize.h (error)
243 AC_CHECK_SIZEOF(char, 0)
244 AC_CHECK_SIZEOF(short, 0)
245 AC_CHECK_SIZEOF(int, 0)
246 AC_CHECK_SIZEOF(long, 0)
247 dnl AC_CHECK_SIZEOF(long long, 0)
249 AC_CACHE_CHECK([for ut_type in struct utmp], ac_cv_struct_ut_type,
250 [AC_TRY_COMPILE([#include <sys/types.h>
251 #include <utmp.h>], [struct utmp ut; ut.ut_type;],
252 ac_cv_struct_ut_type=yes, ac_cv_struct_ut_type=no)])
253 if test $ac_cv_struct_ut_type = yes; then
254 AC_DEFINE(HAVE_UT_TYPE)
257 AC_CACHE_CHECK([for ut_host in struct utmp], ac_cv_struct_ut_host,
258 [AC_TRY_COMPILE([#include <sys/types.h>
259 #include <utmp.h>], [struct utmp ut; ut.ut_host;],
260 ac_cv_struct_ut_host=yes, ac_cv_struct_ut_host=no)])
261 if test $ac_cv_struct_ut_host = yes; then
262 AC_DEFINE(HAVE_UT_HOST)
265 dnl Checks for library functions.
267 AC_PROG_GCC_TRADITIONAL
270 AC_CHECK_FUNCS(getspnam getutxline mkdir mkfifo mktime rmdir select socket strerror strcasecmp strncasecmp)
272 dnl Now check for pthreads -- set up variables so that the compiler will be run
273 dnl with proper flags for pthread programs
275 LIBS="$PTHREAD_LIBS $LIBS"
277 dnl On some platforms, AC_CHECK_FUNC[S] doesn't work for pthreads programs;
278 dnl we need to include pthread.h
279 dnl AC_CHECK_FUNCS(pthread_cancel)
281 AC_CACHE_CHECK([for pthread_cancel], ac_cv_func_pthread_cancel,
282 [AC_TRY_LINK([#include <pthread.h>],
285 /* The GNU C library defines this for functions which it implements
286 to always fail with ENOSYS. Some functions are actually named
287 something starting with __ and the normal name is an alias. */
288 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
291 pthread_cancel(thread);
293 ac_cv_func_pthread_cancel=yes, ac_cv_func_pthread_cancel=no)])
294 if test "$ac_cv_func_pthread_cancel" = yes; then
295 AC_DEFINE(HAVE_PTHREAD_CANCEL)
298 dnl AC_CHECK_FUNC(pthread_create, TARGETS="client server utils serv_modules")
300 AC_CACHE_CHECK([for pthread_create], ac_cv_func_pthread_create,
301 [AC_TRY_LINK([#include <pthread.h>],
302 [ /* The GNU C library defines this for functions which it implements
303 to always fail with ENOSYS. Some functions are actually named
304 something starting with __ and the normal name is an alias. */
305 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
308 pthread_create(NULL, NULL, NULL, NULL);
310 ac_cv_func_pthread_create=yes, ac_cv_func_pthread_create=no)])
311 if test "$ac_cv_func_pthread_create" = yes; then
312 TARGETS="client server utils serv_modules"
313 if test "x$enable_threaded_client" != xno; then
314 AC_DEFINE(THREADED_CLIENT)
315 CLIENT_PTLIBS=$PTHREAD_LIBS
316 CL_LIBOBJS='$(LIBOBJS:.o=.ro)'
321 if test "x$CX" != x.ro; then
322 CL_LIBOBJS='$(LIBOBJS)'
326 dnl Now restore the old libs so we don't pass the wrong stuff to makefile
329 AC_REPLACE_FUNCS(snprintf getutline)
331 dnl Done! Now write the Makefile and sysdep.h
338 AC_SUBST(chkpwd_LIBS)
340 AC_SUBST(PTHREAD_DEFS)
341 AC_SUBST(PTHREAD_LIBS)
342 AC_SUBST(CLIENT_PTLIBS)
346 AC_CONFIG_HEADER(sysdep.h)
347 AC_CONFIG_FILES([Makefile weekly])