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