Made the package compile against ncursesw when available
[centerim.git] / configure.ac
blob8da1c930d2f1a7fcdde2a5bf886569d3202d8122
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 AC_PREREQ(2.59)
5 AC_INIT([centerim], [4.22.0], [http://centericq.de/mailinglist.php])
6 AC_CONFIG_SRCDIR([config.h.in])
7 AC_CONFIG_HEADER([config.h])
8 AM_INIT_AUTOMAKE
10 AM_MAINTAINER_MODE
11 AC_ISC_POSIX
13 AC_CANONICAL_HOST
15 AC_GNU_SOURCE
17 ########################
18 # Checks for programs. #
19 ########################
20 AC_PROG_CC
21 AC_PROG_CXX
22 AM_PROG_LIBTOOL
23 AC_PROG_INSTALL
24 AC_PROG_LN_S
25 AC_PROG_MAKE_SET
26 AM_GNU_GETTEXT
27 AM_GNU_GETTEXT_VERSION([0.16.1])
28 AC_PROG_YACC
29 AC_PROG_GCC_TRADITIONAL
31 #########################
32 # Checks for libraries. #
33 #########################
34 AC_ARG_ENABLE(yahoo,
35               AS_HELP_STRING([--disable-yahoo], [Build without Yahoo!]),
36               build_yahoo="$enableval",
37               build_yahoo="yes"
38               )
39 AC_ARG_ENABLE(aim,
40               AS_HELP_STRING([--disable-aim], [Build without AIM]),
41               build_aim="$enableval",
42               build_aim="yes"
43               )
44 AC_ARG_ENABLE(irc,
45               AS_HELP_STRING([--disable-irc], [Build without IRC]),
46               build_irc="$enableval",
47               build_irc="yes"
48               )
49 AC_ARG_ENABLE(jabber,
50               AS_HELP_STRING([--disable-jabber], [Build without Jabber]),
51               build_jabber="$enableval",
52               build_jabber="yes"
53               )
54 AC_ARG_ENABLE(gg,
55               AS_HELP_STRING([--disable-gg], [Build without Gadu-Gadu]),
56               build_gg="$enableval",
57               build_gg="yes"
58               )
59 AC_ARG_ENABLE(msn,
60               AS_HELP_STRING([--disable-msn], [Build without MSN]),
61               build_msn="$enableval",
62               build_msn="yes"
63               )
64 AC_ARG_ENABLE(rss,
65               AS_HELP_STRING([--disable-rss], [Build without RSS reader]),
66               build_rss="$enableval",
67               build_rss="yes"
68               )
69 AC_ARG_ENABLE(lj,
70               AS_HELP_STRING([--disable-lj], [Build without LiveJournal client]),
71               build_lj="$enableval",
72               build_lj="yes"
73               )
74 AC_ARG_ENABLE(locales-fix,
75               AS_HELP_STRING([--enable-locales-fix], [enables workaround for
76                               broken locales. use this option if some of
77                               characters in your texts in Chinese or Japanese
78                               diappear])
79               )
81 AC_ARG_WITH(fribidi,
82             AS_HELP_STRING([--with-fribidi=[DIR]], [enable Hebrew and Arabic
83                             support using fribidi library in DIR]),
84             [with_fribidi=$withval],
85             [with_fribidi=no]
86             )
87 AC_ARG_WITH(ssl,
88             AS_HELP_STRING([--with-ssl], [enable SSL secured connections using
89                             either OpenSSL or GnuTLS]),
90             [with_ssl=$withval],
91             [with_ssl=no]
92             )
93 AC_ARG_WITH(openssl,
94             AS_HELP_STRING([--with-openssl=[DIR]], [enable SSL secured
95                             connections using the OpenSSL library in DIR
96                             (optional)]),
97             [with_openssl=$withval],
98             [with_openssl=no]
99             )
100 AC_ARG_WITH(gpgme,
101             AS_HELP_STRING([--with-gpgme=[PATH]], [path to gpgme-config (auto)]),
102             [with_gpgme=$withval],
103             [with_gpgme=no]
104             )
105 AC_ARG_WITH(curl,
106             AS_HELP_STRING([--with-curl=[PATH]], [path to curl-config (auto)]),
107             [with_curl=$withval],
108             [with_curl=no]
109             )
110 AC_ARG_WITH(libjpeg,
111             AS_HELP_STRING([--without-libjpeg], [Compile without JPEG token
112                             support (for Gadu-Gadu registration)])
113             )
115 #####################
116 # Check for fribidi #
117 #####################
118 AC_MSG_CHECKING(whether to use fribidi)
119 FRIBIDI_LIBS=""
120 FRIBIDI_CFLAGS=""
121 FRIBIDI_PC="" 
122 have_fribidi=no 
124 if test "x$with_fribidi" = "xyes"; then
125         AC_PATH_PROG(FRIBIDI_CONFIG, fribidi-config, no)
126         if test x$FRIBIDI_CONFIG = xno; then
127                 AC_MSG_ERROR([*** fribidi-config not found])
128         fi
129         
130         FRIBIDI_CFLAGS="`$FRIBIDI_CONFIG --cflags`"
131         CFLAGS="$CFLAGS $FRIBIDI_CFLAGS"
132         FRIBIDI_LIBS="`$FRIBIDI_CONFIG --libs`"
133         FRIBIDI_PC="fribidi,"
135         AC_CHECK_LIB(fribidi, fribidi_get_mirror_char, :, AC_MSG_ERROR([*** libfribidi not found.]), $FRIBIDI_LIBS)
136         AC_DEFINE(HAVE_FRIBIDI, 1, [has fribidi library])
137         have_fribidi=yes
139 AC_MSG_RESULT([$have_fribidi])
141 #################
142 # Check for SSL #
143 #################
144 AC_MSG_CHECKING(for SSL)
145 AC_MSG_RESULT([])
147 if test "$with_ssl" != "no"; then
149         AC_MSG_CHECKING(for OpenSSL)
150         if test -z "$with_openssl"; then
151                 for ac_dir in $with_openssl /usr/local /usr; do
152                         if test -f "$ac_dir/include/openssl/ssl.h"; then
153                                 with_openssl=$ac_dir
154                                 break;
155                         fi
156                 done
157         fi
159         if test -n "$with_openssl" -a "$with_openssl" != "no"; then
160                 if test "$with_openssl" = "yes"; then 
161                         with_openssl="/usr"
162                 fi
163                 AC_MSG_RESULT([found in $with_openssl])
164                 CFLAGS="$CFLAGS -I${with_openssl}"
165                 AC_DEFINE(HAVE_OPENSSL, 1, [use openssl])
166                 AC_CHECK_LIB(crypto, main)
167                 AC_CHECK_LIB(ssl, main)
168         else
169                 AC_MSG_RESULT([not found or disabled])
170                 with_ssl="no"
172                 AM_PATH_LIBGNUTLS_EXTRA(0.0.1, [
173                         CXXFLAGS="$CXXFLAGS $LIBGNUTLS_CFLAGS"
174                         LIBS="$LIBS $LIBGNUTLS_LIBS -lgnutls-extra"
175                         AC_DEFINE(HAVE_GNUTLS, 1, [use gnutls]) with_ssl="yes" ])
176         fi
177 else 
178         AC_MSG_RESULT([disabled (use --with-ssl=[DIR] to enable)])
181 ###################
182 # Check for gpgme #
183 ###################
184 GPGME_CFLAGS=""
185 GPGME_CXXFLAGS=""
186 GPGME_LIBS=""
187 have_gpgme=no
189 if test x"$with_gpgme" = x"no"; then
190     AC_MSG_CHECKING(for gpgme)
192         if test -x "$with_gpgme"; then
193                 GPGME_CONFIG= "$with_gpgme"
194         else
195                 AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no)
196         fi
198         if test x$GPGME_CONFIG = xno; then
199         AC_MSG_RESULT([no])
200     else
201         AC_MSG_RESULT([yes])
202         fi
204         save_CFLAGS="$CFLAGS"
205         save_CXXFLAGS="$CXXFLAGS"
206         save_LIBS="$LIBS"
208         GPGME_CFLAGS="`$GPGME_CONFIG --cflags`"
209         GPGME_CXXFLAGS="`$GPGME_CONFIG --cflags`"
210         GPGME_LIBS="`$GPGME_CONFIG --libs`"
211         CFLAGS="$CFLAGS $GPGME_CFLAGS"
212         CXXFLAGS="$CXXFLAGS $GPGME_CXXFLAGS"
213         LIBS="$LIBS $GPGME_LIBS"
215         AC_MSG_CHECKING(for the OpenPGP protocol in gpgme)
216         AC_TRY_RUN([
217                 #include <gpgme.h>
218                 int main() {
219                         gpgme_ctx_t ctx;
220                         if(!gpgme_new(&ctx)) if(!gpgme_set_protocol(ctx, GPGME_PROTOCOL_OpenPGP)) return 0;
221                         return 1;
222                 }
223         ], opengpg_avail=yes, opengpg_avail=no, opengpg_avail=no)
224         AC_MSG_RESULT([$opengpg_avail])
226         if test "$opengpg_avail" != "yes"; then
227                 CFLAGS="$save_CFLAGS"
228                 CXXFLAGS="$save_CXXFLAGS"
229                 LIBS="$save_LIBS"
230         fi
231         AC_DEFINE(HAVE_GPGME, 1, [has gpgme library])
232         have_gpgme=yes
235 ##################
236 # Check for curl #
237 ##################
238 AC_MSG_CHECKING(for cURL)
239 AC_MSG_RESULT([])
240 CURL_CFLAGS=""
241 CURL_CXXFLAGS=""
242 CURL_LIBS=""
243 have_curl=no
245 if true; then
246         if test -x "$with_curl"; then
247                 CURL_CONFIG= "$with_curl"
248         else
249                 AC_PATH_PROG(CURL_CONFIG, curl-config, no)
250         fi
252         if test x$CURL_CONFIG = xno; then
253                 AC_MSG_ERROR([*** curl-config not found])
254         fi
256         save_CFLAGS="$CFLAGS"
257         save_CXXFLAGS="$CXXFLAGS"
258         save_LIBS="$LIBS"
260         CURL_CFLAGS="`$CURL_CONFIG --cflags`"
261         CURL_CXXFLAGS="`$CURL_CONFIG --cflags`"
262         CURL_LIBS="`$CURL_CONFIG --libs`"
263         CFLAGS="$CFLAGS $CURL_CFLAGS"
264         CXXFLAGS="$CXXFLAGS $CURL_CXXFLAGS"
265         LIBS="$LIBS $CURL_LIBS"
267         AC_MSG_CHECKING(for SSL support in libcurl)
268         curlssl=`$CURL_CONFIG --feature | grep SSL`
269         if test -z "$curlssl"; then
270                 curlssl=no
271                 AC_MSG_RESULT([no])
272         else
273                 curlssl=yes
274                 AC_MSG_RESULT([yes])
275         fi
277         AC_DEFINE(HAVE_CURL, 1, [has curl library])
278         have_curl=yes
281 #####################
282 # Check for libjpeg #
283 #####################
284 AC_MSG_CHECKING(for libjpeg (for Gadu-Gadu registration))
285 JPEG_LIBS=""
286 have_libjpeg=no
288 if test "x$with_libjpeg" != "xno"; then
289         AC_MSG_RESULT([])
291         AC_CHECK_LIB(jpeg, jpeg_start_decompress,
292         [
293                 AC_CHECK_HEADERS(jpeglib.h,
294                 [
295                         AC_DEFINE(HAVE_LIBJPEG, 1, [define if you have libjpeg])
296                         JPEG_LIBS="-ljpeg $LIBS"
297                         LIBS="$LIBS $JPEG_LIBS"
298                         have_libjpeg=yes
299                 ])
300         ])
303 ####################
304 # Check for others #
305 ####################
306 AM_ICONV_LINK
307 LIBS="$LIBS $LIBICONV"
309 AC_CHECK_LIB(socket, socket)
310 AC_CHECK_LIB(nsl, gethostbyname)
311 AC_CHECK_LIB(ncursesw, get_wch,, [AC_CHECK_LIB(ncurses, initscr,,
312                                   [AC_CHECK_LIB(curses, initscr,,
313                                    AC_MSG_ERROR(The ncurses terminal library is
314                                                 required in order to build the
315                                                 program))])])
317 AC_TRY_COMPILE([
318     #include <sys/types.h>
319     #include <sys/socket.h>
320 ],[ socklen_t foo; ], ac_cv_c_socklen_t=yes, ac_cv_c_socklen_t=no)
322 if test "$ac_cv_c_socklen_t" = "no"; then
323   AC_DEFINE(socklen_t, int, [Define type of socklen_t for systems missing it])
326 case "$host_os" in
327         darwin*)
328                 LIBS="$LIBS -flat_namespace"
329                 ;;
330 esac
332 AM_CONDITIONAL(BUILD_YAHOO, test "x$build_yahoo" = xyes)
333 AM_CONDITIONAL(BUILD_AIM, test "x$build_aim" = xyes)
334 AM_CONDITIONAL(BUILD_IRC, test "x$build_irc" = xyes)
335 AM_CONDITIONAL(BUILD_FIRETALK, test "x$build_irc" = xyes -o "x$build_aim" = xyes)
336 AM_CONDITIONAL(BUILD_JABBER, test "x$build_jabber" = xyes)
337 AM_CONDITIONAL(BUILD_GADU, test "x$build_gg" = xyes)
338 AM_CONDITIONAL(BUILD_MSN, test "x$build_msn" = xyes)
339 AM_CONDITIONAL(BUILD_RSS, test "x$build_rss" = xyes -o "x$build_lj" = xyes)
340 AM_CONDITIONAL(BUILD_LJ, test "x$build_lj" = xyes)
341 AM_CONDITIONAL(HAVE_FRIBIDI, test "x$have_fribidi" = xyes)
343 if test "$build_yahoo" = "yes"; then
344         AC_DEFINE(BUILD_YAHOO, 1, [build with yahoo support])
346 if test "$build_aim" = "yes"; then
347         AC_DEFINE(BUILD_AIM, 1, [build with aim support])
349 if test "$build_irc" = "yes";
350         then AC_DEFINE(BUILD_IRC, 1, [build with irc support])
352 if test "$build_jabber" = "yes"; then
353         if test $have_gpgme = no; then
354                 AC_MSG_WARN([No GPG support in Jabber, since GPGME library not found or its setup not ok])
355         fi
356         AC_DEFINE(BUILD_JABBER, 1, [build with jabber support])
358 if test "$build_gg" = "yes"; then
359         if test $have_libjpeg = no; then
360                 AC_MSG_WARN([No jpeg support in Gadu-Gadu, you will not be able to register??????????])
361         fi
362         AC_DEFINE(BUILD_GADU, 1, [build with gadu-gadu support])
364 if test "$build_msn" = "yes"; then
365         if test $have_curl = no; then
366                 AC_MSG_ERROR([MSN cannot be built without the curl library.])
367         fi
368         if test $curlssl = no; then
369                 AC_MSG_ERROR([MSN requires libcurl built with SSL support.])
370         fi
371         AC_DEFINE(BUILD_MSN, 1, [build with MSN support])
373 if test "$build_rss" = "yes" -o "$build_lj" = "yes"; then
374         AC_DEFINE(BUILD_RSS, 1, [build the integrated rss feeds reader])
376 if test "$build_lj" = "yes"; then
377         AC_DEFINE(BUILD_LJ, 1, [build the integrated livejournal client])
380 ############################
381 # Checks for header files. #
382 ############################
383 AC_FUNC_ALLOCA
384 AC_HEADER_DIRENT
385 AC_HEADER_STDC
386 AC_HEADER_SYS_WAIT
387 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])
388 AC_CHECK_HEADERS([stdint.h sys/types.h],,)
390 AC_LANG_SAVE
391 AC_LANG_CPLUSPLUS
392 AC_CHECK_HEADERS([vector iostream fstream string algorithm list memory iterator exception utility],, AC_MSG_ERROR([You need to have the libstdc++ headers installed]))
393 AC_CHECK_HEADERS([hash_map strstream ext/hash_map sstream],,)
394 AC_LANG_RESTORE
396 ##################################################################
397 # Checks for typedefs, structures, and compiler characteristics. #
398 ##################################################################
399 AC_STRUCT_TIMEZONE
400 AC_HEADER_STDBOOL
401 AC_C_CONST
402 AC_C_INLINE
403 AC_C_RESTRICT
404 AC_TYPE_SIZE_T
405 AC_HEADER_TIME
406 AC_STRUCT_TM
407 AC_C_VOLATILE
408 AC_CHECK_TYPES([ptrdiff_t])
409 AC_TYPE_SIGNAL
411 #################
412 # Substitutions #
413 #################
414 AC_SUBST(FRIBIDI_LIBS)
415 AC_SUBST(FRIBIDI_CFLAGS) 
416 AC_SUBST(FRIBIDI_PC) 
418 AC_SUBST(GPGME_LIBS)
419 AC_SUBST(GPGME_CFLAGS) 
420 AC_SUBST(GPGME_CXXFLAGS) 
422 AC_SUBST(CURL_LIBS)
423 AC_SUBST(CURL_CFLAGS) 
424 AC_SUBST(CURL_CXXFLAGS) 
426 AC_SUBST(JPEG_LIBS)
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.Big5 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   CPPFLAGS              $CPPFLAGS
474 Protocols and Clients:])
475 if test "x$build_yahoo" = xyes; then AC_MSG_RESULT([  Yahoo]); fi
476 if test "x$build_aim" = xyes; then AC_MSG_RESULT([  AIM]); fi
477 if test "x$build_jabber" = xyes; then AC_MSG_RESULT([  jabber]); fi
478 if test "x$build_gg" = xyes; then AC_MSG_RESULT([  Gadu-Gadu]); fi
479 if test "x$build_msn" = xyes; then AC_MSG_RESULT([  MSN Messenger]); fi
480 if test "x$build_rss" = xyes; then AC_MSG_RESULT([  RSS Reader]); fi
481 if test "x$build_lj" = xyes; then AC_MSG_RESULT([  LiveJournal client]); fi
482 if test "x$have_fribidi" = xyes; then AC_MSG_RESULT([  LiveJournal client]); fi
483 AC_MSG_RESULT([
484 Enjoy!])