1
2AC_PREREQ(2.59)
3AC_INIT(source/irc.c)
4AC_CONFIG_HEADER(include/defs.h)
5
6dnl configure.in for ScrollZ
7dnl
8dnl Copyright (c) 1993-2002 Matthew R. Green.
9dnl All rights reserved.
10dnl
11dnl Redistribution and use in source and binary forms, with or without
12dnl modification, are permitted provided that the following conditions
13dnl are met:
14dnl 1. Redistributions of source code must retain the above copyright
15dnl    notice, this list of conditions and the following disclaimer.
16dnl 2. Redistributions in binary form must reproduce the above copyright
17dnl    notice, this list of conditions and the following disclaimer in the
18dnl    documentation and/or other materials provided with the distribution.
19dnl 3. The name of the author may not be used to endorse or promote products
20dnl    derived from this software without specific prior written permission.
21dnl
22dnl THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
23dnl IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24dnl OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25dnl IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26dnl INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27dnl BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28dnl LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29dnl AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30dnl OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32dnl SUCH DAMAGE.
33dnl
34dnl certain portions have other attributions, see below.
35dnl
36dnl thanks to the screen 3.3 configure.in for giving me examples to
37dnl work from and steal ;)
38dnl
39dnl @(#)$Id: configure.in,v 1.56 2009-12-21 14:56:02 f Exp $
40
41# So many systems seem to need this that it is better do it here automatically.
42if test "x$prefix" != xNONE; then
43  if test -d "$prefix/lib"; then
44    LIBS="-L${prefix}/lib $LIBS"
45  fi
46else
47  if test -d "$ac_default_prefix/lib"; then
48    LIBS="-L${ac_default_prefix}/lib $LIBS"
49  fi
50fi
51
52dnl
53dnl grok the version number - from source/irc.c
54dnl
55
56VERSION=`sed -n -e 's/"$//' -e '/#define[ 	]*SCROLLZ_VERSION[ 	]*"/s///p' -e '/#define SCROLLZ_VERSION/q' < ${srcdir}/source/irc.c`
57IRCIIVERSION=`sed -n -e 's/"[[^"]]*$//' -e '/^#define[ 	]*IRCII_VERSION[ 	]*"/s///p' -e '/^#define IRCII_VERSION/q' < ${srcdir}/source/irc.c`
58echo this is ScrollZ version $VERSION + ircII version $IRCIIVERSION
59echo
60AC_SUBST(VERSION)
61
62CATEGORIES='build change-request doc pending runtime'
63AC_SUBST(CATEGORIES)
64
65dnl so that the generated configure has an id.
66echo '$Id: configure.in,v 1.56 2009-12-21 14:56:02 f Exp $' > /dev/null
67
68dnl
69dnl initial stuff
70dnl
71
72AC_PROG_CC
73AC_PROG_CPP
74AC_ISC_POSIX
75
76dnl
77dnl setup variables
78dnl
79srcdir=`(cd $srcdir; pwd)`
80AC_SUBST(srcdir)
81objdir=`pwd`
82AC_SUBST(objdir)
83
84ifdef([AC_PROG_EGREP],[AC_PROG_EGREP],[])
85
86dnl
87dnl check for NeXT.. and -bsd switch
88dnl
89
90AC_MSG_CHECKING(for NeXT)
91AC_EGREP_CPP(yes,
92[#if defined(NeXT) || defined(__NeXT) || defined(__NeXT__)
93  yes
94#endif
95],nextstep=1)
96
97if test -n "$nextstep"; then
98  AC_MSG_RESULT(yes)
99else
100  AC_MSG_RESULT(no)
101fi
102
103dnl AC_AIX is broken.  blah.
104
105AC_MSG_CHECKING(for AIX)
106AC_EGREP_CPP(yes,
107[
108#ifdef _AIX
109  yes
110#endif
111],AC_MSG_RESULT(yes)
112  aix=1
113  AC_DEFINE(_ALL_SOURCE),
114  AC_MSG_RESULT(no))
115
116AC_PROG_GCC_TRADITIONAL
117AC_CHECK_LIB(sun, getpwnam)
118
119AC_MSG_CHECKING(for qnx)
120case "`uname -s`" in
121dnl bleck - wish i could ditch this qnx test, but we need to bump the stack
122  QNX*)
123    AC_MSG_RESULT(yes)
124    if test -z "$GCC"; then
125      LDFLAGS="-N256k -M"
126      CFLAGS="-w4 -Otax -zc -Wc,-fr= -Wc,-wcd=121"
127    fi
128    ;;
129  *)
130    AC_MSG_RESULT(no)
131esac
132
133AC_MSG_CHECKING(for solaris)
134if /bin/sun 2> /dev/null
135then
136  uname=`uname -r`
137  case "$uname" in
138    4.*)
139      AC_MSG_RESULT(no)
140      sunos4=1
141      ;;
142    5.*)
143      svr4=1
144      ;;
145  esac
146else
147  AC_MSG_RESULT(no)
148  AC_MSG_CHECKING(for SVR4)
149  AC_EGREP_CPP(yes,
150[#if defined(SVR4) || defined(__svr4__) || defined(__SVR4)
151  yes
152#endif
153],svr4=1)
154fi
155
156if test -n "$svr4"
157then
158  AC_MSG_RESULT(yes)
159  LIBS="-L/usr/ccs/lib $LIBS"
160else
161  if test ! -n "$sunos4"
162  then
163    AC_MSG_RESULT(no)
164  fi
165fi
166
167dnl
168dnl testing for svr3/wollengong tcp's /usr/netinclude
169dnl
170
171AC_MSG_CHECKING(for -I/usr/netinclude)
172if test -d /usr/netinclude; then
173  AC_MSG_RESULT(yes)
174  CFLAGS="$CFLAGS -I/usr/netinclude"
175else
176  AC_MSG_RESULT(no)
177fi
178
179dnl
180dnl check for hpux, and hpux version
181dnl
182
183AC_MSG_CHECKING(for hpux version)
184if test -f /hp-ux -o -f /stand/vmunix; then
185  AC_MSG_RESULT(yes)
186  hpux=1
187  uname=`uname -r` 2> /dev/null
188  case $uname in
189	A.09* | A.9* | a.9* | a.09* | 9* | 09* | B.09*)
190		;;
191	A.08* | A.8* | a.8* | a.08* | 8* | 08*)
192		AC_DEFINE(HPUX8)
193		;;
194	A.07* | A.B7* | A.7* | a.7* | a.07* | 7* | 07*)
195		AC_DEFINE(HPUX7)
196		;;
197	*)
198		AC_DEFINE(HPUXUNKNOWN)
199		;;
200  esac
201else
202  AC_MSG_RESULT(no)
203fi
204
205AC_MSG_CHECKING(for ultrix)
206AC_EGREP_CPP(yes,
207[#if defined(ultrix) || defined(__ultrix) || defined(__ultrix)
208  yes
209#endif
210], ultrix=1)
211if test -n "$ultrix"; then
212  AC_MSG_RESULT(yes)
213  test -z "$GCC" && CC="$CC -YBSD"
214else
215  AC_MSG_RESULT(no)
216fi
217
218AC_MSG_CHECKING(for sequent/ptx)
219AC_EGREP_CPP(yes,
220[#ifdef _SEQUENT_
221  yes
222#endif
223], LIBS="$LIBS -lseq" seqptx=1)
224
225if test -n "$seqptx"; then
226  AC_MSG_RESULT(yes)
227else
228  AC_MSG_RESULT(no)
229fi
230
231
232AC_MSG_CHECKING(whether to enable UTF-8 (iconv) support)
233AC_ARG_ENABLE(utf8,
234[  --disable-utf8          Disable UTF-8 (iconv) support],
235[ case "$enableval" in
236  no) AC_MSG_RESULT(no)
237      ;;
238  *) AC_MSG_RESULT(yes)
239     ;;
240  esac ],
241[ AC_MSG_RESULT(yes)
242  enable_utf8=yes
243])
244
245dnl check for FreeBSD, so we can find iconv.h in /usr/local/include
246AC_MSG_CHECKING(for FreeBSD)
247case "`uname -s`" in
248  FreeBSD*)
249    AC_MSG_RESULT(yes)
250    CFLAGS="$CFLAGS -I/usr/local/include"
251    CPPFLAGS="$CPPFLAGS -I/usr/local/include"
252    LIBS="$LIBS -L/usr/local/lib"
253    freebsd=1
254    ;;
255  *)
256    AC_MSG_RESULT(no)
257esac
258
259dnl check for OpenBSD, so we can find iconv.h in /usr/local/include
260AC_MSG_CHECKING(for OpenBSD)
261case "`uname -s`" in
262  OpenBSD*)
263    AC_MSG_RESULT(yes)
264    CFLAGS="$CFLAGS -I/usr/local/include"
265    CPPFLAGS="$CPPFLAGS -I/usr/local/include"
266    LIBS="$LIBS -L/usr/local/lib"
267    openbsd=1
268    ;;
269  *)
270    AC_MSG_RESULT(no)
271esac
272
273dnl check for IRIX, so we can find iconv.h in /usr/nekoware/include
274AC_MSG_CHECKING(for IRIX)
275case "`uname -s`" in
276  IRIX*)
277    AC_MSG_RESULT(yes)
278    CFLAGS="$CFLAGS -I/usr/nekoware/include"
279    CPPFLAGS="$CPPFLAGS -I/usr/nekoware/include"
280    LIBS="$LIBS -L/usr/nekoware/lib"
281    freebsd=1
282    ;;
283  *)
284    AC_MSG_RESULT(no)
285esac
286
287if test "x$enable_utf8" = "xyes" ; then
288  if test -n "$freebsd"; then
289     case "`uname -r`" in
290       10.*)
291         ;;
292       *)
293         LIBS="$LIBS -liconv"
294         ;;
295     esac
296  fi
297  if test -n "$openbsd"; then
298     LIBS="$LIBS -liconv"
299  fi
300fi
301
302AC_CHECK_HEADERS(sys/un.h sys/select.h sys/fcntl.h sys/ioctl.h sys/file.h sys/time.h sys/wait.h sys/twg_config.h sys/ptem.h sys/uio.h)dnl sys/ ones
303AC_CHECK_HEADERS(unistd.h fcntl.h string.h memory.h netdb.h limits.h)dnl non sys/ ones
304AC_CHECK_HEADERS(stdarg.h varargs.h, break)dnl look for varadic function header
305AC_CHECK_HEADERS(process.h termcap.h)dnl others
306
307if test "x$enable_utf8" = "xyes" ; then
308AC_CHECK_HEADERS(iconv.h)
309fi
310
311if test -n "$ultrix" -o -n "$nextstep"; then
312  # POSIX termios is broken on Ultrix so don't look for it.
313  # NEXTSTEP POSIX is broken so don't look for it.
314  AC_CHECK_HEADERS(termio.h sgtty.h, break)dnl sigh.
315else
316  AC_CHECK_HEADERS(termios.h termio.h sgtty.h, break)dnl sigh.
317fi
318
319AC_CHECK_FUNC(fchmod,, AC_DEFINE(NEED_FCHMOD))
320AC_CHECK_FUNC(getcwd,, AC_DEFINE(NEED_GETCWD))
321AC_CHECK_FUNC(getpgid, AC_DEFINE(HAVE_GETPGID),)
322AC_CHECK_FUNC(getsid, AC_DEFINE(HAVE_GETSID),)
323AC_CHECK_FUNC(getloadavg, AC_DEFINE(HAVEGETLOADAVG),)
324AC_CHECK_FUNC(memmove, AC_DEFINE(HAVE_MEMMOVE),)
325AC_CHECK_FUNC(scandir, AC_DEFINE(HAVE_SCANDIR),)
326AC_CHECK_FUNC(setsid, AC_DEFINE(HAVE_SETSID),)
327AC_CHECK_FUNC(strerror,, AC_DEFINE(NEED_STRERROR))
328AC_CHECK_FUNC(strftime, AC_DEFINE(HAVE_STRFTIME),)
329AC_CHECK_FUNC(uname, AC_DEFINE(HAVE_UNAME),)
330AC_CHECK_FUNC(writev, AC_DEFINE(HAVE_WRITEV),)
331AC_CHECK_FUNC(vasprintf, AC_DEFINE(HAVE_VASPRINTF),)
332AC_CHECK_FUNC(fputc, AC_DEFINE(HAVE_FPUTC),)
333AC_CHECK_FUNC(fwrite, AC_DEFINE(HAVE_FWRITE),)
334AC_CHECK_FUNC(snprintf, AC_DEFINE(HAVE_SNPRINTF),)
335AC_CHECK_FUNC(vsnprintf, AC_DEFINE(HAVE_VSNPRINTF),)
336
337if test "x$enable_utf8" = "xyes" ; then
338AC_CHECK_FUNC(iconv_open, AC_DEFINE([HAVE_ICONV_OPEN]),)
339fi
340
341if test -n "$openbsd" ; then
342AC_CHECK_FUNC(libiconv_open, AC_DEFINE([HAVE_ICONV_OPEN]),)
343fi
344
345AC_HEADER_STDC
346AC_HEADER_TIME
347AC_HEADER_DIRENT
348
349AC_TYPE_SIGNAL
350AC_TYPE_MODE_T
351AC_TYPE_PID_T
352AC_TYPE_SIZE_T
353AC_TYPE_UID_T
354AC_CHECK_TYPE(ssize_t,int)
355
356if test x$ac_cv_header_sys_twg_config_h = xyes
357then
358  AC_DEFINE(WINS)
359fi
360
361dnl
362dnl check if we need snprintf.c
363dnl
364if test x$ac_cv_func_snprintf != xyes || test x$ac_cv_func_vsnprintf != xyes
365then
366  EXTRA_OBJECTS=snprintf.o
367  EXTRA_SOURCES=snprintf.c
368else
369  EXTRA_OBJECTS=
370  EXTRA_SOURCES=
371fi
372AC_SUBST(EXTRA_OBJECTS)
373AC_SUBST(EXTRA_SOURCES)
374
375dnl
376dnl check for struct linger
377dnl
378
379AC_MSG_CHECKING(for struct linger)
380AC_EGREP_HEADER([struct( |	)*linger], sys/socket.h, AC_MSG_RESULT(yes), AC_DEFINE(NO_STRUCT_LINGER) AC_MSG_RESULT(no, ugh.))
381
382dnl
383dnl grok process groups
384dnl
385
386if test x$ac_cv_func_getsid != xyes && test x$ac_cv_func_getpgid != xyes
387then
388  AC_MSG_CHECKING(if getpgrp takes an argument)
389  AC_TRY_RUN([
390main()
391{
392  int pid;
393  int pgid;
394
395  pid = fork();
396
397  if (0 == pid)
398  {
399#ifdef HAVE_SETSID
400    setsid();
401#else
402    setpgrp(0, getpid());
403#endif /* HAVE_SETSID */
404    sleep(10);
405  }
406  else
407  {
408    sleep(2);
409    pgid = getpgrp(pid);
410    kill(pid,9);
411    if (pid != pgid)
412      exit(1);
413  }
414  exit(0);
415}
416],
417  AC_MSG_RESULT(yes),
418  AC_MSG_RESULT(no your getpgrp is painful)
419  AC_DEFINE(BROKEN_GETPGRP), :)
420fi
421
422dnl
423dnl work out wait type..
424dnl
425
426AC_CHECK_FUNC(waitpid,,
427  AC_MSG_RESULT(no)
428  AC_MSG_CHECKING(for bsd wait)
429  AC_TRY_LINK([
430#include <sys/types.h>
431#include <sys/wait.h>
432],[
433  union wait x;
434  int y;
435#ifdef WEXITSTATUS
436  y = WEXITSTATUS(x);
437#endif
438],
439    AC_DEFINE(BSDWAIT)
440    bsdwait=1
441    AC_MSG_RESULT(yes),
442    AC_MSG_RESULT(no)
443    AC_DEFINE(NEED_WAITPID)))
444
445dnl
446dnl checking for select()
447dnl
448
449olibs="$LIBS"
450AC_CHECK_FUNC(select, ,
451  AC_CHECK_LIB(socket, select, LIBS="$LIBS -lsocket",
452    AC_CHECK_LIB(nsl, select, LIBS="$LIBS -lnsl",
453      AC_CHECK_LIB(inet, select, LIBS="$LIBS -linet",
454        AC_CHECK_LIB(cposix, select, LIBS="$LIBS -lcposix",
455          AC_CHECK_LIB(net, select, LIBS="$LIBS -lnet",
456            AC_MSG_WARN(i can not find select.  you might need to help me)))))))
457
458dnl
459dnl termcap or curses
460dnl if termcap, check for tputs declaration
461dnl
462if test x$aix = x1
463then
464  LIBS="-lcurses $LIBS"
465  AC_DEFINE(INCLUDE_CURSES_H)
466else
467  olibs="$LIBS"
468  case "`uname -s`" in
469    Linux*)
470      if test -d /usr/include/ncurses; then
471	CFLAGS="-I/usr/include/ncurses $CFLAGS"
472      fi
473      ;;
474  esac
475  AC_CHECK_LIB(termcap, tgetent, LIBS="-ltermcap $olibs",
476    AC_CHECK_LIB(tinfo, tgetent, LIBS="-ltinfo $olibs",
477      AC_CHECK_LIB(termlib, tgetent, LIBS="-ltermlib $olibs",
478        AC_CHECK_LIB(curses, tgetent, LIBS="-lcurses $olibs",
479          AC_CHECK_LIB(ncurses, tgetent, LIBS="-lncurses $olibs",
480            AC_CHECK_LIB(xtermcap, tgetent, LIBS="-lxtermcap $olibs",
481              AC_MSG_ERROR(Can not find curses or termcap library. Installing package libncurses5-dev or ncurses-devel usually fixes this problem.)))))))
482  AC_MSG_CHECKING(for tputs in curses.h)
483  AC_EGREP_CPP([tputs( |	|\()],[#include <curses.h>
484], AC_DEFINE(INCLUDE_CURSES_H) AC_MSG_RESULT(yes), blahhack=1; AC_MSG_RESULT(no))
485fi
486
487dnl
488dnl libiconv (Sunfreeware gcc)
489dnl
490dnl
491if test "x$enable_utf8" = "xyes" ; then
492if test -n "$svr4" -a -n "$GCC"
493then
494  AC_CHECK_LIB(iconv, iconv_open, LIBS="$LIBS -liconv")
495fi
496fi
497
498dnl <term.h> is broken on most systems; ignoreit.
499
500dnl if test x$blahhack = x1
501dnl then
502dnl   AC_MSG_CHECKING(for tputs in term.h)
503dnl   AC_EGREP_CPP([tputs( |	|\()],[#include <term.h>
504dnl ], AC_DEFINE(INCLUDE_TERM_H) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
505dnl fi
506
507dnl
508dnl signal handling
509dnl
510
511AC_CHECKING(signal implementation)
512AC_CHECK_FUNC(sigaction, AC_DEFINE(USE_SIGACTION)
513  echo using posix signals
514  ,
515  AC_CHECK_FUNC(sigset, AC_DEFINE(USE_SIGSET)
516  echo using ok system v signals
517  ,
518
519echo checking for reliable signals
520AC_TRY_RUN([
521#include <sys/types.h>
522#include <signal.h>
523
524#ifndef SIGCHLD
525# define SIGCHLD SIGCLD
526#endif
527#ifdef USE_SIGSET
528# define signal sigset
529#endif
530
531int got;
532
533#ifdef SIGVOID
534void
535#endif
536hand()
537{
538  got++;
539}
540
541main()
542{
543  (void)signal(SIGCHLD, hand);
544  kill(getpid(), SIGCHLD);
545  kill(getpid(), SIGCHLD);
546  if (got < 2)
547    exit(1);
548  exit(0);
549}
550],
551echo using bsd signals
552, AC_DEFINE(SYSVSIGNALS)
553echo using system v signals, you lose.
554)))
555
556if test x$bsdwait = x1
557then
558  AC_MSG_CHECKING(for wait3 declaration)
559  AC_EGREP_CPP([wait3( |	|\()],[#include <sys/types.h>)
560#include <signal.h>
561#include <sys/wait.h>
562], AC_DEFINE(WAIT3_DECLARED) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
563else
564  AC_MSG_CHECKING(for waitpid declaration)
565  AC_EGREP_CPP([waitpid( |	|\()],[#include <sys/types.h>)
566#include <signal.h>
567#include <sys/wait.h>
568], AC_DEFINE(WAITPID_DECLARED) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
569fi
570
571dnl
572dnl check for errno declaration
573dnl
574
575AC_MSG_CHECKING(for errno declaration)
576AC_TRY_RUN([
577#include <sys/types.h>
578#include <errno.h>
579main()
580{
581  int i = errno;
582  exit(0);
583}
584],
585  AC_MSG_RESULT(yes)
586  AC_DEFINE(ERRNO_DECLARED),
587  AC_MSG_RESULT(no), :)
588
589dnl
590dnl check for sys_errlist declaration
591dnl
592
593AC_MSG_CHECKING(for sys_errlist declaration)
594AC_TRY_RUN([
595#include <sys/types.h>
596#include <stdio.h>
597#include <errno.h>
598main()
599{
600  char *s = sys_errlist[0];
601  exit(0);
602}
603],
604  AC_MSG_RESULT(yes)
605  AC_DEFINE(SYS_ERRLIST_DECLARED),
606  AC_MSG_RESULT(no), :)
607
608dnl
609dnl check the type of iconv(3)'s 2nd argument
610dnl
611
612if test "x$enable_utf8" = "xyes" ; then
613AC_MSG_CHECKING(for const iconv 2nd argument)
614AC_EGREP_HEADER([\\<iconv\\>.*\\(.*const], iconv.h,
615  AC_MSG_RESULT(yes)
616  AC_DEFINE([ICONV_CONST_ARG2]),
617  AC_MSG_RESULT(no))
618fi
619
620dnl
621dnl need this for dcc stuff
622dnl
623
624AC_MSG_CHECKING(for a 32 bit integer)
625AC_TRY_RUN([
626main()
627{
628  if (4 == sizeof(unsigned long))
629    exit(0);
630  exit(1);
631}
632],
633  AC_MSG_RESULT(unsigned long)
634  AC_DEFINE(UNSIGNED_LONG32),
635  AC_TRY_RUN([
636main()
637{
638  if (4 == sizeof(unsigned int))
639    exit(0);
640  exit(1);
641}
642],
643  AC_MSG_RESULT(unsigned int)
644  AC_DEFINE(UNSIGNED_INT32),
645  AC_MSG_RESULT(none, using unsigned long)
646  AC_DEFINE(UNKNOWN_32INT), :),
647:)
648
649dnl
650dnl libraries
651dnl
652
653dnl i think this was only needed for solaris with -lucb.
654dnl AC_HAVE_LIBRARY(elf, LIBS="$LIBS -lelf",)
655dnl AC_HAVE_LIBRARY(nls, libnls=1;AC_DEFINE(HAVE_LIB_NLS),)
656if test ! -n "$libsocket"; then
657	AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket",)
658fi
659dnl this is for isc.  need the nsl_s library as well.
660if test ! -n "$libinet"; then
661	AC_CHECK_LIB(inet, socket, libnsl=1; LIBS="$LIBS -linet -lnsl_s",)
662fi
663AC_CHECK_FUNC(gethostname, ,
664        AC_CHECK_LIB(nsl, gethostname, LIBS="$LIBS -lnsl",) )
665AC_CHECK_LIB(dgc, inet_addr, LIBS="$LIBS -ldgc",)
666AC_CHECK_LIB(resolv, gethostbyname,
667  olibs=$LIBS
668  LIBS="$LIBS -lresolv"
669  AC_TRY_RUN([
670#include <netdb.h>
671main()
672{
673  struct hostent *hp;
674
675  hp = gethostbyname("`uname -n`");
676  exit(0);
677}
678],,LIBS=$olibs, :),
679  AC_CHECK_LIB(nsl, gethostbyname,
680    olibs=$LIBS
681    LIBS="$LIBS -lnsl"))
682AC_CHECK_LIB(resolv, inet_aton, LIBS="$LIBS -lresolv",)
683dnl AC_HAVE_LIBRARY(PW, LIBS="$LIBS -lPW",)
684
685dnl
686dnl check for non-blocking fd style available..
687dnl
688AC_MSG_CHECKING(for non-blocking)
689changequote(<<, >>)dnl
690<<
691precode='#include <sys/types.h>
692#include <sys/socket.h>
693#include <fcntl.h>
694#include <sys/ioctl.h>
695#include <sys/file.h>
696#include <signal.h>
697
698alarmed()
699{
700	exit(1);
701}
702
703main()
704{
705	char b[12], x[32];
706	int f, l = sizeof(x);
707	f = socket(AF_INET, SOCK_DGRAM, 0);
708	if (f >= 0 && (fcntl(f, F_SETFL,'
709postcode=') != -1)) {
710		signal(SIGALRM, alarmed);
711		alarm(3);
712		recvfrom(f, b, 12, 0, (struct sockaddr *)x, &l);
713		alarm(0);
714		exit(0);
715	}
716	exit(1);
717}'
718>>
719changequote([, ])dnl
720
721code="$precode O_NONBLOCK $postcode"
722
723AC_TRY_RUN($code,
724  AC_DEFINE(NBLOCK_POSIX)
725  AC_MSG_RESULT(posix),
726  code="$precode O_NDELAY $postcode"
727  AC_TRY_RUN($code,
728    AC_DEFINE(NBLOCK_BSD)
729    AC_MSG_RESULT(bsd),
730    code="$precode FIONBIO $postcode"
731    AC_TRY_RUN($code,
732      AC_DEFINE(NBLOCK_SYSV)
733      AC_MSG_RESULT(system v),
734      AC_MSG_WARN(i can't find a working non blocking system),
735      :),
736    :),
737  :)
738
739dnl this is all stolen from perl-4.036's Configure.  larry is god.
740dnl well, most of it.  couple of tweaks to make it work better.
741echo "generating a list of signal names..."
742set X `cat /usr/include/signal.h /usr/include/sys/signal.h /usr/include/linux/signal.h 2>&1 | sed 's/^#[ 	]*/#/' | awk '
743$1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $3 ~ /^[1-9][0-9]*$/ {
744  [sig[$3] = substr($2,4,20)]
745  if (max < $3 && $3 < 60) {
746	max = $3
747  }
748}
749
750END {
751  for (i=1; i<=max; i++) {
752    [if (sig[i] == "")]
753      printf "%d", i
754    else
755      [printf "%s", sig[i]]
756    if (i < max)
757      printf " "
758  }
759  printf "\n"
760}
761'`
762shift
763case $# in
7640)
765  set X `kill -l 2> /dev/null`
766  shift
767  case $# in
768  0)
769    if test -f /bin/csh; then
770      set X `/bin/csh -cf 'kill -l'`
771      shift
772      case $# in
773      0)
774dnl this is a reasonable default; HUP, QUIT, ABRT, KILL, BUS, SEGV, ALRM and
775dnl TERM are all reasonably portable defaults -- i (mrg) haven't ever seen
776dnl a system where they are different than these.
777        set HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM
778        ;;
779      esac
780    fi
781    ;;
782  esac
783  ;;
784esac
785
786sig_name="ZERO $*"
787if test -f source/sig.inc; then
788  /bin/rm -f source/sig.inc
789fi
790
791[echo $sig_name | sed -e 's/$/"};/' -e 's/ /", "/g' -e 's/^/char *signals[] = { "/' -e 's/};/, NULL};/' >> source/sig.inc]
792
793dnl work out UNIX mail dir..
794
795AC_MSG_CHECKING(for unix mail directory)
796
797for foo in /var/spool/mail /usr/spool/mail /var/mail /usr/mail
798do
799  if test -d $foo; then
800    mdir=$foo
801    break
802  fi
803done
804
805if test -n "$mdir"; then
806  UNIX_MAIL=\"$mdir\"
807  AC_MSG_RESULT($mdir)
808  AC_DEFINE_UNQUOTED(UNIX_MAIL, "$mdir")
809else
810  AC_MSG_RESULT(none)
811  AC_MSG_CHECKING(for AMS mail)
812  if test "x$HOME" != "/" -o -z "x$HOME" && test -d "$HOME/Mailbox"; then
813    AC_MSG_RESULT(using Mailbox)
814    AC_DEFINE_UNQUOTED(AMS_MAIL, "Mailbox")
815  else
816    AC_MSG_RESULT(no)
817  fi
818fi
819
820
821if test -z "$CFLAGS"; then CFLAGS=-O ; fi
822if test -z "$LDFLAGS"; then LDFLAGS= ; fi
823RM="rm -f"
824LN="ln -s"
825
826if test ! -n "$bindir";
827then
828	bindir=\${exec_prefix}/bin
829fi
830AC_SUBST(bindir)
831
832if test ! -n "$IRCLIB";
833then
834	IRCLIB=\${datadir}/scrollz
835fi
836AC_SUBST(IRCLIB)
837
838if test "x$exec_prefix" = "xNONE"; then
839  if test "x$prefix" = "xNONE"; then
840    libdir="$ac_default_prefix/lib"
841  else
842    if test "x$libdir" = "xNONE"; then
843      libdir="$prefix/lib"
844    fi
845  fi
846else
847  libdir="$exec_prefix/lib"
848fi
849
850AC_MSG_CHECKING(for ElectricFence library)
851AC_ARG_WITH(efence,
852[  --with-efence[=PATH]    Compile with the ElectricFence debugging library.],
853[ case "$withval" in
854  no)
855    AC_MSG_RESULT(no)
856    ;;
857  *)
858    AC_MSG_RESULT(yes)
859    if test "x$withval" = xyes; then
860      withval="-lefence"
861    else
862      if test -d "$withval"; then
863        if test -d "$withval/lib"; then
864	  withval="-L$withval/lib -lefence"
865	else
866	  withval="-L$withval -lefence"
867	fi
868      fi
869    fi
870    LIBS="$withval $LIBS"
871    ;;
872  esac ],
873  AC_MSG_RESULT(no)
874)
875
876AC_MSG_CHECKING(paranoia status)
877AC_ARG_WITH(paranoid,
878[  --with-paranoid         Sets the compile-time paranoid flag.],
879[ AC_MSG_RESULT(yes)
880  AC_DEFINE_UNQUOTED(PARANOID, 1) ],
881  AC_MSG_RESULT(none)
882)
883
884AC_MSG_CHECKING(for /dev/urandom)
885if test -c /dev/urandom; then
886  AC_MSG_RESULT(yes)
887  AC_DEFINE_UNQUOTED(HAVE_DEV_RANDOM, 1)
888  AC_DEFINE_UNQUOTED(DEV_RANDOM_PATH, "/dev/urandom")
889else
890  AC_MSG_RESULT(no)
891  AC_MSG_CHECKING(for /dev/random)
892  if test -c /dev/random; then
893    AC_MSG_RESULT(yes)
894    AC_DEFINE_UNQUOTED(HAVE_DEV_RANDOM, 1)
895    AC_DEFINE_UNQUOTED(DEV_RANDOM_PATH, "/dev/random")
896  else
897    AC_MSG_RESULT(no)
898  fi
899fi
900
901AC_MSG_CHECKING(for default server)
902AC_ARG_WITH(default-server,
903[  --with-default-server=SERVER[:PORT]     Connect to SERVER by default.],
904[ if test "$withval"; then
905    AC_MSG_RESULT($withval)
906    AC_DEFINE_UNQUOTED(DEFAULT_SERVER, "$withval")
907  else
908    AC_MSG_RESULT(none)
909  fi ],
910  AC_MSG_RESULT(none)
911)
912
913AC_CHECK_LIB(c, crypt,
914  [AC_DEFINE(HAVE_CRYPT)
915   LIBS="-lc $LIBS"],
916  AC_CHECK_LIB(crypt, crypt,
917    [AC_DEFINE(HAVE_CRYPT)
918     LIBS="-lcrypt $LIBS"],
919    AC_CHECK_LIB(des, des,
920      [AC_DEFINE(HAVE_CRYPT)
921       LIBS="-ldes $LIBS"])))
922
923AC_MSG_CHECKING(whether to support SOCKS)
924AC_ARG_WITH(socks,
925[  --with-socks            Compile with SOCKS firewall traversal support.],
926[ case "$withval" in
927  no)
928    AC_MSG_RESULT(no)
929    ;;
930  yes)
931    AC_MSG_RESULT(yes)
932    AC_CHECK_LIB(socks5, SOCKSconnect, [
933	    socks=5
934	    LIBS="-lsocks5 $LIBS"], [
935	AC_CHECK_LIB(socks, Rconnect, [
936	    socks=4
937	    LIBS="-lsocks $LIBS"], [
938		AC_MSG_ERROR(Could not find socks library.  You must first install socks.) ] ) ] )
939    ;;
940  esac ],
941  AC_MSG_RESULT(no)
942)
943
944if test "x$socks" = "x"; then
945	AC_MSG_CHECKING(whether to support SOCKS5)
946	AC_ARG_WITH(socks5,
947	[  --with-socks5[=PATH]    Compile with SOCKS5 firewall traversal support.],
948	[ case "$withval" in
949	  no)
950	    AC_MSG_RESULT(no)
951	    ;;
952	  *)
953	    AC_MSG_RESULT(yes)
954	    socks=5
955	    if test "x$withval" = "xyes"; then
956	      withval="-lsocks5"
957	    else
958	      if test -d "$withval"; then
959		if test -d "$withval/include"; then
960		  CFLAGS="$CFLAGS -I$withval/include"
961		else
962		  CFLAGS="$CFLAGS -I$withval"
963		fi
964	        if test -d "$withval/lib"; then
965		  withval="-L$withval/lib -lsocks5"
966		else
967		  withval="-L$withval -lsocks5"
968		fi
969	      fi
970	    fi
971	    LIBS="$withval $LIBS"
972	    # If Socks was compiled with Kerberos support, we will need
973	    # to link against kerberos libraries.  Temporarily append
974	    # to LIBS.  This is harmless if there is no kerberos support.
975	    TMPLIBS="$LIBS"
976	    LIBS="$LIBS $KERBEROS_LIBS"
977	    AC_TRY_LINK([],
978	                [ SOCKSconnect(); ],
979			[],
980			[ AC_MSG_ERROR(Could not find the $withval library.  You must first install socks5.) ])
981	    LIBS="$TMPLIBS"
982	    ;;
983	  esac ],
984	  AC_MSG_RESULT(no)
985	)
986fi
987
988if test "x$socks" = "x"; then
989	AC_MSG_CHECKING(whether to support SOCKS4)
990	AC_ARG_WITH(socks4,
991	[  --with-socks4[=PATH]    Compile with SOCKS4 firewall traversal support.],
992	[ case "$withval" in
993	  no)
994	    AC_MSG_RESULT(no)
995	    ;;
996	  *)
997	    AC_MSG_RESULT(yes)
998	    socks=4
999	    if test "x$withval" = "xyes"; then
1000	      withval="-lsocks"
1001	    else
1002	      if test -d "$withval"; then
1003	        withval="-L$withval -lsocks"
1004	      fi
1005	    fi
1006	    LIBS="$withval $LIBS"
1007	    AC_TRY_LINK([],
1008	                [ Rconnect(); ],
1009			[],
1010			[ AC_MSG_ERROR(Could not find the $withval library.  You must first install socks.) ])
1011	    ;;
1012	  esac ],
1013	  AC_MSG_RESULT(no)
1014	)
1015fi
1016
1017
1018
1019if test "x$socks" = "x4"; then
1020    AC_DEFINE(SOCKS)
1021    AC_DEFINE(SOCKS4)
1022    AC_DEFINE(connect, Rconnect)
1023    AC_DEFINE(getsockname, Rgetsockname)
1024    AC_DEFINE(bind, Rbind)
1025    AC_DEFINE(accept, Raccept)
1026    AC_DEFINE(listen, Rlisten)
1027    AC_DEFINE(select, Rselect)
1028fi
1029
1030if test "x$socks" = "x5"; then
1031    AC_DEFINE(SOCKS)
1032    AC_DEFINE(SOCKS5)
1033    AC_DEFINE(connect,SOCKSconnect)
1034    AC_DEFINE(getsockname,SOCKSgetsockname)
1035    AC_DEFINE(getpeername,SOCKSgetpeername)
1036    AC_DEFINE(bind,SOCKSbind)
1037    AC_DEFINE(accept,SOCKSaccept)
1038    AC_DEFINE(listen,SOCKSlisten)
1039    AC_DEFINE(select,SOCKSselect)
1040    AC_DEFINE(recvfrom,SOCKSrecvfrom)
1041    AC_DEFINE(sendto,SOCKSsendto)
1042    AC_DEFINE(recv,SOCKSrecv)
1043    AC_DEFINE(send,SOCKSsend)
1044    AC_DEFINE(read,SOCKSread)
1045    AC_DEFINE(write,SOCKSwrite)
1046    AC_DEFINE(rresvport,SOCKSrresvport)
1047    AC_DEFINE(shutdown,SOCKSshutdown)
1048    AC_DEFINE(listen,SOCKSlisten)
1049    AC_DEFINE(close,SOCKSclose)
1050    AC_DEFINE(dup,SOCKSdup)
1051    AC_DEFINE(dup2,SOCKSdup2)
1052    AC_DEFINE(fclose,SOCKSfclose)
1053    AC_DEFINE(gethostbyname,SOCKSgethostbyname)
1054fi
1055
1056AC_MSG_CHECKING([whether to enable ipv6])
1057if test "x$socks" = "x4" -o "x$socks" = "x5"; then
1058AC_MSG_RESULT(no, bacause you enabled SOCKS$socks support)
1059else
1060AC_ARG_ENABLE(ipv6,
1061[  --enable-ipv6           Enable ipv6 (with ipv4) support],
1062[ case "$enableval" in
1063  yes) AC_MSG_RESULT(yes)
1064       AC_DEFINE(INET6)
1065       ipv6=yes
1066       ;;
1067  esac ])
1068if test "x$ipv6" = "xno" -o "x$ipv6" = "x" ; then
1069       AC_MSG_RESULT(no)
1070       ipv6=no
1071fi
1072
1073ipv6type=unknown
1074ipv6lib=none
1075ipv6trylibc=no
1076
1077if test "x$ipv6" = "xyes"; then
1078        AC_MSG_CHECKING([ipv6 stack type])
1079        for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
1080                case $i in
1081                inria)
1082                        dnl http://www.kame.net/
1083                        AC_EGREP_CPP(yes, [
1084#include <netinet/in.h>
1085#ifdef IPV6_INRIA_VERSION
1086yes
1087#endif],
1088                                [ipv6type=$i;
1089				AC_DEFINE(INET6)])
1090                        ;;
1091                kame)
1092                        dnl http://www.kame.net/
1093                        AC_EGREP_CPP(yes, [
1094#include <netinet/in.h>
1095#ifdef __KAME__
1096yes
1097#endif],
1098                                [ipv6type=$i;
1099                                ipv6lib=inet6;
1100                                ipv6libdir=/usr/local/v6/lib;
1101                                ipv6trylibc=yes;
1102				AC_DEFINE(INET6)])
1103                        ;;
1104                linux-glibc)
1105                        dnl http://www.v6.linux.or.jp/
1106                        AC_EGREP_CPP(yes, [
1107#include <features.h>
1108#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
1109yes
1110#endif],
1111                                [ipv6type=$i;
1112				AC_DEFINE(INET6)])
1113                        ;;
1114                linux-libinet6)
1115                        dnl http://www.v6.linux.or.jp/
1116                        if test -d /usr/inet6 -a -f /usr/include/netinet/ip6.h; then
1117                                ipv6type=$i
1118                                ipv6lib=inet6
1119                                ipv6libdir=/usr/inet6/lib
1120                                ipv6trylibc=yes;
1121                                CFLAGS="-I/usr/inet6/include $CFLAGS"
1122				AC_DEFINE(INET6)
1123                        fi
1124                        ;;
1125                toshiba)
1126                        AC_EGREP_CPP(yes, [
1127#include <sys/param.h>
1128#ifdef _TOSHIBA_INET6
1129yes
1130#endif],
1131                                [ipv6type=$i;
1132                                ipv6lib=inet6;
1133                                ipv6libdir=/usr/local/v6/lib;
1134				AC_DEFINE(INET6)])
1135                        ;;
1136                v6d)
1137                        AC_EGREP_CPP(yes, [
1138#include </usr/local/v6/include/sys/v6config.h>
1139#ifdef __V6D__
1140yes
1141#endif],
1142                                [ipv6type=$i;
1143                                ipv6lib=v6;
1144                                ipv6libdir=/usr/local/v6/lib;
1145                                CFLAGS="-I/usr/local/v6/include $CFLAGS"])
1146                        ;;
1147                zeta)
1148                        AC_EGREP_CPP(yes, [
1149#include <sys/param.h>
1150#ifdef _ZETA_MINAMI_INET6
1151yes
1152#endif],
1153                                [ipv6type=$i;
1154                                ipv6lib=inet6;
1155                                ipv6libdir=/usr/local/v6/lib;
1156				AC_DEFINE(INET6)])
1157                        ;;
1158                esac
1159                if test "x$ipv6type" != "xunknown"; then
1160                        break
1161                fi
1162        done
1163        AC_MSG_RESULT($ipv6type)
1164fi
1165if test "x$ipv6" = "xyes" -a "x$ipv6lib" != "xnone"; then
1166        if test -d "$ipv6libdir" -a -f "$ipv6libdir/lib$ipv6lib.a"; then
1167                LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
1168                AC_MSG_RESULT(You have $ipv6lib library, using it)
1169        else
1170                if test "x$ipv6trylibc" = "xyes"; then
1171                        AC_MSG_RESULT([You do not have (need) $ipv6lib library, using libc])
1172                else
1173                        AC_MSG_ERROR(Fatal: no $ipv6lib library found.  cannot continue.
1174You need to fetch lib$ipv6lib.a from appropriate
1175ipv6 kit and compile beforehand.)
1176                fi
1177        fi
1178fi
1179AC_MSG_CHECKING(getaddrinfo bug)
1180AC_TRY_RUN([
1181#include <sys/types.h>
1182#include <netdb.h>
1183#include <string.h>
1184#include <sys/socket.h>
1185#include <netinet/in.h>
1186
1187main()
1188{
1189  int passive, gaierr, inet4 = 0, inet6 = 0;
1190  struct addrinfo hints, *ai, *aitop;
1191  char straddr[INET6_ADDRSTRLEN], strport[16];
1192
1193  for (passive = 0; passive <= 1; passive++) {
1194    memset(&hints, 0, sizeof(hints));
1195    hints.ai_family = AF_UNSPEC;
1196    hints.ai_flags = passive ? AI_PASSIVE : 0;
1197    hints.ai_socktype = SOCK_STREAM;
1198    if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
1199      (void)gai_strerror(gaierr);
1200      goto bad;
1201    }
1202    for (ai = aitop; ai; ai = ai->ai_next) {
1203      if (ai->ai_addr == NULL ||
1204          ai->ai_addrlen == 0 ||
1205          getnameinfo(ai->ai_addr, ai->ai_addrlen,
1206                      straddr, sizeof(straddr), strport, sizeof(strport),
1207                      NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
1208        goto bad;
1209      }
1210      switch (ai->ai_family) {
1211      case AF_INET:
1212        if (strcmp(strport, "54321") != 0) {
1213          goto bad;
1214        }
1215        if (passive) {
1216          if (strcmp(straddr, "0.0.0.0") != 0) {
1217            goto bad;
1218          }
1219        } else {
1220          if (strcmp(straddr, "127.0.0.1") != 0) {
1221            goto bad;
1222          }
1223        }
1224        inet4++;
1225        break;
1226      case AF_INET6:
1227        if (strcmp(strport, "54321") != 0) {
1228          goto bad;
1229        }
1230        if (passive) {
1231          if (strcmp(straddr, "::") != 0) {
1232            goto bad;
1233          }
1234        } else {
1235          if (strcmp(straddr, "::1") != 0) {
1236            goto bad;
1237          }
1238        }
1239        inet6++;
1240        break;
1241      case AF_UNSPEC:
1242        goto bad;
1243        break;
1244      default:
1245        /* another family support? */
1246        break;
1247      }
1248    }
1249  }
1250
1251  if (inet4 != 0 && inet4 != 2)
1252    goto bad;
1253  if (inet6 != 0 && inet6 != 2)
1254    goto bad;
1255
1256  if (aitop)
1257    freeaddrinfo(aitop);
1258  exit(0);
1259
1260 bad:
1261  if (aitop)
1262    freeaddrinfo(aitop);
1263  exit(1);
1264}
1265],
1266AC_MSG_RESULT(good)
1267buggygetaddrinfo=no,
1268AC_MSG_RESULT(buggy)
1269buggygetaddrinfo=yes,
1270AC_MSG_RESULT(buggy)
1271buggygetaddrinfo=yes)
1272fi
1273
1274if test "x$buggygetaddrinfo" = "xyes"; then
1275        if test "x$ipv6" = "xyes" -a "x$ipv6type" != "xlinux"; then
1276                AC_MSG_ERROR(Fatal: You must get working getaddrinfo() function.)
1277                AC_MSG_ERROR(       or you can specify "--disable-ipv6".)
1278                exit 1
1279        elif test "x$ipv6type" = "xlinux"; then
1280                AC_MSG_ERROR(Warning: getaddrinfo() implementation on your system seems be buggy.)
1281                AC_MSG_ERROR(         Better upgreade your system library to newest version)
1282                AC_MSG_ERROR([         of GNU C library (aka glibc).])
1283        fi
1284fi
1285
1286AC_MSG_CHECKING(for struct sockaddr's sa_len)
1287AC_TRY_LINK([
1288#include <sys/types.h>
1289#include <sys/socket.h>
1290],[
1291  struct sockaddr sa;
1292  int i;
1293
1294  i = sa.sa_len;
1295  exit(0);
1296],
1297  AC_DEFINE(HAVE_SOCKADDR_SA_LEN)
1298  AC_MSG_RESULT(yes),
1299  AC_MSG_RESULT(no))
1300
1301AC_MSG_CHECKING(whether to enable SSL)
1302AC_ARG_WITH(ssl,
1303[  --with-ssl[=PATH]       Prefix where GNU TLS is installed (optional)],
1304[ case "$withval" in
1305  no)  AC_MSG_RESULT(no)
1306       ;;
1307  *) AC_MSG_RESULT(yes)
1308     olibs="$LIBS"
1309     ocflags="$CFLAGS"
1310     if test "x$withval" = "xyes";
1311     then
1312       gnutls_prefix=""
1313     else
1314       gnutls_prefix="$withval"
1315     fi
1316     AC_MSG_CHECKING(for GNU TLS)
1317     pkg-config --exists gnutls >/dev/null 2>&1
1318     if test $? -ne 0;
1319     then
1320         AC_MSG_RESULT(no)
1321         ssl=no
1322     else
1323         if test -d "$gnutls_prefix/include" -a -n "$gnutls_prefix"; then
1324           CFLAGS="-I$gnutls_prefix/include"
1325         else
1326           CFLAGS="$ocflags `pkg-config --cflags gnutls`"
1327         fi
1328         if test -d "$gnutls_prefix/lib" -a -n "$gnutls_prefix"; then
1329           LIBS="$olibs -L$gnutls_prefix/lib -lgnutls"
1330         else
1331           LIBS="$olibs `pkg-config --libs gnutls`"
1332         fi
1333         AC_TRY_LINK([
1334#include <gnutls/gnutls.h>
1335    ],   [ gnutls_check_version(NULL); ],
1336         [ AC_MSG_RESULT(yes)
1337         AC_DEFINE(HAVE_SSL)
1338         ssl=yes ],
1339         [ AC_MSG_RESULT(no)
1340         LIBS="$olibs"
1341         CFLAGS="$ocflags"
1342         ssl=no ])
1343    fi
1344  esac ],
1345  AC_MSG_RESULT(no)
1346)
1347
1348AC_MSG_CHECKING(whether to enable OpenSSL)
1349if test "x$ssl" = "xyes"; then
1350AC_MSG_RESULT(no (you enabled GNU TLS support))
1351else
1352AC_ARG_WITH(openssl,
1353[  --with-openssl[=PATH]   Prefix where OpenSSL is installed (optional)],
1354[ case "$withval" in
1355  no)  AC_MSG_RESULT(no)
1356       ;;
1357  *) AC_MSG_RESULT(yes)
1358     olibs="$LIBS"
1359     ocflags="$CFLAGS"
1360     if test "x$withval" = "xyes";
1361     then
1362       openssl_prefix=""
1363     else
1364       openssl_prefix="$withval"
1365     fi
1366     AC_MSG_CHECKING(for OpenSSL)
1367     if test -d "$openssl_prefix/include" -a -n "$openssl_prefix"; then
1368       CFLAGS="-I$openssl_prefix/include $CFLAGS"
1369     fi
1370     if test -d "$openssl_prefix/lib" -a -n "$openssl_prefix"; then
1371       LIBS="-L$openssl_prefix/lib $LIBS -lssl -lcrypto"
1372     else
1373       LIBS="$LIBS -lssl -lcrypto"
1374     fi
1375     AC_TRY_LINK([
1376#include <openssl/opensslv.h>
1377],   [ return OPENSSL_VERSION_NUMBER; ],
1378     [ AC_MSG_RESULT(yes)
1379     AC_DEFINE(HAVE_OPENSSL)
1380     openssl=yes ],
1381     [ AC_MSG_RESULT(no)
1382     LIBS="$olibs"
1383     CFLAGS="$ocflags"
1384     openssl=no ])
1385     ;;
1386  esac ],
1387  AC_MSG_RESULT(no)
1388)
1389fi
1390
1391AC_MSG_CHECKING(whether to enable regexp support)
1392AC_ARG_ENABLE(regexp,
1393[  --enable-regexp         Enable POSIX.2 regexp support],
1394[ case "$enableval" in
1395  yes) AC_TRY_LINK([
1396#include <sys/types.h>
1397#include <regex.h>
1398],   [ int rc;
1399       regex_t preg;
1400       rc = regcomp(&preg, "blah", REG_EXTENDED);
1401       if (rc != 0) return 1;
1402       else return 0; ],
1403     [ AC_MSG_RESULT(yes)
1404     AC_DEFINE(HAVE_REGCOMP)
1405     regexp=yes ],
1406     [ AC_MSG_RESULT(no)
1407     LIBS="$ac_save_LIBS"
1408     regexp=no ])
1409     ;;
1410  esac ])
1411if test "x$regexp" = "xno" -o "x$regexp" = "x" ; then
1412    AC_MSG_RESULT(no)
1413    regexp=no
1414fi
1415
1416AC_MSG_CHECKING(whether to enable FiSH support)
1417AC_ARG_ENABLE(fish,
1418[  --disable-fish          Disable FiSH encryption support])
1419
1420if test "x$enable_fish" != "xno"; then
1421    olibs="$LIBS"
1422    LIBS="$LIBS -lgmp"
1423    AC_TRY_LINK([
1424    #include <sys/types.h>
1425    #include <gmp.h>
1426    ],
1427    [ int rc;
1428      mpz_t val;
1429      mpz_init(val);
1430      return 0; ],
1431    [ AC_MSG_RESULT(yes)
1432    AC_DEFINE(HAVE_GMP)
1433    fish=yes ]
1434else
1435    [ LIBS="$olibs"
1436    fish=no ])
1437fi
1438
1439if test "x$fish" = "xno" -o "x$fish" = "x" ; then
1440    AC_MSG_RESULT(no)
1441    fish=no
1442fi
1443
1444if test -n "$hpux"
1445then
1446	# HP-UX's pax is broken
1447	AC_CHECK_PROGS(COPY_DIRECTORY, tar cpio)
1448else
1449	AC_CHECK_PROGS(COPY_DIRECTORY, pax tar cpio)
1450fi
1451if test "x$COPY_DIRECTORY" = "xpax";
1452then
1453    INSTALL_HELP_CMD='cd help; pax -r -w -s ";.*/\.?CVS$$;;" -s ";.*/\.?CVS/.*;;" . $(DESTDIR)/$(HELP_DIR)'
1454else
1455    if test "x$COPY_DIRECTORY" = "xtar";
1456    then
1457	INSTALL_HELP_CMD='cd help; tar -cf - . | ( cd $(DESTDIR)/$(HELP_DIR); tar -xf - )'
1458    else
1459	if test "x$COPY_DIRECTORY" = "xcpio";
1460	then
1461	    INSTALL_HELP_CMD='cd help; find . -print | cpio -pdu $(DESTDIR)/$(HELP_DIR)'
1462	else
1463	    INSTALL_HELP_CMD="@echo \"I couldn't figure out a way to install the help files.\""
1464	fi
1465    fi
1466fi
1467AC_SUBST(INSTALL_HELP_CMD)
1468if test "x$COPY_DIRECTORY" = "xpax";
1469then
1470    INSTALL_TRANSLATION_CMD='cd translation; pax -r -w -s ";.*/\.?CVS$$;;" -s ";.*/\.?CVS/.*;;" . $(DESTDIR)/$(TRANS_PATH)'
1471else
1472    if test "x$COPY_DIRECTORY" = "xtar";
1473    then
1474	INSTALL_TRANSLATION_CMD='cd translation; tar -cf - . | ( cd $(DESTDIR)/$(TRANS_PATH); tar -xf - )'
1475    else
1476	if test "x$COPY_DIRECTORY" = "xcpio";
1477	then
1478	    INSTALL_TRANSLATION_CMD='cd translation; find . -print | cpio -pdu $(DESTDIR)/$(TRANS_PATH)'
1479	else
1480	    INSTALL_TRANSLATION_CMD="@echo \"I couldn't figure out a way to install the translation files.\""
1481	fi
1482    fi
1483fi
1484AC_SUBST(INSTALL_TRANSLATION_CMD)
1485
1486AC_CHECK_PROGS(ZCAT, gzcat zcat gunzip gzip uncompress uncompress)
1487case "x$ZCAT" in
1488  xgzcat)
1489    ZSUFFIX=".gz"
1490    ZARGS=
1491    ;;
1492  xzcat)
1493    ZSUFFIX=".Z"
1494    ZARGS=
1495    ;;
1496  xgunzip)
1497    ZSUFFIX=".gz"
1498    ZARGS="-c"
1499    ;;
1500  xgzip)
1501    ZSUFFIX=".gz"
1502    ZARGS="-dc"
1503    ;;
1504  xuncompress)
1505    ZSUFFIX=".Z"
1506    ZARGS="-c"
1507    ;;
1508  xcompress)
1509    ZSUFFIX=".Z"
1510    ZARGS="-dc"
1511    ;;
1512esac
1513AC_DEFINE_UNQUOTED(ZCAT,"$ZCAT")
1514AC_DEFINE_UNQUOTED(ZSUFFIX,"$ZSUFFIX")
1515if test x"$ZARGS" != x; then
1516  AC_DEFINE_UNQUOTED(ZARGS,"$ZARGS")
1517fi
1518
1519AC_FIND_PROGRAM(SENDMAIL,sendmail,/usr/sbin:/usr/lib:/usr/ucblib)
1520
1521AC_SUBST(RM)
1522AC_SUBST(LN)
1523AC_OUTPUT(Makefile source/Makefile ircbug)
1524
1525#if test ! -f config.h; then
1526#  cp ${srcdir}/include/config.h.dist config.h
1527#fi
1528
1529echo
1530echo well there we are, you now might want to look in config.h and
1531echo see if there is anything you might want to tune, else you can
1532echo just run a make here..  good luck!
1533echo
1534
1535