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