updates.
[crypto.git] / apps / irssi / configure.in
1 AC_INIT(src)
2
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE(Irssi-SILC, 0.7.98.3)
5
6 AM_MAINTAINER_MODE
7
8 AC_ISC_POSIX
9 AC_PROG_CC
10 AC_PROG_CPP
11 AC_STDC_HEADERS
12 AC_ARG_PROGRAM
13 AC_PROG_RANLIB
14
15 dnl * ahem.. :) we don't want static libraries for modules
16 if test "x$lt_target" = "x"; then
17         if test "$target" = "NONE"; then
18                 lt_target="$host"
19         else
20                 lt_target="$target"
21         fi
22 fi
23 dnl * --disable-static isn't a good idea, complain if it's used
24 if test "x$enable_static" = "xno"; then
25         AC_ERROR([Don't give --disable-static option to configure])
26 fi
27
28 AC_CONFIG_AUX_DIR(.)
29
30 AC_CHECK_HEADERS(string.h stdlib.h unistd.h dirent.h sys/ioctl.h libintl.h)
31
32 # check posix headers..
33 AC_CHECK_HEADERS(sys/time.h sys/utsname.h regex.h)
34
35 AC_ARG_WITH(big5,
36 [  --with-big5             Build with tr-Chinese Big5 support],
37         if test x$withval = xyes; then
38                 want_big5=yes
39         else
40                 if test "x$withval" = xno; then
41                         want_big5=no
42                 else
43                         want_big5=yes
44                 fi
45         fi,
46         want_big5=no)
47
48 AC_ARG_WITH(socks,
49 [  --with-socks            Build with socks support],
50         if test x$withval = xyes; then
51                 want_socks=yes
52         else
53                 if test "x$withval" = xno; then
54                         want_socks=no
55                 else
56                         want_socks=yes
57                 fi
58         fi,
59         want_socks=no)
60
61 AC_ARG_WITH(textui,
62 [  --with-textui           Build text frontend],
63         if test x$withval = xyes; then
64                 want_textui=yes
65         else
66                 if test "x$withval" = xno; then
67                         want_textui=no
68                 else
69                         want_textui=yes
70                 fi
71         fi,
72         want_textui=yes)
73
74 AC_ARG_WITH(bot,
75 [  --with-bot              Build irssi-bot],
76         if test x$withval = xyes; then
77                 want_irssibot=yes
78         else
79                 if test "x$withval" = xno; then
80                         want_irssibot=no
81                 else
82                         want_irssibot=yes
83                 fi
84         fi,
85         want_irssibot=no)
86
87 AC_ARG_WITH(proxy,
88 [  --with-proxy            Build irssi-proxy],
89         if test x$withval = xyes; then
90                 want_irssiproxy=yes
91         else
92                 if test "x$withval" = xno; then
93                         want_irssiproxy=no
94                 else
95                         want_irssiproxy=yes
96                 fi
97         fi,
98         want_irssiproxy=no)
99
100
101 AC_ARG_WITH(modules,
102 [  --with-modules          Specify what modules to build in binary],
103         if test x$withval != xyes -a x$withval != xno; then
104                 build_modules="$withval"
105         fi)
106
107 if test "x$prefix" = "xNONE"; then
108         PERL_LIB_DIR=""
109 else
110         PERL_LIB_DIR="$prefix"
111 fi
112
113 AC_ARG_ENABLE(perl-path,
114 [  --enable-perl-path=dir  Specify where to install the Perl libraries for irssi],
115         if test x$enableval = xyes; then
116                 want_perl=yes
117         else
118                 if test "x$enableval" = xno; then
119                         want_perl=no
120                 else
121                         want_perl=yes
122                         PERL_LIB_DIR="$enableval"
123                         perl_lib_dir_given=yes
124                 fi
125         fi,
126         want_perl=no)
127
128 AC_ARG_ENABLE(perl,
129 [  --enable-perl[=yes|no|static]  Build with Perl support - also specifies
130                           if it should be built into main irssi binary
131                           (static) or as module (default)],
132         if test x$enableval = xyes; then
133                 want_perl=yes
134         elif test x$enableval = xstatic; then
135                 want_perl=static
136         else
137                 want_perl=no
138         fi,
139         want_perl=no)
140
141 AC_ARG_WITH(tests,
142 [  --with-tests           Run all the tests],
143         if test x$withval != xno; then
144                 TEST_DIR=test
145         fi,
146         TEST_DIR=)
147 AC_SUBST(TEST_DIR)
148
149 AC_ARG_ENABLE(curses-windows,
150 [  --enable-curses-windows Use curses windows],
151         if test x$enableval != xno; then
152                 AC_DEFINE(USE_CURSES_WINDOWS)
153         fi,
154         AC_DEFINE(USE_CURSES_WINDOWS))
155
156 AC_ARG_ENABLE(memdebug,
157 [  --enable-memdebug       Enable memory debugging],
158         if test x$enableval = xyes; then
159                 want_memdebug=yes
160         else
161                 if test "x$enableval" = xno; then
162                         want_memdebug=no
163                 else
164                         want_memdebug=yes
165                 fi
166         fi,
167         want_memdebug=no)
168
169 AC_ARG_ENABLE(ipv6,
170 [  --enable-ipv6           Enable IPv6 support],
171         if test x$enableval = xyes; then
172                 want_ipv6=yes
173         else
174                 if test "x$enableval" = xno; then
175                         want_ipv6=no
176                 else
177                         want_ipv6=yes
178                 fi
179         fi,
180         want_ipv6=no)
181
182 dnl **
183 dnl ** just some generic stuff...
184 dnl **
185
186 AC_CHECK_FUNCS(mkfifo fcntl)
187
188 AC_CHECK_LIB(socket, socket, [
189         PROG_LIBS="$PROG_LIBS -lsocket"
190 ])
191
192 AC_CHECK_LIB(nsl, inet_addr, [
193         PROG_LIBS="$PROG_LIBS -lnsl"
194 ], -lsocket)
195
196 dnl * gcc specific options
197 if test "x$ac_cv_prog_gcc" = "xyes"; then
198   CFLAGS="$CFLAGS -Wall"
199 fi
200
201 dnl * OS specific options
202 case "$host_os" in
203   hpux*)
204     CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
205     ;;
206   *)
207     ;;
208 esac
209
210 dnl * socklen_t - AC_CHECK_TYPE() would be _really_ useful if it only would
211 dnl * accept header files where to find the typedef..
212 AC_MSG_CHECKING([for socklen_t])
213 AC_CACHE_VAL(irssi_cv_type_socklen_t,
214 [AC_TRY_COMPILE([
215 #include <sys/types.h>
216 #include <sys/socket.h>],
217 [socklen_t t;],
218 irssi_cv_type_socklen_t=yes,
219 irssi_cv_type_socklen_t=no,
220 )])
221 if test $irssi_cv_type_socklen_t = no; then
222 AC_DEFINE(socklen_t, int, Define to 'int' if <sys/socket.h> doesn't define.)
223 fi
224 AC_MSG_RESULT($irssi_cv_type_socklen_t)
225
226 dnl **
227 dnl ** check for socks
228 dnl **
229
230 if test "x$want_socks" = "xyes"; then
231         AC_CHECK_LIB(socks, connect, [
232                 PROG_LIBS="$PROG_LIBS -lsocks"
233                 AC_CHECK_HEADER(socks.h, [
234                         AC_DEFINE(HAVE_SOCKS_H)
235                         CFLAGS="$CFLAGS -DSOCKS"
236                         AC_MSG_RESULT(["socks5 library found, building with it"])
237                 ], [
238                         AC_MSG_RESULT(["socks4 library found, building with it"])
239                         CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dgetpeername=Rgetpeername -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
240                 ])
241         ])
242 fi
243
244 dnl **
245 dnl ** fe-text checks
246 dnl **
247
248 AC_PATH_PROG(sedpath, sed)
249
250 AC_DEFUN(AC_CHECK_GLIBDIR,[
251   AC_MSG_CHECKING([whether GLib is unpacked to irssi dir])
252
253   GLIB_DIR=`for d in *; do test -f $d/glib.h && echo $d; done`
254   if test "x$GLIB_DIR" != "x"; then
255     dnl * glib in irssi directory, use it
256     AC_MSG_RESULT([yes, using it])
257
258     dnl * we have to do this at this point so we know what libs gmodule needs
259     if test ! -f $GLIB_DIR/.libs/libglib.a; then
260       echo
261       echo "configuring GLib ..."
262       echo
263       cd $GLIB_DIR
264       if test ! -f glib-config; then
265         ./configure
266       fi
267       ${MAKE-make}
268       cd ..
269       echo
270     fi
271
272     GLIB_LDEXTRA=`$GLIB_DIR/glib-config --libs gmodule|$sedpath -e 's/-lglib//' -e 's/-lgmodule//' -e 's,-L/usr/local/lib ,,'|$sedpath 's/ \+/ /g'`
273     full_glib_dir="`pwd`/$GLIB_DIR"
274     GLIB_CFLAGS="-I$full_glib_dir -I$full_glib_dir/gmodule"
275     if test -f $full_glib_dir/.libs/libglib.a; then
276       GLIB_LIBS="$full_glib_dir/.libs/libglib.a $GLIB_LDEXTRA"
277       if test -f $full_glib_dir/gmodule/.libs/libgmodule.a; then
278         GLIB_LIBS="$GLIB_LIBS $full_glib_dir/gmodule/.libs/libgmodule.a"
279         AC_DEFINE(HAVE_GMODULE)
280       fi
281     else
282       GLIB_LIBS="$full_glib_dir/libglib.a $GLIB_LDEXTRA"
283       if test -f $full_glib_dir/gmodule/libgmodule.a; then
284         GLIB_LIBS="$GLIB_LIBS $full_glib_dir/gmodule/libgmodule.a"
285         AC_DEFINE(HAVE_GMODULE)
286       fi
287     fi
288     AC_SUBST(GLIB_CFLAGS)
289     AC_SUBST(GLIB_LIBS)
290   else
291     AC_MSG_RESULT([no])
292   fi
293 ])
294
295 AC_CHECK_GLIBDIR
296
297 if test "x$GLIB_DIR" = "x"; then
298   AM_PATH_GLIB(1.2.0,,, gmodule)
299   if test "x$GLIB_LIBS" = "x"; then
300     echo "*** trying without -lgmodule"
301     glib_config_args=
302     AM_PATH_GLIB(1.2.0)
303   else
304     AC_DEFINE(HAVE_GMODULE)
305   fi
306
307   if test "x$GLIB_LIBS" = "x"; then
308     echo
309     echo "*** If you don't have GLIB, you can get it from ftp://ftp.gtk.org"
310     echo "*** If you can't install GLIB anywhere or if you don't want to,"
311     echo "*** you can just unpack it to Irssi's source directory and"
312     echo "*** Irssi will automatically compile and use it."
313     echo
314
315     dnl * I think it's pretty safe to assume GLib 1.2.9 since the next
316     dnl * will be 2.0 (or 1.4?) and it's not sure if irssi compiles
317     dnl * with it (yea, just a few weeks after I put this text for 1.2.8
318     dnl * the 1.2.9 came :) .. and then .10
319     glib_file=glib-1.2.10.tar.gz
320
321     dlcmd=
322     if test "x`ncftpget 2>/dev/null|grep -i ncftp`" != "x"; then
323       dlcmd="ncftpget ftp://ftp.gtk.org/pub/gtk/v1.2/$glib_file"
324     fi
325     if test "x`wget 2>/dev/null|grep -i wget`" != "x"; then
326       dlcmd="wget http://irssi.org/files/$glib_file"
327     fi
328     if test "x$dlcmd" != "x"; then
329       echo "*** I can download GLib for you now. If you don't want to, press CTRL-C now."
330       read answer
331       eval $dlcmd
332       if `gunzip $glib_file`; then
333         glib_file=`echo $glib_file|$sedpath s/\.gz$//`
334         if `tar xf $glib_file`; then
335           rm -f $glib_file
336           AC_CHECK_GLIBDIR
337         fi
338       fi
339     fi
340
341     if test "x$GLIB_LIBS" = "x"; then
342       AC_ERROR([GLIB is required to build irssi.])
343     fi
344   fi
345 fi
346
347 PROG_LIBS="$PROG_LIBS $GLIB_LIBS"
348
349 dnl **
350 dnl ** curses checks
351 dnl **
352
353 dnl Curses detection: Munged from Midnight Commander's configure.in
354 dnl
355 dnl What it does:
356 dnl =============
357 dnl
358 dnl - Determine which version of curses is installed on your system
359 dnl   and set the -I/-L/-l compiler entries and add a few preprocessor
360 dnl   symbols 
361 dnl - Do an AC_SUBST on the CURSES_INCLUDEDIR and CURSES_LIBS so that
362 dnl   @CURSES_INCLUDEDIR@ and @CURSES_LIBS@ will be available in
363 dnl   Makefile.in's
364 dnl - Modify the following configure variables (these are the only
365 dnl   curses.m4 variables you can access from within configure.in)
366 dnl   CURSES_INCLUDEDIR - contains -I's and possibly -DRENAMED_CURSES if
367 dnl                       an ncurses.h that's been renamed to curses.h
368 dnl                       is found.
369 dnl   CURSES_LIBS       - sets -L and -l's appropriately
370 dnl   CFLAGS            - if --with-sco, add -D_SVID3 
371 dnl   has_curses        - exports result of tests to rest of configure
372 dnl
373 dnl Usage:
374 dnl ======
375 dnl 1) Add lines indicated below to acconfig.h
376 dnl 2) call AC_CHECK_CURSES after AC_PROG_CC in your configure.in
377 dnl 3) Instead of #include <curses.h> you should use the following to
378 dnl    properly locate ncurses or curses header file
379 dnl
380 dnl    #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
381 dnl    #include <ncurses.h>
382 dnl    #else
383 dnl    #include <curses.h>
384 dnl    #endif
385 dnl
386 dnl 4) Make sure to add @CURSES_INCLUDEDIR@ to your preprocessor flags
387 dnl 5) Make sure to add @CURSES_LIBS@ to your linker flags or LIBS
388 dnl
389 dnl Notes with automake:
390 dnl - call AM_CONDITIONAL(HAS_CURSES, test "$has_curses" = true) from
391 dnl   configure.in
392 dnl - your Makefile.am can look something like this
393 dnl   -----------------------------------------------
394 dnl   INCLUDES= blah blah blah $(CURSES_INCLUDEDIR) 
395 dnl   if HAS_CURSES
396 dnl   CURSES_TARGETS=name_of_curses_prog
397 dnl   endif
398 dnl   bin_PROGRAMS = other_programs $(CURSES_TARGETS)
399 dnl   other_programs_SOURCES = blah blah blah
400 dnl   name_of_curses_prog_SOURCES = blah blah blah
401 dnl   other_programs_LDADD = blah
402 dnl   name_of_curses_prog_LDADD = blah $(CURSES_LIBS)
403 dnl   -----------------------------------------------
404 dnl
405 dnl
406 dnl The following lines should be added to acconfig.h:
407 dnl ==================================================
408 dnl
409 dnl /*=== Curses version detection defines ===*/
410 dnl /* Found some version of curses that we're going to use */
411 dnl #undef HAS_CURSES
412 dnl    
413 dnl /* Use SunOS SysV curses? */
414 dnl #undef USE_SUNOS_CURSES
415 dnl 
416 dnl /* Use old BSD curses - not used right now */
417 dnl #undef USE_BSD_CURSES
418 dnl 
419 dnl /* Use SystemV curses? */
420 dnl #undef USE_SYSV_CURSES
421 dnl 
422 dnl /* Use Ncurses? */
423 dnl #undef USE_NCURSES
424 dnl 
425 dnl /* If you Curses does not have color define this one */
426 dnl #undef NO_COLOR_CURSES
427 dnl 
428 dnl /* Define if you want to turn on SCO-specific code */
429 dnl #undef SCO_FLAVOR
430 dnl 
431 dnl /* Set to reflect version of ncurses *
432 dnl  *   0 = version 1.*
433 dnl  *   1 = version 1.9.9g
434 dnl  *   2 = version 4.0/4.1 */
435 dnl #undef NCURSES_970530
436 dnl
437 dnl /*=== End new stuff for acconfig.h ===*/
438 dnl 
439
440
441 AC_DEFUN(AC_CHECK_CURSES,[
442         search_ncurses=true
443         screen_manager=""
444         has_curses=false
445
446         CFLAGS=${CFLAGS--O}
447
448         AC_SUBST(CURSES_LIBS)
449         AC_SUBST(CURSES_INCLUDEDIR)
450
451         AC_ARG_WITH(sco,
452           [  --with-sco              Use this to turn on SCO-specific code],[
453           if test x$withval = xyes; then
454                 AC_DEFINE(SCO_FLAVOR)
455                 CFLAGS="$CFLAGS -D_SVID3"
456           fi
457         ])
458
459         AC_ARG_WITH(sunos-curses,
460           [  --with-sunos-curses     Used to force SunOS 4.x curses],[
461           if test x$withval = xyes; then
462                 AC_USE_SUNOS_CURSES
463           fi
464         ])
465
466         AC_ARG_WITH(osf1-curses,
467           [  --with-osf1-curses      Used to force OSF/1 curses],[
468           if test x$withval = xyes; then
469                 AC_USE_OSF1_CURSES
470           fi
471         ])
472
473         AC_ARG_WITH(vcurses,
474           [  --with-vcurses[=incdir] Used to force SysV curses],
475           if test x$withval != xyes; then
476                 CURSES_INCLUDEDIR="-I$withval"
477           fi
478           AC_USE_SYSV_CURSES
479         )
480
481         AC_ARG_WITH(ncurses,
482           [  --with-ncurses[=dir]    Compile with ncurses/locate base dir],
483           if test x$withval = xno ; then
484                 search_ncurses=false
485           elif test x$withval != xyes ; then
486                 AC_NCURSES($withval/include, ncurses.h, -L$withval/lib -lncurses, -I$withval/include, "ncurses on $withval/include")
487           fi
488         )
489
490         if $search_ncurses
491         then
492                 AC_SEARCH_NCURSES()
493         fi
494 ])
495
496
497 AC_DEFUN(AC_USE_SUNOS_CURSES, [
498         search_ncurses=false
499         screen_manager="SunOS 4.x /usr/5include curses"
500         AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
501         AC_DEFINE(USE_SUNOS_CURSES)
502         AC_DEFINE(HAS_CURSES)
503         has_curses=true
504         AC_DEFINE(NO_COLOR_CURSES)
505         AC_DEFINE(USE_SYSV_CURSES)
506         CURSES_INCLUDEDIR="-I/usr/5include"
507         CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
508         AC_MSG_RESULT(Please note that some screen refreshs may fail)
509 ])
510
511 AC_DEFUN(AC_USE_OSF1_CURSES, [
512        AC_MSG_RESULT(Using OSF1 curses)
513        search_ncurses=false
514        screen_manager="OSF1 curses"
515        AC_DEFINE(HAS_CURSES)
516        has_curses=true
517        AC_DEFINE(NO_COLOR_CURSES)
518        AC_DEFINE(USE_SYSV_CURSES)
519        CURSES_LIBS="-lcurses"
520 ])
521
522 AC_DEFUN(AC_USE_SYSV_CURSES, [
523         AC_MSG_RESULT(Using SysV curses)
524         AC_DEFINE(HAS_CURSES)
525         has_curses=true
526         AC_DEFINE(USE_SYSV_CURSES)
527         search_ncurses=false
528         screen_manager="SysV/curses"
529         CURSES_LIBS="-lcurses"
530 ])
531
532 dnl AC_ARG_WITH(bsd-curses,
533 dnl [--with-bsd-curses         Used to compile with bsd curses, not very fancy],
534 dnl     search_ncurses=false
535 dnl     screen_manager="Ultrix/cursesX"
536 dnl     if test $system = ULTRIX
537 dnl     then
538 dnl         THIS_CURSES=cursesX
539 dnl        else
540 dnl         THIS_CURSES=curses
541 dnl     fi
542 dnl
543 dnl     CURSES_LIBS="-l$THIS_CURSES -ltermcap"
544 dnl     AC_DEFINE(HAS_CURSES)
545 dnl     has_curses=true
546 dnl     AC_DEFINE(USE_BSD_CURSES)
547 dnl     AC_MSG_RESULT(Please note that some screen refreshs may fail)
548 dnl     AC_WARN(Use of the bsdcurses extension has some)
549 dnl     AC_WARN(display/input problems.)
550 dnl     AC_WARN(Reconsider using xcurses)
551 dnl)
552
553         
554 dnl
555 dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
556 dnl
557 AC_DEFUN(AC_NCURSES, [
558     if $search_ncurses
559     then
560         if test -f $1/$2
561         then
562             AC_MSG_RESULT(Found ncurses on $1/$2)
563
564             CURSES_LIBS="$3"
565             AC_CHECK_LIB(ncurses, initscr, , [
566                 CHECKLIBS=`echo "$3"|sed 's/-lncurses/-lcurses/g'`
567                 AC_CHECK_LIB(curses, initscr, [
568                         CURSES_LIBS="$CHECKLIBS"
569                 ],, $CHECKLIBS)
570             ], $CURSES_LIBS)
571             CURSES_INCLUDEDIR="$4"
572             search_ncurses=false
573             screen_manager=$5
574             AC_DEFINE(HAS_CURSES)
575             has_curses=true
576             has_ncurses=true
577             AC_DEFINE(USE_NCURSES)
578         fi
579     fi
580 ])
581
582 AC_DEFUN(AC_SEARCH_NCURSES, [
583     AC_CHECKING("location of ncurses.h file")
584
585     AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include")
586     AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses")
587     AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local")
588     AC_NCURSES(/usr/pkg/include, ncurses.h, -L/usr/pkg/lib -lncurses, -I/usr/pkg/include, "ncurses on /usr/pkg")
589     AC_NCURSES(/usr/contrib/include, ncurses.h, -L/usr/contrib/lib -lncurses, -I/usr/contrib/include, "ncurses on /usr/contrib")
590     AC_NCURSES(/usr/local/include/ncurses, ncurses.h, -L/usr/local/lib -L/usr/local/lib/ncurses -lncurses, -I/usr/local/include/ncurses, "ncurses on /usr/local/include/ncurses")
591
592     AC_NCURSES(/usr/local/include/ncurses, curses.h, -L/usr/local/lib -lncurses, -I/usr/local/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/local/.../ncurses")
593
594     AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
595
596     dnl
597     dnl We couldn't find ncurses, try SysV curses
598     dnl
599     if $search_ncurses 
600     then
601         AC_EGREP_HEADER(init_color, /usr/include/curses.h,
602             AC_USE_SYSV_CURSES)
603         AC_EGREP_CPP(USE_NCURSES,[
604 #include <curses.h>
605 #ifdef __NCURSES_H
606 #undef USE_NCURSES
607 USE_NCURSES
608 #endif
609 ],[
610         CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES"
611         AC_DEFINE(HAS_CURSES)
612         has_curses=true
613         has_ncurses=true
614         AC_DEFINE(USE_NCURSES)
615         search_ncurses=false
616         screen_manager="ncurses installed as curses"
617 ])
618     fi
619
620     dnl
621     dnl Try SunOS 4.x /usr/5{lib,include} ncurses
622     dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
623     dnl should be replaced by a more fine grained selection routine
624     dnl
625     if $search_ncurses
626     then
627         if test -f /usr/5include/curses.h
628         then
629             AC_USE_SUNOS_CURSES
630         fi
631     fi
632
633     dnl use whatever curses there happens to be
634     if $search_ncurses
635     then
636         if test -f /usr/include/curses.h
637         then
638           CURSES_LIBS="-lcurses"
639           AC_DEFINE(HAS_CURSES)
640           has_curses=true
641           search_ncurses=false
642           screen_manager="curses"
643         fi
644     fi
645 ])
646
647 if test "x$want_textui" = "xyes"; then
648         AC_CHECK_CURSES
649
650         if test "x$has_ncurses" != "x"; then
651                 AC_CHECK_LIB(ncurses, use_default_colors, [
652                         AC_DEFINE(HAVE_NCURSES_USE_DEFAULT_COLORS)
653                 ],, $CURSES_LIBS)
654                 AC_CHECK_LIB(ncurses, idcok, [
655                         AC_DEFINE(HAVE_CURSES_IDCOK)
656                 ],, $CURSES_LIBS)
657                 AC_CHECK_LIB(ncurses, resizeterm, [
658                         AC_DEFINE(HAVE_CURSES_RESIZETERM)
659                 ],, $CURSES_LIBS)
660                 AC_CHECK_LIB(ncurses, wresize, [
661                         AC_DEFINE(HAVE_CURSES_WRESIZE)
662                 ],, $CURSES_LIBS)
663         elif test "x$has_curses" = "xtrue"; then
664                 AC_CHECK_LIB(curses, idcok, [
665                         AC_DEFINE(HAVE_CURSES_IDCOK)
666                 ],, $CURSES_LIBS)
667                 AC_CHECK_LIB(curses, resizeterm, [
668                         AC_DEFINE(HAVE_CURSES_RESIZETERM)
669                 ],, $CURSES_LIBS)
670                 AC_CHECK_LIB(curses, wresize, [
671                         AC_DEFINE(HAVE_CURSES_WRESIZE)
672                 ],, $CURSES_LIBS)
673         else
674                 want_textui=no
675                 curses_error=yes
676         fi
677 else
678         has_curses=false
679 fi
680
681 dnl **
682 dnl ** perl checks
683 dnl **
684
685 if test "$want_perl" != "no"; then
686         AC_PATH_PROG(perlpath, perl)
687         AC_MSG_CHECKING(for working Perl support)
688
689         if test "x$perlpath" = "x"; then
690                 perl_check_error="perl binary not found"
691         else
692                 PERL_CFLAGS=`$perlpath -MExtUtils::Embed -e ccopts 2>/dev/null`
693         fi
694
695         if test "x$PERL_CFLAGS" = "x"; then
696                 perl_check_error="Error getting perl CFLAGS"
697                 AC_MSG_RESULT([not found, building without Perl])
698                 want_perl=no
699         else
700                 PERL_LDFLAGS=`$perlpath -MExtUtils::Embed -e ldopts 2>/dev/null`
701
702                 dnl * Perl 5.004 and older use perl_xxx variables while
703                 dnl * later use PL_perl_xxx variables ..
704                 have_pl_perl=`$perlpath -e 'print $] < 5.005 ? "no" : "yes";'`
705                 if test "x$have_pl_perl" = "xyes"; then
706                         AC_DEFINE(HAVE_PL_PERL)
707                 fi
708
709                 if test "x$DYNLIB_MODULES" = "xno" -a "$want_perl" != "static"; then
710                         dnl * wanted perl as module, won't get it.
711                         want_perl=static
712                         perl_mod_error="Dynamic library dependencies don't work with modules"
713                 fi
714
715                 if test "$want_perl" != "static"; then
716                         dnl * dynaloader.a -> libperl_dynaloader.la
717                         DYNALOADER_A=`echo $PERL_LDFLAGS | $perlpath -pe 's/^(.* )*([[^ ]]*DynaLoader\.a).*/\2/'`
718                 fi
719
720                 dnl * don't check libperl.a if dynaloader.a wasn't found..
721                 if test "x$DYNALOADER_A" != "x"; then
722                         dnl * find either libperl.a or libperl.so
723                         LIBPERL_A=`echo "$PERL_LDFLAGS -L/usr/lib"|$perlpath -e 'foreach (split(/ /, <STDIN>)) { if (/^-L(.*)/) { my $dir=$1; if (\`ls $dir/libperl.so* 2>/dev/null\`) { print "-lperl"; last; }; if (-e "$dir/libperl.a") { print "$dir/libperl.a"; last } } };'`
724                         if test "x$LIBPERL_A" = "x"; then
725                                 perl_mod_error="Didn't find location of -lperl"
726                                 DYNALOADER_A=
727                         elif test "$LIBPERL_A" = "-lperl"; then
728                                 LIBPERL_A=
729                         fi
730                 fi
731
732                 dnl * remove all database stuffs
733                 dnl * nsl is already in ldflags
734                 dnl * libc is of course linked without needing -lc
735                 dnl * -rdynamic must not be in LIBADD line
736                 for word in -ldb -ldbm -lndbm -lgdbm -lc -rdynamic; do
737                   PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e "s/$word //" -e "s/$word$//"`
738                 done
739
740                 case "$host_os" in
741                   linux*)
742                     PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e 's/-lposix //' -e 's/-lposix$//'`
743                     ;;
744                   hpux*)
745                     if test "x$ac_cv_prog_gcc" = "xyes"; then
746                       PERL_CFLAGS=`echo $PERL_CFLAGS | $sedpath -e 's/-Ae //' -e 's/-Ae$//'`
747                       PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e 's/-Ae //' -e 's/-Ae$//'`
748                     fi
749                     ;;
750                   *)
751                     ;;
752                 esac
753
754                 dnl * check that perl's ldflags actually work
755                 AC_CACHE_VAL(irssi_cv_lib_perl_works, [
756                         echo "main(){perl_alloc(); return 0;}" > conftest.c
757                         $CC $CFLAGS conftest.c -o conftest $LDFLAGS $PERL_LDFLAGS 2> /dev/null > /dev/null
758                         if test -s conftest; then
759                                 irssi_cv_lib_perl_works=yes
760                         else
761                                 irssi_cv_lib_perl_works=no
762                         fi
763                 ])
764
765                 if test "x$irssi_cv_lib_perl_works" = "xno"; then
766                         perl_check_error="Error linking with perl libraries: $PERL_LDFLAGS"
767                         AC_MSG_RESULT([error linking with perl libraries, building without Perl])
768                         want_perl=no
769                 fi
770         fi
771
772         if test "x$want_perl" != "xno"; then
773                 if test "x$want_perl" = "xstatic"; then
774                         AC_MSG_RESULT(ok)
775                 elif test "x$DYNALOADER_A" = "x"; then
776                         AC_MSG_RESULT([error parsing ldopts, building Perl into irssi binary instead of as module])
777                         want_perl=static
778                 else
779                         AC_MSG_RESULT(ok)
780                         PERL_LDFLAGS=`echo $PERL_LDFLAGS | $perlpath -pe 's/^(.* )*[[^ ]]*DynaLoader\.a/\1libperl_dynaloader.la/'`
781                         if test "x$LIBPERL_A" != "x"; then
782                                 PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e 's/-lperl /libperl_orig.la /' -e 's/-lperl$/libperl_orig.la$/'`
783                         fi
784                         AC_SUBST(LIBPERL_A)
785                         AC_SUBST(DYNALOADER_A)
786                 fi
787
788                 if test "x$want_perl" = "xstatic"; then
789                         dnl * building with static perl support
790                         dnl * all PERL_LDFLAGS linking is done in fe-text
791                         PERL_LDFLAGS="../perl/libperl_static.la $PERL_LDFLAGS"
792                         PERL_LINK_LIBS="$PERL_LDFLAGS"
793                         PERL_FE_LINK_LIBS="../perl/libfe_perl_static.la"
794                         PERL_LDFLAGS=
795                         AC_DEFINE(HAVE_STATIC_PERL)
796
797                         dnl * build only static library of perl module
798                         perl_module_lib=
799                         perl_module_fe_lib=
800                         perl_static_lib=libperl_static.la
801                         perl_static_fe_lib=libfe_perl_static.la
802                         PERL_LIBTOOL='$(SHELL) $(top_builddir)/libtool'
803                 else
804                         dnl * build dynamic library of perl module,
805                         dnl * use libtool-shared to prevent creating of
806                         dnl * libperl.a
807                         perl_module_lib=libperl_core.la
808                         perl_module_fe_lib=libfe_perl.la
809                         perl_static_lib=
810                         perl_static_fe_lib=
811                         PERL_LIBTOOL='$(SHELL) $(top_builddir)/libtool-shared'
812                 fi
813                 AC_SUBST(perl_module_lib)
814                 AC_SUBST(perl_static_lib)
815                 AC_SUBST(perl_module_fe_lib)
816                 AC_SUBST(perl_static_fe_lib)
817                 AC_SUBST(PERL_LIBTOOL)
818
819                 AC_SUBST(PERL_LINK_LIBS)
820                 AC_SUBST(PERL_FE_LINK_LIBS)
821
822                 AC_SUBST(PERL_LDFLAGS)
823                 AC_SUBST(PERL_CFLAGS)
824                 AC_SUBST(PERL_LIB_DIR)
825         fi
826 fi
827
828 dnl ** check what we want to build
829 AM_CONDITIONAL(BUILD_TEXTUI, test "$want_textui" = "yes")
830 AM_CONDITIONAL(BUILD_IRSSIBOT, test "$want_irssibot" = "yes")
831 AM_CONDITIONAL(BUILD_IRSSIPROXY, test "$want_irssiproxy" = "yes")
832 AM_CONDITIONAL(BUILD_PLUGINS, test "$want_plugins" = "yes")
833 AM_CONDITIONAL(BUILD_SERVERTEST, test "x$TEST_DIR" != "x")
834 AM_CONDITIONAL(HAVE_PERL, test "$want_perl" != "no")
835 AM_CONDITIONAL(HAVE_STATIC_PERL, test "$want_perl" = "static")
836
837 AC_SUBST(PROG_LIBS)
838
839 dnl **
840 dnl ** Keep all the libraries here so each frontend doesn't need to
841 dnl ** keep track of them all
842 dnl **
843 dnl ** (these could be made configurable)
844
845 CHAT_MODULES="silc"
846 silc_MODULES=""
847 if test "x$build_modules" != "x"; then
848         silc_MODULES="$silc_MODULES $build_modules"
849 fi
850 #PROG_LIBS="$PROG_LIBS -lsilc"
851
852 dnl ****************************************
853
854 AC_SUBST(CHAT_MODULES)
855 AC_SUBST(silc_MODULES)
856
857 CORE_LIBS="../core/libcore.a ../lib-config/libirssi_config.a ../lib-popt/libpopt.a"
858 FE_COMMON_LIBS=""
859
860 CHAT_LIBS=""
861 for c in $CHAT_MODULES; do
862         module_inits=""
863         module_deinits=""
864         fe_module_inits=""
865         fe_module_deinits=""
866         CHAT_LIBS="$CHAT_LIBS ../$c/lib$c.a ../$c/core/lib${c}_core.a"
867         if test -f $srcdir/src/fe-common/$c/module.h; then
868                 FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/$c/libfe_common_$c.a "
869         fi
870         for s in `eval echo \\$${c}_MODULES`; do
871                 CHAT_LIBS="$CHAT_LIBS ../$c/$s/.libs/lib${c}_$s.a"
872                 module_inits="$module_inits ${c}_${s}_init();"
873                 module_deinits="${c}_${s}_deinit(); $module_deinits"
874                 if test -f $srcdir/src/fe-common/$c/$s/module.h; then
875                         FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/$c/$s/.libs/libfe_${c}_$s.a "
876                         fe_module_inits="$fe_module_inits fe_${c}_${s}_init();"
877                         fe_module_deinits="fe_${c}_${s}_deinit(); $fe_module_deinits"
878                 fi
879         done
880
881         file="$srcdir/src/$c/$c.c"
882         echo "/* this file is automatically generated by configure - don't change */" > $file
883         echo "void ${c}_core_init(void); void ${c}_core_init_finish(void); void ${c}_core_deinit(void);" >> $file
884         if test "x$module_inits" != "x"; then
885                 echo "$module_inits" | $sedpath -e 's/()/(void)/g' -e 's/ /void /g' >> $file
886                 echo "$module_deinits" | $sedpath -e 's/ *$//' -e 's/()/(void)/g' -e 's/ /void /g' -e 's/^/void /' >> $file
887         fi
888         echo "void ${c}_init(void) { ${c}_core_init(); $module_inits }" >> $file
889         echo "void ${c}_init_finish(void) { ${c}_core_init_finish(); $module_inits }" >> $file
890         echo "void ${c}_deinit(void) { $module_deinits ${c}_core_deinit(); }" >> $file
891
892         if test -f $srcdir/src/fe-common/$c/module.h; then
893                 file="$srcdir/src/fe-common/$c/${c}-modules.c"
894                 echo "/* this file is automatically generated by configure - don't change */" > $file
895                 if test "x$fe_module_inits" != "x"; then
896                         echo "$fe_module_inits" | $sedpath -e 's/()/(void)/g' -e 's/ /void /g' >> $file
897                         echo "$fe_module_deinits" | $sedpath -e 's/ *$//' -e 's/()/(void)/g' -e 's/ /void /g' -e 's/^/void /' >> $file
898                 fi
899                 echo "void fe_${c}_modules_init(void) { $fe_module_inits }" >> $file
900                 echo "void fe_${c}_modules_deinit(void) { $fe_module_deinits }" >> $file
901         fi
902 done
903
904 FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/core/libfe_common_core.a"
905
906 dnl ** common libraries needed by frontends
907 COMMON_NOUI_LIBS="$CHAT_LIBS $CORE_LIBS $INTLLIBS"
908 COMMON_LIBS="$FE_COMMON_LIBS $COMMON_NOUI_LIBS"
909 AC_SUBST(COMMON_NOUI_LIBS)
910 AC_SUBST(COMMON_LIBS)
911
912 dnl **
913 dnl ** memory debugging
914 dnl **
915
916 if test "x$want_memdebug" = "xyes"; then
917         AC_DEFINE(MEM_DEBUG)
918 fi
919 AM_CONDITIONAL(BUILD_MEMDEBUG, test "x$want_memdebug" = "xyes")
920
921 dnl **
922 dnl ** tr-Chinese Big5 support
923 dnl **
924
925 if test "x$want_big5" = "xyes"; then
926         AC_DEFINE(WANT_BIG5)
927 fi
928
929 dnl **
930 dnl ** IPv6 support
931 dnl **
932
933 if test "x$want_ipv6" = "xyes"; then
934         AC_DEFINE(HAVE_IPV6)
935 fi
936
937 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
938 AC_SUBST(INCLUDE_DEFINES_INT)
939
940 AC_OUTPUT(
941 Makefile
942 src/Makefile
943 src/core/Makefile
944 src/fe-common/Makefile
945 src/fe-common/core/Makefile
946 src/fe-common/silc/Makefile
947 src/fe-text/Makefile
948 src/lib-config/Makefile
949 src/lib-popt/Makefile
950 src/silc/Makefile
951 src/silc/core/Makefile
952 docs/Makefile
953 docs/help/Makefile
954 docs/help/in/Makefile
955 stamp.h
956 irssi.spec
957 irssi-version.h
958 irssi-config)
959
960 dnl ** for building from objdir
961 if test "x$want_perl" != "xno"; then
962         old_dir=`pwd` && cd $srcdir && whole_dir=`pwd` && cd $old_dir
963
964         if test "x$old_dir" != "x$whole_dir"; then
965                 for file in $whole_dir/src/perl/*.[[ch]] $whole_dir/src/perl/libperl_orig.la $whole_dir/src/perl/libperl_dynaloader.la $whole_dir/src/perl/common/typemap $whole_dir/src/perl/common/module.h $whole_dir/src/perl/common/*.xs $whole_dir/src/perl/irc/typemap $whole_dir/src/perl/irc/module.h $whole_dir/src/perl/irc/*.xs; do
966                         link=`echo $file|$sedpath "s?$whole_dir/??"`
967                         rm -f $link
968                         $LN_S $file $link
969                 done
970         fi
971 fi
972
973 echo
974
975 if test "x$curses_error" != "xyes"; then
976         echo "Building text frontend ..... : $want_textui"
977 else
978         echo "Building text frontend ..... : NO!!"
979         echo " - Because curses was not found, specify the path to it with"
980         echo "   --with-curses=/dir and make sure you have the curses headers"
981         echo "   installed (usually in ncurses-devel package)"
982 fi
983 echo "Building irssi bot ......... : $want_irssibot"
984 echo "Building irssi proxy ....... : $want_irssiproxy"
985 echo "Building with IPv6 support . : $want_ipv6"
986
987 if test "x$want_perl" = "xstatic"; then
988         echo "Building with Perl support . : static (in irssi binary)"
989 elif test "x$want_perl" = "xyes"; then
990         echo "Building with Perl support . : module"
991 else
992         if test "x$perl_check_error" = "x"; then
993                 echo "Building with Perl support . : no"
994         else
995                 echo "Building with Perl support . : NO!"
996                 echo " - $perl_check_error"
997         fi
998 fi
999
1000 if test "x$want_perl" != "xno" -a "x$perl_mod_error" != "x"; then
1001         echo " - NOTE: Perl support will be compiled statically to irssi, not as"
1002         echo "   a module as requested. Reason:"
1003         echo "   $perl_mod_error"
1004 fi
1005
1006 if test "x$want_perl" = "xyes"; then
1007         if test "x$PERL_LIB_DIR" = "x"; then
1008                 echo "Perl library directory ..... : (default - usually /usr/local/lib/perl_site)"
1009         else
1010                 echo "Perl library directory ..... : $PERL_LIB_DIR"
1011                 if test "x$perl_lib_dir_given" != "xyes"; then
1012                         echo " - NOTE: This was automatically set to the same directory you gave with"
1013                         echo "   --prefix. If you want the perl libraries to install to their 'correct'"
1014                         echo "   path, you'll need to give --enable-perl-path= (nothing after '=') option"
1015                         echo "   to configure. Anyway, installing perl to this directory should work"
1016                         echo "   just as well.."
1017                 fi
1018         fi
1019 fi
1020 echo "Install prefix ............. : $prefix"