Merge branch 'mob' of git+ssh://repo.or.cz/srv/git/centerim into mob
[centerim.git] / configure.ac
blob2a5e2fd942d0cae0e70112e1bc999b0de4fd1259
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 AC_PREREQ(2.59)
5 AC_INIT([centerim], m4_esyscmd([misc/git-version-gen .version]), [http://bugzilla.centerim.org])
6 AC_CONFIG_SRCDIR([config.h.in])
7 AC_CONFIG_HEADER([config.h])
8 AM_INIT_AUTOMAKE([-Wall])
10 AC_ISC_POSIX
12 AC_CANONICAL_HOST
14 AC_GNU_SOURCE
16 ########################
17 # Checks for programs. #
18 ########################
19 AC_PROG_CC
20 AC_PROG_CXX
21 AM_PROG_LIBTOOL
22 AC_PROG_INSTALL
23 AC_PROG_LN_S
24 AC_PROG_MAKE_SET
25 AM_GNU_GETTEXT
26 AM_GNU_GETTEXT_VERSION([0.16.1])
27 AC_PROG_YACC
28 AC_PROG_GCC_TRADITIONAL
30 #########################
31 # Checks for libraries. #
32 #########################
33 AC_ARG_ENABLE(icq,
34               AS_HELP_STRING([--disable-icq], [Build without ICQ]),
35               build_icq="$enableval",
36               build_icq="yes"
37               )
38 AC_ARG_ENABLE(yahoo,
39               AS_HELP_STRING([--disable-yahoo], [Build without Yahoo!]),
40               build_yahoo="$enableval",
41               build_yahoo="yes"
42               )
43 AC_ARG_ENABLE(aim,
44               AS_HELP_STRING([--disable-aim], [Build without AIM]),
45               build_aim="$enableval",
46               build_aim="yes"
47               )
48 AC_ARG_ENABLE(irc,
49               AS_HELP_STRING([--disable-irc], [Build without IRC]),
50               build_irc="$enableval",
51               build_irc="yes"
52               )
53 AC_ARG_ENABLE(jabber,
54               AS_HELP_STRING([--disable-jabber], [Build without Jabber]),
55               build_jabber="$enableval",
56               build_jabber="yes"
57               )
58 AC_ARG_ENABLE(gg,
59               AS_HELP_STRING([--disable-gg], [Build without Gadu-Gadu]),
60               build_gg="$enableval",
61               build_gg="yes"
62               )
63 AC_ARG_ENABLE(msn,
64               AS_HELP_STRING([--disable-msn], [Build without MSN]),
65               build_msn="$enableval",
66               build_msn="yes"
67               )
68 AC_ARG_ENABLE(rss,
69               AS_HELP_STRING([--disable-rss], [Build without RSS reader]),
70               build_rss="$enableval",
71               build_rss="yes"
72               )
73 AC_ARG_ENABLE(lj,
74               AS_HELP_STRING([--disable-lj], [Build without LiveJournal client]),
75               build_lj="$enableval",
76               build_lj="yes"
77               )
78 AC_ARG_ENABLE(locales-fix,
79               AS_HELP_STRING([--enable-locales-fix], [enables workaround for
80                               broken locales. use this option if some of
81                               characters in your texts in Chinese or Japanese
82                               diappear])
83               )
85 AC_ARG_WITH(fribidi,
86             AS_HELP_STRING([--with-fribidi=[DIR]], [enable Hebrew and Arabic
87                             support using fribidi library in DIR]),
88             [with_fribidi=$withval],
89             [with_fribidi=no]
90             )
91 AC_ARG_WITH(ssl,
92             AS_HELP_STRING([--with-ssl], [enable SSL secured connections using
93                             either OpenSSL or GnuTLS (auto)]),
94             [with_ssl=$withval]
95             )
96 AC_ARG_WITH(openssl,
97             AS_HELP_STRING([--with-openssl=[DIR]], [enable SSL secured
98                             connections using the OpenSSL library in DIR
99                             (optional)]),
100             [with_openssl=$withval]
101             )
102 AM_PATH_GPGME(
103             [0.4.2],
104             [have_gpgme=yes],
105             [have_gpgme=no]
106             )
107 LIBCURL_CHECK_CONFIG(
108             [yes],
109             [4.12.0],
110             [have_libcurl=yes],
111             [have_libcurl=no]
112             )
113 AC_ARG_WITH(libjpeg,
114             AS_HELP_STRING([--without-libjpeg], [Compile without JPEG token
115                             support (for Gadu-Gadu registration)])
116             )
117 AC_ARG_WITH(libotr,
118             AS_HELP_STRING([--with-libotr], [enable Off-the-Record Messaging (libotr) WARNING: use at your own risk, not suppoerted yet]),
119             [with_libotr=$withval],
120             [with_libotr=no]
121             )
123 #####################
124 # Check for fribidi #
125 #####################
126 AC_MSG_CHECKING(whether to use fribidi)
127 FRIBIDI_LIBS=""
128 FRIBIDI_CFLAGS=""
129 FRIBIDI_PC="" 
130 have_fribidi=no 
132 if test "x$with_fribidi" = "xyes"; then
133         AC_PATH_PROG(FRIBIDI_CONFIG, fribidi-config, no)
134         if test "x$FRIBIDI_CONFIG" = "xno"; then
135                 AC_MSG_ERROR([*** fribidi-config not found])
136         fi
137         
138         FRIBIDI_CFLAGS="`$FRIBIDI_CONFIG --cflags`"
139         CFLAGS="$CFLAGS $FRIBIDI_CFLAGS"
140         FRIBIDI_LIBS="`$FRIBIDI_CONFIG --libs`"
141         FRIBIDI_PC="fribidi,"
143         AC_CHECK_LIB(fribidi, fribidi_get_mirror_char, :, AC_MSG_ERROR([*** libfribidi not found.]), $FRIBIDI_LIBS)
144         AC_DEFINE(HAVE_FRIBIDI, 1, [has fribidi library])
145         have_fribidi=yes
147 AC_MSG_RESULT([$have_fribidi])
149 #################
150 # Check for SSL #
151 #################
152 AC_MSG_CHECKING(for SSL)
153 AC_MSG_RESULT([])
155 if test "x$with_ssl" != "xno"; then
157         AC_MSG_CHECKING(for OpenSSL)
158         if test -z "$with_openssl" -o "x$with_openssl" = "xyes"; then
159                 for ac_dir in $with_openssl /usr/local /usr; do
160                         if test -f "$ac_dir/include/openssl/ssl.h"; then
161                                 with_openssl=$ac_dir
162                                 break;
163                         fi
164                 done
165         fi
167         if test -n "$with_openssl" -a "x$with_openssl" != "xno"; then
168                 AC_MSG_RESULT([found in $with_openssl])
169                 CFLAGS="$CFLAGS -I${with_openssl}"
170                 AC_DEFINE(HAVE_OPENSSL, 1, [use openssl])
171         AC_CHECK_LIB(crypto, main, [
172             AC_CHECK_LIB(crypto, SSLeay_add_all_algorithms, [
173                 AC_DEFINE(HAVE_SSLEAY, 1, [use SSLeay])
174             ])
175             ])
176                 AC_CHECK_LIB(ssl, main)
177         ac_configure_args="$ac_configure_args --with-ssl --with-openssl=$with_openssl"
178         else
179                 AC_MSG_RESULT([not found or disabled])
180                 with_ssl="no"
182                 AM_PATH_LIBGNUTLS_EXTRA(0.0.1, [
183                 AC_CHECK_LIB(lzo, lzo1x_1_compress, LZO_LIBS=-llzo)
184                 if test -z "$LZO_LIBS"; then
185                  AC_CHECK_LIB(lzo2, lzo1x_1_compress, LZO_LIBS=-llzo2, [
186                   AC_MSG_ERROR(
188 *** Could not find liblzo or liblzo2.
190                   ])
191                 fi
192                         CXXFLAGS="$CXXFLAGS $LIBGNUTLS_CFLAGS"
193                         LIBS="$LIBS $LIBGNUTLS_LIBS -lgnutls-extra"
194                         AC_DEFINE(HAVE_GNUTLS, 1, [use gnutls])
195             with_ssl="yes"
196             ac_configure_args="$ac_configure_args --with-ssl"
197             ])
198         fi
199 else 
200         AC_MSG_RESULT([disabled (use --with-ssl=[DIR] to enable)])
203 ###################
204 # Check for gpgme #
205 ###################
206 if test "x$have_gpgme" = "xyes"; then
207          AC_DEFINE(HAVE_GPGME, 1, [has gpgme library])
208          GPGME_CXXFLAGS="$GPGME_CFLAGS"
209          CFLAGS="$CFLAGS $GPGME_CFLAGS"
210          CXXFLAGS="$CFLAGS $GPGME_CXXFLAGS"
211          LIBS="$LIBS $GPGME_LIBS"
214 #####################
215 # Check for libcurl #
216 #####################
218 CURL_CFLAGS="$LIBCURL_CPPFLAGS"
219 CURL_CXXFLAGS="$LIBCURL_CPPFLAGS"
220 CURL_LIBS="$LIBCURL"
221 CFLAGS="$CFLAGS $CURL_CFLAGS"
222 CXXFLAGS="$CXXFLAGS $CURL_CXXFLAGS"
223 LIBS="$LIBS $CURL_LIBS"
225 #####################
226 # Check for libjpeg #
227 #####################
228 AC_MSG_CHECKING(for libjpeg (for Gadu-Gadu registration))
229 JPEG_LIBS=""
230 have_libjpeg=no
232 if test "x$with_libjpeg" != "xno"; then
233         AC_MSG_RESULT([])
235         AC_CHECK_LIB(jpeg, jpeg_start_decompress,
236         [
237                 AC_CHECK_HEADERS(jpeglib.h,
238                 [
239                         AC_DEFINE(HAVE_LIBJPEG, 1, [define if you have libjpeg])
240                         JPEG_LIBS="-ljpeg $LIBS"
241                         LIBS="$LIBS $JPEG_LIBS"
242                         have_libjpeg=yes
243                 ])
244         ])
248 #####################
249 # Check for libotr #
250 #####################
251 AC_MSG_CHECKING(for libotr)
252 have_libotr=no
254 if test "x$with_libotr" != "xno"; then
255         AC_MSG_RESULT([])
257         AC_CHECK_LIB(otr, otrl_init,
258         [
259                 AC_CHECK_HEADERS(libotr/context.h, libotr/userstate.h
260                 [
261                         AC_DEFINE(HAVE_LIBOTR, 1, [define if you have libotr])
262             OTR_LIBS="-lotr $LIBS"
263                         LIBS="$LIBS $OTR_LIBS"
264             have_libotr=yes
265                 ])
266         ])
270 ####################
271 # Check for others #
272 ####################
273 AM_ICONV
275 AC_CHECK_LIB(socket, socket)
276 AC_CHECK_LIB(nsl, gethostbyname)
277 AC_CHECK_LIB(ncursesw, get_wch,, [AC_CHECK_LIB(ncurses, initscr,,
278                                   [AC_CHECK_LIB(curses, initscr,,
279                                    AC_MSG_ERROR(The ncurses terminal library is required in order to build the program))])])
281 AC_TRY_COMPILE([
282     #include <sys/types.h>
283     #include <sys/socket.h>
284 ],[ socklen_t foo; ], ac_cv_c_socklen_t=yes, ac_cv_c_socklen_t=no)
286 if test "x$ac_cv_c_socklen_t" = "xno"; then
287   AC_DEFINE(socklen_t, int, [Define type of socklen_t for systems missing it])
290 case "$host_os" in
291         darwin*)
292                 LIBS="$LIBS -flat_namespace"
293                 ;;
294 esac
296 AM_CONDITIONAL(BUILD_ICQ, test "x$build_icq" = "xyes")
297 AM_CONDITIONAL(BUILD_YAHOO, test "x$build_yahoo" = "xyes")
298 AM_CONDITIONAL(BUILD_AIM, test "x$build_aim" = "xyes")
299 AM_CONDITIONAL(BUILD_IRC, test "x$build_irc" = "xyes")
300 AM_CONDITIONAL(BUILD_FIRETALK, test "x$build_irc" = "xyes" -o "x$build_aim" = xyes)
301 AM_CONDITIONAL(BUILD_JABBER, test "x$build_jabber" = "xyes")
302 AM_CONDITIONAL(BUILD_GADU, test "x$build_gg" = "xyes")
303 AM_CONDITIONAL(BUILD_MSN, test "x$build_msn" = "xyes")
304 AM_CONDITIONAL(BUILD_RSS, test "x$build_rss" = "xyes" -o "x$build_lj" = "xyes")
305 AM_CONDITIONAL(BUILD_LJ, test "x$build_lj" = "xyes")
306 AM_CONDITIONAL(HAVE_LIBOTR, test "x$have_libotr" = "xyes")
307 AM_CONDITIONAL(HAVE_FRIBIDI, test "x$have_fribidi" = "xyes")
309 if test "x$build_icq" = "xyes"; then
310         AC_DEFINE(BUILD_ICQ, 1, [build with ICQ support])
312 if test "x$build_yahoo" = "xyes"; then
313         AC_DEFINE(BUILD_YAHOO, 1, [build with yahoo support])
315 if test "x$build_aim" = "xyes"; then
316         AC_DEFINE(BUILD_AIM, 1, [build with aim support])
318 if test "x$build_irc" = "xyes";
319         then AC_DEFINE(BUILD_IRC, 1, [build with irc support])
321 if test "x$build_jabber" = "xyes"; then
322         if test "x$have_gpgme" = "xno"; then
323                 AC_MSG_WARN([No GPG support in Jabber, since GPGME library not found or its setup not ok])
324         fi
325         AC_DEFINE(BUILD_JABBER, 1, [build with jabber support])
327 if test "x$build_gg" = "xyes"; then
328         if test "x$have_libjpeg" = "xno"; then
329                 AC_MSG_WARN([No jpeg support in Gadu-Gadu, you will not be able to register??????????])
330         fi
331         AC_DEFINE(BUILD_GADU, 1, [build with gadu-gadu support])
333 if test "x$build_msn" = "xyes"; then
334         if test "x$have_curl" = "xno"; then
335                 AC_MSG_ERROR([MSN cannot be built without the curl library.])
336         fi
337         if test -z "$libcurl_feature_SSL" -o "x$libcurl_feature_SSL" = "xno"; then
338                 AC_MSG_ERROR([MSN requires libcurl built with SSL support.])
339         fi
340         AC_DEFINE(BUILD_MSN, 1, [build with MSN support])
342 if test "x$build_rss" = "xyes" -o "x$build_lj" = "xyes"; then
343         AC_DEFINE(BUILD_RSS, 1, [build the integrated rss feeds reader])
345 if test "x$build_lj" = "xyes"; then
346         AC_DEFINE(BUILD_LJ, 1, [build the integrated livejournal client])
349 ############################
350 # Checks for header files. #
351 ############################
352 AC_FUNC_ALLOCA
353 AC_HEADER_DIRENT
354 AC_HEADER_STDC
355 AC_HEADER_SYS_WAIT
356 AC_CHECK_HEADERS([argz.h arpa/inet.h fcntl.h float.h inttypes.h langinfo.h libintl.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdio_ext.h stdlib.h string.h strings.h sys/ioctl.h sys/mount.h sys/param.h sys/socket.h sys/statvfs.h sys/time.h sys/vfs.h syslog.h unistd.h utmp.h wchar.h])
357 AC_CHECK_HEADERS([stdint.h sys/types.h],,)
359 AC_LANG_SAVE
360 AC_LANG_CPLUSPLUS
361 AC_CHECK_HEADERS([vector iostream fstream string algorithm list memory iterator exception utility],, AC_MSG_ERROR([You need to have the libstdc++ headers installed]))
362 AC_CHECK_HEADERS([hash_map strstream ext/hash_map sstream],,)
363 AC_LANG_RESTORE
365 ##################################################
366 # check whether make supports order-only targets #
367 ##################################################
369 AC_CACHE_CHECK([whether ${MAKE-make} supports order-only targets],
370 [centerim_cv_make_order_only],
371 [cat >conftest.make <<\_ACEOF
372 SHELL = /bin/sh
373 all: | say
375 say:
376         echo say
378 .PHONY: all say
379 _ACEOF
380 centerim_cv_make_order_only=no
382 ${MAKE-make} -f conftest.make >/dev/null 2>&1 && centerim_cv_make_order_only=yes
383 rm -f conftest.make
385 if test x$centerim_cv_make_order_only = xyes; then
386   ORDER_ONLY="|"
390 ##################################################################
391 # Checks for typedefs, structures, and compiler characteristics. #
392 ##################################################################
393 AC_STRUCT_TIMEZONE
394 AC_HEADER_STDBOOL
395 AC_C_CONST
396 AC_C_INLINE
397 AC_C_RESTRICT
398 AC_TYPE_SIZE_T
399 AC_HEADER_TIME
400 AC_STRUCT_TM
401 AC_C_VOLATILE
402 AC_CHECK_TYPES([ptrdiff_t])
403 AC_TYPE_SIGNAL
405 #################
406 # Substitutions #
407 #################
408 AC_SUBST(FRIBIDI_LIBS)
409 AC_SUBST(FRIBIDI_CFLAGS) 
410 AC_SUBST(FRIBIDI_PC) 
412 AC_SUBST(GPGME_LIBS)
413 AC_SUBST(GPGME_CFLAGS) 
414 AC_SUBST(GPGME_CXXFLAGS) 
416 AC_SUBST(GNUTLS_LIBS)
417 AC_SUBST(GNUTLS_CFLAGS) 
418 AC_SUBST(GNUTLS_CXXFLAGS) 
420 AC_SUBST(CURL_LIBS)
421 AC_SUBST(CURL_CFLAGS) 
422 AC_SUBST(CURL_CXXFLAGS) 
424 AC_SUBST(JPEG_LIBS)
426 AC_SUBST(ORDER_ONLY)
428 #################################
429 # Checks for library functions. #
430 #################################
431 AC_FUNC_CLOSEDIR_VOID
432 AC_FUNC_ERROR_AT_LINE
433 AC_FUNC_FORK
434 AC_FUNC_LSTAT
435 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
436 AC_FUNC_MALLOC
437 AC_FUNC_MEMCMP
438 AC_FUNC_MKTIME
439 AC_FUNC_MMAP
440 AC_FUNC_REALLOC
441 AC_FUNC_SELECT_ARGTYPES
442 AC_FUNC_STAT
443 AC_FUNC_STRFTIME
444 AC_FUNC_VPRINTF
445 AC_FUNC_WAIT3                                  
446 AC_CHECK_FUNCS([__argz_count __argz_next __argz_stringify alarm atexit bzero dup2 floor getcwd gethostbyname gethostname gettimeofday inet_ntoa isascii memmove mempcpy memset mkdir modf munmap nl_langinfo putenv regcomp rmdir select setenv setlocale socket stpcpy strcasecmp strchr strcspn strdup strerror strncasecmp strpbrk strrchr strspn strstr strtol strtoul uname])
448 ########################
449 # Create output files. #
450 ########################
451 # also configure other packages
452 AC_CONFIG_SUBDIRS(connwrap firetalk kkconsui kkstrtext kksystr libgadu libicq2000 libjabber libmsn libyahoo2)
454 ALL_LINGUAS="zh_TW zh_CN uk sv ru ro pt_BR pl nl ms it hu fr es de cs bg"
455 AC_CONFIG_FILES([Makefile
456                  misc/Makefile
457                  share/Makefile
458                  src/Makefile
459                  src/hooks/Makefile
460                  intl/Makefile
461                  po/Makefile.in])
463 AC_OUTPUT
465 AC_MSG_RESULT([
466 Build options:
467   Version               $VERSION
468   Install prefix        $prefix
469   Build shared libs     $enable_shared
470   Build static libs     $enable_static
471   CFLAGS                $CFLAGS
472   CXXFLAGS              $CXXFLAGS
474 Protocols and Clients:])
475 if test "x$build_icq" = "xyes"; then AC_MSG_RESULT([  ICQ]); fi
476 if test "x$build_yahoo" = "xyes"; then AC_MSG_RESULT([  Yahoo]); fi
477 if test "x$build_aim" = "xyes"; then AC_MSG_RESULT([  AIM]); fi
478 if test "x$build_jabber" = "xyes"; then AC_MSG_RESULT([  jabber]); fi
479 if test "x$build_gg" = "xyes"; then AC_MSG_RESULT([  Gadu-Gadu]); fi
480 if test "x$build_msn" = "xyes"; then AC_MSG_RESULT([  MSN Messenger]); fi
481 if test "x$build_rss" = "xyes"; then AC_MSG_RESULT([  RSS Reader]); fi
482 if test "x$build_lj" = "xyes"; then AC_MSG_RESULT([  LiveJournal client]); fi
483 if test "x$have_fribidi" = "xyes"; then AC_MSG_RESULT([  LiveJournal client]); fi
484 if test "x$with_ssl" = "xno"; then 
485 AC_MSG_RESULT([
486 WARNING: SSL disabled (This means no Google Talk)
488 else
489 if test "x$have_gpgme" = "xno"; then
490 AC_MSG_RESULT([
491 WARNING: GPGME disabled (This means no encrypted messages between users)
492 ]); fi
493 if test "x$have_libotr" = "xyes"; then
494 AC_MSG_RESULT([
495 WARNING: libotr enabled (OTR is not supported yet, use at your own risk)
496 ]); fi
498 AC_MSG_RESULT([
499 Enjoy!])