Renderers cleanup part 2
[citadel.git] / textclient / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.52)
3 AC_INIT([CitadelTextClient],m4_esyscmd_s([grep CLIENT_VERSION src/include/citadel_ipc.h | sed 's/[^0-9]*//g']),[http://uncensored.citadel.org])
4 AC_REVISION([$Revision: 5108 $])
5
6 AC_CONFIG_HEADER(sysdep.h)
7 AC_CONFIG_MACRO_DIR([m4])
8 AC_PREFIX_DEFAULT(/usr/local/citadel)
9 if test "$prefix" = NONE; then
10         AC_DEFINE_UNQUOTED(CTDLDIR, "$ac_default_prefix", [define this to the Citadel home directory])
11         ssl_dir="$ac_default_prefix/keys"
12         localedir=$ac_default_prefix
13 else
14         AC_DEFINE_UNQUOTED(CTDLDIR, "$prefix", [define this to the Citadel home directory])
15         ssl_dir="$prefix/keys"
16         localedir=$prefix
17 fi
18
19 dnl Make sure we see all GNU and Solaris extensions.
20 AC_GNU_SOURCE
21
22
23 dnl Checks for the Datadir
24 AC_ARG_WITH(datadir, 
25                     [  --with-datadir          directory to store the databases under],
26                         [ if test "x$withval" != "xno" ; then
27                                               AC_DEFINE(HAVE_DATA_DIR,[],[use alternate database location?])
28                                               AC_DEFINE_UNQUOTED(DATA_DIR, "$withval",[define, if the user suplied a data-directory to use.])
29                                               MAKE_DATA_DIR=$withval
30                                               AC_SUBST(MAKE_DATA_DIR)
31                           fi
32                         ]
33 )
34
35
36 dnl Checks for the helpDatadir
37 AC_ARG_WITH(helpdir, 
38                     [  --with-helpdir          directory to store the helpfiles under],
39                         [ if test "x$withval" != "xno" ; then
40                                               AC_DEFINE(HAVE_HELP_DIR,[],[use alternate database location?])
41                                               AC_DEFINE_UNQUOTED(HELP_DIR, "$withval",[define, if the user suplied a helpfile-directory to use.])
42                                               MAKE_HELP_DIR=$withval
43                                               AC_SUBST(MAKE_HELP_DIR)
44                           fi
45                         ]
46 )
47
48 dnl Checks for the Static Datadir
49 AC_ARG_WITH(staticdatadir, 
50                     [  --with-staticdatadir    directory to store citadels system messages under],
51                         [ if test "x$withval" != "xno" ; then
52                                                   AC_DEFINE(HAVE_STATICDATA_DIR, [], [should we activate an alternate static text location?])
53                                                   AC_DEFINE_UNQUOTED(STATICDATA_DIR, "$withval", [where do we put our static text data?])
54                                                   MAKE_STATICDATA_DIR=$withval
55                                                   AC_SUBST(MAKE_STATICDATA_DIR)
56                           fi
57                         ]
58 )
59
60
61 dnl Checks for the SSLdir
62 dnl this is a bit different than the rest, 
63 dnl because of the citadel used to have a keys/ subdir.
64 AC_ARG_WITH(ssldir, 
65                     [  --with-ssldir           directory to store the ssl certificates under],
66                         [ if test "x$withval" != "xno" ; then
67                                               
68                                                   ssl_dir="$withval"
69                           fi
70                         AC_SUBST(MAKE_SSL_DIR)
71                         ]
72 )
73 AC_DEFINE_UNQUOTED(SSL_DIR, "$ssl_dir", [were should we put our keys?])
74
75
76 dnl Checks for the spooldir
77 AC_ARG_WITH(spooldir, 
78                         [  --with-spooldir         directory to keep queues under],
79                         [ if test "x$withval" != "xno" ; then
80                                                 AC_DEFINE(HAVE_SPOOL_DIR, [], [enable alternate spool dir?])
81                                                 AC_DEFINE_UNQUOTED(SPOOL_DIR,"$withval", [where do we place our spool dirs?])
82                                                 MAKE_SPOOL_DIR=$withval
83                                                 AC_SUBST(MAKE_SPOOL_DIR)
84                            fi
85                         ]
86 )
87
88
89 dnl Checks for the Configdir
90 AC_ARG_WITH(sysconfdir, 
91                         [  --with-sysconfdir       directory to store the configs under],
92                         [ if test "x$withval" != "xno" ; then
93                                             AC_DEFINE(HAVE_ETC_DIR, [], [should we search our system config in an alternate place?])
94                                                 AC_DEFINE_UNQUOTED(ETC_DIR, "$withval", [where to search our config files])
95                                                 MAKE_ETC_DIR=$withval
96                                                 AC_SUBST(MAKE_ETC_DIR)
97                           fi
98                         ]
99 )
100
101 dnl Checks for the Configdir
102 AC_ARG_WITH(autosysconfdir, 
103                         [  --with-autosysconfdir         directory to store the automaticaly maintained configs under],
104                         [ if test "x$withval" != "xno" ; then
105                                             AC_DEFINE(HAVE_AUTO_ETC_DIR, [], [should we search our automatic config in an alternate place?])
106                                                 AC_DEFINE_UNQUOTED(AUTO_ETC_DIR, "$withval", [where to search our automatic config files])
107                                                 MAKE_AUTO_ETC_DIR=$withval
108                                                 AC_SUBST(MAKE_AUTO_ETC_DIR)
109                           fi
110                         ]
111 )
112
113 dnl Checks for where to put our utilities
114 AC_ARG_WITH(utility-bindir, 
115                         [  --with-utility-bindir   directory where to find helper binaries],
116                         [ if test "x$withval" != "xno" ; then
117                                             AC_DEFINE(HAVE_UTILBIN_DIR,[],[should we put our helper binaries to another location?])
118                                                 AC_DEFINE_UNQUOTED(UTILBIN_DIR, "$withval", [were to put our helper programs])
119                                                 MAKE_UTILBIN_DIR=$withval
120                                                 AC_SUBST(MAKE_UTILBIN_DIR)
121                           fi
122                         ]
123 )
124
125
126 dnl Checks for the run-dir for the sockets
127 AC_ARG_WITH(rundir, 
128                         [  --with-rundir           directory to place runtime files (UDS) to?],
129                         [ if test "x$withval" != "xno" ; then
130                                             AC_DEFINE(HAVE_RUN_DIR, [], [should we put our non volatile files elsewhere?])
131                                                 AC_DEFINE_UNQUOTED(RUN_DIR, "$withval", [define, where the config should go in unix style])
132                                                 MAKE_RUN_DIR=$withval
133                                                 AC_SUBST(MAKE_RUN_DIR)
134                           fi
135                         ]
136 )
137
138
139 dnl Checks for the Pseudo Random Generator sockets TODO: this keeps being default.
140 AC_DEFINE_UNQUOTED(EGD_POOL, "/var/run/egd-pool", [place to keep our pseudo random generator file])
141 AC_ARG_WITH(egdpool, 
142                         [  --with-egdpool          the socket from Pseudo Random Generator, defaults to /var/run/egd-pool],
143                         [ if test "x$withval" != "xno" ; then
144                                                 AC_DEFINE_UNQUOTED(EGD_POOL, "$withval", [the socket from Pseudo Random Generator])
145                           fi
146                         ]
147 )
148
149
150 AC_ARG_WITH(docdir,
151                         [  --with-docdir           where to install the documentation. default: /usr/local/citadel/],
152                         [ if test "x$withval" != "xno" ; then
153                                         MAKE_DOC_DIR=$withval
154                                         AC_SUBST(MAKE_DOC_DIR)
155                           fi
156                         ]
157 )
158
159 dnl where to put the locale files
160 AC_ARG_WITH(localedir, 
161                     [  --with-localedir          directory to put the locale files to],
162                         [ if test "x$withval" != "xno" ; then
163                             localedir=$withval
164                           fi
165                         ]
166 )
167 AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir",[where to find our pot files])
168 LOCALEDIR=$localedir
169 AC_SUBST(LOCALEDIR)
170
171
172
173 dnl Checks for the zlib compression library.
174 saved_CFLAGS="$CFLAGS"
175 CFLAGS="$CFLAGS"
176 AC_CHECK_HEADER(zlib.h,
177         [AC_CHECK_LIB(z, zlibVersion,
178                 [
179                         LIBS="-lz $LIBS"
180                 ],
181                 [
182                         AC_MSG_ERROR(zlib was not found or is not usable.  Please install zlib.)
183                 ]
184         ,
185         )],
186         [
187                 AC_MSG_ERROR(zlib.h was not found or is not usable.  Please install zlib.)
188         ]
189 )
190 CFLAGS="$saved_CFLAGS"
191
192 dnl Here is the check for a libc integrated iconv
193 AC_ARG_ENABLE(iconv,
194         [  --disable-iconv         do not use iconv charset conversion],
195         ok_iconv=no, ok_iconv=yes)
196
197 AC_MSG_CHECKING(Checking to see if your system supports iconv)
198 AC_TRY_RUN([
199         #include <iconv.h>
200         main() {
201                 iconv_t ic = (iconv_t)(-1) ;
202                 ic = iconv_open("UTF-8", "us-ascii");
203                 iconv_close(ic);
204                 exit(0);
205         }
206  ],
207                 [
208                   ok_iconv=yes
209                   AC_MSG_RESULT([yes])
210                 ],
211                 [ 
212                   ok_iconv=no
213                   AC_MSG_RESULT([no])
214                 ]
215 )
216
217 dnl Check for iconv in external libiconv
218 if test "$ok_iconv" = no; then
219         AC_MSG_CHECKING(Checking for an external libiconv)
220         OLD_LDFLAGS="$LDFLAGS"
221         LDFLAGS="$LDFLAGS -liconv"
222         AC_TRY_RUN([
223                         #include <iconv.h>
224                         main() {
225                                 iconv_t ic = (iconv_t)(-1) ;
226                                 ic = iconv_open("UTF-8", "us-ascii");
227                                 iconv_close(ic);
228                         }
229                 ],
230                         [
231                           ok_iconv=yes
232                           AC_MSG_RESULT([yes])
233                         ],
234                         [ 
235                           ok_iconv=no
236                           LDFLAGS="$OLD_LDFLAGS"
237                           AC_MSG_RESULT([no])
238                         ]
239                 )
240 fi      
241 if test "$ok_iconv" != "no"; then
242         AC_MSG_RESULT(Citadel will be built with character set conversion.)
243         AC_DEFINE(HAVE_ICONV,[],[whether we have iconv for charset conversion])
244 else
245         AC_MSG_RESULT(Citadel will be built without character set conversion.)
246 fi
247
248 AC_CHECK_LIB(intl, libintl_bindtextdomain, [LDFLAGS="$LDFLAGS -lintl"])
249
250
251
252 AC_ARG_ENABLE(threaded-client, [  --disable-threaded-client
253                           disable multithreaded client])
254
255 AC_ARG_ENABLE(pie, [  --enable-pie            build position-independent executables])
256
257 AC_ARG_WITH(pam, [  --with-pam              use PAM if present (see PAM.txt before you try this)])
258 AC_ARG_WITH(kthread, [  --with-kthread          use kernel threads (on FreeBSD) (not recommended yet)])
259
260 AC_ARG_WITH(ssl,
261         [  --with-ssl=PATH         Specify path to OpenSSL installation ],
262         [
263                 if test "x$withval" != "xno" ; then
264                         tryssldir=$withval
265                 fi
266         ]
267 )
268
269
270 dnl By default, we only build the client (citadel and whobbs) unless we can
271 dnl figure out how to build with POSIX threads.
272 TARGETS=client
273
274 AC_CANONICAL_HOST
275 PTHREAD_DEFS=-D_REENTRANT
276 AC_MSG_CHECKING([how to compile with POSIX threads])
277 case "$host" in
278         dnl BSDI 3.0 wants relocatable object modules instead of shared libs
279         dnl for dlopen(), and has a wrapper script to link with shared libs.
280         dnl Also has stupid non-reentrant gethostbyaddr() and friends.
281         *-*-bsdi[123]*)
282                 test -z "$CC" -a -x /usr/bin/shlicc2 && CC=shlicc2
283                 AC_DEFINE(HAVE_NONREENTRANT_NETDB,[], [define this if the OS has broken non-reentrant gethostby{name,addr}() ])
284                 AC_MSG_RESULT([Old BSDI])
285         ;;
286         *-*-bsdi*)
287                 AC_DEFINE(HAVE_NONREENTRANT_NETDB, [], [define this if the OS has broken non-reentrant gethostby{name,addr}() ])
288                 AC_MSG_RESULT([BSD/OS])
289         ;;
290         dnl Curses support on Mac OS X is kind of screwed at the moment.
291         dnl TCP buffering isn't ideal under OS X. This define should also be
292         dnl checked in other cases of OS X-Linux differences.
293         *-*-darwin*)
294                 AC_DEFINE(HAVE_DARWIN, [], [define if using OS X/Darwin])
295                 AC_MSG_RESULT([Mac OS X])
296         ;;
297         dnl Digital Unix has an odd way to build for pthreads, and we can't
298         dnl build pthreads programs with gcc due to header problems.
299         alpha*-dec-osf*)
300                 test -z "$CC" && CC=cc
301                 LIBS="-lpthread -lexc $LIBS"
302                 check_pthread=no
303                 AC_MSG_RESULT([Tru64 or Digital UNIX])
304         ;;
305         dnl FreeBSD is similar to Digital UNIX with DEC C, which has a -pthread flag:
306         *-*-freebsd*)
307                 if test "$with_kthread" = yes; then
308                         LIBS="-kthread $LIBS"
309                 else
310                         LIBS="-pthread $LIBS"
311                 fi
312                 check_pthread=no
313                 PTHREAD_DEFS=-D_THREAD_SAFE
314                 AC_MSG_RESULT([FreeBSD])
315         ;;
316         *-*-openbsd*)
317                 LIBS="-pthread $LIBS"
318                 check_pthread=no
319                 PTHREAD_DEFS=-pthread
320                 AC_MSG_RESULT([OpenBSD])
321         ;;
322         *-*-linux*)
323                 PTHREAD_DEFS="-D_REENTRANT -pthread"
324                 AC_MSG_RESULT([Linux])
325         ;;
326         *-*-solaris*)
327                 PTHREAD_DEFS="-D_REENTRANT -D_PTHREADS"
328                 AC_MSG_RESULT([Solaris])
329         ;;
330         *-*-cygwin*)
331                 SERVER_LDFLAGS="-Wl,-subsystem,windows"
332                 AC_MSG_RESULT([Cygwin])
333         ;;
334         *)
335                 AC_MSG_RESULT([default])
336         ;;
337 esac
338 dnl DEFS="$DEFS $PTHREAD_DEFS"
339
340
341 dnl Checks for programs.
342 AC_PROG_CC
343
344
345
346 dnl Set up system-dependent compiler flags.
347 if test "$GCC" = yes; then
348         if test "$CC" = icc; then
349                 CFLAGS="$CFLAGS -w1"
350         else
351                 case "$host" in
352                         *-*-solaris*|alpha*-dec-osf*)
353                                 CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wno-char-subscripts $PTHREAD_DEFS"
354                         ;;
355                         *)
356                         CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wstrict-prototypes -Wno-strict-aliasing $PTHREAD_DEFS"
357                         ;;
358                 esac
359         fi
360 fi
361
362 if test "x$enable_pie" = xyes; then
363         save_CFLAGS="$CFLAGS"
364         save_LDFLAGS="$LDFLAGS"
365         CFLAGS="$CFLAGS -fpie"
366         LDFLAGS="$LDFLAGS -pie -fpie"
367         AC_CACHE_CHECK([whether compiler accepts -pie -fpie], ac_cv_pie_fpie,
368         [AC_TRY_LINK([], [],
369         ac_cv_pie_fpie=yes, ac_cv_pie_fpie=no)])
370         if test $ac_cv_pie_fpie = no; then
371                 CFLAGS="$save_CFLAGS"
372                 LDFLAGS="$save_LDFLAGS"
373         fi
374 fi
375
376 AC_MSG_CHECKING([how to create dependancy checks])
377                  if test -n "`$CC -V 2>&1 |grep Sun`"; then 
378                         DEPEND_FLAG=-xM;
379                  else 
380                         DEPEND_FLAG=-M
381                  fi
382 AC_SUBST(DEPEND_FLAG)
383
384
385 AC_PROG_INSTALL
386 AC_PROG_YACC
387 AC_PATH_PROG(DIFF,diff)
388 AC_PATH_PROG(PATCH,patch)
389 missing_dir=`cd $ac_aux_dir && pwd`
390 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
391 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
392
393 dnl Checks for system services.
394
395 dnl Check the size of various builtin types; see typesize.h (error)
396 AC_CHECK_SIZEOF(char, 0)
397 AC_CHECK_SIZEOF(short, 0)
398 AC_CHECK_SIZEOF(int, 0)
399 AC_CHECK_SIZEOF(long, 0)
400 AC_CHECK_SIZEOF(size_t, 0)
401 dnl AC_CHECK_SIZEOF(long long, 0)
402
403 dnl Checks for libraries.
404
405 dnl We want to test for the following in libc before checking for their
406 dnl respective libraries, because some systems (like Irix) have both, and the
407 dnl non-libc versions may be broken.
408 AC_CHECK_FUNCS(crypt gethostbyname connect flock getpwnam_r getpwuid_r getloadavg)
409
410 AC_CHECK_FUNCS(strftime_l uselocale gettext)
411
412 if test "$ok_nls" != "no"; then
413         AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
414         ok_nls=$ok_xgettext
415 fi
416
417 if test "$ok_nls" != "no"; then
418         AC_CHECK_PROG(ok_msgmerge, msgmerge, yes, no)
419         ok_nls=$ok_msgmerge
420 fi
421
422 if test "$ok_nls" != "no"; then
423         AC_CHECK_PROG(ok_msgfmt, msgfmt, yes, no)
424         ok_nls=$ok_msgfmt
425 fi
426
427 if test "$ok_nls" != "no"; then
428         AC_MSG_RESULT(citadel will be built with national language support.)
429         AC_DEFINE(ENABLE_NLS, [], [whether we have NLS support])
430         PROG_SUBDIRS="$PROG_SUBDIRS po/citadel-setup"
431 else
432         AC_MSG_RESULT(citadel will be built without national language support.)
433 fi
434
435 dnl disable backtrace if we don't want it.
436 AC_ARG_WITH(backtrace, 
437                     [  --with-backtrace        enable backtrace dumps in the syslog],
438                         [ if test "x$withval" != "xno" ; then
439                              CFLAGS="$CFLAGS  -rdynamic "
440                              LDFLAGS="$LDFLAGS  -rdynamic "
441                              AC_CHECK_FUNCS(backtrace)
442                           fi
443                         ]
444 )
445
446 dnl disable backtrace if we don't want it.
447 AC_ARG_WITH(gprof, 
448                     [  --with-gprof            enable profiling],
449                         [ if test "x$withval" != "xno" ; then
450                              CFLAGS="$CFLAGS  -pg "
451                              LDFLAGS="$LDFLAGS  -pg "
452                           fi
453                         ]
454 )
455
456 if test "$ac_cv_func_gethostbyname" = no; then
457         AC_CHECK_LIB(nsl, gethostbyname)
458 fi
459
460 if test "$ac_cv_func_connect" = no; then
461         AC_CHECK_LIB(socket, connect)
462 fi
463
464 dnl Check for Solaris realtime support
465 AC_CHECK_LIB(rt, sched_yield)
466
467 AC_CHECK_FUNCS(vw_printw wcolor_set resizeterm wresize)
468
469 dnl Check for libpthread(s) if we're not using Digital UNIX or FreeBSD. (On
470 dnl which the -pthread flag takes care of this.)
471 if test "$check_pthread" != no; then
472         AC_CHECK_LIB(pthread, pthread_create)
473         AC_CHECK_LIB(pthreads, pthread_create)
474 fi
475
476 test -d /usr/kerberos/include && CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
477
478
479 saved_CFLAGS="$CFLAGS"
480 CFLAGS="$CFLAGS"
481 dnl Check for libcitadel
482 AC_CHECK_HEADER(libcitadel.h,
483         [AC_CHECK_LIB(citadel, libcitadel_version_string,
484                 [
485                         LIBS="-lcitadel $LIBS"
486                 ],
487                 [
488                         AC_MSG_ERROR(libcitadel was not found or is not usable.  Please install libcitadel.)
489                 ]
490         ,
491         )],
492         [
493                 AC_MSG_ERROR(libcitadel.h was not found or is not usable.  Please install libcitadel.)
494         ]
495 )
496
497 CFLAGS="$saved_CFLAGS"
498
499 saved_CFLAGS="$CFLAGS"
500 CFLAGS="$CFLAGS "
501 dnl Check for libcitadelclient
502 dnl AC_CHECK_HEADER(citadel_ipc.h,
503 dnl     [AC_CHECK_LIB(citadelclient, libcitadelclient_version_string,
504 dnl             [
505 dnl                     LIBS="-lcitadelclient $LIBS "
506 dnl             ],
507 dnl             [
508 dnl                     AC_MSG_ERROR(libcitadelclient was not found or is not usable.  Please install libcitadelclient.)
509 dnl             ]
510 dnl     ,
511 dnl     )],
512 dnl     [
513 dnl             AC_MSG_ERROR(citadel_ipc.h was not found or is not usable.  Please install libcitadelclient.)
514 dnl     ]
515 dnl )
516 dnl 
517 dnl CFLAGS="$saved_CFLAGS"
518
519
520 # The big search for OpenSSL
521 if test "$with_ssl" != "no"; then
522         saved_LIBS="$LIBS"
523         saved_LDFLAGS="$LDFLAGS"
524         saved_CFLAGS="$CFLAGS"
525         if test "x$prefix" != "xNONE"; then
526                 tryssldir="$tryssldir $prefix"
527         fi
528         AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
529                 for ssldir in $tryssldir "" /usr /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
530                         CFLAGS="$saved_CFLAGS"
531                         LDFLAGS="$saved_LDFLAGS"
532                         LIBS="$saved_LIBS -lssl -lcrypto"
533         
534                         # Skip directories if they don't exist
535                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
536                                 continue;
537                         fi
538                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
539                                 # Try to use $ssldir/lib if it exists, otherwise
540                                 # $ssldir
541                                 if test -d "$ssldir/lib" ; then
542                                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
543                                         if test ! -z "$need_dash_r" ; then
544                                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
545                                         fi
546                                 else
547                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
548                                         if test ! -z "$need_dash_r" ; then
549                                                 LDFLAGS="-R$ssldir $LDFLAGS"
550                                         fi
551                                 fi
552                                 # Try to use $ssldir/include if it exists, otherwise
553                                 # $ssldir
554                                 if test -d "$ssldir/include" ; then
555                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
556                                 else
557                                         CFLAGS="-I$ssldir $saved_CFLAGS"
558                                 fi
559                         fi
560         
561                         # Basic test to check for compatible version and correct linking
562                         # *does not* test for RSA - that comes later.
563                         AC_TRY_RUN(
564                                 [
565         #include <string.h>
566         #include <openssl/rand.h>
567         int main(void)
568         {
569                 char a[2048];
570                 memset(a, 0, sizeof(a));
571                 RAND_add(a, sizeof(a), sizeof(a));
572                 return(RAND_status() <= 0);
573         }
574                                 ],
575                                 [
576                                         found_crypto=1
577                                         break;
578                                 ], []
579                         )
580         
581                         if test ! -z "$found_crypto" ; then
582                                 break;
583                         fi
584                 done
585         
586                 if test -z "$ssldir" ; then
587                         ssldir="(system)"
588                 fi
589         
590                 if test ! -z "$found_crypto" ; then
591                         ac_cv_openssldir=$ssldir
592                 else
593                         ac_cv_openssldir="no"
594                 fi
595         ])
596         LIBS="$saved_LIBS"
597         LDFLAGS="$saved_LDFLAGS"
598         CFLAGS="$saved_CFLAGS"
599         
600         if test "x$ac_cv_openssldir" != "xno" ; then
601                 AC_DEFINE(HAVE_OPENSSL, [], [Define if you have OpenSSL.])
602                 LIBS="-lssl -lcrypto $LIBS"
603                 dnl Need to recover ssldir - test above runs in subshell
604                 ssldir=$ac_cv_openssldir
605                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
606                         # Try to use $ssldir/lib if it exists, otherwise
607                         # $ssldir
608                         if test -d "$ssldir/lib" ; then
609                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
610                                 if test ! -z "$need_dash_r" ; then
611                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
612                                 fi
613                         else
614                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
615                                 if test ! -z "$need_dash_r" ; then
616                                         LDFLAGS="-R$ssldir $LDFLAGS"
617                                 fi
618                         fi
619                         # Try to use $ssldir/include if it exists, otherwise
620                         # $ssldir
621                         if test -d "$ssldir/include" ; then
622                                 CFLAGS="-I$ssldir/include $saved_CFLAGS"
623                         else
624                                 CFLAGS="-I$ssldir $saved_CFLAGS"
625                         fi
626                 fi
627         fi
628 fi
629
630
631
632
633
634
635
636 dnl Checks for header files.
637 AC_HEADER_DIRENT
638 AC_HEADER_STDC
639 AC_HEADER_SYS_WAIT
640
641 dnl
642 dnl TODO: for the DB header checks, we should check whether the headers
643 dnl define db_env_create, somehow
644 dnl
645 AC_CHECK_HEADERS(dl.h fcntl.h limits.h malloc.h termios.h sys/ioctl.h sys/select.h sys/stat.h sys/time.h sys/prctl.h syslog.h unistd.h paths.h db.h db4/db.h pthread.h netinet/in.h arpa/nameser.h arpa/nameser_compat.h syscall.h sys/syscall.h)
646
647 AC_CHECK_HEADER(resolv.h,AC_DEFINE(HAVE_RESOLV_H, [], [define this if you have the resolv.h header file.]),,
648 [#ifdef HAVE_SYS_TYPES_H
649 #include <sys/types.h>
650 #endif
651 #ifdef HAVE_NETINET_IN_H
652 #include <netinet/in.h>
653 #endif
654 #ifdef HAVE_ARPA_NAMESER_H
655 #include <arpa/nameser.h>
656 #endif])
657
658
659 dnl Checks for typedefs, structures, and compiler characteristics.
660 AC_C_CONST
661 AC_TYPE_PID_T
662 AC_TYPE_SIZE_T
663 AC_HEADER_TIME
664
665 dnl defined in acinclude.m4:
666 CIT_STRUCT_TM
667
668 AC_CACHE_CHECK(
669         [for call semantics from getpwuid_r], 
670         ac_cv_call_getpwuid_r,
671         [AC_TRY_COMPILE([#include <sys/types.h>
672 #include <pwd.h>], 
673                          [
674                                 struct passwd pw, *pwp;
675                                 char pwbuf[64];
676                                 uid_t uid;
677
678                                 getpwuid_r(uid, &pw, pwbuf, sizeof(pwbuf), &pwp);
679                         ],
680                         ac_cv_call_getpwuid_r=yes, 
681                         ac_cv_call_getpwuid_r=no)
682         ])
683
684 if test $ac_cv_call_getpwuid_r = no; then
685         AC_DEFINE(SOLARIS_GETPWUID,[],[do we need to use solaris call syntax?])
686         AC_DEFINE(F_UID_T, "%ld", [whats the matching format string for uid_t?])
687         AC_DEFINE(F_PID_T, "%ld",  [whats the matching format string for pid_t?])
688         AC_DEFINE(F_XPID_T, "%lx",  [whats the matching format string for xpid_t?])
689 else
690         AC_DEFINE(F_UID_T, "%d",  [whats the matching format string for uid_t?])
691         AC_DEFINE(F_PID_T, "%d",  [whats the matching format string for pid_t?])
692         AC_DEFINE(F_XPID_T, "%x",  [whats the matching format string for xpid_t?])
693 fi
694
695
696 dnl Our own happy little check for the resolver library.
697
698 case "`uname -a`" in 
699  OpenBSD*)
700         echo "we don't need to check for resolv on openbsd"  
701         ;;
702  FreeBSD*)
703         echo "we don't need to check for resolv on freeBSD"  
704         ;;
705  *)
706         test -f /usr/local/lib/libresolv.a && LDFLAGS="$LDFLAGS -L/usr/local/lib"
707         AC_CHECK_LIB(resolv, res_query,
708                 RESOLV="$RESOLV -lresolv",
709                 [dnl Have to include resolv.h as res_query is sometimes defined as a macro
710                         AC_MSG_CHECKING([for res_query in -lresolv (with resolv.h if present)])
711                         saved_libs="$LIBS"
712                         LIBS="-lresolv $LIBS"
713                         AC_TRY_LINK([
714                                 #ifdef HAVE_RESOLV_H
715                                 #include <resolv.h>
716                                 #endif],
717                                 [res_query(0,0,0,0,0)],
718                                 [AC_MSG_RESULT(yes)
719                                                 have_res_query=yes],
720                                 [AC_MSG_RESULT(no)
721                                         AC_MSG_ERROR(libresolv was not found.  Citadel requires the resolver library.)
722                                 ])
723          ]
724         )
725         ;;
726 esac
727
728
729
730 dnl Checks for library functions.
731 AC_FUNC_GETPGRP
732 AC_PROG_GCC_TRADITIONAL
733 AC_TYPE_SIGNAL
734 AC_FUNC_VPRINTF
735 AC_CHECK_FUNCS(getspnam mkdir mkfifo mktime rmdir select socket strerror strcasecmp strncasecmp)
736
737 dnl Now check for pthreads
738
739 dnl On some platforms, AC_CHECK_FUNC[S] doesn't work for pthreads programs;
740 dnl we need to include pthread.h
741
742 AC_CACHE_CHECK([for pthread_cancel], ac_cv_func_pthread_cancel,
743 [AC_TRY_LINK([#include <pthread.h>],
744 [       pthread_t thread;
745
746         /* The GNU C library defines this for functions which it implements
747            to always fail with ENOSYS.  Some functions are actually named
748            something starting with __ and the normal name is an alias.  */
749 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
750         choke me
751 #else
752         pthread_cancel(thread);
753 #endif],
754 ac_cv_func_pthread_cancel=yes, ac_cv_func_pthread_cancel=no)])
755 if test "$ac_cv_func_pthread_cancel" = yes; then
756         AC_DEFINE(HAVE_PTHREAD_CANCEL, [], [define this if you have the pthread_cancel() function])
757 fi
758
759 AC_CACHE_CHECK([for pthread_create], ac_cv_func_pthread_create,
760 [AC_TRY_LINK([#include <pthread.h>],
761 [       /* The GNU C library defines this for functions which it implements
762            to always fail with ENOSYS.  Some functions are actually named
763            something starting with __ and the normal name is an alias.  */
764 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
765         choke me
766 #else
767         pthread_create(NULL, NULL, NULL, NULL);
768 #endif],
769 ac_cv_func_pthread_create=yes, ac_cv_func_pthread_create=no)])
770 if test "$ac_cv_func_pthread_create" = yes; then
771         test "$DATABASE" && TARGETS="client server utils"
772         if test "x$enable_threaded_client" != xno; then
773                 AC_DEFINE(THREADED_CLIENT, [], [define this if you want to enable the multithreaded client])
774         fi
775 fi
776
777 AC_REPLACE_FUNCS(snprintf getutline)
778
779 AC_CACHE_CHECK([the weather], ac_cv_weather, [
780         sleep 1
781         echo $ECHO_N "opening your window... $ECHO_C" >&6
782         sleep 2
783         month=`date | cut -f 2 -d ' '`
784         case $month in
785         Dec | Jan | Feb)
786                 ac_cv_weather="it's cold!"
787                 ;;
788         Mar | Apr)
789                 ac_cv_weather="it's wet!"
790                 ;;
791         Jul | Aug)
792                 ac_cv_weather="it's hot!"
793                 ;;
794         Oct | Nov)
795                 ac_cv_weather="it's cool"
796                 ;;
797         May | Jun | Sep | *)
798                 ac_cv_weather="it's fine"
799                 ;;
800         esac
801         ])
802
803
804
805
806 AC_CACHE_CHECK([under the bed], ac_cv_under_the_bed, [
807         number=`date | cut -c 19`
808         case $number in
809         7)
810                 ac_cv_under_the_bed="lunatics and monsters found"
811                 ;;
812         *)
813                 ac_cv_under_the_bed="dust bunnies found"
814                 ;;
815         esac
816         ])
817
818
819 dnl Done! Now write the Makefile and sysdep.h
820 AC_SUBST(RESOLV)
821 AC_SUBST(TARGETS)
822 AC_SUBST(DIFF)
823 AC_SUBST(PATCH)
824 AC_CONFIG_FILES([Makefile])
825 AC_OUTPUT()
826
827
828 abs_srcdir="`cd $srcdir && pwd`"
829 abs_builddir="`pwd`"
830 if test "$abs_srcdir" != "$abs_builddir"; then
831    ln -sf $abs_srcdir/include $abs_builddir
832    ln -sf $abs_srcdir/Make_sources $abs_builddir
833    ln -sf $abs_srcdir/Make_modules $abs_builddir
834    for i in $abs_srcdir/*.h ; do
835       if test "$abs_srcdir/sysdep.h" != "$i"; then
836          ln -sf $i $abs_builddir
837       fi
838    done
839    for d in `/bin/ls $abs_srcdir/modules/`; do 
840         (mkdir -p $abs_builddir/modules/$d) 
841    done
842    if test -d "$abs_srcdir/user_modules/"; then
843       for d in `/bin/ls $abs_srcdir/user_modules/`; do 
844         (mkdir -p $abs_builddir/user_modules/$d) 
845         done
846    fi
847    mkdir -p $abs_builddir/utils
848    mkdir -p $abs_builddir/utillib
849    mkdir -p $abs_builddir/textclient
850 fi
851
852 if test -n "$srcdir"; then 
853    export srcdir=.
854 fi
855
856
857 echo ------------------------------------------------------------------------
858 echo 'Character set conversion support:' $ok_iconv
859 echo 
860 echo 'Note: if you are not using Linux, make sure you are using GNU make'
861 echo '(gmake) to compile Citadel.'
862 echo