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