258bd3150fc705fa07e3430c229a8466ad8ce5c1
[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
14 dnl By default, we only build the client (citadel and whobbs) unless we can
15 dnl figure out how to build with POSIX threads.
16 TARGETS=client
17
18 AC_CANONICAL_HOST
19 SO=.so
20 case "$host" in
21         dnl BSDI 3.0 wants relocatable object modules instead of shared libs
22         dnl for dlopen(), and has a wrapper script to link with shared libs.
23         dnl Also has stupid non-reentrant gethostbyaddr() and friends.
24         i?86-*-bsdi*)
25                 test -z "$CC" -a -x /usr/bin/shlicc2 && CC=shlicc2
26                 SO=.mo
27                 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
28         ;;
29         dnl Digital Unix has an odd way to build pthreads, and we can't build
30         dnl pthreads programs with gcc due to header problems.
31         alpha*-dec-osf*)
32                 test -z "$CC" && CC=cc
33                 SERVER_LDFLAGS=-pthread
34         ;;
35         *-*-cygwin32)
36                 SUFFIX=.exe
37         ;;
38 esac
39
40 dnl Checks for programs.
41 AC_PROG_CC
42
43 dnl Set up system-dependent compiler flags.
44 if test "$GCC" = yes; then
45         CFLAGS="$CFLAGS -Wall -Wstrict-prototypes"
46         case "$host" in
47                 i?86-*-bsdi*)
48                 ;;
49                 mips*-sgi-irix*)
50                         PICFLAGS=-fPIC
51                 ;;
52                 *)
53                         SERVER_LDFLAGS=-rdynamic
54                         PICFLAGS=-fPIC
55                 ;;
56         esac
57 fi
58 AC_PROG_RANLIB
59 AC_PROG_INSTALL
60 missing_dir=`cd $ac_aux_dir && pwd`
61 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
62
63 dnl Checks for libraries.
64
65 dnl libdl, libgdbm, and libcrypt are only used in the server, so the
66 dnl Makefile only passes $(LIBS) to that target. If other programs start
67 dnl requiring additional libraries, we'll have to use other variables, as is
68 dnl done with curses.
69
70 dnl We want to test for crypt() and dlopen() in libc before checking for
71 dnl -lcrypt and -ldl, because some systems (like Irix) have both.
72 AC_CHECK_FUNCS(crypt dlopen)
73
74 dnl We only need crypt() if we're using autologin. FIXME: implement shadow
75 dnl passwords and/or PAM...
76 if test "$enable_autologin" != no -a "$ac_cv_func_crypt" = no; then
77         AC_CHECK_LIB(crypt, crypt)
78 fi
79
80 dnl Enable autologin if the feature is requested (which is the default) and
81 dnl a crypt() functin is available.
82 if test "$enable_autologin" != no -a \( "$ac_cv_func_crypt" = yes -o "$ac_cv_lib_crypt_crypt" = yes \); then
83         AC_DEFINE(ENABLE_AUTOLOGIN)
84 fi
85
86 if test "$ac_cv_func_dlopen" = no; then
87         AC_CHECK_LIB(dl, dlopen)
88 fi
89
90 AC_CHECK_LIB(gdbm, gdbm_open)
91
92 save_LIBS=$LIBS
93 AC_CHECK_LIB(termcap, tgetent, [LIBS="$LIBS -ltermcap"
94         CURSES=-ltermcap])
95 AC_CHECK_LIB(curses, initscr, CURSES="-lcurses $CURSES")
96 LIBS=$save_LIBS
97
98 dnl Check for libpthread(s) if we're not using Digital UNIX. (On which the
99 dnl -pthread flag takes care of this.)
100 if test "$SERVER_LDFLAGS" != -pthread; then
101         AC_CHECK_LIB(pthread, pthread_create)
102         AC_CHECK_LIB(pthreads, pthread_create)
103 fi
104
105 dnl Checks for header files.
106 AC_HEADER_DIRENT
107 AC_HEADER_STDC
108 AC_HEADER_SYS_WAIT
109 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 pthread.h gdbm.h utmp.h)
110
111 dnl Checks for typedefs, structures, and compiler characteristics.
112 AC_C_CONST
113 AC_TYPE_PID_T
114 AC_TYPE_SIZE_T
115 AC_HEADER_TIME
116 AC_STRUCT_TM
117
118 AC_CACHE_CHECK([for ut_type in struct utmp], ac_cv_struct_ut_type,
119 [AC_TRY_COMPILE([#include <utmp.h>], [struct utmp ut; ut.ut_type;],
120 ac_cv_struct_ut_type=yes, ac_cv_struct_ut_type=no)])
121 if test $ac_cv_struct_ut_type = yes; then
122         AC_DEFINE(HAVE_UT_TYPE)
123 fi
124
125 dnl Checks for library functions.
126 AC_FUNC_GETPGRP
127 AC_PROG_GCC_TRADITIONAL
128 AC_TYPE_SIGNAL
129 AC_FUNC_VPRINTF
130 AC_CHECK_FUNCS(mkdir mkfifo mktime pthread_cancel rmdir select socket strerror)
131 AC_CHECK_FUNC(pthread_create, TARGETS="client server utils serv_modules")
132 AC_REPLACE_FUNCS(snprintf getutline)
133
134 dnl Done! Now write the Makefile and sysdep.h
135 AC_SUBST(SO)
136 AC_SUBST(CURSES)
137 AC_SUBST(TARGETS)
138 AC_SUBST(SERVER_LDFLAGS)
139 AC_SUBST(PICFLAGS)
140 AC_SUBST(SUFFIX)
141 AC_CONFIG_HEADER(sysdep.h)
142 AC_OUTPUT(Makefile weekly)