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