configure: rewrite check for GSSAPI headers & libs
[siplcs.git] / configure.ac
blob112e654157b87098d5f5e9a181047546b9d11751
1 dnl ensure recent enough version of Autoconf
2 AC_PREREQ([2.50])
4 dnl Use 'VERSION' files to get version.
5 m4_define([SIPE_VERSION_DATA], m4_include([VERSION]))
7 dnl Strip off newline characters.
8 m4_define([SIPE_VERSION],
9         m4_substr(SIPE_VERSION_DATA,
10                   [0], m4_decr(m4_len(SIPE_VERSION_DATA))))
12 dnl homepage
13 m4_define([SIPE_HOMEPAGE], [http://sipe.sourceforge.net/])
15 dnl initialize package name, version, bugtracker & homepage
16 AC_INIT([pidgin-sipe], SIPE_VERSION,
17         [https://sourceforge.net/p/sipe/bugs/], [],
18         SIPE_HOMEPAGE)
20 AC_DEFINE([SIPE_TRANSLATIONS_URL],
21         ["https://www.transifex.com/projects/p/pidgin-sipe/r/mob/"],
22         [URL for submitting translations.])
24 dnl define optional git commit ID generated by autogen.sh
25 m4_define([SIPE_GIT_COMMIT], m4_sinclude([GITVERSION]))
26 AS_IF([test "x"SIPE_GIT_COMMIT != x],
27         [AC_MSG_NOTICE([set git commit])
28          AC_DEFINE(PACKAGE_GIT_COMMIT, "SIPE_GIT_COMMIT", [Define to the git commit for this package.])
31 dnl setup automake and require recent enough version
32 AM_INIT_AUTOMAKE([1.9 dist-bzip2 no-define tar-ustar])
34 AC_CANONICAL_HOST
36 dnl set PACKAGE_URL for autoconf < 2.64
37 AS_IF([test "x${PACKAGE_URL}" = x],
38         [AC_MSG_NOTICE([set PACKAGE_URL for autoconf < 2.64])
39          AC_DEFINE(PACKAGE_URL, "SIPE_HOMEPAGE", [Define to the home page for this package.])
42 dnl set programming language
43 AC_LANG(C)
44 AM_PROG_CC_C_O
45 AC_HEADER_STDC
47 dnl setup shared library generation
48 LT_INIT([disable-static])
50 dnl checks for tools
51 IT_PROG_INTLTOOL([0.35.0])
52 AC_PROG_INSTALL
53 AC_PROG_RANLIB
55 dnl ******************************
56 dnl Win32
57 dnl ******************************
58 AC_MSG_CHECKING([for Win32])
59 AS_CASE(["$host"],
60                 [*-mingw*], [os_win32=yes],
61                 [os_win32=no])
62 AC_MSG_RESULT([$os_win32])
63 AM_CONDITIONAL(SIPE_OS_WIN32, [test "x${os_win32}" = xyes])
65 dnl checks for header files
66 AC_CHECK_HEADERS([sys/sockio.h])
68 dnl checks for library functions
69 AC_CHECK_FUNCS([])
71 dnl tell pkgconfig to look in the same prefix where we're installing this to,
72 dnl as that is likely where libpurple will be found if it is not in the default
73 dnl pkgconfig path
74 PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${libdir}/pkgconfig"
75 export PKG_CONFIG_PATH
77 dnl debug mode
78 AC_ARG_ENABLE(debug,
79         [AS_HELP_STRING([--enable-debug],
80                         [compile with debugging support [default=no]])],
81         [],
82         [enable_debug=no])
84 AS_IF([test "x$enable_debug" = xyes],
85         [AC_DEFINE(DEBUG, 1, [Define if debugging is enabled.])])
86 AC_SUBST(DEBUG_CFLAGS)
88 dnl quality check mode
89 dnl For people who are interested in finding bugs and not hiding them
90 AC_ARG_ENABLE(quality-check,
91         [AS_HELP_STRING([--enable-quality-check],
92                         [compile with compiler checks enabled [default=yes]])],
93         [],
94         [enable_quality_check=yes])
96 AS_IF([test "x$enable_quality_check" = xyes],
97         [dnl default quality configuration
98          QUALITY_CFLAGS="$QUALITY_CFLAGS -Werror -Wall"
100          dnl enable warnings supported by the GCC on the build system
101          for newflag in \
102                         "-Wextra" \
103                         "-Waggregate-return" \
104                         "-Wcast-align" \
105                         "-Wdeclaration-after-statement" \
106                         "-Wdeprecated-declarations" \
107                         "-Winit-self" \
108                         "-Wmaybe-uninitialized" \
109                         "-Wmissing-declarations" \
110                         "-Wmissing-prototypes" \
111                         "-Wnested-externs" \
112                         "-Wpointer-arith" \
113                         "-Wundef" \
114                         "-Wunused-but-set-variable" \
115          ; do
116                  ac_save_CFLAGS=$CFLAGS
117                  AC_MSG_CHECKING([if $CC supports $newflag])
118                  CFLAGS="$QUALITY_CFLAGS $newflag"
119                  AC_COMPILE_IFELSE(
120                         [AC_LANG_SOURCE([[]])],
121                         [AC_MSG_RESULT(yes)
122                          QUALITY_CFLAGS="$QUALITY_CFLAGS $newflag"],
123                         [AC_MSG_RESULT(no)]
124                  )
125                  CFLAGS=$ac_save_CFLAGS
126          done
127         ])
128 AC_SUBST(QUALITY_CFLAGS)
130 dnl Check for pkg-config before using it
131 PKG_PROG_PKG_CONFIG
133 dnl check for valgrind (optional, only needed for debugging)
134 PKG_CHECK_MODULES(VALGRIND, [valgrind],
135         [AC_DEFINE(HAVE_VALGRIND, 1, [Define to 1 if you have the valgrind headers])],
136         [AC_MSG_RESULT(no)])
138 dnl build option: with voice & video support (for all backends)
139 AC_ARG_WITH(vv,
140         [AC_HELP_STRING([--with-vv],
141                 [compile with voice and video support @<:@default=check@:>@])],
142         [AS_IF([test "x$withval" = xyes], [with_vv=check])],
143         [with_vv=check])
145 dnl check for Kerberos 5 support
146 AC_ARG_WITH([krb5],
147         [AC_HELP_STRING([--with-krb5],
148                 [compile with Kerberos 5 support @<:@default=check@:>@])],
149         [AS_IF([test "x$withval" = xyes], [with_krb5=check])],
150         [with_krb5=check])
152 AS_IF([test "x$with_krb5" = xno], [], dnl disabled by user
153       [test "x$with_krb5" = xcheck],  dnl autodetect with krb5-config
154         [AC_MSG_CHECKING(if Kerberos 5 is available)
155          AS_IF([AC_RUN_LOG([krb5-config --version])],
156                 [KRB5_CFLAGS=`krb5-config --cflags 2>/dev/null`
157                  KRB5_LDFLAGS=""
159                  dnl same as AC_CHECK_LIB()
160                  LIBS="$LIBS `krb5-config --libs gssapi 2>/dev/null`"],
161                 [AC_MSG_RESULT(no)
162                  with_krb5=no])],
163       [                               dnl path specified by user
164         KRB5_CFLAGS="-I${with_krb5}/include"
165         KRB5_LDFLAGS="-L${with_krb5}/lib"
166       ])
167 AS_IF([test "x$with_krb5" != xno],
168       [ac_save_CFLAGS="$CFLAGS"
169        ac_save_LDFLAGS="$LDLAGS"
170        CFLAGS="$CFLAGS $KRB5_CFLAGS"
171        LDFLAGS="$LDFLAGS $KRB5_LDFLAGS"
172        AC_CHECK_HEADERS([gssapi/gssapi.h gssapi/gssapi_ext.h gssapi/gssapi_krb5.h],
173                         ,
174                         [AC_ERROR([GSSAPI headers not found])])
175        AC_CHECK_FUNC([gss_acquire_cred_with_password],
176                      ,
177                      [AC_ERROR([GSSAPI libraries not found])])
178        CFLAGS="$ac_save_CFLAGS"
179        LDFLAGS="$ac_save_LDFLAGS"
180        AC_DEFINE(HAVE_LIBKRB5, 1, [Define to 1 ifyou have the `krb5' library (-lkrb5)])
181       ])
183 AM_CONDITIONAL(SIP_SEC_KRB5, [test "x$with_krb5" != xno])
184 AC_SUBST(KRB5_CFLAGS)
185 AC_SUBST(KRB5_LDFLAGS)
187 dnl check for glib
188 PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.12.0])
189 PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.12.0])
191 dnl check for gmime
192 dnl See also: https://bugzilla.gnome.org/show_bug.cgi?id=613653#c8
193 PKG_CHECK_MODULES(GMIME, [gmime-2.6 >= 2.5.2],
194         [ac_have_gmime=yes],
195         [PKG_CHECK_MODULES(GMIME, [gmime-2.4 >= 2.4.16],
196                 [ac_have_gmime=yes],
197                 [ac_have_gmime=no])
199 AM_CONDITIONAL(SIPE_MIME_GMIME, [test "x$ac_have_gmime" = xyes])
200 AS_IF([test "x$ac_have_gmime" = xyes],
201         [AC_DEFINE(HAVE_GMIME, 1, [Define if gmime should be used in sipe.])])
203 dnl check for NSS
204 PKG_CHECK_MODULES(NSS, [nss],
205         [],
206         [PKG_CHECK_MODULES(NSS, [mozilla-nss],
207                 [],
208                 [PKG_CHECK_MODULES(NSS, [microb-engine-nss],
209                         [],
210                         [AC_ERROR([nss, mozilla-nss or microb-engine-nss package is required])])
211         ])
214 dnl check for libxml2
215 PKG_CHECK_MODULES(LIBXML2, [libxml-2.0])
217 dnl assumption check: sizof(uuid_t) must be 16 (see uuid.c)
218 AC_MSG_CHECKING([that sizeof(uuid_t) is 16])
219 ac_save_CFLAGS=$CFLAGS
220 CFLAGS="$GLIB_CFLAGS $QUALITY_CFLAGS"
221 dnl note the [[[ quoting: our code contains []!
222 AC_RUN_IFELSE(
223         [AC_LANG_PROGRAM(
224                 [[
225 #include <glib.h>
226 #include <stdio.h>
228 /* Copied from uuid.c */
229 typedef struct {
230    guint32 time_low;
231    guint16 time_mid;
232    guint16 time_hi_and_version;
233    guint8  clock_seq_hi_and_reserved;
234    guint8  clock_seq_low;
235    guint8  node[6];
236 } uuid_t;
237                 ]],
238                 [[if (sizeof(uuid_t) == 16) {
239                         return(0);
240                  } else {
241                         printf("\n\nOoops, sizeof(uuid_t) is %" G_GSIZE_FORMAT ".\n\n", sizeof(uuid_t));
242                         return(1);
243                  }]])],
244         [AC_MSG_RESULT(yes)],
245         [AC_MSG_FAILURE([sizeof(uuid_t) is not 16
247 Please notify the SIPE developers.
249 Copy & paste all lines starting with the line
251   checking that sizeof(uuid_t) is 16...
253 to the report and attach the file "config.log".
255 Compiler information:
257  host:     $host
258  build:    $build
259  compiler: $CC
260 ])],
261         [AC_MSG_WARN([cross compiling: not checking])])
262 CFLAGS=$ac_save_CFLAGS
264 dnl build option: OCS2005 client hack
265 AC_ARG_ENABLE([ocs2005-message-hack],
266         [AC_HELP_STRING([--enable-ocs2005-message-hack], [disable message timeout for OCS2005 clients
267                                                           which causes "false" not delivered error messages
268                                                           @<:@default=no@:>@])],
269         [AC_DEFINE([ENABLE_OCS2005_MESSAGE_HACK], [1],
270                    [Define to 1 to disable SIP MESSAGE timeout feature.
271                     OCS2005 clients don't seem to acknowledge MESSAGEs and
272                     disabling the timeout suppresses "false" error messages])])
274 dnl build option: purple backend
275 AC_ARG_ENABLE([purple],
276         [AC_HELP_STRING([--enable-purple], [build purple plugin @<:@default=yes@:>@])],
277         [],
278         [enable_purple=yes])
279 with_purple_vv=no
280 AS_IF([test "x$enable_purple" != xno],
281         [PKG_CHECK_MODULES(PURPLE, [purple >= 2.4.0],
282                 [dnl unfortunately PURPLE_MAJOR_VERSION is not exported by purple.m4
283                  PURPLE_MAJOR_VERSION=`$PKG_CONFIG --modversion purple | cut -d. -f 1`
284                  AC_SUBST(PURPLE_MAJOR_VERSION)
286                  dnl let user now if he has a 32- and 64-bit header conflict...
287                  AC_MSG_CHECKING([for 32- and 64-bit header conflicts])
288                  ac_save_CFLAGS=$CFLAGS
289                  CFLAGS="$PURPLE_CFLAGS $QUALITY_CFLAGS"
290                  AC_COMPILE_IFELSE(
291                         [AC_LANG_PROGRAM([[
292 #include <unistd.h>
293 #include <glib.h>
294 #include <cipher.h>
295 #include <version.h>
297 /* Compile some code that has caused trouble in the past */
298 static void testfunc(unsigned long len)
300   PurpleCipherContext *rc4 = NULL;
301   guchar *plaintext = NULL;
302   gsize plaintext_length = 0;
303   guchar *encrypted_text = NULL;
304   gsize dummy = 0;
305   purple_cipher_context_set_option(rc4, "key_len", GUINT_TO_POINTER(len));
306   purple_cipher_context_encrypt(rc4, plaintext, plaintext_length,
307                                 encrypted_text,
308 #if PURPLE_VERSION_CHECK(3,0,0)
309                                 dummy);
310 #else
311                                 &dummy);
312 #endif
314                                         ]],
315                                         [[testfunc(16);]])],
316                         [AC_MSG_RESULT(none)],
317                         [AC_MSG_FAILURE([conflicts found.
319 Check that you have the correct glib/libpurple headers installed for
320 your architecture or set GLIB_CFLAGS/PURPLE_CFLAGS to override the
321 system defaults.
323                         ])
325                  dnl on windows
326                  dnl test program needs to be in the same location as libpurple
327                  dnl installation for latter to load ssl plugin referenced by
328                  dnl RELATIVE path.
329                  AS_IF([test "x${os_win32}" != xyes],
330                         [dnl purple SSL support is mandatory
331                          AC_MSG_CHECKING([for purple SSL support])
332                          ac_save_LIBS=$LIBS
333                          LIBS="$PURPLE_LIBS"
334                          AC_RUN_IFELSE(
335                                 [AC_LANG_PROGRAM([[
336 #include <glib.h>
337 #include <plugin.h>
338 #include <sslconn.h>
339                                                 ]],
340                                                 [[
341         purple_plugins_init();
342         purple_plugins_probe(G_MODULE_SUFFIX);
343         purple_ssl_init();
344         return(purple_ssl_is_supported()?0:1);
345                                                 ]])],
346                                 [AC_MSG_RESULT(ok)],
347                                 [AC_MSG_FAILURE([your purple hasn't been compiled with SSL support.
349                                 ],
350                                 [AC_MSG_WARN([cross compiling: not checking])])
351                  ])
353                  dnl check whether enable voice and video support
354                  AS_IF([test "x$with_vv" = xno], [], dnl disabled by user
355                        [test "x$with_vv" = xcheck],  dnl autodetect
356                          [AC_MSG_CHECKING(for purple voice and video support)
357                           AC_RUN_IFELSE(
358                                 [AC_LANG_PROGRAM([[
359 #include <media.h>
360                                         ]],
361                                         [[return (purple_media_get_type() == G_TYPE_NONE ? 1 : 0);]]
362                                 )],
363                                 [AC_MSG_RESULT(ok)
364                                  PKG_CHECK_MODULES(NICE, [nice >= 0.1.0],
365                                         dnl sipe-media.c uses g_slist_free_full()
366                                         [PKG_CHECK_MODULES(_SIPE_MEDIA_RECHECK_PLEASE_IGNORE, [purple >= 2.8.0],
367                                                 [PKG_CHECK_MODULES(GSTREAMER, [gstreamer-0.10],
368                                                         [with_purple_vv=yes],
369                                                         [AC_MSG_NOTICE(GStreamer required: disabling purple voice and video support)])],
370                                                 [AC_MSG_NOTICE(libpurple >= 2.8.0 required: disabling purple voice and video support)])],
371                                         [AC_MSG_NOTICE(libnice required: disabling purple voice and video support)])],
372                                 [AC_MSG_RESULT(no - your purple hasn't been compiled with voice and video support.)],
373                                 [AC_MSG_WARN([cross compiling: not checking])])
374                          ])
376                  dnl check if we have TCP media transport patches in libpurple
377                  AS_IF([test "x$with_purple_vv" != xno],
378                         [
379                          AC_MSG_CHECKING(for TCP media transport)
380                          AC_COMPILE_IFELSE(
381                                 [AC_LANG_PROGRAM([[#include <media.h>]],[[return PURPLE_MEDIA_NETWORK_PROTOCOL_TCP_ACTIVE]])],
382                                 [
383                                  with_purple_tcp=yes
384                                  AC_DEFINE(HAVE_ICE_TCP, 1, [Define if we have support for TCP media transport.])
385                                  AC_MSG_RESULT(yes)
386                                 ],
387                                 [AC_MSG_RESULT(no)]
388                          )
389                         ])
391                  CFLAGS=$ac_save_CFLAGS
392                  LIBS=$ac_save_LIBS],
393                 [enable_purple=no])])
394 AM_CONDITIONAL(SIPE_INCLUDE_PURPLE, [test "x$enable_purple" != xno])
396 dnl build option: telepathy backend
397 AC_ARG_ENABLE([telepathy],
398         [AC_HELP_STRING([--enable-telepathy], [build telepathy plugin @<:@default=yes@:>@])],
399         [],
400         [enable_telepathy=yes])
401 AS_IF([test "x$enable_telepathy" != xno],
402         [PKG_CHECK_MODULES(TELEPATHY_GLIB, [telepathy-glib >= 0.18.0],
403                 [dnl GMIME is a build requirement
404                  AS_IF([test "x$ac_have_gmime" = xyes],
405                         [],
406                         [AC_ERROR(GMIME package is required for telepathy plugin)])
408                  dnl telepathy is based on GObject & D-Bus GLib
409                  PKG_CHECK_MODULES(GOBJECT, [gobject-2.0])
410                  PKG_CHECK_MODULES(DBUS_GLIB, [dbus-glib-1])
412                  dnl telepathy uses from gio:
413                  dnl  - GIOStream      (>= 2.22.0)
414                  dnl  - GResolver      (>= 2.22.0)
415                  dnl  - GSocketClient  (>= 2.32.0)
416                  dnl  - GTlsConnection (>= 2.28.0)
417                  PKG_CHECK_MODULES(GIO, [gio-2.0 >= 2.32.0])
419                 ],
420                 [enable_telepathy=no])])
421 AM_CONDITIONAL(SIPE_INCLUDE_TELEPATHY, [test "x$enable_telepathy" != xno])
423 dnl sanity check
424 AS_IF([test "x$enable_purple" = xno -a "x$enable_telepathy" = xno],
425         [AC_ERROR(at least one plugin must be selected
427 If you didn't use a --enable option then please check that you have
428 the headers for the packages "purple" or "telepathy-glib" installed.
430         [])
432 dnl enable voice & video support if any backend supports it
433 AS_IF([test "x$with_purple_vv" != xno],
434         [AC_DEFINE(HAVE_VV, 1, [Define if voice & video is enabled.])])
435 AM_CONDITIONAL(SIPE_WITH_VV, [test "x$with_purple_vv" != xno])
437 dnl these code parts rely on interfaces that require GValueArray. This
438 dnl type has been declared "deprectated" in glib-2.0 >= 2.32.0, but there
439 dnl is no backward compatible replacement implementation possible
440 AS_IF([test "x$with_purple_vv" != xno -o "x$enable_telepathy" != xno],
441         [AC_DEFINE(GLIB_VERSION_MIN_REQUIRED, GLIB_VERSION_2_28,
442                    [We need GValueArray for which no replacement is available])])
444 dnl i18n
445 AC_MSG_CHECKING([locale_CPPFLAGS])
446 LOCALE_CPPFLAGS='-DLOCALEDIR=\"$(datadir)/locale\"'
447 AC_SUBST([LOCALE_CPPFLAGS])
448 AC_MSG_RESULT([$LOCALE_CPPFLAGS])
449 AM_GLIB_GNU_GETTEXT
450 AC_SUBST(GETTEXT_PACKAGE, "${PACKAGE_NAME}")
452 dnl codeset
453 AM_LANGINFO_CODESET
455 dnl substitutions and generated files
456 AC_CONFIG_HEADERS([config.h])
457 AC_CONFIG_FILES([
458         Makefile
459         pixmaps/Makefile
460         m4macros/Makefile
461         po/Makefile.in
462         pixmaps/16/Makefile
463         pixmaps/22/Makefile
464         pixmaps/24/Makefile
465         pixmaps/32/Makefile
466         pixmaps/48/Makefile
467         pixmaps/scalable/Makefile
468         src/Makefile
469         src/core/Makefile
470         src/api/Makefile
471         src/purple/Makefile
472         src/telepathy/Makefile
473         src/telepathy/data/Makefile
474         ])
476 dnl generate files
477 AC_OUTPUT()
479 dnl additional info for the user
480 AS_ECHO()
481 AS_IF([test "x$enable_purple" = xno],
482         [AS_ECHO("Not building purple plugin")],
483         [AS_ECHO("Build purple plugin")
484          AS_ECHO("PURPLE_CFLAGS  : $PURPLE_CFLAGS")
485          AS_ECHO("PURPLE_LIBS    : $PURPLE_LIBS")
486          AS_ECHO_N("Voice and video: ")
487          AS_IF([test "x$with_purple_vv" = xno],
488           [AS_ECHO("disabled")],
489           [
490            AS_ECHO_N("enabled")
491            AS_IF([test "x$with_purple_tcp" = xyes], [AS_ECHO_N(" with TCP transport")])
492            AS_ECHO()
493           ])
494         ])
495 AS_ECHO()
496 AS_IF([test "x$enable_telepathy" = xno],
497         [AS_ECHO("Not building telepathy plugin")],
498         [AS_ECHO("Build telepathy plugin")
499          AS_ECHO("TELEPATHY_GLIB_CFLAGS: $TELEPATHY_GLIB_CFLAGS")
500          AS_ECHO("TELEPATHY_GLIB_LIBS  : $TELEPATHY_GLIB_LIBS")])
501 AS_ECHO()
502 AS_IF([test "x$with_krb5" = xno],
503         [AS_ECHO("Not building with Kerberos 5 support")],
504         [AS_ECHO("Build with Kerberos 5 support")
505          AS_ECHO("KRB5_CFLAGS    : $KRB5_CFLAGS")
506          AS_ECHO("KRB5_LDFLAGS   : $KRB5_LDFLAGS")])
507 AS_ECHO()
508 AS_IF([test "x$enable_debug" = xno],
509         [AS_ECHO("Debugging not enabled")],
510         [AS_ECHO("Build with debugging enabled")
511          AS_ECHO("DEBUG_CFLAGS   : $DEBUG_CFLAGS")])
512 AS_ECHO()
513 AS_IF([test "x$QUALITY_CFLAGS" = x],
514         [AS_ECHO("Compiler checks disabled")],
515         [AS_ECHO("Build with compiler checks enabled")
516          AS_ECHO("QUALITY_CFLAGS : $QUALITY_CFLAGS")])
517 AS_ECHO()
518 AS_ECHO("configure complete. Now run 'make'")
519 AS_ECHO()
521 dnl The End.