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