1# configure.in for ircii
2dnl
3dnl Copyright (c) 1993-2021 Matthew R. Green.
4dnl All rights reserved.
5dnl
6dnl Redistribution and use in source and binary forms, with or without
7dnl modification, are permitted provided that the following conditions
8dnl are met:
9dnl 1. Redistributions of source code must retain the above copyright
10dnl    notice, this list of conditions and the following disclaimer.
11dnl 2. Redistributions in binary form must reproduce the above copyright
12dnl    notice, this list of conditions and the following disclaimer in the
13dnl    documentation and/or other materials provided with the distribution.
14dnl 3. The name of the author may not be used to endorse or promote products
15dnl    derived from this software without specific prior written permission.
16dnl
17dnl THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
18dnl IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19dnl OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20dnl IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21dnl INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22dnl BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23dnl LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24dnl AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25dnl OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27dnl SUCH DAMAGE.
28dnl
29dnl certain portions have other attributions, see below.
30dnl
31dnl thanks to the screen 3.3 configure.in for giving me examples to
32dnl work from and steal ;)
33dnl
34dnl @(#)$eterna: configure.in,v 1.228 2021/03/14 18:22:31 mrg Exp $
35
36AC_PREREQ([2.69])
37AC_REVISION($Revision: 1.228 $)dnl
38AC_INIT(${srcdir}/source/irc.c)
39AC_CONFIG_HEADER(defs.h:include/defs.h.in)
40
41dnl
42dnl grok the version number - from source/irc.c
43dnl
44
45VERSION=`sed -n -e 's/"[[^"]]*$//' -e '/#define[ 	]*IRCII_VERSION[ 	]*"/s///p' -e '/#define IRCII_VERSION/q' < ${srcdir}/source/irc.c`
46echo this is ircii version $VERSION
47echo
48AC_SUBST(VERSION)
49
50CATEGORIES='build change-request doc pending runtime'
51AC_SUBST(CATEGORIES)
52
53dnl so that the generated configure has an id.
54echo '$eterna: configure.in,v 1.228 2021/03/14 18:22:31 mrg Exp $' > /dev/null
55
56dnl So many systems seem to need this that it is better do it here automatically.
57AC_MSG_CHECKING(for prefix paths)
58AC_ARG_WITH(prefix_paths,
59[  --with-prefix-paths                  Add include and library diectories from prefix],
60[ case "$withval" in
61  no)
62    AC_MSG_RESULT(no)
63    ;;
64  *)
65    AC_MSG_RESULT(yes)
66    if test "x$prefix" != xNONE; then
67      if test -d "$prefix/lib"; then
68        LIBS="-L${prefix}/lib $LIBS"
69      fi
70      if test -d "$prefix/include"; then
71        CFLAGS="-I${prefix}/include $CFLAGS"
72      fi
73    else
74      if test -d "$ac_default_prefix/lib"; then
75        LIBS="-L${ac_default_prefix}/lib $LIBS"
76      fi
77      if test -d "$ac_default_prefix/include"; then
78        CFLAGS="-I${ac_default_prefix}/include $CFLAGS"
79      fi
80    fi
81    ;;
82  esac ]
83  AC_MSG_RESULT(no)
84)
85
86dnl
87dnl initial stuff
88dnl
89
90AC_PROG_CC
91AC_PROG_CPP
92
93dnl
94dnl setup variables
95dnl
96srcdir=`(cd $srcdir; pwd)`
97AC_SUBST(srcdir)
98objdir=`pwd`
99AC_SUBST(objdir)
100
101dnl AC_AIX is broken.  blah.
102
103AC_PROG_GCC_TRADITIONAL
104if test $ac_cv_prog_gcc = yes; then
105  CFLAGS="-pipe $CFLAGS"
106fi
107
108AC_MSG_CHECKING(for qnx)
109case "`uname -s`" in
110dnl bleck - wish i could ditch this qnx test, but we need to bump the stack
111  QNX*)
112    AC_MSG_RESULT(yes)
113    if test -z "$GCC"; then
114      LDFLAGS="-N256k -M"
115      CFLAGS="-w4 -Otax -zc -Wc,-fr= -Wc,-wcd=121"
116    fi
117    ;;
118  *)
119    AC_MSG_RESULT(no)
120esac
121AC_MSG_CHECKING(for solaris)
122if /bin/sun 2> /dev/null
123then
124  uname=`uname -r`
125  case "$uname" in
126    5.*)
127      AC_MSG_RESULT(yes)
128      svr4=1
129      ;;
130  esac
131else
132  AC_MSG_RESULT(no)
133  AC_MSG_CHECKING(for SVR4)
134  AC_EGREP_CPP(yes,
135[#if defined(SVR4) || defined(__svr4__) || defined(__SVR4)
136  yes
137#endif
138],AC_MSG_RESULT(yes)
139  svr4=1)
140fi
141
142if test -n "$svr4"
143then
144  LIBS="-L/usr/ccs/lib -lnsl -lsocket $LIBS"
145else
146  AC_MSG_RESULT(no)
147fi
148
149dnl
150dnl linux ncurses
151dnl
152case "`uname -s`" in
153  Linux*)
154    if test -d /usr/include/ncurses; then
155      CFLAGS="-I/usr/include/ncurses $CFLAGS"
156    fi
157    ;;
158esac
159
160AC_CHECK_HEADERS(sys/un.h sys/select.h sys/fcntl.h sys/ioctl.h sys/file.h sys/time.h sys/uio.h)dnl sys/ ones
161AC_CHECK_HEADERS(fcntl.h memory.h netdb.h crypt.h)dnl non sys/ ones
162AC_CHECK_HEADERS(process.h termcap.h iconv.h)dnl others
163
164AC_CHECK_FUNC(fchmod,, AC_DEFINE([NEED_FCHMOD], 1, [define this if you need fchmod()]))
165
166AC_CHECK_FUNCS(\
167	getpgid getsid memmove scandir setsid strftime writev \
168	snprintf vsnprintf fputc fwrite setenv unsetenv \
169	tzset waitpid iconv_open)
170
171dnl
172dnl look for get*info in libmedia
173dnl
174
175AC_CHECK_LIB(media, getaddrinfo, LIBS="$LIBS -lmedia")
176
177AC_HEADER_TIME
178
179AC_TYPE_MODE_T
180AC_TYPE_PID_T
181AC_TYPE_SIZE_T
182AC_TYPE_UID_T
183AC_CHECK_TYPES([ssize_t], [AC_DEFINE([HAVE_SSIZE_T], 1, [define this if you have ssize_t type])])
184
185AC_MSG_TRY_COMPILE(for sockaddr_in.sin_len, ircii_cv_HAVE_SOCKADDR_SA_LEN, [
186#include <sys/types.h>
187#include <sys/socket.h>
188#include <netinet/in.h> ],
189  [ struct sockaddr_in sin;
190    int X = sin.sin_len ],
191  [AC_DEFINE([HAVE_SOCKADDR_SA_LEN], 1, [define this if your struct sockaddr has a sa_len member])])
192
193AC_MSG_TRY_COMPILE(for socklen_t, ircii_cv_HAVE_SOCKLEN_T, [
194#include <sys/types.h>
195#include <sys/socket.h> ], [ socklen_t X ], [AC_DEFINE([HAVE_SOCKLEN_T], 1, [define this if you have socklen_t])])
196
197dnl
198dnl checking for select()
199dnl
200
201olibs="$LIBS"
202AC_CHECK_FUNC(select, ,
203  AC_CHECK_LIB(socket, select, LIBS="$LIBS -lsocket",
204    AC_CHECK_LIB(nsl, select, LIBS="$LIBS -lnsl",
205      AC_CHECK_LIB(inet, select, LIBS="$LIBS -linet",
206        AC_CHECK_LIB(cposix, select, LIBS="$LIBS -lcposix",
207          AC_CHECK_LIB(net, select, LIBS="$LIBS -lnet",
208            AC_MSG_WARN(i can not find select.  you might need to help me)))))))
209
210dnl
211dnl termcap or curses
212dnl if termcap, check for tputs declaration
213dnl
214if test x$aix = x1
215then
216  LIBS="$LIBS -lcurses"
217  include_curses_h=1
218else
219  olibs="$LIBS"
220  AC_CHECK_LIB(termcap, tgetent, LIBS="-ltermcap $olibs",
221    AC_CHECK_LIB(tinfo, tgetent, LIBS="-ltinfo $olibs",
222      AC_CHECK_LIB(termlib, tgetent, LIBS="$olibs -ltermlib",
223        AC_CHECK_LIB(curses, tgetent, LIBS="$olibs -lcurses",
224          AC_CHECK_LIB(xtermcap, tgetent, LIBS="$olibs -lxtermcap",
225            AC_CHECK_LIB(ncurses, tgetent, LIBS="$olibs -lncurses",
226              AC_MSG_WARN(i can not find tgetent.  you might need to help me)))))))
227  AC_MSG_CHECKING(for tputs in curses.h)
228  AC_EGREP_CPP([tputs( |	|\()],[#include <curses.h>
229], include_curses_h=1
230   AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
231fi
232
233if test -n "$include_curses_h"
234then
235  AC_DEFINE([INCLUDE_CURSES_H], 1, [define this if you have usable curses.h])
236fi
237
238
239dnl
240dnl check the type of iconv(3)'s 2nd argument
241dnl
242
243AC_MSG_CHECKING(for const iconv 2nd argument)
244AC_EGREP_HEADER([\\<iconv\\>.*\\(.*const], iconv.h,
245  AC_MSG_RESULT(yes)
246  AC_DEFINE([ICONV_CONST_ARG2], 1,
247    [define this if your iconv(3)'s 2nd argument is const]),
248  AC_MSG_RESULT(no))
249
250
251dnl
252dnl check the type of scandir(3)'s comparision function
253dnl actually, we check alphasort since that is almost certainly
254dnl on the same line. ugh.
255dnl
256
257AC_MSG_CHECKING(for scandir void * comparision function)
258AC_EGREP_HEADER([\\<alphasort\\>.*\\(.*void], dirent.h,
259  AC_MSG_RESULT(yes)
260  AC_DEFINE([ALPHASORT_VOID_ARG], 1,
261    [define this if your scandir(3)'s comparision takes void * or dirent *]),
262  AC_MSG_RESULT(no))
263
264
265dnl
266dnl libraries
267dnl
268
269dnl work out UNIX mail dir..
270
271AC_MSG_CHECKING(for unix mail directory)
272
273for foo in /var/spool/mail /usr/spool/mail /var/mail /usr/mail
274do
275  if test -d $foo; then
276    mdir=$foo
277    break
278  fi
279done
280
281if test -n "$mdir"; then
282  UNIX_MAIL=\"$mdir\"
283  AC_MSG_RESULT($mdir)
284  AC_DEFINE_UNQUOTED([UNIX_MAIL], ["$mdir"], [define this to the location of normal unix mail])
285else
286  AC_MSG_RESULT(none)
287fi
288
289if test -z "$CFLAGS"; then CFLAGS=-O ; fi
290if test -z "$LDFLAGS"; then LDFLAGS= ; fi
291RM="rm -f"
292LN="ln -s"
293
294if test ! -n "$bindir";
295then
296	bindir=\${exec_prefix}/bin
297fi
298AC_SUBST(bindir)
299
300if test ! -n "$IRCLIB";
301then
302	IRCLIB=\${datarootdir}/irc
303fi
304AC_SUBST(IRCLIB)
305
306if test "x$libexecdir" = "x"; then
307  if test "x$exec_prefix" = "xNONE"; then
308    if test "x$prefix" = "xNONE"; then
309      libexecdir="$ac_default_prefix/libexec"
310    else
311      libexecdir="$prefix/libexec"
312    fi
313  else
314    libexecdir="$exec_prefix/libexec"
315  fi
316fi
317AC_SUBST(libexecdir)
318
319AC_MSG_CHECKING(for ElectricFence library)
320AC_ARG_WITH(efence,
321[changequote(, )  --with-efence[=PATH]                 Compile with the ElectricFence debugging library.changequote([, ])],
322[ case "$withval" in
323  no)
324    AC_MSG_RESULT(no)
325    ;;
326  *)
327    AC_MSG_RESULT(yes)
328    if test "x$withval" = xyes; then
329      withval="-lefence"
330    else
331      if test -d "$withval"; then
332        if test -d "$withval/lib"; then
333	  withval="-L$withval/lib -R$withval/lib -lefence"
334	else
335	  withval="-L$withval -lefence"
336	fi
337      fi
338    fi
339    LIBS="$withval $LIBS"
340    ;;
341  esac
342], [
343  AC_MSG_RESULT(no)
344])
345
346AC_MSG_CHECKING(for OpenSSL library)
347checkopenssl=no
348ssl_path=
349AC_ARG_WITH(openssl,
350[changequote(, )  --with-openssl[=PATH]                Compile with OpenSSL.changequote([, ])],
351[ case "$withval" in
352  no)
353    ;;
354  *)
355    if test "x$withval" != "xyes"; then
356      ssl_path="$withval"
357    fi
358    checkopenssl=yes
359    ;;
360  esac
361], [
362  checkopenssl=maybe
363])
364
365ssl_libs=""
366ssl_cflags=""
367if test "x$checkopenssl" != xno; then
368  if test "x$ssl_path" = x; then
369    ssl_libs="-lssl -lcrypto"
370  else
371    if test -d "$ssl_path"; then
372      if test -d "$ssl_path/lib"; then
373        ssl_libs="-L$ssl_path/lib -lssl -lcrypto"
374	ssl_cflags="-I$ssl_path/include"
375      else
376        ssl_libs="-L$ssl_path -lssl -lcrypto"
377	ssl_cflags="-I$ssl_path/../include"
378      fi
379    fi
380  fi
381fi
382
383if test "x$ssl_libs" != x; then
384  AC_MSG_RESULT(yes)
385  LIBS="$LIBS $ssl_libs"
386  CFLAGS="$CFLAGS $ssl_cflags"
387  AC_DEFINE([USE_OPENSSL], 1, [define this if you want to use OpenSSL])
388else
389  AC_MSG_RESULT(no)
390fi
391
392AC_MSG_CHECKING(for debug flags)
393AC_ARG_WITH(debugging,
394[changequote(, )  --with-debugging[=flags]             Build with debugging support.changequote([, ])],
395[ case "$withval" in
396  no)
397    AC_MSG_RESULT(no)
398    DEBUGFLAGS=
399    ;;
400  *)
401    AC_MSG_RESULT(yes)
402    if test "x$withval" = xyes; then
403      withval=-g
404    fi
405    DEBUGFLAGS="$withval"
406    for flag in $CFLAGS; do
407      case "$CFLAGS" in
408        -DDEBUG|-DDEBUG=*)
409	  found=1
410	  break
411	  ;;
412        *)
413          found=0
414	  ;;
415      esac
416    done
417    if test $found -eq 0; then
418      CFLAGS="$CFLAGS -DDEBUG"
419    fi
420    ;;
421  esac ],
422  AC_MSG_RESULT(no)
423)
424AC_SUBST(DEBUGFLAGS)
425
426AC_MSG_CHECKING(for warning flags)
427AC_ARG_WITH(warnings,
428[changequote(, )  --with-warnings[=flags]              Build with GCC warnings.changequote([, ])],
429[ case "$withval" in
430  no)
431    AC_MSG_RESULT(no)
432    WARNINGFLAGS=
433    ;;
434  *)
435    AC_MSG_RESULT(yes)
436    if test "x$withval" = xyes; then
437      withval='-Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wmissing-declarations -Wnested-externs -Wpointer-arith -Wformat -Wformat-security'
438    fi
439    WARNINGFLAGS="$withval"
440    ;;
441  esac ],
442  AC_MSG_RESULT(no)
443)
444AC_SUBST(WARNINGFLAGS)
445
446AC_MSG_CHECKING(for warnings as errors)
447AC_ARG_WITH(warning-errors,
448[changequote(, )  --with-warning-errors[=flags]        Turn warnings into errors.changequote([, ])],
449[ case "$withval" in
450  no)
451    AC_MSG_RESULT(no)
452    ERRORFLAGS=
453    ;;
454  *)
455    AC_MSG_RESULT(yes)
456    if test "x$withval" = xyes; then
457      withval='-Werror'
458    fi
459    ERRORFLAGS="$withval"
460    ;;
461  esac ],
462  AC_MSG_RESULT(no)
463)
464AC_SUBST(ERRORFLAGS)
465
466AC_MSG_CHECKING(for sanitizers)
467AC_ARG_WITH(sanitizer,
468[changequote(, )  --with-sanitizer[=<list>]            Use sanitizers, default ASAN.changequote([, ])],
469[ case "$withval" in
470  no)
471    AC_MSG_RESULT(no)
472    LIBSANI=
473    ;;
474  *)
475    if test "x$withval" = xyes; then
476      withval='address'
477    fi
478    have_asan=0
479    have_lsan=0
480    have_ubsan=0
481    for val in `echo "$withval" | sed "s/,/ /"`
482    do
483      LIBSANI=
484      case "$val" in
485      asan|address)
486        FSANI=address
487        LIBSANI=asan
488        have_asan=1
489        ;;
490      lsan|leak)
491        FSANI=leak
492        LIBSANI=lsan
493        have_lsan=1
494        ;;
495      ubsan|undefined)
496        FSANI=undefined
497        LIBSANI=ubsan
498        have_ubsan=1
499        ;;
500      *)
501        AC_MSG_ERROR(Sanitizer support for address, leak, and undefined behaviour only.)
502        ;;
503      esac
504    done
505    if test "$have_asan" -eq 1 -a "$have_lsan" -eq 1; then
506      AC_MSG_ERROR(Do not combine address and leak sanitizers.)
507    fi
508    list=""
509    sep=""
510    if test "$have_asan" -eq 1; then
511      CFLAGS="$CFLAGS -fsanitize=address"
512      LIBS="$LIBS -lasan"
513      list="$list$sep"address
514      sep=" "
515    fi
516    if test "$have_lsan" -eq 1; then
517      CFLAGS="$CFLAGS -fsanitize=leak"
518      LIBS="$LIBS -llsan"
519      list="$list$sep"leak
520      sep=" "
521    fi
522    if test "$have_ubsan" -eq 1; then
523      CFLAGS="$CFLAGS -fsanitize=undefined"
524      LIBS="$LIBS -lubsan"
525      list="$list$sep"undefined
526      sep=" "
527    fi
528    AC_MSG_RESULT($list)
529    ;;
530  esac ],
531  AC_MSG_RESULT(no)
532)
533
534AC_MSG_CHECKING(for emacs meta keys)
535AC_ARG_WITH(emacs-meta-keys,
536[changequote(, )  --with-emacs-meta-keys               Enable Emacs meta key support.changequote([, ])],
537[ case "$withval" in
538  no)
539    AC_MSG_RESULT(no)
540    ;;
541  *)
542    AC_MSG_RESULT(yes)
543    AC_DEFINE([WITH_EMACS_META_KEYS], 1, [define this if you want Emacs metakey support])
544    ;;
545  esac ],
546  AC_MSG_RESULT(no)
547)
548
549AC_MSG_CHECKING(paranoia status)
550AC_ARG_WITH(paranoid,
551[changequote(, )  --with-paranoid                      Sets the compile-time paranoid flag.changequote([, ])],
552[ AC_MSG_RESULT(yes)
553  AC_DEFINE_UNQUOTED([PARANOID], 1, [define this if you want to be paranoid]) ],
554  AC_MSG_RESULT(none)
555)
556
557AC_MSG_CHECKING(for /dev/urandom)
558if test -c /dev/urandom; then
559  AC_MSG_RESULT(yes)
560  have_dev_random=1
561  dev_random_path="/dev/urandom"
562else
563  AC_MSG_RESULT(no)
564  AC_MSG_CHECKING(for /dev/random)
565  if test -c /dev/random; then
566    AC_MSG_RESULT(yes)
567    have_dev_random=1
568    dev_random_path="/dev/random"
569  else
570    AC_MSG_RESULT(no)
571  fi
572fi
573
574if test -n "$have_dev_random"
575then
576  AC_DEFINE([HAVE_DEV_RANDOM], 1, [Define this if you have /dev/random])
577  AC_DEFINE_UNQUOTED([DEV_RANDOM_PATH], ["$dev_random_path"], [Define this to the random device to use])
578fi
579
580AC_MSG_CHECKING(for default server)
581AC_ARG_WITH(default-server,
582[changequote(, )  --with-default-server=SERVER[:PORT]  Connect to SERVER by default.changequote([, ])],
583[ if test "$withval"; then
584    AC_MSG_RESULT($withval)
585    AC_DEFINE_UNQUOTED([DEFAULT_SERVER], ["$withval"], [define this to be the name<:port> of the default server])
586  else
587    AC_MSG_RESULT(none)
588  fi ],
589  AC_MSG_RESULT(none)
590)
591
592dnl
593dnl transitory option to disable the new window resizer
594dnl
595
596AC_MSG_CHECKING(for default window resize method)
597defval=1
598AC_ARG_WITH(default-resize-method,
599[  --with-default-resize-method[=type]    Either "old" or "new"],
600[ case "$withval" in
601  new|old)
602    AC_MSG_RESULT($withval)
603    if test "$withval" = old; then
604      defval=0;
605    fi
606    ;;
607  *)
608    AC_MSG_ERROR(Window resize method must be either "old" or "new".)
609    ;;
610  esac ],
611  AC_MSG_RESULT("new")
612)
613if test $defval -eq 1; then
614  AC_DEFINE_UNQUOTED([DEFAULT_RESIZE_METHOD], [$defval], [Use default window resize method. 0 for old method.])
615fi
616
617dnl
618dnl check for -lcrypt
619dnl
620
621AC_CHECK_LIB(c, crypt,
622  [have_crypt=1],
623  AC_CHECK_LIB(crypt, crypt,
624    [have_crypt=1
625     LIBS="$LIBS -lcrypt"],
626    AC_CHECK_LIB(des, des,
627      [have_crypt=1
628       LIBS="$LIBS -ldes"])))
629
630if test -n "$have_crypt"
631then
632  AC_DEFINE([HAVE_CRYPT], 1, [define this if you have crypt(3)])
633fi
634
635dnl
636dnl check for SOCKS
637dnl
638
639AC_MSG_CHECKING(whether to support SOCKS)
640AC_ARG_WITH(socks,
641[  --with-socks                         Compile with SOCKS firewall traversal support],
642[ case "$withval" in
643  no)
644    AC_MSG_RESULT(no)
645    ;;
646  yes)
647    AC_MSG_RESULT(yes)
648    AC_CHECK_LIB(socks5, SOCKSconnect, [
649	    socks=5
650	    LIBS="$LIBS -lsocks5"], [
651	AC_CHECK_LIB(socks, Rconnect, [
652	    socks=4
653	    LIBS="$LIBS -lsocks"], [
654		AC_MSG_ERROR(Could not find socks library.  You must first install socks.) ] ) ] )
655    ;;
656  esac ],
657  AC_MSG_RESULT(no)
658)
659
660if test "x$socks" = "x"; then
661	AC_MSG_CHECKING(whether to support SOCKS5)
662	AC_ARG_WITH(socks5,
663	[changequote(, )  --with-socks5[=PATH]                 Compile with SOCKS5 firewall traversal support.changequote([, ])],
664	[ case "$withval" in
665	  no)
666	    AC_MSG_RESULT(no)
667	    ;;
668	  *)
669	    AC_MSG_RESULT(yes)
670	    socks=5
671	    socks5lib=""
672	    if test "x$withval" = "xyes"; then
673	      socks5lib="-lsocks5"
674	    else
675	      if test -d "$withval"; then
676		if test -d "$withval/include"; then
677		  CFLAGS="$CFLAGS -I$withval/include"
678		else
679		  CFLAGS="$CFLAGS -I$withval"
680		fi
681	        if test -d "$withval/lib"; then
682		  socks5lib="-L$withval/lib -lsocks5"
683		else
684		  socks5lib="-L$withval -lsocks5"
685		fi
686	      else
687		socks5lib="$withval"
688	      fi
689	    fi
690	    LIBS="$socks5lib $LIBS"
691	    # If Socks was compiled with Kerberos support, we will need
692	    # to link against kerberos libraries.  Temporarily append
693	    # to LIBS.  This is harmless if there is no kerberos support.
694	    TMPLIBS="$LIBS"
695	    LIBS="$LIBS $KERBEROS_LIBS"
696	    AC_TRY_LINK([],
697	                [ SOCKSconnect(); ],
698			[],
699			[ AC_MSG_ERROR(Could not find the $withval library.  You must first install socks5.) ])
700	    LIBS="$TMPLIBS"
701	    ;;
702	  esac ],
703	  AC_MSG_RESULT(no)
704	)
705fi
706
707if test "x$socks" = "x"; then
708	AC_MSG_CHECKING(whether to support SOCKS4)
709	AC_ARG_WITH(socks4,
710	[changequote(, )  --with-socks4[=PATH]                 Compile with SOCKS4 firewall traversal support.changequote([, ])],
711	[ case "$withval" in
712	  no)
713	    AC_MSG_RESULT(no)
714	    ;;
715	  *)
716	    AC_MSG_RESULT(yes)
717	    socks=4
718	    if test "x$withval" = "xyes"; then
719	      withval="-lsocks"
720	    else
721	      if test -d "$withval"; then
722	        withval="-L$withval -lsocks"
723	      fi
724	    fi
725	    LIBS="$withval $LIBS"
726	    AC_TRY_LINK([],
727	                [ Rconnect(); ],
728			[],
729			[ AC_MSG_ERROR(Could not find the $withval library.  You must first install socks.) ])
730	    ;;
731	  esac ],
732	  AC_MSG_RESULT(no)
733	)
734fi
735
736if test -n "$socks"; then
737  AC_DEFINE([SOCKS], 1, [Define this if compiling with SOCKS (the firewall traversal library)])
738fi
739
740if test "x$socks" = "x4"; then
741    AC_DEFINE([SOCKS4], 1, [Define this if using the SOCKS version 4 library])
742fi
743
744if test "x$socks" = "x5"; then
745    AC_DEFINE([SOCKS5], 1, [Define this if using the SOCKS version 5 library])
746fi
747
748AC_MSG_CHECKING(for non-blocking)
749AC_ARG_WITH(non-blocking,
750[changequote(, )  --with-non-blocking=[TYPE]           Use TYPE non-blocking, yes or no.changequote([, ])],
751[
752  case "$withval" in
753  no|none)
754    AC_MSG_RESULT(no)
755    ;;
756  *)
757    if test -z "$socks"; then
758      withval=no
759      AC_MSG_RESULT(no, disabled due to SOCKS support)
760    else
761      AC_MSG_RESULT(yes)
762      non_blocking_connects=1
763    fi
764    ;;
765  esac ],
766[
767  AC_MSG_RESULT(yes)
768  non_blocking_connects=1
769])
770
771if test -n "$non_blocking_connects"
772then
773  AC_DEFINE([NON_BLOCKING_CONNECTS], 1, [define this to use non-blocking connects. Precluded by SOCKS])
774fi
775
776if test -n "$hpux"
777then
778	# HP-UX's pax is broken
779	AC_CHECK_PROGS(COPY_DIRECTORY, tar cpio)
780else
781	AC_CHECK_PROGS(COPY_DIRECTORY, pax tar cpio)
782fi
783if test "x$COPY_DIRECTORY" = "xpax";
784then
785    INSTALL_HELP_CMD='cd $(topdir)/help; pax -r -w -s ";.*/CVS$$;;" -s ";.*/\.CVS$$;;" -s ";.*/CVS/.*;;" -s ";.*/\.CVS/.*;;" . $(HELP_DIR)'
786else
787    if test "x$COPY_DIRECTORY" = "xtar";
788    then
789	INSTALL_HELP_CMD='cd $(topdir)/help; tar -cf - . | ( cd $(HELP_DIR); tar -xf - )'
790    else
791	if test "x$COPY_DIRECTORY" = "xcpio";
792	then
793	    INSTALL_HELP_CMD='cd $(topdir)/help; find . -print | cpio -pdu $(HELP_DIR)'
794	else
795	    INSTALL_HELP_CMD="@echo \"I couldn't figure out a way to install the help files.\""
796	fi
797    fi
798fi
799AC_SUBST(INSTALL_HELP_CMD)
800
801AC_CHECK_PROGS(ZCAT, gzcat zcat gunzip gzip uncompress uncompress)
802case "x$ZCAT" in
803  xgzcat)
804    ZSUFFIX=".gz"
805    ZARGS=
806    ;;
807  xzcat)
808    ZSUFFIX=".Z"
809    ZARGS=
810    ;;
811  xgunzip)
812    ZSUFFIX=".gz"
813    ZARGS="-c"
814    ;;
815  xgzip)
816    ZSUFFIX=".gz"
817    ZARGS="-dc"
818    ;;
819  xuncompress)
820    ZSUFFIX=".Z"
821    ZARGS="-c"
822    ;;
823  xcompress)
824    ZSUFFIX=".Z"
825    ZARGS="-dc"
826    ;;
827esac
828AC_DEFINE_UNQUOTED([ZCAT],["$ZCAT"], [define this to the ZCAT program of your choice])
829AC_DEFINE_UNQUOTED([ZSUFFIX],["$ZSUFFIX"], [define these to the ZCAT suffer of your choice(.gz)])
830if test x"$ZARGS" != x; then
831  AC_DEFINE_UNQUOTED([ZARGS],["$ZARGS"], [define these to the ZCAT args of your choice])
832fi
833
834AC_FIND_PROGRAM(SENDMAIL,sendmail,/usr/sbin:/usr/lib:/usr/ucblib:/usr/local/sbin:/usr/pkg/sbin)
835
836AC_SUBST(RM)
837AC_SUBST(LN)
838AC_OUTPUT(Makefile ircbug)
839
840if test ! -f config.h; then
841  cp ${srcdir}/include/config.h.dist config.h
842fi
843
844echo
845echo well there we are, you now might want to look in config.h and
846echo see if there is anything you might want to tune, else you can
847echo just run a make here..  good luck!
848echo
849
850