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