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(threaded-client, [ --disable-threaded-client
16 disable multithreaded client])
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)])
21 dnl By default, we only build the client (citadel and whobbs) unless we can
22 dnl figure out how to build with POSIX threads.
27 PTHREAD_DEFS=-D_REENTRANT
28 LINK_SHARED='$(CC) -shared -fPIC'
30 dnl BSDI 3.0 wants relocatable object modules instead of shared libs
31 dnl for dlopen(), and has a wrapper script to link with shared libs.
32 dnl Also has stupid non-reentrant gethostbyaddr() and friends.
34 test -z "$CC" -a -x /usr/bin/shlicc2 && CC=shlicc2
36 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
39 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
41 dnl Digital Unix has an odd way to build for pthreads, and we can't
42 dnl build pthreads programs with gcc due to header problems.
44 test -z "$CC" && CC=cc
49 dnl FreeBSD is similar to Digital UNIX:
51 if test "$with_kthread" = yes; then
57 PTHREAD_DEFS=-D_THREAD_SAFE
63 LINK_SHARED="ld -x -Bshareable"
66 PTHREAD_DEFS="-D_REENTRANT -D_PTHREADS"
70 dnl Checks for programs.
73 dnl Set up system-dependent compiler flags.
74 if test "$GCC" = yes; then
77 CFLAGS="$CFLAGS -Wall -Wstrict-prototypes"
80 CFLAGS="$CFLAGS -Wall -Wstrict-prototypes"
84 CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
88 CFLAGS="$CFLAGS -Wall -Wstrict-prototypes"
89 SERVER_LDFLAGS="$SERVER_LDFLAGS -rdynamic"
97 missing_dir=`cd $ac_aux_dir && pwd`
98 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
100 dnl Checks for system services.
103 dnl Checks for libraries.
105 dnl libdl, libgdbm, and libcrypt are only used in the server, so the
106 dnl Makefile only passes $(LIBS) to that target. If other programs start
107 dnl requiring additional libraries, we'll have to use other variables, as is
108 dnl done with curses.
110 dnl We want to test for the following in libc before checking for their
111 dnl respective libraries, because some systems (like Irix) have both, and the
112 dnl non-libc versions may be broken.
113 AC_CHECK_FUNCS(crypt dlopen gethostbyname connect)
115 if test "$ac_cv_func_gethostbyname" = no; then
116 AC_CHECK_LIB(nsl, gethostbyname, NETLIBS="-lnsl $NETLIBS")
119 if test "$ac_cv_func_connect" = no; then
120 AC_CHECK_LIB(socket, connect, NETLIBS="-lsocket $NETLIBS",, $NETLIBS)
123 if test "$ac_cv_func_dlopen" = no; then
124 AC_CHECK_LIB(dl, dlopen, [LIBS="-ldl $LIBS"
125 test "$with_pam" = yes && chkpwd_LIBS="-ldl $chkpwd_LIBS"])
128 dnl Check for HP/UX dyanmic loader. This should only be in -ldld.
129 AC_CHECK_LIB(dld, shl_load, LIBS="-ldld $LIBS")
131 dnl Determine the system's authentication capabilities, if autologin is
132 dnl requested. We currently support PAM, standard getpwnam(), and getspnam()
133 dnl (Linux shadow passwords)
134 if test "$enable_autologin" != no; then
135 if test "$with_pam" = yes; then
137 AC_CHECK_LIB(pam, pam_start, [chkpwd_LIBS="-lpam $chkpwd_LIBS"
139 AC_CHECK_FUNCS(pam_start)
140 test "$enable_chkpwd" != no && LIBS=$save_LIBS
142 if test "$ac_cv_func_pam_start" = no -o "$with_pam" != yes; then
144 AC_SEARCH_LIBS(getspnam, shadow, [
145 if test "$ac_cv_search_getspnam" = -lshadow; then
146 chkpwd_LIBS="-lshadow $chkpwd_LIBS"
148 test "$enable_chkpwd" != no && LIBS=$save_LIBS
149 if test "$ac_cv_func_crypt" = no; then
150 AC_CHECK_LIB(crypt, crypt, [
151 chkpwd_LIBS="-lcrypt $chkpwd_LIBS"
152 test "$enable_chkpwd" = no && \
153 LIBS="-lcrypt $LIBS"])
156 if test "$ac_cv_func_crypt" = yes -o "$ac_cv_lib_crypt_crypt" = yes -o "$ac_cv_func_pam_start" = yes; then
157 AC_DEFINE(ENABLE_AUTOLOGIN)
158 if test "$enable_chkpwd" != no; then
159 AC_DEFINE(ENABLE_CHKPWD)
167 test -f /usr/local/lib/libgdbm.a && LDFLAGS="$LDFLAGS -L/usr/local/lib"
168 AC_CHECK_LIB(gdbm, gdbm_open, GDBM="$GDBM -lgdbm")
170 test -f /usr/local/lib/libresolv.a && LDFLAGS="$LDFLAGS -L/usr/local/lib"
171 AC_CHECK_LIB(resolv, res_query, RESOLV="$RESOLV -lresolv")
175 AC_SEARCH_LIBS(tgetent, [curses termcap])
176 AC_SEARCH_LIBS(initscr, [curses ncurses])
180 dnl Check for libpthread(s) if we're not using Digital UNIX or FreeBSD. (On
181 dnl which the -pthread flag takes care of this.)
182 if test "$check_pthread" != no; then
183 AC_CHECK_LIB(pthread, pthread_create,
184 PTHREAD_LIBS="-lpthread $PTHREAD_LIBS")
185 AC_CHECK_LIB(pthreads, pthread_create,
186 PTHREAD_LIBS="-lpthreads $PTHREAD_LIBS")
189 dnl Checks for header files.
193 test -f /usr/local/include/gdbm.h && CPPFLAGS="$CPPFLAGS -I/usr/local/include"
194 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 gdbm.h utmp.h utmpx.h paths.h)
196 dnl some systems require -pthread, -D_REENTRANT, etc to be passed to cc if we
197 dnl include pthread.h:
198 save_CPPFLAGS=$CPPFLAGS
199 CPPFLAGS="$CPPFLAGS $PTHREAD_DEFS"
200 AC_CHECK_HEADERS(pthread.h)
201 CPPFLAGS=$save_CPPFLAGS
203 dnl Checks for typedefs, structures, and compiler characteristics.
210 dnl Check the size of various builtin types; see typesize.h (error)
211 AC_CHECK_SIZEOF(char, 0)
212 AC_CHECK_SIZEOF(short, 0)
213 AC_CHECK_SIZEOF(int, 0)
214 AC_CHECK_SIZEOF(long, 0)
215 dnl AC_CHECK_SIZEOF(long long, 0)
217 AC_CACHE_CHECK([for ut_type in struct utmp], ac_cv_struct_ut_type,
218 [AC_TRY_COMPILE([#include <sys/types.h>
219 #include <utmp.h>], [struct utmp ut; ut.ut_type;],
220 ac_cv_struct_ut_type=yes, ac_cv_struct_ut_type=no)])
221 if test $ac_cv_struct_ut_type = yes; then
222 AC_DEFINE(HAVE_UT_TYPE)
225 AC_CACHE_CHECK([for ut_host in struct utmp], ac_cv_struct_ut_host,
226 [AC_TRY_COMPILE([#include <sys/types.h>
227 #include <utmp.h>], [struct utmp ut; ut.ut_host;],
228 ac_cv_struct_ut_host=yes, ac_cv_struct_ut_host=no)])
229 if test $ac_cv_struct_ut_host = yes; then
230 AC_DEFINE(HAVE_UT_HOST)
233 dnl Checks for library functions.
235 AC_PROG_GCC_TRADITIONAL
238 AC_CHECK_FUNCS(getspnam getutxline mkdir mkfifo mktime rmdir select socket strerror strcasecmp strncasecmp)
240 dnl Now check for pthreads -- set up variables so that the compiler will be run
241 dnl with proper flags for pthread programs
242 save_LDFLAGS=$LDFLAGS
243 LDFLAGS="$LDFLAGS $SERVER_LDFLAGS"
245 LIBS="$PTHREAD_LIBS $LIBS"
247 dnl On some platforms, AC_CHECK_FUNC[S] doesn't work for pthreads programs;
248 dnl we need to include pthread.h
249 dnl AC_CHECK_FUNCS(pthread_cancel)
251 AC_CACHE_CHECK([for pthread_cancel], ac_cv_func_pthread_cancel,
252 [AC_TRY_LINK([#include <pthread.h>],
255 /* The GNU C library defines this for functions which it implements
256 to always fail with ENOSYS. Some functions are actually named
257 something starting with __ and the normal name is an alias. */
258 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
261 pthread_cancel(thread);
263 ac_cv_func_pthread_cancel=yes, ac_cv_func_pthread_cancel=no)])
264 if test "$ac_cv_func_pthread_cancel" = yes; then
265 AC_DEFINE(HAVE_PTHREAD_CANCEL)
268 dnl AC_CHECK_FUNC(pthread_create, TARGETS="client server utils serv_modules")
270 AC_CACHE_CHECK([for pthread_create], ac_cv_func_pthread_create,
271 [AC_TRY_LINK([#include <pthread.h>],
272 [ /* The GNU C library defines this for functions which it implements
273 to always fail with ENOSYS. Some functions are actually named
274 something starting with __ and the normal name is an alias. */
275 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
278 pthread_create(NULL, NULL, NULL, NULL);
280 ac_cv_func_pthread_create=yes, ac_cv_func_pthread_create=no)])
281 if test "$ac_cv_func_pthread_create" = yes; then
282 TARGETS="client server utils serv_modules"
283 if test "x$enable_threaded_client" != xno; then
284 AC_DEFINE(THREADED_CLIENT)
285 CLIENT_PTLIBS=$PTHREAD_LIBS
286 CL_LIBOBJS='$(LIBOBJS:.o=.ro)'
291 if test "x$CX" != x.ro; then
292 CL_LIBOBJS='$(LIBOBJS)'
296 dnl Now restore the old ldflags so we don't pass the wrong stuff to makefile
297 LDFLAGS=$save_LDFLAGS
300 AC_REPLACE_FUNCS(snprintf getutline)
302 dnl Done! Now write the Makefile and sysdep.h
310 AC_SUBST(chkpwd_LIBS)
312 AC_SUBST(SERVER_LDFLAGS)
314 AC_SUBST(LINK_SHARED)
315 AC_SUBST(PTHREAD_DEFS)
316 AC_SUBST(PTHREAD_LIBS)
317 AC_SUBST(CLIENT_PTLIBS)
320 AC_CONFIG_HEADER(sysdep.h)
321 AC_OUTPUT(Makefile weekly)