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