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