Merged with Irssi CVS.
[silc.git] / apps / irssi / configure.in
1 AC_INIT(src)
2
3 # we don't want VERSION in our config.h
4 if test -n "`grep '^#undef VERSION' config.h.in`"; then
5   grep -v '^#undef VERSION' config.h.in > config.h.in.temp
6   mv -f config.h.in.temp config.h.in
7 fi
8
9 AM_CONFIG_HEADER(config.h)
10 AM_INIT_AUTOMAKE(Irssi-SILC, 0.8.6)
11
12 AM_MAINTAINER_MODE
13
14 AC_ISC_POSIX
15 AC_PROG_CC
16 AC_PROG_CPP
17 AC_STDC_HEADERS
18 AC_ARG_PROGRAM
19 AM_PROG_LIBTOOL
20
21 AC_PATH_PROG(sedpath, sed)
22 AC_PATH_PROG(perlpath, perl)
23
24 dnl * --disable-static isn't a good idea, complain if it's used
25 if test "x$enable_static" = "xno"; then
26         AC_ERROR([Don't give --disable-static option to configure])
27 fi
28
29 AC_CHECK_HEADERS(string.h stdlib.h unistd.h dirent.h sys/ioctl.h sys/resource.h)
30
31 # check posix headers..
32 AC_CHECK_HEADERS(sys/time.h sys/utsname.h regex.h)
33
34 AC_ARG_WITH(socks,
35 [  --with-socks            Build with socks support],
36         if test x$withval = xyes; then
37                 want_socks=yes
38         else
39                 if test "x$withval" = xno; then
40                         want_socks=no
41                 else
42                         want_socks=yes
43                 fi
44         fi,
45         want_socks=no)
46
47 AC_ARG_WITH(textui,
48 [  --with-textui           Build text frontend],
49         if test x$withval = xyes; then
50                 want_textui=yes
51         else
52                 if test "x$withval" = xno; then
53                         want_textui=no
54                 else
55                         want_textui=yes
56                 fi
57         fi,
58         want_textui=yes)
59
60 AC_ARG_WITH(bot,
61 [  --with-bot              Build irssi-bot],
62         if test x$withval = xyes; then
63                 want_irssibot=yes
64         else
65                 if test "x$withval" = xno; then
66                         want_irssibot=no
67                 else
68                         want_irssibot=yes
69                 fi
70         fi,
71         want_irssibot=no)
72
73 AC_ARG_WITH(proxy,
74 [  --with-proxy            Build irssi-proxy],
75         if test x$withval = xyes; then
76                 want_irssiproxy=yes
77         else
78                 if test "x$withval" = xno; then
79                         want_irssiproxy=no
80                 else
81                         want_irssiproxy=yes
82                 fi
83         fi,
84         want_irssiproxy=no)
85
86 AC_ARG_WITH(terminfo,
87 [  --with-terminfo         Use terminfo directly instead of curses],
88         if test x$withval = xyes; then
89                 want_terminfo=yes
90         else
91                 if test "x$withval" = xno; then
92                         want_terminfo=no
93                 else
94                         want_terminfo=yes
95                 fi
96         fi,
97         want_terminfo=yes)
98
99 AC_ARG_WITH(modules,
100 [  --with-modules          Specify what modules to build in binary],
101         if test x$withval != xyes -a x$withval != xno; then
102                 build_modules="$withval"
103         fi)
104
105 if test "x$prefix" != "xNONE"; then
106         prefix=`eval echo $prefix`
107         PERL_MM_PARAMS="INSTALLDIRS=perl PREFIX=$prefix"
108         perl_library_dir="PERL_USE_LIB"
109         perl_set_use_lib=yes
110
111         perl_prefix_note=yes
112 fi
113
114 AC_ARG_WITH(with-glib2,
115 [  --with-glib2           Use GLIB 2.0 instead of 1.2],
116         if test x$withval = xyes; then
117                 want_glib2=yes
118         else
119                 if test "x$withval" = xno; then
120                         want_glib2=no
121                 else
122                         want_glib2=yes
123                 fi
124         fi,
125         want_glib2=yes)
126
127 AC_ARG_WITH(perl-staticlib,
128 [  --with-perl-staticlib   Specify that we want to link perl libraries
129                         statically in irssi, default is no],
130         if test x$withval = xyes; then
131                 want_staticperllib=yes
132         else
133                 if test "x$withval" = xno; then
134                         want_staticperllib=no
135                 else
136                         want_staticperllib=yes
137                 fi
138         fi,
139         want_staticperllib=no)
140
141
142 AC_ARG_WITH(perl-lib,
143 [  --with-perl-lib=[site|vendor|DIR]  Specify where to install the
144                         Perl libraries for irssi, default is site],
145         if test "x$withval" = xyes; then
146                 want_perl=yes
147         elif test "x$withval" = xno; then
148                 want_perl=no
149         elif test "x$withval" = xsite; then
150                 want_perl=yes
151                 perl_prefix_note=no
152                 PERL_MM_PARAMS=""
153         elif test "x$withval" = xvendor; then
154                 want_perl=yes
155                 perl_prefix_note=no
156                 if test -z "`$perlpath -v|grep '5\.0'`"; then
157                         PERL_MM_PARAMS="INSTALLDIRS=vendor"
158                 else
159                         PERL_MM_PARAMS="INSTALLDIRS=perl PREFIX=`perl -e 'use Config; print $Config{prefix}'`"
160                 fi
161                 perl_library_dir="(vendor default - `$perlpath -e 'use Config; print $Config{archlib}'`)"
162         else
163                 want_perl=yes
164                 perl_prefix_note=no
165                 PERL_MM_PARAMS="INSTALLDIRS=perl LIB=$withval"
166                 perl_library_dir="PERL_USE_LIB"
167                 perl_set_use_lib=yes
168         fi,
169         want_perl=yes)
170
171 AC_ARG_WITH(perl,
172 [  --with-perl[=yes|no|module]  Build with Perl support - also specifies
173                         if it should be built into main irssi binary
174                         (static, default) or as module],
175         if test x$withval = xyes; then
176                 want_perl=static
177         elif test x$withval = xstatic; then
178                 want_perl=static
179         elif test x$withval = xmodule; then
180                 want_perl=module
181         else
182                 want_perl=no
183         fi,
184         want_perl=static)
185
186 AC_ARG_ENABLE(ipv6,
187 [  --enable-ipv6           Enable IPv6 support],
188         if test x$enableval = xyes; then
189                 want_ipv6=yes
190         else
191                 if test "x$enableval" = xno; then
192                         want_ipv6=no
193                 else
194                         want_ipv6=yes
195                 fi
196         fi,
197         want_ipv6=no)
198
199 dnl **
200 dnl ** just some generic stuff...
201 dnl **
202
203 dnl * OS specific options
204 case "$host_os" in
205   hpux*)
206     CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
207     ;;
208   *)
209     ;;
210 esac
211
212
213 AC_CHECK_FUNCS(mkfifo fcntl nl_langinfo)
214
215 AC_CHECK_FUNC(socket, [], [
216         AC_CHECK_LIB(socket, socket, [
217                 LIBS="$LIBS -lsocket"
218         ])
219 ])
220
221 AC_CHECK_FUNC(inet_addr, [], [
222         AC_CHECK_LIB(nsl, inet_addr, [
223                 LIBS="$LIBS -lnsl"
224         ])
225 ])
226
227 dnl * gcc specific options
228 if test "x$ac_cv_prog_gcc" = "xyes"; then
229   CFLAGS="$CFLAGS -Wall"
230 fi
231
232 dnl * socklen_t - AC_CHECK_TYPE() would be _really_ useful if it only would
233 dnl * accept header files where to find the typedef..
234 AC_MSG_CHECKING([for socklen_t])
235 AC_CACHE_VAL(irssi_cv_type_socklen_t,
236 [AC_TRY_COMPILE([
237 #include <sys/types.h>
238 #include <sys/socket.h>],
239 [socklen_t t;],
240 irssi_cv_type_socklen_t=yes,
241 irssi_cv_type_socklen_t=no,
242 )])
243 if test $irssi_cv_type_socklen_t = no; then
244 AC_DEFINE(socklen_t, int, Define to 'int' if <sys/socket.h> doesn't define.)
245 fi
246 AC_MSG_RESULT($irssi_cv_type_socklen_t)
247
248 dnl **
249 dnl ** check for socks
250 dnl **
251
252 if test "x$want_socks" = "xyes"; then
253         AC_CHECK_LIB(socks, connect, [
254                 LIBS="$LIBS -lsocks"
255                 AC_CHECK_HEADER(socks.h, [
256                         AC_DEFINE(HAVE_SOCKS_H)
257                         CFLAGS="$CFLAGS -DSOCKS"
258                         AC_MSG_RESULT(["socks5 library found, building with it"])
259                 ], [
260                         AC_MSG_RESULT(["socks4 library found, building with it"])
261                         CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dgetpeername=Rgetpeername -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
262                 ])
263         ])
264 fi
265
266 dnl **
267 dnl ** fe-text checks
268 dnl **
269
270 AC_DEFUN(AC_CHECK_GLIBDIR,[
271   AC_MSG_CHECKING([whether GLib is unpacked to irssi dir])
272
273   GLIB_DIR=`for d in *; do test -f $d/glib.h && echo $d; done`
274   if test -n "$GLIB_DIR"; then
275     dnl * glib in irssi directory, use it
276     AC_MSG_RESULT([yes, using it])
277
278     dnl * we have to do this at this point so we know what libs gmodule needs
279     if test ! -f $GLIB_DIR/.libs/libglib.a; then
280       echo
281       echo "configuring GLib ..."
282       echo
283       cd $GLIB_DIR
284       if test ! -f glib-config; then
285         ./configure
286       fi
287       ${MAKE-make}
288       cd ..
289       echo
290     fi
291
292     GLIB_LDEXTRA=`$GLIB_DIR/glib-config --libs gmodule|$sedpath -e 's/-lglib//' -e 's/-lgmodule//' -e 's,-L/usr/local/lib ,,'|$sedpath 's/ \+/ /g'`
293     full_glib_dir="`pwd`/$GLIB_DIR"
294     GLIB_CFLAGS="-I$full_glib_dir -I$full_glib_dir/gmodule"
295     if test -f $full_glib_dir/.libs/libglib.a; then
296       GLIB_LIBS="$full_glib_dir/.libs/libglib.a $GLIB_LDEXTRA"
297       if test -f $full_glib_dir/gmodule/.libs/libgmodule.a; then
298         GLIB_LIBS="$GLIB_LIBS $full_glib_dir/gmodule/.libs/libgmodule.a"
299         AC_DEFINE(HAVE_GMODULE)
300         have_gmodule=yes
301       fi
302     else
303       GLIB_LIBS="$full_glib_dir/libglib.a $GLIB_LDEXTRA"
304       if test -f $full_glib_dir/gmodule/libgmodule.a; then
305         GLIB_LIBS="$GLIB_LIBS $full_glib_dir/gmodule/libgmodule.a"
306         AC_DEFINE(HAVE_GMODULE)
307         have_gmodule=yes
308       fi
309     fi
310     AC_SUBST(GLIB_CFLAGS)
311     AC_SUBST(GLIB_LIBS)
312   else
313     AC_MSG_RESULT([no])
314   fi
315 ])
316
317 AC_CHECK_GLIBDIR
318
319 if test -z "$GLIB_DIR"; then
320   if test "x$with_glib2" = "xyes"; then
321     dnl * check only for glib2
322     checks="3 4"
323   else
324     dnl * check glib1 then glib2
325     checks="1 2 3 4"
326   fi
327
328   for try in $checks; do
329     glib_config_args=
330     if test $try = 1 -o $try = 3; then
331       glib_modules=gmodule
332     else
333       echo "*** trying without -lgmodule"
334       glib_modules=
335     fi
336     if test $try = 1 -o $try = 2; then
337       glib_version=1.2.0
338     else
339       glib_version=2.0.0
340     fi
341     AM_PATH_GLIB($glib_version,[],[], [$glib_modules])
342     if test "$GLIB_LIBS"; then
343       if test $glib_modules = gmodule; then
344         AC_DEFINE(HAVE_GMODULE)
345         have_gmodule=yes
346       fi
347       break
348     fi
349   done
350
351   if test -z "$GLIB_LIBS"; then
352     echo
353     echo "*** If you don't have GLIB, you can get it from ftp://ftp.gtk.org"
354     echo "*** If you can't install GLIB anywhere or if you don't want to,"
355     echo "*** you can just unpack it to Irssi's source directory and"
356     echo "*** Irssi will automatically compile and use it."
357     echo
358
359     dnl * I think it's pretty safe to assume GLib 1.2.9 since the next
360     dnl * will be 2.0 (or 1.4?) and it's not sure if irssi compiles
361     dnl * with it (yea, just a few weeks after I put this text for 1.2.8
362     dnl * the 1.2.9 came :) .. and then .10
363     glib_file=glib-1.2.10.tar.gz
364
365     dlcmd=
366     if test -n "`ncftpget 2>/dev/null|grep -i ncftp`"; then
367       dlcmd="ncftpget ftp://ftp.gtk.org/pub/gtk/v1.2/$glib_file"
368     fi
369     if test -n "`wget 2>/dev/null|grep -i wget`"; then
370       dlcmd="wget http://irssi.org/files/$glib_file"
371     fi
372     if test -n "$dlcmd"; then
373       echo "*** I can download GLib for you now. If you don't want to, press CTRL-C now."
374       echo
375       echo "*** Press ENTER to continue"
376       read answer
377       eval $dlcmd
378       if `gunzip $glib_file`; then
379         glib_file=`echo $glib_file|$sedpath s/\.gz$//`
380         if `tar xf $glib_file`; then
381           rm -f $glib_file
382           AC_CHECK_GLIBDIR
383         fi
384       fi
385     fi
386
387     if test -z "$GLIB_LIBS"; then
388       AC_ERROR([GLIB is required to build irssi.])
389     fi
390   fi
391 fi
392
393 LIBS="$LIBS $GLIB_LIBS"
394
395 dnl **
396 dnl ** check if we can link dynamic libraries to modules
397 dnl ** also checks if libraries are built to .libs dir
398 dnl **
399
400 AC_MSG_CHECKING([if we can link dynamic libraries with modules])
401 DYNLIB_MODULES=no
402
403 dnl ** compile object file
404 cat > conftest.c <<EOF
405 #include <math.h>
406 int modfunc(){return (int)floor(1.2);}
407 EOF
408
409 ./libtool --mode=compile $CC $CFLAGS -c conftest.c 2> /dev/null > /dev/null
410 if test ! -s conftest.lo; then
411   AC_ERROR([error compiling test module])
412 fi
413
414 dnl ** link to library
415 ./libtool --mode=link $CC $CFLAGS $LDFLAGS -rpath /usr/lib conftest.lo -lm -o libconftest.la > /dev/null
416 if test ! -s .libs/libconftest.a; then
417   AC_ERROR([error, can't even find .a library])
418 fi
419
420 dnl ** check if dynamic linking worked
421 libfile=`grep '^library_names' libconftest.la|$sedpath "s/library_names='\(.*\)'.*/\1/"|$sedpath 's/.* \([[^ ]]*\)$/\1/'`
422 if test ! -s .libs/$libfile; then
423   AC_MSG_RESULT([no, error linking test module])
424 else
425   cat > conftest.c <<EOF
426 #include <gmodule.h>
427 main() {
428 GModule *m; int (*modfunc)(void);
429 m = g_module_open(".libs/$libfile", 0);
430 if (!m) g_print("error loading: %s", g_module_error());
431 else if (!g_module_symbol(m, "modfunc", (gpointer *) &modfunc))
432   g_print("modfunc() symbol not found from module");
433 else if (modfunc() == 1) g_print("ok"); else g_print("wrong result?! 1 vs %d", modfunc());
434 return 0; }
435 EOF
436   $CC $CFLAGS $LDFLAGS conftest.c -o conftest $GLIB_CFLAGS $GLIB_LIBS 2> /dev/null > /dev/null
437   if test ! -s conftest; then
438     AC_MSG_RESULT([no, error compiling test program])
439   else
440     status="`./conftest`"
441     if test "x$status" = "xok"; then
442       DYNLIB_MODULES=yes
443       AC_MSG_RESULT([yes])
444     else
445       AC_MSG_RESULT([no, error running: $status])
446     fi
447   fi
448 fi
449 rm -rf conftest conftest.* libconftest.* .libs
450
451 dnl **
452 dnl ** curses checks
453 dnl **
454
455 if test "x$want_textui" = "xyes"; then
456         AC_CHECK_CURSES
457
458         TEXTUI_LIBS="$LIBS $CURSES_LIBS"
459         if test "x$has_curses" = "xtrue"; then
460                 AC_CHECK_FUNC(use_default_colors, AC_DEFINE(HAVE_NCURSES_USE_DEFAULT_COLORS))
461                 AC_CHECK_FUNC(idcok, AC_DEFINE(HAVE_CURSES_IDCOK))
462                 AC_CHECK_FUNC(resizeterm, AC_DEFINE(HAVE_CURSES_RESIZETERM))
463                 AC_CHECK_FUNC(wresize, AC_DEFINE(HAVE_CURSES_WRESIZE))
464                 AC_CHECK_FUNC(setupterm,, [
465                         want_termcap=yes
466                 ])
467         else
468                 AC_CHECK_LIB(tinfo, setupterm, [
469                   TEXTUI_LIBS="$LIBS -ltinfo"
470                   want_terminfo=yes
471                 ], AC_CHECK_LIB(termlib, tgetent, [
472                   TEXTUI_LIBS="$LIBS -ltermlib"
473                   want_termcap=yes
474                 ], AC_CHECK_LIB(termcap, tgetent, [
475                   TEXTUI_LIBS="$LIBS -ltermcap"
476                   want_termcap=yes
477                 ], [
478                   AC_ERROR(Terminfo/termcap not found - install ncurses-devel package)
479                   want_textui=no
480                 ])))
481         fi
482         AC_SUBST(TEXTUI_LIBS)
483         if test "x$want_termcap" = "xyes"; then
484                 AC_CHECK_FUNC(tparm,, need_tparm=yes)
485         else
486                 AC_DEFINE(HAVE_TERMINFO)
487         fi
488 fi
489
490 dnl **
491 dnl ** perl checks
492 dnl **
493
494 if test "$want_perl" != "no"; then
495         AC_MSG_CHECKING(for working Perl support)
496
497         if test -z "$perlpath"; then
498                 perl_check_error="perl binary not found"
499         else
500                 PERL_CFLAGS=`$perlpath -MExtUtils::Embed -e ccopts 2>/dev/null`
501         fi
502
503         if test -z "$PERL_CFLAGS"; then
504                 if test -n "$perl_check_error"; then
505                         perl_check_error="Error getting perl CFLAGS"
506                 fi
507                 AC_MSG_RESULT([not found, building without Perl])
508                 want_perl=no
509         else
510                 PERL_LDFLAGS=`$perlpath -MExtUtils::Embed -e ldopts 2>/dev/null`
511
512                 dnl * Perl 5.004 and older use perl_xxx variables while
513                 dnl * later use PL_perl_xxx variables ..
514                 have_pl_perl=`$perlpath -e 'print $] < 5.005 ? "no" : "yes";'`
515                 if test "x$have_pl_perl" = "xyes"; then
516                         AC_DEFINE(HAVE_PL_PERL)
517                 fi
518
519                 if test "x$DYNLIB_MODULES" = "xno" -a "$want_perl" != "static"; then
520                         dnl * wanted perl as module, won't get it.
521                         want_perl=static
522                         perl_mod_error="Dynamic library dependencies don't work with modules"
523                 fi
524
525                 if test "$want_perl" != "static"; then
526                         dnl * dynaloader.a -> libperl_dynaloader.la
527                         DYNALOADER_A=`echo $PERL_LDFLAGS | $perlpath -pe 's/^(.* )*([[^ ]]*DynaLoader\.a).*/\2/'`
528                 fi
529
530                 dnl * don't check libperl.a if dynaloader.a wasn't found..
531                 if test -n "$DYNALOADER_A"; then
532                         dnl * find either libperl.a or libperl.so
533                         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 } } };'`
534                         if test -z "$LIBPERL_A"; then
535                                 perl_mod_error="Didn't find location of -lperl"
536                                 DYNALOADER_A=
537                         elif test "$LIBPERL_A" = "-lperl"; then
538                                 LIBPERL_A=
539                         fi
540                 fi
541
542                 dnl * remove all database stuffs
543                 dnl * nsl is already in ldflags
544                 dnl * libc is of course linked without needing -lc
545                 dnl * -rdynamic must not be in LIBADD line
546                 for word in -ldb -ldbm -lndbm -lgdbm -lc -rdynamic; do
547                   PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e "s/$word //" -e "s/$word$//"`
548                 done
549
550                 case "$host_os" in
551                   linux*)
552                     PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e 's/-lposix //' -e 's/-lposix$//'`
553                     ;;
554                   hpux*)
555                     if test "x$ac_cv_prog_gcc" = "xyes"; then
556                       PERL_CFLAGS=`echo $PERL_CFLAGS | $sedpath -e 's/-Ae //' -e 's/-Ae$//'`
557                       PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e 's/-Ae //' -e 's/-Ae$//'`
558                     fi
559                     ;;
560                   *)
561                     ;;
562                 esac
563
564                 dnl * check that perl's ldflags actually work
565                 echo "main(){perl_alloc(); return 0;}" > conftest.c
566                 $CC $CFLAGS conftest.c -o conftest $LDFLAGS $PERL_LDFLAGS 2> perl.error.tmp > /dev/null
567                 if test ! -s conftest; then
568                         perl_check_error="Error linking with perl libraries: $PERL_LDFLAGS: `cat perl.error.tmp`"
569                         AC_MSG_RESULT([error linking with perl libraries, building without Perl])
570                         want_perl=no
571                 fi
572
573                 rm -f perl.error.tmp
574         fi
575
576         if test "x$want_perl" != "xno"; then
577                 if test "x$want_perl" = "xstatic"; then
578                         AC_MSG_RESULT(ok)
579                 elif test -z "$DYNALOADER_A"; then
580                         AC_MSG_RESULT([error parsing ldopts, building Perl into irssi binary instead of as module])
581                         want_perl=static
582                 else
583                         AC_MSG_RESULT(ok)
584                         PERL_LDFLAGS=`echo $PERL_LDFLAGS | $perlpath -pe 's/^(.* )*[[^ ]]*DynaLoader\.a/\1libperl_dynaloader.la/'`
585                         if test -n "$LIBPERL_A"; then
586                                 PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e 's/-lperl /libperl_orig.la /' -e 's/-lperl$/libperl_orig.la$/'`
587                         fi
588                         AC_SUBST(LIBPERL_A)
589                         AC_SUBST(DYNALOADER_A)
590                 fi
591
592                 if test "x$want_perl" = "xstatic"; then
593                         dnl * building with static perl support
594                         dnl * all PERL_LDFLAGS linking is done in fe-text
595                         PERL_LINK_FLAGS="$PERL_LDFLAGS"
596                         PERL_LINK_LIBS="../perl/libperl_core_static.la"
597                         PERL_FE_LINK_LIBS="../perl/libfe_perl_static.la"
598                         PERL_LDFLAGS=
599                         AC_DEFINE(HAVE_STATIC_PERL)
600
601                         dnl * build only static library of perl module
602                         perl_module_lib=
603                         perl_module_fe_lib=
604                         perl_static_lib=libperl_core_static.la
605                         perl_static_fe_lib=libfe_perl_static.la
606                         PERL_LIBTOOL='$(SHELL) $(top_builddir)/libtool'
607                 else
608                         dnl * build dynamic library of perl module
609                         perl_module_lib=libperl_core.la
610                         perl_module_fe_lib=libfe_perl.la
611                         perl_static_lib=
612                         perl_static_fe_lib=
613                         PERL_LIBTOOL='$(SHELL) $(top_builddir)/libtool'
614                 fi
615
616                 if test "x$want_staticperllib" = "xyes"; then
617                         PERL_MM_PARAMS="$PERL_MM_PARAMS LINKTYPE=static"
618                         PERL_LINK_LIBS="$PERL_LINK_LIBS ../perl/common/blib/arch/auto/Irssi/Irssi.a ../perl/irc/blib/arch/auto/Irssi/Irc/Irc.a ../perl/ui/blib/arch/auto/Irssi/UI/UI.a ../perl/textui/blib/arch/auto/Irssi/TextUI/TextUI.a"
619                         PERL_STATIC_LIBS=1
620                 else
621                         PERL_STATIC_LIBS=0
622                 fi
623
624                 # figure out the correct @INC path - we'll need to do this
625                 # through MakeMaker since it's difficult to get it right
626                 # otherwise.
627                 if test "x$perl_set_use_lib" = "xyes"; then
628                         perl -e 'use ExtUtils::MakeMaker; WriteMakefile("NAME" => "test", "MAKEFILE" => "Makefile.test");' $PERL_MM_PARAMS >/dev/null
629                         PERL_USE_LIB=`perl -e 'open(F, "Makefile.test"); while (<F>) { chomp; if (/^(\w+) = (.*$)/) { $keys{$1} = $2; } }; $key = $keys{INSTALLARCHLIB}; while ($key =~ /\\$\((\w+)\)/) { $value = $keys{$1}; $key =~ s/\\$\($1\)/$value/; }; print $key;'`
630                         rm -f Makefile.test
631                 fi
632
633                 AC_SUBST(perl_module_lib)
634                 AC_SUBST(perl_static_lib)
635                 AC_SUBST(perl_module_fe_lib)
636                 AC_SUBST(perl_static_fe_lib)
637                 AC_SUBST(PERL_LIBTOOL)
638
639                 AC_SUBST(PERL_LINK_FLAGS)
640                 AC_SUBST(PERL_LINK_LIBS)
641                 AC_SUBST(PERL_FE_LINK_LIBS)
642
643                 AC_SUBST(PERL_LDFLAGS)
644                 AC_SUBST(PERL_CFLAGS)
645
646                 AC_SUBST(PERL_USE_LIB)
647                 AC_SUBST(PERL_MM_PARAMS)
648                 AC_SUBST(PERL_STATIC_LIBS)
649         fi
650 fi
651
652 dnl ** check what we want to build
653 AM_CONDITIONAL(BUILD_TEXTUI, test "$want_textui" = "yes")
654 AM_CONDITIONAL(BUILD_IRSSIBOT, test "$want_irssibot" = "yes")
655 AM_CONDITIONAL(BUILD_IRSSIPROXY, test "$want_irssiproxy" = "yes")
656 AM_CONDITIONAL(BUILD_PLUGINS, test "$want_plugins" = "yes")
657 AM_CONDITIONAL(HAVE_PERL, test "$want_perl" != "no")
658 AM_CONDITIONAL(HAVE_STATIC_PERL, test "$want_perl" = "static")
659 AM_CONDITIONAL(NEED_TPARM, test "$need_tparm" = "yes")
660 AM_CONDITIONAL(USE_CURSES, test "$want_terminfo" != "yes" -a "$want_termcap" != "yes")
661
662 # move LIBS to PROG_LIBS so they're not tried to be used when linking eg. perl libraries
663 PROG_LIBS=$LIBS
664 LIBS=
665 AC_SUBST(PROG_LIBS)
666
667 dnl **
668 dnl ** Keep all the libraries here so each frontend doesn't need to
669 dnl ** keep track of them all
670 dnl **
671 dnl ** (these could be made configurable)
672
673 CHAT_MODULES="silc"
674 silc_MODULES=""
675 if test -n "$build_modules"; then
676         silc_MODULES="$silc_MODULES $build_modules"
677 fi
678
679 dnl ****************************************
680
681 AC_SUBST(CHAT_MODULES)
682 AC_SUBST(silc_MODULES)
683
684 CORE_LIBS="../core/libcore.a ../lib-config/libirssi_config.a ../lib-popt/libpopt.a"
685 FE_COMMON_LIBS=""
686
687 CHAT_LIBS=""
688 for c in $CHAT_MODULES; do
689         module_inits=""
690         module_deinits=""
691         fe_module_inits=""
692         fe_module_deinits=""
693         CHAT_LIBS="$CHAT_LIBS ../$c/lib$c.a ../$c/core/lib${c}_core.a"
694         if test -f $srcdir/src/fe-common/$c/module.h; then
695                 FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/$c/libfe_common_$c.a "
696         fi
697         for s in `eval echo \\$${c}_MODULES`; do
698                 CHAT_LIBS="$CHAT_LIBS ../$c/$s/lib${c}_$s.a"
699                 module_inits="$module_inits ${c}_${s}_init();"
700                 module_deinits="${c}_${s}_deinit(); $module_deinits"
701                 if test -f $srcdir/src/fe-common/$c/$s/module.h; then
702                         FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/$c/$s/libfe_${c}_$s.a "
703                         fe_module_inits="$fe_module_inits fe_${c}_${s}_init();"
704                         fe_module_deinits="fe_${c}_${s}_deinit(); $fe_module_deinits"
705                 fi
706         done
707
708         file="$srcdir/src/$c/$c.c"
709         echo "/* this file is automatically generated by configure - don't change */" > $file
710         echo "void ${c}_core_init(void); void ${c}_core_deinit(void);" >> $file
711         if test -n "$module_inits"; then
712                 echo "$module_inits" | $sedpath -e 's/()/(void)/g' -e 's/ /void /g' >> $file
713                 echo "$module_deinits" | $sedpath -e 's/ *$//' -e 's/()/(void)/g' -e 's/ /void /g' -e 's/^/void /' >> $file
714         fi
715         echo "void ${c}_init(void) { ${c}_core_init(); $module_inits }" >> $file
716         echo "void ${c}_deinit(void) { $module_deinits ${c}_core_deinit(); }" >> $file
717
718         if test -f $srcdir/src/fe-common/$c/module.h; then
719                 file="$srcdir/src/fe-common/$c/${c}-modules.c"
720                 echo "/* this file is automatically generated by configure - don't change */" > $file
721                 if test -n "$fe_module_inits"; then
722                         echo "$fe_module_inits" | $sedpath -e 's/()/(void)/g' -e 's/ /void /g' >> $file
723                         echo "$fe_module_deinits" | $sedpath -e 's/ *$//' -e 's/()/(void)/g' -e 's/ /void /g' -e 's/^/void /' >> $file
724                 fi
725                 echo "void fe_${c}_modules_init(void) { $fe_module_inits }" >> $file
726                 echo "void fe_${c}_modules_deinit(void) { $fe_module_deinits }" >> $file
727         fi
728 done
729
730 FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/core/libfe_common_core.a"
731
732 dnl ** common libraries needed by frontends
733 COMMON_NOUI_LIBS="$CHAT_LIBS $CORE_LIBS"
734 COMMON_LIBS="$FE_COMMON_LIBS $COMMON_NOUI_LIBS"
735 AC_SUBST(COMMON_NOUI_LIBS)
736 AC_SUBST(COMMON_LIBS)
737
738 dnl **
739 dnl ** IPv6 support
740 dnl **
741
742 if test "x$want_ipv6" = "xyes"; then
743         AC_MSG_CHECKING([for IPv6])
744         AC_CACHE_VAL(irssi_cv_type_in6_addr,
745         [AC_TRY_COMPILE([
746         #include <sys/types.h>
747         #include <sys/socket.h>
748         #include <netinet/in.h>
749         #include <netdb.h>
750         #include <arpa/inet.h>],
751         [struct in6_addr i;],
752         irssi_cv_type_in6_addr=yes,
753         irssi_cv_type_in6_addr=no,
754         )])
755         if test $irssi_cv_type_in6_addr = yes; then
756                 AC_DEFINE(HAVE_IPV6)
757         fi
758         AC_MSG_RESULT($irssi_cv_type_in6_addr)
759 fi
760
761 dnl **
762 dnl ** IRSSI_VERSION_DATE and IRSSI_VERSION_TIME
763 dnl **
764 #VERSION_DATE=`head -1 $srcdir/ChangeLog|sed 's/^\(....\)-\(..\)-\(..\).*/\1\2\3/'`
765 #VERSION_TIME=`head -1 $srcdir/ChangeLog|sed -e 's/^[[^ ]]* \(..\):\(..\).*/\1\2/' -e 's/^0*//'`
766 #AC_SUBST(VERSION_DATE)
767 #AC_SUBST(VERSION_TIME)
768
769 #
770 # Glue into SILC build system
771 #
772 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
773 AC_SUBST(INCLUDE_DEFINES_INT)
774
775 AC_OUTPUT(
776 Makefile
777 src/Makefile
778 src/core/Makefile
779 src/fe-common/Makefile
780 src/fe-common/core/Makefile
781 src/fe-common/silc/Makefile
782 src/fe-text/Makefile
783 src/lib-config/Makefile
784 src/lib-popt/Makefile
785 src/silc/Makefile
786 src/silc/core/Makefile
787 src/perl/Makefile
788 src/perl/common/Makefile.PL
789 src/perl/ui/Makefile.PL
790 src/perl/textui/Makefile.PL
791 scripts/Makefile
792 docs/Makefile
793 docs/help/Makefile
794 docs/help/in/Makefile
795 irssi-version.h
796 stamp.h
797 irssi.spec
798 irssi-config)
799
800 dnl ** for building from objdir
801 old_dir=`pwd` && cd $srcdir && whole_dir=`pwd` && cd $old_dir
802 if test "x$old_dir" != "x$whole_dir"; then
803         $LN_S $srcdir/irssi-version.h irssi-version.h
804
805         if test "x$want_perl" != "xno"; then
806                 subdirfiles=""
807                 for i in $whole_dir/src/perl/common $whole_dir/src/perl/irc $whole_dir/src/perl/ui $whole_dir/src/perl/textui; do
808                         subdirfiles=`echo $subdirfiles $i/typemap $i/module.h $i/*.pm $i/*.xs`
809                 done
810                 for file in $whole_dir/src/perl/*.[[ch]] $whole_dir/src/perl/libperl_orig.la $whole_dir/src/perl/libperl_dynaloader.la $subdirfiles; do
811                         link=`echo $file|$sedpath "s?$whole_dir/??"`
812                         rm -f $link
813                         $LN_S $file $link
814                 done
815         fi
816 fi
817
818 echo
819
820 if test "x$want_textui" = "xno"; then
821         text=no
822 elif test "x$want_termcap" = "xyes"; then
823         text="yes, using termcap"
824 elif test "x$want_terminfo" = "xyes"; then
825         text="yes, using terminfo"
826 else
827         text="yes, using curses"
828 fi
829 echo "Building text frontend ..... : $text"
830 echo "Building irssi bot ......... : $want_irssibot"
831 echo "Building irssi proxy ....... : $want_irssiproxy"
832 echo "Building with IPv6 support . : $want_ipv6"
833 if test "x$have_gmodule" = "xyes"; then
834         echo "Building with module support : yes"
835 else
836         echo "Building with module support : NO!! /LOAD will not work!"
837         echo " - You're missing gmodule (comes with glib) for some reason,"
838         echo "   or it doesn't work in your system."
839 fi
840
841 if test "x$want_perl" = "xstatic"; then
842         echo "Building with Perl support . : static (in irssi binary)"
843 elif test "x$want_perl" = "xmodule"; then
844         echo "Building with Perl support . : module"
845 else
846         if test -z "$perl_check_error"; then
847                 echo "Building with Perl support . : no"
848         else
849                 echo "Building with Perl support . : NO!"
850                 echo " - $perl_check_error"
851         fi
852 fi
853
854 if test "x$want_perl" != "xno" -a "x$perl_mod_error" != "x"; then
855         echo " - NOTE: Perl support will be compiled statically to irssi, not as"
856         echo "   a module as requested. Reason:"
857         echo "   $perl_mod_error"
858
859         if test -f /etc/debian_version; then
860                 echo " - Try: apt-get install libperl-dev"
861         fi
862 fi
863
864 if test "x$want_perl" != "xno"; then
865         if test "$perl_library_dir" = "PERL_USE_LIB"; then
866                 perl_library_dir=$PERL_USE_LIB
867         fi
868         if test -z "$perl_library_dir"; then
869                 perl_library_dir="(site default - `$perlpath -e 'use Config; print $Config{sitearch}'`)"
870         fi
871         echo "Perl library directory ..... : $perl_library_dir"
872         if test "x$perl_prefix_note" = "xyes"; then
873                 echo "  - NOTE: This was automatically set to the same directory you gave with"
874                 echo "  --prefix. If you want the perl libraries to install to their 'correct'"
875                 echo "  path, you'll need to give --with-perl-lib=site option to configure."
876                 echo "  Anyway, installing perl to this directory should work just as well."
877         fi
878 fi
879
880 echo "Install prefix ............. : $prefix"
881
882 echo
883 echo "If there was any problems, read the INSTALL file."