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