1AC_INIT(irssi, 1.2.3)
2AC_CONFIG_SRCDIR([src])
3AC_CONFIG_AUX_DIR(build-aux)
4AC_PREREQ(2.50)
5
6AC_CONFIG_HEADERS([irssi-config.h])
7AC_CONFIG_MACRO_DIR([m4])
8AM_INIT_AUTOMAKE([1.9 no-define foreign subdir-objects nostdinc])
9
10AM_SILENT_RULES([yes])
11
12AM_MAINTAINER_MODE
13
14AC_PROG_CC
15AC_PROG_CPP
16AM_PROG_LIBTOOL
17
18AC_PATH_PROG(sedpath, sed)
19AC_PATH_PROG(perlpath, perl)
20
21AC_CHECK_HEADERS(unistd.h dirent.h sys/ioctl.h sys/resource.h)
22
23# check posix headers..
24AC_CHECK_HEADERS(sys/socket.h sys/time.h sys/utsname.h)
25
26AC_SYS_LARGEFILE
27
28AC_ARG_WITH(socks,
29[  --with-socks            Build with socks support],
30	if test x$withval = xno; then
31		want_socks=no
32	else
33		want_socks=yes
34	fi,
35	want_socks=no)
36
37AC_ARG_WITH(textui,
38[  --without-textui        Build without text frontend],
39	if test x$withval = xno; then
40		want_textui=no
41	else
42		want_textui=yes
43	fi,
44	want_textui=yes)
45
46AC_ARG_WITH(bot,
47[  --with-bot              Build irssi-bot],
48	if test x$withval = xno; then
49		want_irssibot=no
50	else
51		want_irssibot=yes
52	fi,
53	want_irssibot=no)
54
55AC_ARG_WITH(fuzzer,
56[  --with-fuzzer           Build irssi-fuzzer],
57	if test x$withval = xno; then
58		want_irssifuzzer=no
59	else
60		want_irssifuzzer=yes
61	fi,
62	want_irssifuzzer=no)
63
64AC_ARG_WITH(fuzzer-lib,
65[  --with-fuzzer-lib       Specify path to fuzzer library],
66	fuzzerlibpath="$withval")
67
68AC_ARG_WITH(proxy,
69[  --with-proxy            Build irssi-proxy],
70	if test x$withval = xno; then
71		want_irssiproxy=no
72	else
73		want_irssiproxy=yes
74	fi,
75	want_irssiproxy=no)
76
77AC_ARG_WITH(modules,
78[  --with-modules          Specify what modules to build in binary],
79	if test x$withval != xyes -a x$withval != xno; then
80		build_modules="$withval"
81	fi)
82
83if test "x$prefix" != "xNONE"; then
84	prefix=`eval echo $prefix`
85	PERL_MM_PARAMS="INSTALLDIRS=perl INSTALL_BASE=$prefix"
86	perl_set_use_lib=yes
87
88	perl_prefix_note=yes
89fi
90
91AC_ARG_WITH(perl-staticlib,
92[  --with-perl-staticlib   Specify that we want to link perl libraries
93                          statically in irssi, default is no],
94	if test x$withval = xno; then
95		want_staticperllib=no
96	else
97		want_staticperllib=yes
98	fi,
99	want_staticperllib=no)
100
101
102AC_ARG_WITH(perl-lib,
103[  --with-perl-lib=[perl|site|vendor|DIR]  Specify where to install the
104                          Perl libraries for irssi, default is site],
105	if test "x$withval" = xyes; then
106		want_perl=yes
107	elif test "x$withval" = xno; then
108		want_perl=no
109	elif test "x$withval" = xperl; then
110		want_perl=yes
111		perl_prefix_note=no
112		PERL_MM_PARAMS="INSTALLDIRS=perl"
113		perl_set_use_lib=no
114	elif test "x$withval" = xsite; then
115		want_perl=yes
116		perl_prefix_note=no
117		PERL_MM_PARAMS=""
118		perl_set_use_lib=no
119	elif test "x$withval" = xvendor; then
120		want_perl=yes
121		perl_prefix_note=no
122		if test -z "`$perlpath -v|grep '5\.0'`"; then
123			PERL_MM_PARAMS="INSTALLDIRS=vendor"
124		else
125			PERL_MM_PARAMS="INSTALLDIRS=perl PREFIX=`$perlpath -e 'use Config; print $Config{prefix}'`"
126		fi
127		perl_set_use_lib=no
128	else
129		want_perl=yes
130		perl_prefix_note=no
131		PERL_MM_PARAMS="INSTALLDIRS=perl LIB=$withval"
132		perl_set_use_lib=yes
133	fi,
134	want_perl=yes)
135
136AC_ARG_WITH(perl,
137[  --with-perl[=yes|no|module]  Build with Perl support - also specifies
138                          if it should be built into main irssi binary
139                          (static, default) or as module],
140	if test x$withval = xyes; then
141		want_perl=static
142	elif test x$withval = xstatic; then
143		want_perl=static
144	elif test x$withval = xmodule; then
145		want_perl=module
146	else
147		want_perl=no
148	fi,
149	want_perl=static)
150
151AC_ARG_WITH(otr,
152[  --with-otr[=yes|no|static]   Build with OTR support - also specifies
153                                if it should be built into the main irssi
154                                binary (static) or as a module (default)],
155	if test x$withval = xyes; then
156		want_otr=module
157	elif test x$withval = xstatic; then
158		want_otr=static
159	elif test x$withval = xmodule; then
160		want_otr=module
161	else
162		want_otr=no
163	fi,
164	want_otr=no)
165
166AC_ARG_ENABLE(true-color,
167[  --enable-true-color     Build with true color support in terminal],
168	if test x$enableval = xno ; then
169		want_truecolor=no
170	else
171		want_truecolor=yes
172	fi,
173	want_truecolor=no)
174
175AC_ARG_ENABLE(gregex,
176[  --disable-gregex        Build without GRegex (fall back to regex.h)],
177	if test x$enableval = xno ; then
178		want_gregex=no
179	else
180		want_gregex=yes
181	fi,
182	want_gregex=yes)
183
184AC_ARG_ENABLE(utf8proc,
185[  --disable-utf8proc        Build without Julia's utf8proc],
186	if test x$enableval = xno ; then
187		want_utf8proc=no
188	else
189		want_utf8proc=yes
190	fi,
191	want_utf8proc=yes)
192
193AC_ARG_WITH(capsicum,
194[  --with-capsicum         Build with Capsicum support],
195	if test x$withval = xno; then
196		want_capsicum=no
197	else
198		want_capsicum=yes
199	fi,
200	want_capsicum=yes)
201
202dnl **
203dnl ** just some generic stuff...
204dnl **
205
206dnl * OS specific options
207case "$host_os" in
208  hpux*)
209    CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
210    ;;
211  *)
212    ;;
213esac
214
215
216AC_SEARCH_LIBS([socket], [network socket])
217
218AC_SEARCH_LIBS([inet_addr], [nsl])
219
220dnl * gcc specific options
221if test "x$ac_cv_prog_gcc" = "xyes"; then
222  CFLAGS="$CFLAGS -Wall"
223fi
224
225AC_CHECK_TYPE(socklen_t, ,
226	[AC_DEFINE([socklen_t], [int], [Define to 'int' if <sys/socket.h> doesn't define.])], [
227AC_INCLUDES_DEFAULT
228#ifdef HAVE_SYS_SOCKET_H
229#  include <sys/socket.h>
230#endif
231])
232
233AC_CHECK_SIZEOF(int)
234AC_CHECK_SIZEOF(long)
235AC_CHECK_SIZEOF(long long)
236AC_CHECK_SIZEOF(off_t)
237
238if test $ac_cv_sizeof_off_t = 8; then
239  offt_64bit=yes
240else
241  offt_64bit=no
242fi
243
244if test x$ac_cv_sizeof_off_t = x$ac_cv_sizeof_long; then
245  # try to use unsigned long always first
246  AC_DEFINE_UNQUOTED(PRIuUOFF_T, "lu")
247  AC_DEFINE(UOFF_T_LONG)
248elif test x$ac_cv_sizeof_off_t = x$ac_cv_sizeof_int; then
249  # next try int
250  AC_DEFINE_UNQUOTED(PRIuUOFF_T, "u")
251  AC_DEFINE(UOFF_T_INT)
252elif test x$ac_cv_sizeof_off_t = x$ac_cv_sizeof_long_long; then
253  # and finally long long
254  AC_DEFINE_UNQUOTED(PRIuUOFF_T, "llu")
255  AC_DEFINE(UOFF_T_LONG_LONG)
256else
257  AC_ERROR([Couldn't find integer type for off_t])
258fi
259
260dnl **
261dnl ** check for socks
262dnl **
263
264if test "x$want_socks" = "xyes"; then
265	AC_CHECK_LIB(socks, connect, [
266		AC_DEFINE(HAVE_SOCKS,, Build with socks support)
267		LIBS="$LIBS -lsocks"
268		AC_CHECK_HEADER(socks.h, [
269			AC_DEFINE(HAVE_SOCKS_H)
270			CFLAGS="$CFLAGS -DSOCKS"
271			AC_MSG_RESULT(["socks5 library found, building with it"])
272		], [
273			AC_MSG_RESULT(["socks4 library found, building with it"])
274			CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dgetpeername=Rgetpeername -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
275		])
276	])
277fi
278
279dnl **
280dnl ** fe-text checks
281dnl **
282
283for try in 1 2; do
284  if test $try = 1; then
285    glib_modules=gmodule
286  else
287    echo "*** trying without -lgmodule"
288    glib_modules=
289  fi
290  AM_PATH_GLIB_2_0(2.28.0,,, $glib_modules)
291  if test "$GLIB_LIBS"; then
292    if test $glib_modules = gmodule; then
293      AC_DEFINE(HAVE_GMODULE)
294      have_gmodule=yes
295    fi
296    break
297  fi
298done
299
300if test -z "$GLIB_LIBS"; then
301  echo
302  echo "*** If you don't have GLIB, you can get it from ftp://ftp.gtk.org/pub/glib/"
303  echo "*** We recommend you get the latest stable GLIB 2 version."
304  echo "*** Compile and install it, and make sure pkg-config finds it,"
305  echo "*** by adding the path where the .pc file is located to PKG_CONFIG_PATH"
306  echo -n "*** Or alternatively install your distribution's package"
307  if test -f /etc/debian_version; then
308    echo :
309    echo "*** sudo apt-get install libglib2.0-dev"
310  elif test -f /etc/redhat-release; then
311    echo " (glib2-devel)"
312  else
313    echo .
314  fi
315  echo
316
317  AC_ERROR([GLIB is required to build irssi.])
318fi
319
320LIBS="$LIBS $GLIB_LIBS"
321
322GLIB_TESTS
323
324dnl **
325dnl ** OpenSSL checks
326dnl **
327PKG_CHECK_MODULES([OPENSSL], [openssl], [
328	CFLAGS="$CFLAGS $OPENSSL_CFLAGS"
329	LIBS="$LIBS $OPENSSL_LIBS"
330], [
331	AC_CHECK_LIB([ssl], [SSL_library_init], [
332		LIBS="$LIBS -lssl -lcrypto"
333	], [
334		AC_CHECK_LIB([ssl], [OPENSSL_init_ssl], [
335			LIBS="$LIBS -lssl -lcrypto"
336		], [
337			AC_MSG_ERROR([The OpenSSL library was not found])
338		])
339	])
340])
341
342dnl **
343dnl ** utf8proc
344dnl **
345if test "x$want_utf8proc" != "xno"; then
346	AC_CHECK_HEADER([utf8proc.h], [
347		AC_CHECK_LIB([utf8proc], [utf8proc_version], [
348			want_utf8proc=yes
349			AC_DEFINE(HAVE_LIBUTF8PROC,, [Define to 1 if you have the `utf8proc' library (-lutf8proc).])
350			LIBS="$LIBS -lutf8proc"
351		], [
352			want_utf8proc="no, library not found"
353		])
354	], [
355		want_utf8proc="no, library header not found"
356	])
357fi
358
359dnl **
360dnl ** curses checks
361dnl **
362
363if test "x$want_textui" != "xno"; then
364
365	TEXTUI_NO_LIBS="$LIBS"
366	LIBS=
367	AC_SEARCH_LIBS([setupterm], [tinfo ncursesw ncurses terminfo], [want_textui=yes], [
368		AC_ERROR(Terminfo not found - install libncurses-dev or ncurses-devel package)
369		want_textui="no, Terminfo not found"
370	])
371
372	TEXTUI_LIBS="$LIBS"
373	AC_SUBST(TEXTUI_LIBS)
374	LIBS="$TEXTUI_NO_LIBS"
375
376	AC_CHECK_HEADER([term.h], [
377		AC_DEFINE(HAVE_TERM_H, [], [Define to 1 if you have the `term.h' header.])
378	])
379
380fi
381
382dnl **
383dnl ** irssifuzzer checks
384dnl **
385
386if test "$want_irssifuzzer" != "no"; then
387	dnl * we need to build with -fsanitize-coverage=trace-pc-guard
388	dnl * otherwise fuzzer won't be very successful at finding bugs :)
389	if test -z "$SANFLAGS"; then
390		SANFLAGS="-g -fsanitize=address -fsanitize-coverage=trace-pc-guard"
391	fi
392	CFLAGS="$CFLAGS $SANFLAGS"
393	CXXFLAGS="$CXXFLAGS $SANFLAGS"
394
395	AC_MSG_CHECKING(for fuzzer library)
396
397	if test -z "$fuzzerlibpath"; then
398		AC_MSG_RESULT([not found, building without fuzzer front end])
399		want_irssifuzzer=no
400	else
401		FUZZER_LIBS="$fuzzerlibpath"
402		AC_SUBST(FUZZER_LIBS)
403	fi
404fi
405
406dnl **
407dnl ** perl checks
408dnl **
409
410if test "$want_perl" != "no"; then
411	AC_MSG_CHECKING(for working Perl support)
412
413	if test -z "$perlpath"; then
414		perl_check_error="perl binary not found"
415	else
416		PERL_CFLAGS=`$perlpath -MExtUtils::Embed -e ccopts 2>/dev/null`
417	fi
418
419	if test "x$ac_cv_prog_gcc" = "xyes" -a -z "`echo $host_os|grep 'bsd\|linux'`"; then
420		dnl * several systems have Perl compiled with native compiler
421		dnl * but irssi is being compiled with GCC. Here we try to
422		dnl * fix those command line options a bit so GCC won't
423		dnl * complain about them. Normally there's only few options
424		dnl * that we want to keep:
425		dnl * -Ddefine -Uundef -I/path -fopt -mopt -iwithsysroot
426		PERL_CFLAGS=`echo $PERL_CFLAGS | $perlpath -pe 's/^(.* )?-@<:@^DUIifm@:>@@<:@^ @:>@+/\1/g; s/^(.* )?\+@<:@^ @:>@+/\1/g'`
427
428		PERL_EXTRA_OPTS="CCCDLFLAGS=\"-fPIC\""
429		AC_SUBST(PERL_EXTRA_OPTS)
430	fi
431
432	if test -z "$PERL_CFLAGS"; then
433		if test -n "$perl_check_error"; then
434			perl_check_error="Error getting perl CFLAGS"
435		fi
436		AC_MSG_RESULT([not found, building without Perl])
437		want_perl=no
438	else
439		PERL_LDFLAGS=`$perlpath -MExtUtils::Embed -e ldopts 2>/dev/null`
440
441		dnl * remove all database stuffs
442		dnl * nsl is already in ldflags
443		dnl * libc is of course linked without needing -lc
444		dnl * -rdynamic must not be in LIBADD line
445		for word in -ldb -ldbm -lndbm -lgdbm -lc -rdynamic; do
446		  PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e "s/$word //" -e "s/$word$//"`
447		done
448
449		case "$host_os" in
450		  linux*)
451		    PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e 's/-lposix //' -e 's/-lposix$//'`
452		    ;;
453		  hpux*)
454		    if test "x$ac_cv_prog_gcc" = "xyes"; then
455		      PERL_CFLAGS=`echo $PERL_CFLAGS | $sedpath -e 's/-Ae //' -e 's/-Ae$//'`
456		      PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e 's/-Ae //' -e 's/-Ae$//'`
457		    fi
458		    ;;
459		  *)
460		    ;;
461		esac
462
463		dnl * check that perl's ldflags actually work
464		echo "#include <EXTERN.h>" > conftest.c
465		echo "#include <perl.h>" >> conftest.c
466		echo "int main(){perl_alloc(); return 0;}" >> conftest.c
467		$CC $CFLAGS $PERL_CFLAGS conftest.c -o conftest $LDFLAGS $PERL_LDFLAGS 2> perl.error.tmp > /dev/null
468		if test ! -s conftest -a "x$ignore_perl_errors" = "x"; then
469			perl_check_error="Error linking with perl libraries: $PERL_LDFLAGS: `cat perl.error.tmp`"
470			AC_MSG_RESULT([error linking with perl libraries, building without Perl])
471			want_perl=no
472		fi
473
474		rm -f perl.error.tmp
475	fi
476
477	if test "x$want_perl" != "xno"; then
478		AC_MSG_RESULT(ok)
479
480		if test "x$want_perl" = "xstatic"; then
481			dnl * building with static perl support
482			dnl * all PERL_LDFLAGS linking is done in fe-text
483			PERL_LINK_FLAGS="$PERL_LDFLAGS"
484			PERL_LINK_LIBS="../perl/libperl_core_static.la"
485			PERL_FE_LINK_LIBS="../perl/libfe_perl_static.la"
486			PERL_LDFLAGS=
487			AC_DEFINE(HAVE_STATIC_PERL)
488
489			dnl * build only static library of perl module
490			perl_module_lib=
491			perl_module_fe_lib=
492			perl_static_lib=libperl_core_static.la
493			perl_static_fe_lib=libfe_perl_static.la
494		else
495			dnl * build dynamic library of perl module
496			perl_module_lib=libperl_core.la
497			perl_module_fe_lib=libfe_perl.la
498			perl_static_lib=
499			perl_static_fe_lib=
500		fi
501
502		if test "x$want_staticperllib" = "xyes"; then
503			PERL_MM_PARAMS="$PERL_MM_PARAMS LINKTYPE=static"
504			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"
505			PERL_STATIC_LIBS=1
506		else
507			PERL_STATIC_LIBS=0
508		fi
509
510		# remove any prefix from PERL_MM_OPT
511		PERL_MM_OPT=`perl -MText::ParseWords -e 'sub qu{$_=shift;s{^(.*?)=(.*)$}{($a,$b)=($1,$2);$b=~s/"/\\\\"/g;qq{$a="$b"}}ge if /@<:@\s"@:>@/;$_} local $,=" "; print map qu($_), grep !/^(INSTALL_BASE|PREFIX)=/, shellwords(@ARGV)' "$PERL_MM_OPT"`
512		# figure out the correct @INC path - we'll need to do this
513		# through MakeMaker since it's difficult to get it right
514		# otherwise.
515		$perlpath -MExtUtils::MakeMaker -e 'WriteMakefile(NAME => "test", MAKEFILE => "Makefile.test", FIRST_MAKEFILE => "/dev/null", NO_META => 1, NO_MYMETA => 1);' $PERL_MM_PARAMS >/dev/null
516		echo 'show-INSTALLDIRS:' >> Makefile.test
517		echo '	@echo $(INSTALLDIRS)' >> Makefile.test
518		perl_INSTALLDIRS=`$am_make -s -f Makefile.test show-INSTALLDIRS`
519		if test "x$perl_INSTALLDIRS" = "xsite"; then
520			perl_library_dir="site default"
521			perl_INSTALL_VAR=INSTALLSITEARCH
522		elif test "x$perl_INSTALLDIRS" = "xvendor"; then
523			perl_library_dir="vendor default"
524			perl_INSTALL_VAR=INSTALLVENDORARCH
525		else
526			perl_library_dir="module default"
527			perl_INSTALL_VAR=INSTALLARCHLIB
528		fi
529		echo 'show-ARCHLIB:' >> Makefile.test
530		echo '	@echo $('"$perl_INSTALL_VAR"')' >> Makefile.test
531		perl_use_lib=`$am_make -s -f Makefile.test show-ARCHLIB`
532		rm -f Makefile.test
533		if test "x$perl_set_use_lib" = "xyes"; then
534			if $perlpath -e 'exit ! grep $_ eq $ARGV@<:@0@:>@, grep /^\//, @INC' "$perl_use_lib"; then
535				perl_library_dir="other path in @INC"
536				perl_set_use_lib=no
537			else
538				perl_library_dir="prepends to @INC with /set perl_use_lib"
539				PERL_USE_LIB="$perl_use_lib"
540			fi
541		fi
542
543		AC_SUBST(perl_module_lib)
544		AC_SUBST(perl_static_lib)
545		AC_SUBST(perl_module_fe_lib)
546		AC_SUBST(perl_static_fe_lib)
547
548		AC_SUBST(PERL_LINK_FLAGS)
549		AC_SUBST(PERL_LINK_LIBS)
550		AC_SUBST(PERL_FE_LINK_LIBS)
551
552		AC_SUBST(PERL_LDFLAGS)
553		AC_SUBST(PERL_CFLAGS)
554
555		AC_SUBST(PERL_USE_LIB)
556		AC_SUBST(PERL_MM_OPT)
557		AC_SUBST(PERL_MM_PARAMS)
558		AC_SUBST(PERL_STATIC_LIBS)
559	fi
560fi
561
562dnl **
563dnl ** check for capsicum
564dnl **
565
566if test "x$want_capsicum" = "xyes"; then
567	AC_CHECK_LIB(c, cap_enter, [
568		AC_CHECK_LIB(nv, nvlist_create, [
569			AC_DEFINE(HAVE_CAPSICUM,, Build with Capsicum support)
570			LIBS="$LIBS -lnv"
571		], [
572			want_capsicum="no, nvlist_create not found"
573		])
574	], [
575		want_capsicum="no, cap_enter not found"
576	])
577fi
578
579dnl **
580dnl ** OTR checks
581dnl **
582
583have_otr=no
584if test "x$want_otr" != "xno"; then
585	AM_PATH_LIBGCRYPT(1:1.2.0, [], [AC_ERROR(libgcrypt 1.2.0 or newer is required.)])
586	AM_PATH_LIBOTR(4.1.0, [], [AC_ERROR([libotr 4.1.0 or newer is required.])])
587
588	OTR_CFLAGS="$LIBOTR_CFLAGS $LIBGCRYPT_CFLAGS"
589	OTR_LDFLAGS="$LIBOTR_LIBS $LIBGCRYPT_LIBS"
590
591	AC_SUBST(otr_module_lib)
592	AC_SUBST(otr_static_lib)
593
594	if test "x$want_otr" != "xno"; then
595		if test "x$want_otr" = "xstatic"; then
596			otr_module_lib=
597			otr_static_lib=libotr_core_static.la
598
599			OTR_LINK_LIBS="../otr/libotr_core_static.la"
600			OTR_LINK_FLAGS="$OTR_LDFLAGS"
601
602			AC_DEFINE(HAVE_STATIC_OTR)
603		else
604			otr_module_lib=libotr_core.la
605			otr_static_lib=
606		fi
607	fi
608
609	AC_SUBST(otr_module_lib)
610	AC_SUBST(otr_static_lib)
611
612	AC_SUBST(OTR_CFLAGS)
613	AC_SUBST(OTR_LDFLAGS)
614
615	AC_SUBST(OTR_LINK_LIBS)
616	AC_SUBST(OTR_LINK_FLAGS)
617
618	have_otr=yes
619fi
620
621dnl ** check what we want to build
622AM_CONDITIONAL(BUILD_TEXTUI, test "$want_textui" = "yes")
623AM_CONDITIONAL(BUILD_IRSSIBOT, test "$want_irssibot" = "yes")
624AM_CONDITIONAL(BUILD_IRSSIFUZZER, test "$want_irssifuzzer" = "yes")
625AM_CONDITIONAL(BUILD_IRSSIPROXY, test "$want_irssiproxy" = "yes")
626AM_CONDITIONAL(HAVE_PERL, test "$want_perl" != "no")
627AM_CONDITIONAL(HAVE_CAPSICUM, test "x$want_capsicum" = "xyes")
628AM_CONDITIONAL(USE_GREGEX, test "x$want_gregex" = "xyes")
629AM_CONDITIONAL(HAVE_OTR, test "x$have_otr" != "xno")
630
631# move LIBS to PROG_LIBS so they're not tried to be used when linking eg. perl libraries
632PROG_LIBS=$LIBS
633LIBS=
634AC_SUBST(PROG_LIBS)
635
636dnl **
637dnl ** Keep all the libraries here so each frontend doesn't need to
638dnl ** keep track of them all
639dnl **
640dnl ** (these could be made configurable)
641
642CHAT_MODULES="irc"
643irc_MODULES="dcc flood notifylist"
644if test -n "$build_modules"; then
645	irc_MODULES="$irc_MODULES $build_modules"
646fi
647
648dnl ****************************************
649
650AC_SUBST(CHAT_MODULES)
651AC_SUBST(irc_MODULES)
652
653CORE_LIBS="../core/libcore.a ../lib-config/libirssi_config.a"
654FE_COMMON_LIBS=""
655
656CHAT_LIBS=""
657for c in $CHAT_MODULES; do
658	module_inits=""
659	module_deinits=""
660	fe_module_inits=""
661	fe_module_deinits=""
662	CHAT_LIBS="$CHAT_LIBS ../$c/lib$c.a ../$c/core/lib${c}_core.a"
663	if test -f $srcdir/src/fe-common/$c/module.h; then
664		FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/$c/libfe_common_$c.a "
665	fi
666	for s in `eval echo \\$${c}_MODULES`; do
667		CHAT_LIBS="$CHAT_LIBS ../$c/$s/lib${c}_$s.a"
668		module_inits="$module_inits ${c}_${s}_init();"
669		module_deinits="${c}_${s}_deinit(); $module_deinits"
670		if test -f $srcdir/src/fe-common/$c/$s/module.h; then
671			FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/$c/$s/libfe_${c}_$s.a "
672			fe_module_inits="$fe_module_inits fe_${c}_${s}_init();"
673			fe_module_deinits="fe_${c}_${s}_deinit(); $fe_module_deinits"
674		fi
675	done
676
677	mkdir -p src/$c
678	file="src/$c/$c.c"
679	echo "/* this file is automatically generated by configure - don't change */" > $file
680	echo "void ${c}_core_init(void); void ${c}_core_deinit(void);" >> $file
681	if test -n "$module_inits"; then
682		echo "$module_inits" | $sedpath -e 's/()/(void)/g' -e 's/ /void /g' >> $file
683		echo "$module_deinits" | $sedpath -e 's/ *$//' -e 's/()/(void)/g' -e 's/ /void /g' -e 's/^/void /' >> $file
684	fi
685	echo "void ${c}_init(void) { ${c}_core_init(); $module_inits }" >> $file
686	echo "void ${c}_deinit(void) { $module_deinits ${c}_core_deinit(); }" >> $file
687
688	if test -f $srcdir/src/fe-common/$c/module.h; then
689		mkdir -p src/fe-common/$c
690		file="src/fe-common/$c/${c}-modules.c"
691		echo "/* this file is automatically generated by configure - don't change */" > $file
692		if test -n "$fe_module_inits"; then
693			echo "$fe_module_inits" | $sedpath -e 's/()/(void)/g' -e 's/ /void /g' >> $file
694			echo "$fe_module_deinits" | $sedpath -e 's/ *$//' -e 's/()/(void)/g' -e 's/ /void /g' -e 's/^/void /' >> $file
695		fi
696		echo "void fe_${c}_modules_init(void) { $fe_module_inits }" >> $file
697		echo "void fe_${c}_modules_deinit(void) { $fe_module_deinits }" >> $file
698	fi
699done
700
701FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/core/libfe_common_core.a"
702
703dnl ** common libraries needed by frontends
704COMMON_NOUI_LIBS="$CHAT_LIBS $CORE_LIBS"
705COMMON_LIBS="$FE_COMMON_LIBS $COMMON_NOUI_LIBS"
706AC_SUBST(COMMON_NOUI_LIBS)
707AC_SUBST(COMMON_LIBS)
708
709if test "x$want_truecolor" = "xyes"; then
710	AC_DEFINE([TERM_TRUECOLOR], [], [true color support in terminal])
711else
712	want_truecolor=no
713fi
714
715if test "x$want_gregex" = "xyes"; then
716	AC_DEFINE([USE_GREGEX], [], [use GRegex for regular expressions])
717else
718	want_gregex=no
719fi
720
721AH_TEMPLATE(HAVE_GMODULE)
722AH_TEMPLATE(HAVE_SOCKS_H, [misc..])
723AH_TEMPLATE(HAVE_STATIC_PERL)
724AH_TEMPLATE(HAVE_STATIC_OTR)
725AH_TEMPLATE(PRIuUOFF_T, [printf()-format for uoff_t, eg. "u" or "lu" or "llu"])
726AH_TEMPLATE(UOFF_T_INT, [What type should be used for uoff_t])
727AH_TEMPLATE(UOFF_T_LONG)
728AH_TEMPLATE(UOFF_T_LONG_LONG)
729
730AC_CONFIG_FILES([
731Makefile
732src/Makefile
733src/core/Makefile
734src/irc/Makefile
735src/irc/core/Makefile
736src/irc/dcc/Makefile
737src/irc/notifylist/Makefile
738src/irc/proxy/Makefile
739src/irc/flood/Makefile
740src/fe-common/Makefile
741src/fe-common/core/Makefile
742src/fe-common/irc/Makefile
743src/fe-common/irc/dcc/Makefile
744src/fe-common/irc/notifylist/Makefile
745src/fe-fuzz/Makefile
746src/fe-fuzz/irc/Makefile
747src/fe-fuzz/irc/core/Makefile
748src/fe-fuzz/fe-common/Makefile
749src/fe-fuzz/fe-common/core/Makefile
750src/fe-none/Makefile
751src/fe-text/Makefile
752src/lib-config/Makefile
753src/perl/Makefile
754src/perl/common/Makefile.PL
755src/perl/irc/Makefile.PL
756src/perl/ui/Makefile.PL
757src/perl/textui/Makefile.PL
758src/otr/Makefile
759scripts/Makefile
760scripts/examples/Makefile
761tests/Makefile
762tests/fe-common/Makefile
763tests/fe-common/core/Makefile
764tests/fe-text/Makefile
765tests/irc/Makefile
766tests/irc/core/Makefile
767tests/irc/flood/Makefile
768docs/Makefile
769docs/help/Makefile
770docs/help/in/Makefile
771utils/Makefile
772themes/Makefile
773irssi-config
774])
775
776AC_OUTPUT
777
778dnl ** for building from objdir
779old_dir=`pwd` && cd $srcdir && whole_dir=`pwd` && cd $old_dir
780if test "x$old_dir" != "x$whole_dir"; then
781	$LN_S $srcdir/irssi-version.h irssi-version.h
782	if test "x$want_perl" != "xno"; then
783		subdirfiles=""
784		for i in $whole_dir/src/perl/common $whole_dir/src/perl/irc $whole_dir/src/perl/ui $whole_dir/src/perl/textui; do
785			subdirfiles=`echo $subdirfiles $i/typemap $i/module.h $i/*.pm $i/*.xs`
786		done
787		for file in $whole_dir/src/perl/module.h $subdirfiles; do
788			link=`echo $file|$sedpath "s?$whole_dir/??"`
789			rm -f $link
790			$LN_S $file $link
791		done
792	fi
793fi
794
795echo
796
797echo "Building text frontend ........... : $want_textui"
798echo "Building irssi bot ............... : $want_irssibot"
799echo "Building irssi proxy ............. : $want_irssiproxy"
800if test "x$have_gmodule" = "xyes"; then
801	echo "Building with module support ..... : yes"
802else
803	echo "Building with module support : NO!! /LOAD will not work!"
804	echo " - You're missing gmodule (comes with glib) for some reason,"
805	echo "   or it doesn't work in your system."
806fi
807
808if test "x$want_perl" = "xstatic"; then
809	echo "Building with Perl support ....... : static (in irssi binary)"
810elif test "x$want_perl" = "xmodule"; then
811	echo "Building with Perl support ....... : module"
812else
813	if test -z "$perl_check_error"; then
814		echo "Building with Perl support ....... : no"
815	else
816		echo "Building with Perl support ....... : NO!"
817		echo " - $perl_check_error"
818                if test -f /etc/debian_version; then
819                  echo " - Try: sudo apt-get install libperl-dev"
820                elif test -f /etc/redhat-release; then
821                  echo " - Try installing perl-devel"
822                fi
823	fi
824fi
825
826if test "x$want_perl" != "xno" -a "x$perl_mod_error" != "x"; then
827	echo " - NOTE: Perl support will be compiled statically to irssi, not as"
828	echo "   a module as requested. Reason:"
829	echo "   $perl_mod_error"
830
831	if test -f /etc/debian_version; then
832		echo " - Try: sudo apt-get install libperl-dev"
833	fi
834fi
835
836if test "x$want_perl" != "xno"; then
837	echo "Perl library directory ........... : ($perl_library_dir - $perl_use_lib)"
838	if test "x$perl_prefix_note" = "xyes"; then
839		echo "  - NOTE: This was automatically set to the same directory you gave with"
840		echo "  --prefix. If you want the perl libraries to install to their 'correct'"
841		echo "  path, you'll need to give --with-perl-lib=site option to configure."
842		echo "  Anyway, installing perl to this directory should work just as well."
843	fi
844fi
845echo "Install prefix ................... : $prefix"
846
847echo
848
849echo "Building with 64bit DCC support .. : $offt_64bit"
850echo "Building with true color support.. : $want_truecolor"
851echo "Building with GRegex ............. : $want_gregex"
852echo "Building with Capsicum ........... : $want_capsicum"
853echo "Building with utf8proc ........... : $want_utf8proc"
854if test "x$want_otr" = "xstatic"; then
855	echo "Building with OTR support ........ : static (in irssi binary)"
856elif test "x$want_otr" = "xmodule"; then
857	echo "Building with OTR support ........ : module"
858else
859	echo "Building with OTR support ........ : no"
860fi
861
862
863echo
864echo "If there are any problems, read the INSTALL file."
865