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