1 dnl Process this file with autoconf to produce a configure script.
5 AC_PREFIX_DEFAULT(/usr/local/citadel)
6 if test "$prefix" = NONE; then
7 AC_DEFINE_UNQUOTED(BBSDIR, "$ac_default_prefix")
9 AC_DEFINE_UNQUOTED(BBSDIR, "$prefix")
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'])
15 AC_ARG_ENABLE(icq, [ --enable-icq include server ICQ support], [
16 if test "x$enableval" = xyes; then
17 SERV_ICQ='modules/serv_icq$(SO)'
19 AC_ARG_ENABLE(threaded-client, [ --disable-threaded-client
20 disable multithreaded client])
22 AC_ARG_WITH(pam, [ --with-pam use PAM if present (see PAM.txt before you try this)])
23 AC_ARG_WITH(kthread, [ --with-kthread use kernel threads (on FreeBSD) (not recommended yet)])
25 dnl By default, we only build the client (citadel and whobbs) unless we can
26 dnl figure out how to build with POSIX threads.
31 PTHREAD_DEFS=-D_REENTRANT
32 LINK_SHARED='$(CC) -shared'
34 dnl BSDI 3.0 wants relocatable object modules instead of shared libs
35 dnl for dlopen(), and has a wrapper script to link with shared libs.
36 dnl Also has stupid non-reentrant gethostbyaddr() and friends.
38 test -z "$CC" -a -x /usr/bin/shlicc2 && CC=shlicc2
40 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
43 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
45 dnl Digital Unix has an odd way to build for pthreads, and we can't
46 dnl build pthreads programs with gcc due to header problems.
48 test -z "$CC" && CC=cc
53 dnl FreeBSD is similar to Digital UNIX:
55 if test "$with_kthread" = yes; then
61 PTHREAD_DEFS=-D_THREAD_SAFE
67 LINK_SHARED="ld -x -Bshareable"
71 dnl Checks for programs.
74 dnl Set up system-dependent compiler flags.
75 if test "$GCC" = yes; then
76 CFLAGS="$CFLAGS -Wall -Wstrict-prototypes"
84 SERVER_LDFLAGS="$SERVER_LDFLAGS -rdynamic"
91 missing_dir=`cd $ac_aux_dir && pwd`
92 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
94 dnl Checks for system services.
97 dnl Checks for libraries.
99 dnl libdl, libgdbm, and libcrypt are only used in the server, so the
100 dnl Makefile only passes $(LIBS) to that target. If other programs start
101 dnl requiring additional libraries, we'll have to use other variables, as is
102 dnl done with curses.
104 dnl We want to test for the following in libc before checking for their
105 dnl respective libraries, because some systems (like Irix) have both, and the
106 dnl non-libc versions may be broken.
107 AC_CHECK_FUNCS(crypt dlopen gethostbyname connect)
109 if test "$ac_cv_func_gethostbyname" = no; then
110 AC_CHECK_LIB(nsl, gethostbyname, NETLIBS="-lnsl $NETLIBS")
113 if test "$ac_cv_func_connect" = no; then
114 AC_CHECK_LIB(socket, connect, NETLIBS="-lsocket $NETLIBS",, $NETLIBS)
117 if test "$ac_cv_func_dlopen" = no; then
118 AC_CHECK_LIB(dl, dlopen, [LIBS="-ldl $LIBS"
119 test "$with_pam" = yes && chkpwd_LIBS="-ldl $chkpwd_LIBS"])
122 dnl Determine the system's authentication capabilities, if autologin is
123 dnl requested. We currently support PAM, standard getpwnam(), and getspnam()
124 dnl (Linux shadow passwords)
125 if test "$enable_autologin" != no; then
126 if test "$with_pam" = yes; then
128 AC_CHECK_LIB(pam, pam_start, [chkpwd_LIBS="-lpam $chkpwd_LIBS"
130 AC_CHECK_FUNCS(pam_start)
131 test "$enable_chkpwd" != no && LIBS=$save_LIBS
133 if test "$ac_cv_func_pam_start" = no -o "$with_pam" != yes; then
135 AC_SEARCH_LIBS(getspnam, shadow, [
136 if test "$ac_cv_search_getspnam" = -lshadow; then
137 chkpwd_LIBS="-lshadow $chkpwd_LIBS"
139 test "$enable_chkpwd" != no && LIBS=$save_LIBS
140 if test "$ac_cv_func_crypt" = no; then
141 AC_CHECK_LIB(crypt, crypt, [
142 chkpwd_LIBS="-lcrypt $chkpwd_LIBS"
143 test "$enable_chkpwd" = no && \
144 LIBS="-lcrypt $LIBS"])
147 if test "$ac_cv_func_crypt" = yes -o "$ac_cv_lib_crypt_crypt" = yes -o "$ac_cv_func_pam_start" = yes; then
148 AC_DEFINE(ENABLE_AUTOLOGIN)
149 if test "$enable_chkpwd" != no; then
150 AC_DEFINE(ENABLE_CHKPWD)
158 test -f /usr/local/lib/libgdbm.a && LDFLAGS="$LDFLAGS -L/usr/local/lib"
159 AC_CHECK_LIB(gdbm, gdbm_open, GDBM="$GDBM -lgdbm")
161 test -f /usr/local/lib/libresolv.a && LDFLAGS="$LDFLAGS -L/usr/local/lib"
162 AC_CHECK_LIB(resolv, res_query, RESOLV="$RESOLV -lresolv")
165 AC_CHECK_LIB(termcap, tgetent, [LIBS="$LIBS -ltermcap"
167 AC_CHECK_LIB(curses, initscr, CURSES="-lcurses $CURSES", [
168 AC_CHECK_LIB(ncurses, initscr, CURSES="-lncurses")])
171 dnl Check for libpthread(s) if we're not using Digital UNIX or FreeBSD. (On
172 dnl which the -pthread flag takes care of this.)
173 if test "$check_pthread" != no; then
174 AC_CHECK_LIB(pthread, pthread_create,
175 PTHREAD_LIBS="-lpthread $PTHREAD_LIBS")
176 AC_CHECK_LIB(pthreads, pthread_create,
177 PTHREAD_LIBS="-lpthreads $PTHREAD_LIBS")
180 dnl Checks for header files.
184 test -f /usr/local/include/gdbm.h && CPPFLAGS="$CPPFLAGS -I/usr/local/include"
185 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)
187 dnl some systems require -pthread, -D_REENTRANT, etc to be passed to cc if we
188 dnl include pthread.h:
189 save_CPPFLAGS=$CPPFLAGS
190 CPPFLAGS="$CPPFLAGS $PTHREAD_DEFS"
191 AC_CHECK_HEADERS(pthread.h)
192 CPPFLAGS=$save_CPPFLAGS
194 dnl Checks for typedefs, structures, and compiler characteristics.
201 AC_CACHE_CHECK([for ut_type in struct utmp], ac_cv_struct_ut_type,
202 [AC_TRY_COMPILE([#include <sys/types.h>
203 #include <utmp.h>], [struct utmp ut; ut.ut_type;],
204 ac_cv_struct_ut_type=yes, ac_cv_struct_ut_type=no)])
205 if test $ac_cv_struct_ut_type = yes; then
206 AC_DEFINE(HAVE_UT_TYPE)
209 AC_CACHE_CHECK([for ut_host in struct utmp], ac_cv_struct_ut_host,
210 [AC_TRY_COMPILE([#include <sys/types.h>
211 #include <utmp.h>], [struct utmp ut; ut.ut_host;],
212 ac_cv_struct_ut_host=yes, ac_cv_struct_ut_host=no)])
213 if test $ac_cv_struct_ut_host = yes; then
214 AC_DEFINE(HAVE_UT_HOST)
217 dnl Checks for library functions.
219 AC_PROG_GCC_TRADITIONAL
222 AC_CHECK_FUNCS(getspnam mkdir mkfifo mktime rmdir select socket strerror)
224 dnl Now check for pthreads -- set up variables so that the compiler will be run
225 dnl with proper flags for pthread programs
226 save_LDFLAGS=$LDFLAGS
227 LDFLAGS="$LDFLAGS $SERVER_LDFLAGS"
229 LIBS="$PTHREAD_LIBS $LIBS"
231 dnl On some platforms, AC_CHECK_FUNC[S] doesn't work for pthreads programs;
232 dnl we need to include pthread.h
233 dnl AC_CHECK_FUNCS(pthread_cancel)
235 AC_CACHE_CHECK([for pthread_cancel], ac_cv_func_pthread_cancel,
236 [AC_TRY_LINK([#include <pthread.h>],
239 /* The GNU C library defines this for functions which it implements
240 to always fail with ENOSYS. Some functions are actually named
241 something starting with __ and the normal name is an alias. */
242 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
245 pthread_cancel(thread);
247 ac_cv_func_pthread_cancel=yes, ac_cv_func_pthread_cancel=no)])
248 if test "$ac_cv_func_pthread_cancel" = yes; then
249 AC_DEFINE(HAVE_PTHREAD_CANCEL)
252 dnl AC_CHECK_FUNC(pthread_create, TARGETS="client server utils serv_modules")
254 AC_CACHE_CHECK([for pthread_create], ac_cv_func_pthread_create,
255 [AC_TRY_LINK([#include <pthread.h>],
256 [ /* The GNU C library defines this for functions which it implements
257 to always fail with ENOSYS. Some functions are actually named
258 something starting with __ and the normal name is an alias. */
259 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
262 pthread_create(NULL, NULL, NULL, NULL);
264 ac_cv_func_pthread_create=yes, ac_cv_func_pthread_create=no)])
265 if test "$ac_cv_func_pthread_create" = yes; then
266 TARGETS="client server utils serv_modules"
267 if test "x$enable_threaded_client" != xno; then
268 AC_DEFINE(THREADED_CLIENT)
269 CLIENT_PTLIBS=$PTHREAD_LIBS
270 CL_LIBOBJS='$(LIBOBJS:.o=.ro)'
275 if test "x$CX" != x.ro; then
276 CL_LIBOBJS='$(LIBOBJS)'
280 dnl Now restore the old ldflags so we don't pass the wrong stuff to makefile
281 LDFLAGS=$save_LDFLAGS
284 AC_REPLACE_FUNCS(snprintf getutline)
286 dnl Done! Now write the Makefile and sysdep.h
294 AC_SUBST(chkpwd_LIBS)
296 AC_SUBST(SERVER_LDFLAGS)
299 AC_SUBST(LINK_SHARED)
300 AC_SUBST(PTHREAD_DEFS)
301 AC_SUBST(PTHREAD_LIBS)
302 AC_SUBST(CLIENT_PTLIBS)
305 AC_CONFIG_HEADER(sysdep.h)
306 AC_OUTPUT(Makefile weekly)