summaryrefslogtreecommitdiff
path: root/configure.in
blob: cbe0b122b3edb08c98bbd21e8b0f88a925b7e0a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
AC_INIT(src)

AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(irssi, 0.7.98.CVS)

AM_MAINTAINER_MODE

AC_ISC_POSIX
AC_PROG_CC
AC_PROG_CPP
AC_STDC_HEADERS
AC_ARG_PROGRAM
AM_PROG_LIBTOOL

AC_PATH_PROG(sedpath, sed)
AC_PATH_PROG(perlpath, perl)

dnl * --disable-static isn't a good idea, complain if it's used
if test "x$enable_static" = "xno"; then
	AC_ERROR([Don't give --disable-static option to configure])
fi

AC_CHECK_HEADERS(string.h stdlib.h unistd.h dirent.h sys/ioctl.h sys/resource.h)

# check posix headers..
AC_CHECK_HEADERS(sys/time.h sys/utsname.h regex.h)

AC_ARG_WITH(big5,
[  --with-big5             Build with tr-Chinese Big5 support],
	if test x$withval = xyes; then
		want_big5=yes
	else
		if test "x$withval" = xno; then
			want_big5=no
		else
			want_big5=yes
		fi
	fi,
	want_big5=no)

AC_ARG_WITH(socks,
[  --with-socks            Build with socks support],
	if test x$withval = xyes; then
		want_socks=yes
	else
		if test "x$withval" = xno; then
			want_socks=no
		else
			want_socks=yes
		fi
	fi,
	want_socks=no)

AC_ARG_WITH(textui,
[  --with-textui           Build text frontend],
	if test x$withval = xyes; then
		want_textui=yes
	else
		if test "x$withval" = xno; then
			want_textui=no
		else
			want_textui=yes
		fi
	fi,
	want_textui=yes)

AC_ARG_WITH(bot,
[  --with-bot              Build irssi-bot],
	if test x$withval = xyes; then
		want_irssibot=yes
	else
		if test "x$withval" = xno; then
			want_irssibot=no
		else
			want_irssibot=yes
		fi
	fi,
	want_irssibot=no)

AC_ARG_WITH(proxy,
[  --with-proxy            Build irssi-proxy],
	if test x$withval = xyes; then
		want_irssiproxy=yes
	else
		if test "x$withval" = xno; then
			want_irssiproxy=no
		else
			want_irssiproxy=yes
		fi
	fi,
	want_irssiproxy=no)


AC_ARG_WITH(modules,
[  --with-modules          Specify what modules to build in binary],
	if test x$withval != xyes -a x$withval != xno; then
		build_modules="$withval"
	fi)

if test "x$prefix" != "xNONE"; then
        prefix=`eval echo $prefix`
	PERL_MM_PARAMS="INSTALLDIRS=perl PREFIX=$prefix"
	PERL_USE_LIB="$prefix`$perlpath -e 'use Config; $dir = $Config{archlibexp}; $prefix = $Config{prefixexp}; $dir =~ s/^$prefix//; print $dir;'`"

	perl_library_dir="$PERL_USE_LIB"
	perl_prefix_note=yes
fi

AC_ARG_WITH(perl-lib,
[  --with-perl-lib=[site|vendor|DIR]  Specify where to install the
                        Perl libraries for irssi, default is site],
	if test "x$withval" = xyes; then
		want_perl=yes
	elif test "x$withval" = xno; then
		want_perl=no
	elif test "x$withval" = xsite; then
		want_perl=yes
	elif test "x$withval" = xvendor; then
		want_perl=yes
		if test -z "`$perlpath -v|grep '5\.0'`"; then
			PERL_MM_PARAMS="INSTALLDIRS=vendor"
		else
			PERL_MM_PARAMS="INSTALLDIRS=perl PREFIX=`perl -e 'use Config; print $Config{prefix}'`"
		fi
		perl_library_dir="(vendor default - `$perlpath -e 'use Config; print $Config{archlib}'`)"
	else
		want_perl=yes
		PERL_MM_PARAMS="INSTALLDIRS=perl LIB=$withval"
		PERL_USE_LIB="$withval"
	fi,
	want_perl=yes)

AC_ARG_WITH(perl,
[  --with-perl[=yes|no|static]  Build with Perl support - also specifies
                        if it should be built into main irssi binary
                        (static) or as module (default)],
	if test x$withval = xyes; then
		want_perl=yes
	elif test x$withval = xstatic; then
		want_perl=static
	else
		want_perl=no
	fi,
	want_perl=yes)

AC_ARG_WITH(tests,
[  --with-tests           Run all the tests],
	if test x$withval != xno; then
		TEST_DIR=test
	fi,
	TEST_DIR=)
AC_SUBST(TEST_DIR)

AC_ARG_ENABLE(curses-windows,
[  --enable-curses-windows Use curses windows],
	if test x$enableval != xno; then
		AC_DEFINE(USE_CURSES_WINDOWS)
	fi,
	AC_DEFINE(USE_CURSES_WINDOWS))

AC_ARG_ENABLE(memdebug,
[  --enable-memdebug       Enable memory debugging],
	if test x$enableval = xyes; then
    		want_memdebug=yes
	else
		if test "x$enableval" = xno; then
			want_memdebug=no
		else
			want_memdebug=yes
		fi
	fi,
	want_memdebug=no)

AC_ARG_ENABLE(ipv6,
[  --enable-ipv6           Enable IPv6 support],
	if test x$enableval = xyes; then
		want_ipv6=yes
	else
		if test "x$enableval" = xno; then
			want_ipv6=no
		else
			want_ipv6=yes
		fi
	fi,
	want_ipv6=no)

dnl **
dnl ** just some generic stuff...
dnl **

AC_CHECK_FUNCS(mkfifo fcntl)

AC_CHECK_LIB(socket, socket, [
	PROG_LIBS="$PROG_LIBS -lsocket"
])

AC_CHECK_LIB(nsl, inet_addr, [
	PROG_LIBS="$PROG_LIBS -lnsl"
], -lsocket)

dnl * gcc specific options
if test "x$ac_cv_prog_gcc" = "xyes"; then
  CFLAGS="$CFLAGS -Wall"
fi

dnl * OS specific options
case "$host_os" in
  hpux*)
    CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
    ;;
  *)
    ;;
esac

dnl * socklen_t - AC_CHECK_TYPE() would be _really_ useful if it only would
dnl * accept header files where to find the typedef..
AC_MSG_CHECKING([for socklen_t])
AC_CACHE_VAL(irssi_cv_type_socklen_t,
[AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>],
[socklen_t t;],
irssi_cv_type_socklen_t=yes,
irssi_cv_type_socklen_t=no,
)])
if test $irssi_cv_type_socklen_t = no; then
AC_DEFINE(socklen_t, int, Define to 'int' if <sys/socket.h> doesn't define.)
fi
AC_MSG_RESULT($irssi_cv_type_socklen_t)

dnl **
dnl ** check for socks
dnl **

if test "x$want_socks" = "xyes"; then
	AC_CHECK_LIB(socks, connect, [
		PROG_LIBS="$PROG_LIBS -lsocks"
		AC_CHECK_HEADER(socks.h, [
			AC_DEFINE(HAVE_SOCKS_H)
			CFLAGS="$CFLAGS -DSOCKS"
			AC_MSG_RESULT(["socks5 library found, building with it"])
		], [
			AC_MSG_RESULT(["socks4 library found, building with it"])
			CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dgetpeername=Rgetpeername -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
		])
	])
fi

dnl **
dnl ** fe-text checks
dnl **

AC_DEFUN(AC_CHECK_GLIBDIR,[
  AC_MSG_CHECKING([whether GLib is unpacked to irssi dir])

  GLIB_DIR=`for d in *; do test -f $d/glib.h && echo $d; done`
  if test -n "$GLIB_DIR"; then
    dnl * glib in irssi directory, use it
    AC_MSG_RESULT([yes, using it])

    dnl * we have to do this at this point so we know what libs gmodule needs
    if test ! -f $GLIB_DIR/.libs/libglib.a; then
      echo
      echo "configuring GLib ..."
      echo
      cd $GLIB_DIR
      if test ! -f glib-config; then
        ./configure
      fi
      ${MAKE-make}
      cd ..
      echo
    fi

    GLIB_LDEXTRA=`$GLIB_DIR/glib-config --libs gmodule|$sedpath -e 's/-lglib//' -e 's/-lgmodule//' -e 's,-L/usr/local/lib ,,'|$sedpath 's/ \+/ /g'`
    full_glib_dir="`pwd`/$GLIB_DIR"
    GLIB_CFLAGS="-I$full_glib_dir -I$full_glib_dir/gmodule"
    if test -f $full_glib_dir/.libs/libglib.a; then
      GLIB_LIBS="$full_glib_dir/.libs/libglib.a $GLIB_LDEXTRA"
      if test -f $full_glib_dir/gmodule/.libs/libgmodule.a; then
	GLIB_LIBS="$GLIB_LIBS $full_glib_dir/gmodule/.libs/libgmodule.a"
        AC_DEFINE(HAVE_GMODULE)
      fi
    else
      GLIB_LIBS="$full_glib_dir/libglib.a $GLIB_LDEXTRA"
      if test -f $full_glib_dir/gmodule/libgmodule.a; then
	GLIB_LIBS="$GLIB_LIBS $full_glib_dir/gmodule/libgmodule.a"
        AC_DEFINE(HAVE_GMODULE)
      fi
    fi
    AC_SUBST(GLIB_CFLAGS)
    AC_SUBST(GLIB_LIBS)
  else
    AC_MSG_RESULT([no])
  fi
])

AC_CHECK_GLIBDIR

if test -z "$GLIB_DIR"; then
  AM_PATH_GLIB(1.2.0,,, gmodule)
  if test -z "$GLIB_LIBS"; then
    echo "*** trying without -lgmodule"
    glib_config_args=
    AM_PATH_GLIB(1.2.0)
  else
    AC_DEFINE(HAVE_GMODULE)
  fi

  if test -z "$GLIB_LIBS"; then
    echo
    echo "*** If you don't have GLIB, you can get it from ftp://ftp.gtk.org"
    echo "*** If you can't install GLIB anywhere or if you don't want to,"
    echo "*** you can just unpack it to Irssi's source directory and"
    echo "*** Irssi will automatically compile and use it."
    echo

    dnl * I think it's pretty safe to assume GLib 1.2.9 since the next
    dnl * will be 2.0 (or 1.4?) and it's not sure if irssi compiles
    dnl * with it (yea, just a few weeks after I put this text for 1.2.8
    dnl * the 1.2.9 came :) .. and then .10
    glib_file=glib-1.2.10.tar.gz

    dlcmd=
    if test -n "`ncftpget 2>/dev/null|grep -i ncftp`"; then
      dlcmd="ncftpget ftp://ftp.gtk.org/pub/gtk/v1.2/$glib_file"
    fi
    if test -n "`wget 2>/dev/null|grep -i wget`"; then
      dlcmd="wget http://irssi.org/files/$glib_file"
    fi
    if test -n "$dlcmd"; then
      echo "*** I can download GLib for you now. If you don't want to, press CTRL-C now."
      read answer
      eval $dlcmd
      if `gunzip $glib_file`; then
	glib_file=`echo $glib_file|$sedpath s/\.gz$//`
	if `tar xf $glib_file`; then
	  rm -f $glib_file
	  AC_CHECK_GLIBDIR
	fi
      fi
    fi

    if test -z "$GLIB_LIBS"; then
      AC_ERROR([GLIB is required to build irssi.])
    fi
  fi
fi

PROG_LIBS="$PROG_LIBS $GLIB_LIBS"

dnl **
dnl ** check if we can link dynamic libraries to modules
dnl ** also checks if libraries are built to .libs dir
dnl **

AC_MSG_CHECKING([if we can link dynamic libraries with modules])
DYNLIB_MODULES=no

dnl ** compile object file
cat > conftest.c <<EOF
#include <math.h>
int modfunc(void){return (int)floor(1.2);}
EOF

./libtool --mode=compile $CC $CFLAGS -c conftest.c 2> /dev/null > /dev/null
if test ! -s conftest.lo; then
  AC_ERROR([error compiling test module])
fi

dnl ** link to library
./libtool --mode=link $CC $CFLAGS $LDFLAGS -rpath /usr/lib conftest.lo -lm -o libconftest.la > /dev/null
if test ! -s .libs/libconftest.a; then
  AC_ERROR([error, can't even find .a library])
fi

dnl ** check if dynamic linking worked
libfile=`grep '^library_names' libconftest.la|$sedpath "s/library_names='\(.*\)'.*/\1/"|$sedpath 's/.* \([[^ ]]*\)$/\1/'`
if test ! -s .libs/$libfile; then
  AC_MSG_RESULT([no, error linking test module])
else
  cat > conftest.c <<EOF
#include <gmodule.h>
main() {
GModule *m; int (*modfunc)(void);
m = g_module_open(".libs/$libfile", 0);
if (!m) g_print("error loading: %s", g_module_error());
else if (!g_module_symbol(m, "modfunc", (gpointer *) &modfunc))
  g_print("modfunc() symbol not found from module");
else if (modfunc() == 1) g_print("ok"); else g_print("wrong result?! 1 vs %d", modfunc());
return 0; }
EOF
  $CC $CFLAGS conftest.c -o conftest $GLIB_CFLAGS $GLIB_LIBS 2> /dev/null > /dev/null
  if test ! -s conftest; then
    AC_MSG_RESULT([no, error compiling test program])
  else
    status="`./conftest`"
    if test "x$status" = "xok"; then
      DYNLIB_MODULES=yes
      AC_MSG_RESULT([yes])
    else
      AC_MSG_RESULT([no, error running: $status])
    fi
  fi
fi
rm -rf conftest conftest.* libconftest.* .libs

dnl **
dnl ** curses checks
dnl **

if test "x$want_textui" = "xyes"; then
	AC_CHECK_CURSES

	if test -n "$has_ncurses"; then
		AC_CHECK_LIB(ncurses, use_default_colors, [
			AC_DEFINE(HAVE_NCURSES_USE_DEFAULT_COLORS)
		],, $CURSES_LIBS)
		AC_CHECK_LIB(ncurses, idcok, [
			AC_DEFINE(HAVE_CURSES_IDCOK)
		],, $CURSES_LIBS)
		AC_CHECK_LIB(ncurses, resizeterm, [
			AC_DEFINE(HAVE_CURSES_RESIZETERM)
		],, $CURSES_LIBS)
		AC_CHECK_LIB(ncurses, wresize, [
			AC_DEFINE(HAVE_CURSES_WRESIZE)
		],, $CURSES_LIBS)
	elif test "x$has_curses" = "xtrue"; then
		AC_CHECK_LIB(curses, idcok, [
			AC_DEFINE(HAVE_CURSES_IDCOK)
		],, $CURSES_LIBS)
		AC_CHECK_LIB(curses, resizeterm, [
			AC_DEFINE(HAVE_CURSES_RESIZETERM)
		],, $CURSES_LIBS)
		AC_CHECK_LIB(curses, wresize, [
			AC_DEFINE(HAVE_CURSES_WRESIZE)
		],, $CURSES_LIBS)
	else
		want_textui=no
		curses_error=yes
        fi
else
	has_curses=false
fi

dnl **
dnl ** perl checks
dnl **

if test "$want_perl" != "no"; then
	AC_MSG_CHECKING(for working Perl support)

	if test -z "$perlpath"; then
       		perl_check_error="perl binary not found"
	else
		PERL_CFLAGS=`$perlpath -MExtUtils::Embed -e ccopts 2>/dev/null`
	fi

	if test -z "$PERL_CFLAGS"; then
		if test -n "$perl_check_error"; then
			perl_check_error="Error getting perl CFLAGS"
		fi
		AC_MSG_RESULT([not found, building without Perl])
		want_perl=no
	else
		PERL_LDFLAGS=`$perlpath -MExtUtils::Embed -e ldopts 2>/dev/null`

		dnl * Perl 5.004 and older use perl_xxx variables while
		dnl * later use PL_perl_xxx variables ..
		have_pl_perl=`$perlpath -e 'print $] < 5.005 ? "no" : "yes";'`
                if test "x$have_pl_perl" = "xyes"; then
			AC_DEFINE(HAVE_PL_PERL)
		fi

		if test "x$DYNLIB_MODULES" = "xno" -a "$want_perl" != "static"; then
			dnl * wanted perl as module, won't get it.
			want_perl=static
			perl_mod_error="Dynamic library dependencies don't work with modules"
		fi

		if test "$want_perl" != "static"; then
			dnl * dynaloader.a -> libperl_dynaloader.la
			DYNALOADER_A=`echo $PERL_LDFLAGS | $perlpath -pe 's/^(.* )*([[^ ]]*DynaLoader\.a).*/\2/'`
		fi

		dnl * don't check libperl.a if dynaloader.a wasn't found..
		if test -n "$DYNALOADER_A"; then
			dnl * find either libperl.a or libperl.so
			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 } } };'`
			if test -z "$LIBPERL_A"; then
				perl_mod_error="Didn't find location of -lperl"
				DYNALOADER_A=
			elif test "$LIBPERL_A" = "-lperl"; then
				LIBPERL_A=
			fi
		fi

		dnl * remove all database stuffs
		dnl * nsl is already in ldflags
		dnl * libc is of course linked without needing -lc
		dnl * -rdynamic must not be in LIBADD line
		for word in -ldb -ldbm -lndbm -lgdbm -lc -rdynamic; do
		  PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e "s/$word //" -e "s/$word$//"`
		done

		case "$host_os" in
		  linux*)
		    PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e 's/-lposix //' -e 's/-lposix$//'`
		    ;;
		  hpux*)
		    if test "x$ac_cv_prog_gcc" = "xyes"; then
		      PERL_CFLAGS=`echo $PERL_CFLAGS | $sedpath -e 's/-Ae //' -e 's/-Ae$//'`
		      PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e 's/-Ae //' -e 's/-Ae$//'`
		    fi
		    ;;
		  *)
		    ;;
		esac

		dnl * check that perl's ldflags actually work
		AC_CACHE_VAL(irssi_cv_lib_perl_works, [
			echo "main(){perl_alloc(); return 0;}" > conftest.c
			$CC $CFLAGS conftest.c -o conftest $LDFLAGS $PERL_LDFLAGS 2> /dev/null > /dev/null
			if test -s conftest; then
				irssi_cv_lib_perl_works=yes
			else
				irssi_cv_lib_perl_works=no
			fi
		])

		if test "x$irssi_cv_lib_perl_works" = "xno"; then
			perl_check_error="Error linking with perl libraries: $PERL_LDFLAGS"
			AC_MSG_RESULT([error linking with perl libraries, building without Perl])
			want_perl=no
		fi
	fi

	if test "x$want_perl" != "xno"; then
		if test "x$want_perl" = "xstatic"; then
			AC_MSG_RESULT(ok)
		elif test -z "$DYNALOADER_A"; then
			AC_MSG_RESULT([error parsing ldopts, building Perl into irssi binary instead of as module])
			want_perl=static
		else
			AC_MSG_RESULT(ok)
			PERL_LDFLAGS=`echo $PERL_LDFLAGS | $perlpath -pe 's/^(.* )*[[^ ]]*DynaLoader\.a/\1libperl_dynaloader.la/'`
			if test -n "$LIBPERL_A"; then
				PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e 's/-lperl /libperl_orig.la /' -e 's/-lperl$/libperl_orig.la$/'`
			fi
			AC_SUBST(LIBPERL_A)
			AC_SUBST(DYNALOADER_A)
		fi

		if test "x$want_perl" = "xstatic"; then
			dnl * building with static perl support
			dnl * all PERL_LDFLAGS linking is done in fe-text
			PERL_LINK_FLAGS="$PERL_LDFLAGS"
			PERL_LINK_LIBS="../perl/libperl_core_static.la"
			PERL_FE_LINK_LIBS="../perl/libfe_perl_static.la"
			PERL_LDFLAGS=
			AC_DEFINE(HAVE_STATIC_PERL)

			dnl * build only static library of perl module
			perl_module_lib=
			perl_module_fe_lib=
			perl_static_lib=libperl_core_static.la
			perl_static_fe_lib=libfe_perl_static.la
			PERL_LIBTOOL='$(SHELL) $(top_builddir)/libtool'
		else
			dnl * build dynamic library of perl module
			perl_module_lib=libperl_core.la
			perl_module_fe_lib=libfe_perl.la
			perl_static_lib=
			perl_static_fe_lib=
			PERL_LIBTOOL='$(SHELL) $(top_builddir)/libtool'
		fi
		AC_SUBST(perl_module_lib)
		AC_SUBST(perl_static_lib)
		AC_SUBST(perl_module_fe_lib)
		AC_SUBST(perl_static_fe_lib)
		AC_SUBST(PERL_LIBTOOL)

		AC_SUBST(PERL_LINK_FLAGS)
		AC_SUBST(PERL_LINK_LIBS)
                AC_SUBST(PERL_FE_LINK_LIBS)

		AC_SUBST(PERL_LDFLAGS)
		AC_SUBST(PERL_CFLAGS)

		AC_SUBST(PERL_USE_LIB)
		AC_SUBST(PERL_MM_PARAMS)
	fi
fi

dnl ** check what we want to build
AM_CONDITIONAL(BUILD_TEXTUI, test "$want_textui" = "yes")
AM_CONDITIONAL(BUILD_IRSSIBOT, test "$want_irssibot" = "yes")
AM_CONDITIONAL(BUILD_IRSSIPROXY, test "$want_irssiproxy" = "yes")
AM_CONDITIONAL(BUILD_PLUGINS, test "$want_plugins" = "yes")
AM_CONDITIONAL(BUILD_SERVERTEST, test -n "$TEST_DIR")
AM_CONDITIONAL(HAVE_PERL, test "$want_perl" != "no")
AM_CONDITIONAL(HAVE_STATIC_PERL, test "$want_perl" = "static")

AC_SUBST(PROG_LIBS)

dnl **
dnl ** Keep all the libraries here so each frontend doesn't need to
dnl ** keep track of them all
dnl **
dnl ** (these could be made configurable)

CHAT_MODULES="irc"
irc_MODULES="dcc flood notifylist"
if test -n "$build_modules"; then
	irc_MODULES="$irc_MODULES $build_modules"
fi

dnl ****************************************

AC_SUBST(CHAT_MODULES)
AC_SUBST(irc_MODULES)

CORE_LIBS="../core/libcore.a ../lib-config/libirssi_config.a ../lib-popt/libpopt.a"
FE_COMMON_LIBS=""

CHAT_LIBS=""
for c in $CHAT_MODULES; do
	module_inits=""
	module_deinits=""
	fe_module_inits=""
	fe_module_deinits=""
	CHAT_LIBS="$CHAT_LIBS ../$c/lib$c.a ../$c/core/lib${c}_core.a"
	if test -f $srcdir/src/fe-common/$c/module.h; then
		FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/$c/libfe_common_$c.a "
	fi
	for s in `eval echo \\$${c}_MODULES`; do
		CHAT_LIBS="$CHAT_LIBS ../$c/$s/lib${c}_$s.a"
		module_inits="$module_inits ${c}_${s}_init();"
		module_deinits="${c}_${s}_deinit(); $module_deinits"
		if test -f $srcdir/src/fe-common/$c/$s/module.h; then
			FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/$c/$s/libfe_${c}_$s.a "
			fe_module_inits="$fe_module_inits fe_${c}_${s}_init();"
			fe_module_deinits="fe_${c}_${s}_deinit(); $fe_module_deinits"
		fi
	done

	file="$srcdir/src/$c/$c.c"
        echo "/* this file is automatically generated by configure - don't change */" > $file
	echo "void ${c}_core_init(void); void ${c}_core_deinit(void);" >> $file
	if test -n "$module_inits"; then
        	echo "$module_inits" | $sedpath -e 's/()/(void)/g' -e 's/ /void /g' >> $file
        	echo "$module_deinits" | $sedpath -e 's/ *$//' -e 's/()/(void)/g' -e 's/ /void /g' -e 's/^/void /' >> $file
	fi
        echo "void ${c}_init(void) { ${c}_core_init(); $module_inits }" >> $file
        echo "void ${c}_deinit(void) { $module_deinits ${c}_core_deinit(); }" >> $file

	if test -f $srcdir/src/fe-common/$c/module.h; then
	        file="$srcdir/src/fe-common/$c/${c}-modules.c"
	        echo "/* this file is automatically generated by configure - don't change */" > $file
                if test -n "$fe_module_inits"; then
		        echo "$fe_module_inits" | $sedpath -e 's/()/(void)/g' -e 's/ /void /g' >> $file
		        echo "$fe_module_deinits" | $sedpath -e 's/ *$//' -e 's/()/(void)/g' -e 's/ /void /g' -e 's/^/void /' >> $file
		fi
	        echo "void fe_${c}_modules_init(void) { $fe_module_inits }" >> $file
	        echo "void fe_${c}_modules_deinit(void) { $fe_module_deinits }" >> $file
	fi
done

FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/core/libfe_common_core.a"

dnl ** common libraries needed by frontends
COMMON_NOUI_LIBS="$CHAT_LIBS $CORE_LIBS $INTLLIBS"
COMMON_LIBS="$FE_COMMON_LIBS $COMMON_NOUI_LIBS"
AC_SUBST(COMMON_NOUI_LIBS)
AC_SUBST(COMMON_LIBS)

dnl **
dnl ** memory debugging
dnl **

if test "x$want_memdebug" = "xyes"; then
	AC_DEFINE(MEM_DEBUG)
fi
AM_CONDITIONAL(BUILD_MEMDEBUG, test "x$want_memdebug" = "xyes")

dnl **
dnl ** tr-Chinese Big5 support
dnl **

if test "x$want_big5" = "xyes"; then
	AC_DEFINE(WANT_BIG5)
fi

dnl **
dnl ** IPv6 support
dnl **

if test "x$want_ipv6" = "xyes"; then
	AC_MSG_CHECKING([for IPv6])
	AC_CACHE_VAL(irssi_cv_type_in6_addr,
	[AC_TRY_COMPILE([
	#include <sys/types.h>
	#include <sys/socket.h>
	#include <netinet/in.h>
	#include <netdb.h>
	#include <arpa/inet.h>],
	[struct in6_addr i;],
	irssi_cv_type_in6_addr=yes,
	irssi_cv_type_in6_addr=no,
	)])
	if test $irssi_cv_type_in6_addr = yes; then
		AC_DEFINE(HAVE_IPV6)
	fi
	AC_MSG_RESULT($irssi_cv_type_in6_addr)
fi

AC_OUTPUT(
Makefile
src/Makefile
src/core/Makefile
src/irc/Makefile
src/irc/core/Makefile
src/irc/bot/Makefile
src/irc/dcc/Makefile
src/irc/notifylist/Makefile
src/irc/proxy/Makefile
src/irc/flood/Makefile
src/fe-common/Makefile
src/fe-common/core/Makefile
src/fe-common/irc/Makefile
src/fe-common/irc/dcc/Makefile
src/fe-common/irc/notifylist/Makefile
src/fe-none/Makefile
src/fe-text/Makefile
src/lib-config/Makefile
src/lib-popt/Makefile
src/perl/Makefile
src/perl/common/Makefile.PL
src/perl/irc/Makefile.PL
src/perl/ui/Makefile.PL
src/perl/textui/Makefile.PL
servertest/Makefile
scripts/Makefile
docs/Makefile
docs/help/Makefile
docs/help/in/Makefile
stamp.h
irssi.spec
irssi-config)

dnl ** for building from objdir
if test "x$want_perl" != "xno"; then
	old_dir=`pwd` && cd $srcdir && whole_dir=`pwd` && cd $old_dir

	if test "x$old_dir" != "x$whole_dir"; then
		for file in $whole_dir/src/perl/*.[[ch]] $whole_dir/src/perl/libperl_orig.la $whole_dir/src/perl/libperl_dynaloader.la $whole_dir/src/perl/common/typemap $whole_dir/src/perl/common/module.h $whole_dir/src/perl/common/*.xs $whole_dir/src/perl/irc/typemap $whole_dir/src/perl/irc/module.h $whole_dir/src/perl/irc/*.xs; do
			link=`echo $file|$sedpath "s?$whole_dir/??"`
			rm -f $link
			$LN_S $file $link
		done
	fi
fi

echo

if test "x$curses_error" != "xyes"; then
	echo "Building text frontend ..... : $want_textui"
else
	echo "Building text frontend ..... : NO!!"
	echo " - Because curses was not found, specify the path to it with"
	echo "   --with-curses=/dir and make sure you have the curses headers"
	echo "   installed (usually in ncurses-devel package)"
fi
echo "Building irssi bot ......... : $want_irssibot"
echo "Building irssi proxy ....... : $want_irssiproxy"
echo "Building with IPv6 support . : $want_ipv6"

if test "x$want_perl" = "xstatic"; then
	echo "Building with Perl support . : static (in irssi binary)"
elif test "x$want_perl" = "xyes"; then
	echo "Building with Perl support . : module"
else
	if test -z "$perl_check_error"; then
		echo "Building with Perl support . : no"
	else
		echo "Building with Perl support . : NO!"
		echo " - $perl_check_error"
	fi
fi

if test "x$want_perl" != "xno" -a "x$perl_mod_error" != "x"; then
	echo " - NOTE: Perl support will be compiled statically to irssi, not as"
	echo "   a module as requested. Reason:"
	echo "   $perl_mod_error"
fi

if test "x$want_perl" = "xyes"; then
	if test -z "$perl_library_dir"; then
		perl_library_dir="(site default - `$perlpath -e 'use Config; print $Config{sitearch}'`)"
	fi
       	echo "Perl library directory ..... : $perl_library_dir"
	if test "x$perl_prefix_note" = "xyes"; then
		echo "  - NOTE: This was automatically set to the same directory you gave with"
		echo "  --prefix. If you want the perl libraries to install to their 'correct'"
		echo "  path, you'll need to give --with-perl-lib=site option to configure."
		echo "  Anyway, installing perl to this directory should work just as well."
	fi
fi
echo "Install prefix ............. : $prefix"