New silcconfig library and server parser. Merged silc-newconfig-final.patch.
[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.7.99)
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(big5,
34 [  --with-big5             Build with tr-Chinese Big5 support],
35         if test x$withval = xyes; then
36                 want_big5=yes
37         else
38                 if test "x$withval" = xno; then
39                         want_big5=no
40                 else
41                         want_big5=yes
42                 fi
43         fi,
44         want_big5=no)
45
46 AC_ARG_WITH(socks,
47 [  --with-socks            Build with socks support],
48         if test x$withval = xyes; then
49                 want_socks=yes
50         else
51                 if test "x$withval" = xno; then
52                         want_socks=no
53                 else
54                         want_socks=yes
55                 fi
56         fi,
57         want_socks=no)
58
59 AC_ARG_WITH(textui,
60 [  --with-textui           Build text frontend],
61         if test x$withval = xyes; then
62                 want_textui=yes
63         else
64                 if test "x$withval" = xno; then
65                         want_textui=no
66                 else
67                         want_textui=yes
68                 fi
69         fi,
70         want_textui=yes)
71
72 AC_ARG_WITH(bot,
73 [  --with-bot              Build irssi-bot],
74         if test x$withval = xyes; then
75                 want_irssibot=yes
76         else
77                 if test "x$withval" = xno; then
78                         want_irssibot=no
79                 else
80                         want_irssibot=yes
81                 fi
82         fi,
83         want_irssibot=no)
84
85 AC_ARG_WITH(proxy,
86 [  --with-proxy            Build irssi-proxy],
87         if test x$withval = xyes; then
88                 want_irssiproxy=yes
89         else
90                 if test "x$withval" = xno; then
91                         want_irssiproxy=no
92                 else
93                         want_irssiproxy=yes
94                 fi
95         fi,
96         want_irssiproxy=no)
97
98 AC_ARG_WITH(terminfo,
99 [  --with-terminfo         Use terminfo directly instead of curses],
100         if test x$withval = xyes; then
101                 want_terminfo=yes
102         else
103                 if test "x$withval" = xno; then
104                         want_terminfo=no
105                 else
106                         want_terminfo=yes
107                 fi
108         fi,
109         want_terminfo=yes)
110
111 AC_ARG_WITH(modules,
112 [  --with-modules          Specify what modules to build in binary],
113         if test x$withval != xyes -a x$withval != xno; then
114                 build_modules="$withval"
115         fi)
116
117 if test "x$prefix" != "xNONE"; then
118         prefix=`eval echo $prefix`
119         PERL_MM_PARAMS="INSTALLDIRS=perl PREFIX=$prefix"
120         perl_library_dir="PERL_USE_LIB"
121         perl_set_use_lib=yes
122
123         perl_prefix_note=yes
124 fi
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)
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       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       fi
314     fi
315     AC_SUBST(GLIB_CFLAGS)
316     AC_SUBST(GLIB_LIBS)
317   else
318     AC_MSG_RESULT([no])
319   fi
320 ])
321
322 AC_CHECK_GLIBDIR
323
324 if test -z "$GLIB_DIR"; then
325   AM_PATH_GLIB(1.2.0,,, gmodule)
326   if test -z "$GLIB_LIBS"; then
327     echo "*** trying without -lgmodule"
328     glib_config_args=
329     AM_PATH_GLIB(1.2.0)
330   else
331     AC_DEFINE(HAVE_GMODULE)
332   fi
333
334   if test -z "$GLIB_LIBS"; then
335     echo
336     echo "*** If you don't have GLIB, you can get it from ftp://ftp.gtk.org"
337     echo "*** If you can't install GLIB anywhere or if you don't want to,"
338     echo "*** you can just unpack it to Irssi's source directory and"
339     echo "*** Irssi will automatically compile and use it."
340     echo
341
342     dnl * I think it's pretty safe to assume GLib 1.2.9 since the next
343     dnl * will be 2.0 (or 1.4?) and it's not sure if irssi compiles
344     dnl * with it (yea, just a few weeks after I put this text for 1.2.8
345     dnl * the 1.2.9 came :) .. and then .10
346     glib_file=glib-1.2.10.tar.gz
347
348     dlcmd=
349     if test -n "`ncftpget 2>/dev/null|grep -i ncftp`"; then
350       dlcmd="ncftpget ftp://ftp.gtk.org/pub/gtk/v1.2/$glib_file"
351     fi
352     if test -n "`wget 2>/dev/null|grep -i wget`"; then
353       dlcmd="wget http://irssi.org/files/$glib_file"
354     fi
355     if test -n "$dlcmd"; then
356       echo "*** I can download GLib for you now. If you don't want to, press CTRL-C now."
357       echo
358       echo "*** Press ENTER to continue"
359       read answer
360       eval $dlcmd
361       if `gunzip $glib_file`; then
362         glib_file=`echo $glib_file|$sedpath s/\.gz$//`
363         if `tar xf $glib_file`; then
364           rm -f $glib_file
365           AC_CHECK_GLIBDIR
366         fi
367       fi
368     fi
369
370     if test -z "$GLIB_LIBS"; then
371       AC_ERROR([GLIB is required to build irssi.])
372     fi
373   fi
374 fi
375
376 LIBS="$LIBS $GLIB_LIBS"
377
378 dnl **
379 dnl ** check if we can link dynamic libraries to modules
380 dnl ** also checks if libraries are built to .libs dir
381 dnl **
382
383 AC_MSG_CHECKING([if we can link dynamic libraries with modules])
384 DYNLIB_MODULES=no
385
386 dnl ** compile object file
387 cat > conftest.c <<EOF
388 #include <math.h>
389 int modfunc(){return (int)floor(1.2);}
390 EOF
391
392 ./libtool --mode=compile $CC $CFLAGS -c conftest.c 2> /dev/null > /dev/null
393 if test ! -s conftest.lo; then
394   AC_ERROR([error compiling test module])
395 fi
396
397 dnl ** link to library
398 ./libtool --mode=link $CC $CFLAGS $LDFLAGS -rpath /usr/lib conftest.lo -lm -o libconftest.la > /dev/null
399 if test ! -s .libs/libconftest.a; then
400   AC_ERROR([error, can't even find .a library])
401 fi
402
403 dnl ** check if dynamic linking worked
404 libfile=`grep '^library_names' libconftest.la|$sedpath "s/library_names='\(.*\)'.*/\1/"|$sedpath 's/.* \([[^ ]]*\)$/\1/'`
405 if test ! -s .libs/$libfile; then
406   AC_MSG_RESULT([no, error linking test module])
407 else
408   cat > conftest.c <<EOF
409 #include <gmodule.h>
410 main() {
411 GModule *m; int (*modfunc)(void);
412 m = g_module_open(".libs/$libfile", 0);
413 if (!m) g_print("error loading: %s", g_module_error());
414 else if (!g_module_symbol(m, "modfunc", (gpointer *) &modfunc))
415   g_print("modfunc() symbol not found from module");
416 else if (modfunc() == 1) g_print("ok"); else g_print("wrong result?! 1 vs %d", modfunc());
417 return 0; }
418 EOF
419   $CC $CFLAGS $LDFLAGS conftest.c -o conftest $GLIB_CFLAGS $GLIB_LIBS 2> /dev/null > /dev/null
420   if test ! -s conftest; then
421     AC_MSG_RESULT([no, error compiling test program])
422   else
423     status="`./conftest`"
424     if test "x$status" = "xok"; then
425       DYNLIB_MODULES=yes
426       AC_MSG_RESULT([yes])
427     else
428       AC_MSG_RESULT([no, error running: $status])
429     fi
430   fi
431 fi
432 rm -rf conftest conftest.* libconftest.* .libs
433
434 dnl **
435 dnl ** curses checks
436 dnl **
437
438 if test "x$want_textui" = "xyes"; then
439         AC_CHECK_CURSES
440
441         LIBS="$LIBS $CURSES_LIBS"
442         if test "x$has_curses" = "xtrue"; then
443                 AC_CHECK_FUNC(use_default_colors, AC_DEFINE(HAVE_NCURSES_USE_DEFAULT_COLORS))
444                 AC_CHECK_FUNC(idcok, AC_DEFINE(HAVE_CURSES_IDCOK))
445                 AC_CHECK_FUNC(resizeterm, AC_DEFINE(HAVE_CURSES_RESIZETERM))
446                 AC_CHECK_FUNC(wresize, AC_DEFINE(HAVE_CURSES_WRESIZE))
447                 if test "x$want_terminfo" = "xyes"; then
448                         AC_CHECK_LIB(curses, setupterm,, [
449                                 want_termcap=yes
450                         ])
451                 fi
452         else
453                 AC_CHECK_LIB(tinfo, setupterm, [
454                   LIBS="$LIBS -ltinfo"
455                   want_terminfo=yes
456                 ], AC_CHECK_LIB(termlib, tgetent, [
457                   LIBS="$LIBS -ltermlib"
458                   want_termcap=yes
459                 ], AC_CHECK_LIB(termcap, tgetent, [
460                   LIBS="$LIBS -ltermcap"
461                   want_termcap=yes
462                 ], [
463                   AC_MSG_WARN(Terminfo/termcap not found)
464                   want_textui=no
465                   curses_error=yes
466                 ])))
467         fi
468         if test "x$want_termcap" = "xyes"; then
469                 AC_CHECK_FUNC(tparm,, need_tparm=yes)
470         else
471                 AC_DEFINE(HAVE_TERMINFO)
472         fi
473 fi
474
475 dnl **
476 dnl ** perl checks
477 dnl **
478
479 if test "$want_perl" != "no"; then
480         AC_MSG_CHECKING(for working Perl support)
481
482         if test -z "$perlpath"; then
483                 perl_check_error="perl binary not found"
484         else
485                 PERL_CFLAGS=`$perlpath -MExtUtils::Embed -e ccopts 2>/dev/null`
486         fi
487
488         if test -z "$PERL_CFLAGS"; then
489                 if test -n "$perl_check_error"; then
490                         perl_check_error="Error getting perl CFLAGS"
491                 fi
492                 AC_MSG_RESULT([not found, building without Perl])
493                 want_perl=no
494         else
495                 PERL_LDFLAGS=`$perlpath -MExtUtils::Embed -e ldopts 2>/dev/null`
496
497                 dnl * Perl 5.004 and older use perl_xxx variables while
498                 dnl * later use PL_perl_xxx variables ..
499                 have_pl_perl=`$perlpath -e 'print $] < 5.005 ? "no" : "yes";'`
500                 if test "x$have_pl_perl" = "xyes"; then
501                         AC_DEFINE(HAVE_PL_PERL)
502                 fi
503
504                 if test "x$DYNLIB_MODULES" = "xno" -a "$want_perl" != "static"; then
505                         dnl * wanted perl as module, won't get it.
506                         want_perl=static
507                         perl_mod_error="Dynamic library dependencies don't work with modules"
508                 fi
509
510                 if test "$want_perl" != "static"; then
511                         dnl * dynaloader.a -> libperl_dynaloader.la
512                         DYNALOADER_A=`echo $PERL_LDFLAGS | $perlpath -pe 's/^(.* )*([[^ ]]*DynaLoader\.a).*/\2/'`
513                 fi
514
515                 dnl * don't check libperl.a if dynaloader.a wasn't found..
516                 if test -n "$DYNALOADER_A"; then
517                         dnl * find either libperl.a or libperl.so
518                         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 } } };'`
519                         if test -z "$LIBPERL_A"; then
520                                 perl_mod_error="Didn't find location of -lperl"
521                                 DYNALOADER_A=
522                         elif test "$LIBPERL_A" = "-lperl"; then
523                                 LIBPERL_A=
524                         fi
525                 fi
526
527                 dnl * remove all database stuffs
528                 dnl * nsl is already in ldflags
529                 dnl * libc is of course linked without needing -lc
530                 dnl * -rdynamic must not be in LIBADD line
531                 for word in -ldb -ldbm -lndbm -lgdbm -lc -rdynamic; do
532                   PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e "s/$word //" -e "s/$word$//"`
533                 done
534
535                 case "$host_os" in
536                   linux*)
537                     PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e 's/-lposix //' -e 's/-lposix$//'`
538                     ;;
539                   hpux*)
540                     if test "x$ac_cv_prog_gcc" = "xyes"; then
541                       PERL_CFLAGS=`echo $PERL_CFLAGS | $sedpath -e 's/-Ae //' -e 's/-Ae$//'`
542                       PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e 's/-Ae //' -e 's/-Ae$//'`
543                     fi
544                     ;;
545                   *)
546                     ;;
547                 esac
548
549                 dnl * check that perl's ldflags actually work
550                 AC_CACHE_VAL(irssi_cv_lib_perl_works, [
551                         echo "main(){perl_alloc(); return 0;}" > conftest.c
552                         $CC $CFLAGS conftest.c -o conftest $LDFLAGS $PERL_LDFLAGS 2> perl.error.tmp > /dev/null
553                         if test -s conftest; then
554                                 irssi_cv_lib_perl_works=yes
555                         else
556                                 irssi_cv_lib_perl_works=no
557                         fi
558                 ])
559
560                 if test "x$irssi_cv_lib_perl_works" = "xno"; then
561                         perl_check_error="Error linking with perl libraries: $PERL_LDFLAGS: `cat perl.error.tmp`"
562                         AC_MSG_RESULT([error linking with perl libraries, building without Perl])
563                         want_perl=no
564                 fi
565                 rm -f perl.error.tmp
566         fi
567
568         if test "x$want_perl" != "xno"; then
569                 if test "x$want_perl" = "xstatic"; then
570                         AC_MSG_RESULT(ok)
571                 elif test -z "$DYNALOADER_A"; then
572                         AC_MSG_RESULT([error parsing ldopts, building Perl into irssi binary instead of as module])
573                         want_perl=static
574                 else
575                         AC_MSG_RESULT(ok)
576                         PERL_LDFLAGS=`echo $PERL_LDFLAGS | $perlpath -pe 's/^(.* )*[[^ ]]*DynaLoader\.a/\1libperl_dynaloader.la/'`
577                         if test -n "$LIBPERL_A"; then
578                                 PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e 's/-lperl /libperl_orig.la /' -e 's/-lperl$/libperl_orig.la$/'`
579                         fi
580                         AC_SUBST(LIBPERL_A)
581                         AC_SUBST(DYNALOADER_A)
582                 fi
583
584                 if test "x$want_perl" = "xstatic"; then
585                         dnl * building with static perl support
586                         dnl * all PERL_LDFLAGS linking is done in fe-text
587                         PERL_LINK_FLAGS="$PERL_LDFLAGS"
588                         PERL_LINK_LIBS="../perl/libperl_core_static.la"
589                         PERL_FE_LINK_LIBS="../perl/libfe_perl_static.la"
590                         PERL_LDFLAGS=
591                         AC_DEFINE(HAVE_STATIC_PERL)
592
593                         dnl * build only static library of perl module
594                         perl_module_lib=
595                         perl_module_fe_lib=
596                         perl_static_lib=libperl_core_static.la
597                         perl_static_fe_lib=libfe_perl_static.la
598                         PERL_LIBTOOL='$(SHELL) $(top_builddir)/libtool'
599                 else
600                         dnl * build dynamic library of perl module
601                         perl_module_lib=libperl_core.la
602                         perl_module_fe_lib=libfe_perl.la
603                         perl_static_lib=
604                         perl_static_fe_lib=
605                         PERL_LIBTOOL='$(SHELL) $(top_builddir)/libtool'
606                 fi
607
608                 if test "x$want_staticperllib" = "xyes"; then
609                         PERL_MM_PARAMS="$PERL_MM_PARAMS LINKTYPE=static"
610                         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"
611                         PERL_STATIC_LIBS=1
612                 else
613                         PERL_STATIC_LIBS=0
614                 fi
615
616                 # figure out the correct @INC path - we'll need to do this
617                 # through MakeMaker since it's difficult to get it right
618                 # otherwise.
619                 if test "x$perl_set_use_lib" = "xyes"; then
620                         perl -e 'use ExtUtils::MakeMaker; WriteMakefile("NAME" => "test", "MAKEFILE" => "Makefile.test");' $PERL_MM_PARAMS >/dev/null
621                         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;'`
622                         rm -f Makefile.test
623                 fi
624
625                 AC_SUBST(perl_module_lib)
626                 AC_SUBST(perl_static_lib)
627                 AC_SUBST(perl_module_fe_lib)
628                 AC_SUBST(perl_static_fe_lib)
629                 AC_SUBST(PERL_LIBTOOL)
630
631                 AC_SUBST(PERL_LINK_FLAGS)
632                 AC_SUBST(PERL_LINK_LIBS)
633                 AC_SUBST(PERL_FE_LINK_LIBS)
634
635                 AC_SUBST(PERL_LDFLAGS)
636                 AC_SUBST(PERL_CFLAGS)
637
638                 AC_SUBST(PERL_USE_LIB)
639                 AC_SUBST(PERL_MM_PARAMS)
640                 AC_SUBST(PERL_STATIC_LIBS)
641         fi
642 fi
643
644 dnl ** check what we want to build
645 AM_CONDITIONAL(BUILD_TEXTUI, test "$want_textui" = "yes")
646 AM_CONDITIONAL(BUILD_IRSSIBOT, test "$want_irssibot" = "yes")
647 AM_CONDITIONAL(BUILD_IRSSIPROXY, test "$want_irssiproxy" = "yes")
648 AM_CONDITIONAL(BUILD_PLUGINS, test "$want_plugins" = "yes")
649 AM_CONDITIONAL(BUILD_SERVERTEST, test -n "$TEST_DIR")
650 AM_CONDITIONAL(HAVE_PERL, test "$want_perl" != "no")
651 AM_CONDITIONAL(HAVE_STATIC_PERL, test "$want_perl" = "static")
652 AM_CONDITIONAL(NEED_TPARM, test "$need_tparm" = "yes")
653 AM_CONDITIONAL(USE_CURSES, test "$want_terminfo" != "yes" -a "$want_termcap" != "yes")
654
655 # move LIBS to PROG_LIBS so they're not tried to be used when linking eg. perl libraries
656 PROG_LIBS=$LIBS
657 LIBS=
658 AC_SUBST(PROG_LIBS)
659
660 dnl **
661 dnl ** Keep all the libraries here so each frontend doesn't need to
662 dnl ** keep track of them all
663 dnl **
664 dnl ** (these could be made configurable)
665
666 CHAT_MODULES="silc"
667 silc_MODULES=""
668 if test -n "$build_modules"; then
669         silc_MODULES="$silc_MODULES $build_modules"
670 fi
671
672 dnl ****************************************
673
674 AC_SUBST(CHAT_MODULES)
675 AC_SUBST(silc_MODULES)
676
677 CORE_LIBS="../core/libcore.a ../lib-config/libirssi_config.a ../lib-popt/libpopt.a"
678 FE_COMMON_LIBS=""
679
680 CHAT_LIBS=""
681 for c in $CHAT_MODULES; do
682         module_inits=""
683         module_deinits=""
684         fe_module_inits=""
685         fe_module_deinits=""
686         CHAT_LIBS="$CHAT_LIBS ../$c/lib$c.a ../$c/core/lib${c}_core.a"
687         if test -f $srcdir/src/fe-common/$c/module.h; then
688                 FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/$c/libfe_common_$c.a "
689         fi
690         for s in `eval echo \\$${c}_MODULES`; do
691                 CHAT_LIBS="$CHAT_LIBS ../$c/$s/lib${c}_$s.a"
692                 module_inits="$module_inits ${c}_${s}_init();"
693                 module_deinits="${c}_${s}_deinit(); $module_deinits"
694                 if test -f $srcdir/src/fe-common/$c/$s/module.h; then
695                         FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/$c/$s/libfe_${c}_$s.a "
696                         fe_module_inits="$fe_module_inits fe_${c}_${s}_init();"
697                         fe_module_deinits="fe_${c}_${s}_deinit(); $fe_module_deinits"
698                 fi
699         done
700
701         file="$srcdir/src/$c/$c.c"
702         echo "/* this file is automatically generated by configure - don't change */" > $file
703         echo "void ${c}_core_init(void); void ${c}_core_deinit(void);" >> $file
704         if test -n "$module_inits"; then
705                 echo "$module_inits" | $sedpath -e 's/()/(void)/g' -e 's/ /void /g' >> $file
706                 echo "$module_deinits" | $sedpath -e 's/ *$//' -e 's/()/(void)/g' -e 's/ /void /g' -e 's/^/void /' >> $file
707         fi
708         echo "void ${c}_init(void) { ${c}_core_init(); $module_inits }" >> $file
709         echo "void ${c}_deinit(void) { $module_deinits ${c}_core_deinit(); }" >> $file
710
711         if test -f $srcdir/src/fe-common/$c/module.h; then
712                 file="$srcdir/src/fe-common/$c/${c}-modules.c"
713                 echo "/* this file is automatically generated by configure - don't change */" > $file
714                 if test -n "$fe_module_inits"; then
715                         echo "$fe_module_inits" | $sedpath -e 's/()/(void)/g' -e 's/ /void /g' >> $file
716                         echo "$fe_module_deinits" | $sedpath -e 's/ *$//' -e 's/()/(void)/g' -e 's/ /void /g' -e 's/^/void /' >> $file
717                 fi
718                 echo "void fe_${c}_modules_init(void) { $fe_module_inits }" >> $file
719                 echo "void fe_${c}_modules_deinit(void) { $fe_module_deinits }" >> $file
720         fi
721 done
722
723 FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/core/libfe_common_core.a"
724
725 dnl ** common libraries needed by frontends
726 COMMON_NOUI_LIBS="$CHAT_LIBS $CORE_LIBS $INTLLIBS"
727 COMMON_LIBS="$FE_COMMON_LIBS $COMMON_NOUI_LIBS"
728 AC_SUBST(COMMON_NOUI_LIBS)
729 AC_SUBST(COMMON_LIBS)
730
731 dnl **
732 dnl ** tr-Chinese Big5 support
733 dnl **
734
735 if test "x$want_big5" = "xyes"; then
736         AC_DEFINE(WANT_BIG5)
737 fi
738
739 dnl **
740 dnl ** IPv6 support
741 dnl **
742
743 if test "x$want_ipv6" = "xyes"; then
744         AC_MSG_CHECKING([for IPv6])
745         AC_CACHE_VAL(irssi_cv_type_in6_addr,
746         [AC_TRY_COMPILE([
747         #include <sys/types.h>
748         #include <sys/socket.h>
749         #include <netinet/in.h>
750         #include <netdb.h>
751         #include <arpa/inet.h>],
752         [struct in6_addr i;],
753         irssi_cv_type_in6_addr=yes,
754         irssi_cv_type_in6_addr=no,
755         )])
756         if test $irssi_cv_type_in6_addr = yes; then
757                 AC_DEFINE(HAVE_IPV6)
758         fi
759         AC_MSG_RESULT($irssi_cv_type_in6_addr)
760 fi
761
762 dnl **
763 dnl ** IRSSI_VERSION_DATE and IRSSI_VERSION_TIME
764 dnl **
765 #VERSION_DATE=`head -1 $srcdir/ChangeLog|sed 's/^\(....\)-\(..\)-\(..\).*/\1\2\3/'`
766 #VERSION_TIME=`head -1 $srcdir/ChangeLog|sed -e 's/^[[^ ]]* \(..\):\(..\).*/\1\2/' -e 's/^0*//'`
767 #AC_SUBST(VERSION_DATE)
768 #AC_SUBST(VERSION_TIME)
769
770 #
771 # Glue into SILC build system
772 #
773 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
774 AC_SUBST(INCLUDE_DEFINES_INT)
775
776 AC_OUTPUT(
777 Makefile
778 src/Makefile
779 src/core/Makefile
780 src/fe-common/Makefile
781 src/fe-common/core/Makefile
782 src/fe-common/silc/Makefile
783 src/fe-text/Makefile
784 src/lib-config/Makefile
785 src/lib-popt/Makefile
786 src/silc/Makefile
787 src/silc/core/Makefile
788 src/perl/Makefile
789 src/perl/common/Makefile.PL
790 src/perl/ui/Makefile.PL
791 src/perl/textui/Makefile.PL
792 scripts/Makefile
793 docs/Makefile
794 docs/help/Makefile
795 docs/help/in/Makefile
796 irssi-version.h
797 stamp.h
798 irssi.spec
799 irssi-config)
800
801 dnl ** for building from objdir
802 old_dir=`pwd` && cd $srcdir && whole_dir=`pwd` && cd $old_dir
803 if test "x$old_dir" != "x$whole_dir"; then
804         $LN_S $srcdir/irssi-version.h irssi-version.h
805
806         if test "x$want_perl" != "xno"; then
807                 subdirfiles=""
808                 for i in $whole_dir/src/perl/common $whole_dir/src/perl/irc $whole_dir/src/perl/ui $whole_dir/src/perl/textui; do
809                         subdirfiles=`echo $subdirfiles $i/typemap $i/module.h $i/*.pm $i/*.xs`
810                 done
811                 for file in $whole_dir/src/perl/*.[[ch]] $whole_dir/src/perl/libperl_orig.la $whole_dir/src/perl/libperl_dynaloader.la $subdirfiles; do
812                         link=`echo $file|$sedpath "s?$whole_dir/??"`
813                         rm -f $link
814                         $LN_S $file $link
815                 done
816         fi
817 fi
818
819 echo
820
821 if test "x$curses_error" != "xyes"; then
822         if test "x$want_textui" = "xno"; then
823                 text=no
824         elif test "x$want_termcap" = "xyes"; then
825                 text="yes, using termcap"
826         elif test "x$want_terminfo" = "xyes"; then
827                 text="yes, using terminfo"
828         else
829                 text="yes, using curses"
830         fi
831         echo "Building text frontend ..... : $text"
832 else
833         echo "Building text frontend ..... : NO!!"
834         echo " - Because curses was not found, specify the path to it with"
835         echo "   --with-curses=/dir and make sure you have the curses headers"
836         echo "   installed (usually in ncurses-devel package)"
837 fi
838 echo "Building irssi bot ......... : $want_irssibot"
839 echo "Building irssi proxy ....... : $want_irssiproxy"
840 echo "Building with IPv6 support . : $want_ipv6"
841
842 if test "x$want_perl" = "xstatic"; then
843         echo "Building with Perl support . : static (in irssi binary)"
844 elif test "x$want_perl" = "xmodule"; then
845         echo "Building with Perl support . : module"
846 else
847         if test -z "$perl_check_error"; then
848                 echo "Building with Perl support . : no"
849         else
850                 echo "Building with Perl support . : NO!"
851                 echo " - $perl_check_error"
852         fi
853 fi
854
855 if test "x$want_perl" != "xno" -a "x$perl_mod_error" != "x"; then
856         echo " - NOTE: Perl support will be compiled statically to irssi, not as"
857         echo "   a module as requested. Reason:"
858         echo "   $perl_mod_error"
859 fi
860
861 if test "x$want_perl" != "xno"; then
862         if test "$perl_library_dir" = "PERL_USE_LIB"; then
863                 perl_library_dir=$PERL_USE_LIB
864         fi
865         if test -z "$perl_library_dir"; then
866                 perl_library_dir="(site default - `$perlpath -e 'use Config; print $Config{sitearch}'`)"
867         fi
868         echo "Perl library directory ..... : $perl_library_dir"
869         if test "x$perl_prefix_note" = "xyes"; then
870                 echo "  - NOTE: This was automatically set to the same directory you gave with"
871                 echo "  --prefix. If you want the perl libraries to install to their 'correct'"
872                 echo "  path, you'll need to give --with-perl-lib=site option to configure."
873                 echo "  Anyway, installing perl to this directory should work just as well."
874         fi
875 fi
876 echo "Install prefix ............. : $prefix"
877