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