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