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