summaryrefslogtreecommitdiff
path: root/configure.ac
blob: ef3fd7c608a86b5052da495daaaf04fe6899cb9d (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
AC_PREREQ([2.59])

# Making releases:
#   set the new version number:
#     odd minor -> development series
#     even minor -> stable series
#     increment micro for each release within a series
#   set wockynano_version to 0.

m4_define([wocky_major_version], [0])
m4_define([wocky_minor_version], [0])
m4_define([wocky_micro_version], [0])
m4_define([wocky_nano_version], [1])

# Some magic
m4_define([wocky_base_version],
          [wocky_major_version.wocky_minor_version.wocky_micro_version])
m4_define([wocky_version],
          [m4_if(wocky_nano_version, 0, [wocky_base_version], [wocky_base_version].[wocky_nano_version])])dnl

AC_INIT([Wocky], [wocky_version])
AC_CONFIG_MACRO_DIR([m4])

AM_INIT_AUTOMAKE([1.9 -Wno-portability tar-ustar])
AM_PROG_LIBTOOL
AM_CONFIG_HEADER(config.h)

m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])

dnl check for tools
AC_PROG_CC
AC_PROG_CC_STDC
AM_PROG_AS
AM_PROG_MKDIR_P

dnl decide error flags
dnl ifelse(wocky_nano_version, 0,
dnl     [ official_release=yes ],
dnl     [ official_release=no ])
official_release=no

TP_COMPILER_WARNINGS([ERROR_CFLAGS], [test "x$official_release" = xno],
  [all \
   extra \
   declaration-after-statement \
   shadow \
   strict-prototypes \
   missing-prototypes \
   sign-compare \
   nested-externs \
   pointer-arith \
   format-security \
   init-self],
  [missing-field-initializers \
   unused-parameter])
AC_SUBST([ERROR_CFLAGS])

ifelse(wocky_nano_version, 0,
    [ # Wocky is version x.y.z - disable coding style checks by default
AC_ARG_ENABLE(coding-style-checks,
  AC_HELP_STRING([--enable-coding-style-checks],
                 [check coding style using grep]),
    [ENABLE_CODING_STYLE_CHECKS=$enableval], [ENABLE_CODING_STYLE_CHECKS=no] )
    ],
    [ # Wocky is version x.y.z.1 - enable coding style checks by default
AC_ARG_ENABLE(coding-style-checks,
  AC_HELP_STRING([--disable-coding-style-checks],
                 [do not check coding style using grep]),
    [ENABLE_CODING_STYLE_CHECKS=$enableval], [ENABLE_CODING_STYLE_CHECKS=yes])
    ])

AC_SUBST([ENABLE_CODING_STYLE_CHECKS])

dnl debugging stuff
AC_ARG_ENABLE(debug,
  AC_HELP_STRING([--disable-debug],[compile without debug code]),
  [
    case "${enableval}" in
      yes|no) enable_debug="${enableval}" ;;
      *)   AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
    esac
  ],
  [enable_debug=yes])

if test "$enable_debug" = yes; then
  AC_DEFINE(ENABLE_DEBUG, [], [Enable debug code])
else
  enable_debug=no
fi

AC_ARG_WITH(installed-headers,
  AC_HELP_STRING([--with-installed-headers=DIR],
                 [install development headers to DIR @<:@default=nowhere@:>@]),
  [],
  [with_installed_headers=])

AM_CONDITIONAL(INSTALL_HEADERS, test x$with_installed_headers != x)

HEADER_DIR=$with_installed_headers
AC_SUBST(HEADER_DIR)

dnl Build a shared library even though Wocky isn't stable yet?
AC_ARG_ENABLE([shared-suffix],
  AC_HELP_STRING([--enable-shared-suffix=],
    [install a shared library with a version-specific suffix]),
  [],
  [enable_shared_suffix=])
AM_CONDITIONAL([ENABLE_SHARED_SUFFIX], [test x$enable_shared_suffix != x])
SHARED_SUFFIX="$enable_shared_suffix"
AC_SUBST([SHARED_SUFFIX])

dnl Check for code generation tools
AC_HEADER_STDC([])
AC_CHECK_HEADERS_ONCE([unistd.h])
AC_C_INLINE

dnl Check endianness (Needed for the sha1 implementation)
AC_C_BIGENDIAN

dnl Check for Glib
PKG_CHECK_MODULES(GLIB,
  [glib-2.0 >= 2.32, gobject-2.0 >= 2.32, gthread-2.0 >= 2.32, gio-2.0 >= 2.32])

AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_32], [Ignore post 2.32 deprecations])
AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_32], [Prevent post 2.32 APIs])

AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)

dnl Check GIO proxy support
PKG_CHECK_EXISTS([gio-2.0 >= 2.25.15],
  [HAVE_GIO_PROXY=yes
   AC_DEFINE(HAVE_GIO_PROXY, [1], [Defined if GIO supports proxy])],
  [HAVE_GIO_PROXY=no])
AM_CONDITIONAL(HAVE_GIO_PROXY, [test "x${HAVE_GIO_PROXY}" = "xyes"])


dnl Choose an SSL/TLS backend (default gnutls)
AC_ARG_WITH([tls],
  AC_HELP_STRING([--with-tls=BACKEND],
      [which TLS backend to use (gnutls, openssl, or auto) @<:@default=auto@:>@]),
  [],
  [with_tls=auto])


AS_CASE([$with_tls],
    [gnutls],  [PKG_CHECK_MODULES(TLS, [gnutls  >= 2.8.2 ])],
    [openssl], [USING_OPENSSL=yes
                AC_DEFINE(USING_OPENSSL, 1, [Define if using openssl])
                PKG_CHECK_MODULES(TLS, [openssl >= 0.9.8g])],
    [auto],    [PKG_CHECK_MODULES(TLS, [gnutls  >= 2.8.2 ],
                    [with_tls=gnutls],
                    [USING_OPENSSL=yes
                     AC_DEFINE(USING_OPENSSL, 1, [Define if using openssl])
                     PKG_CHECK_MODULES(TLS, [openssl >= 0.9.8g],[with_tls=openssl],
                         AC_MSG_ERROR([Neither gnutls nor openssl found]))])],
    [*],       AC_MSG_ERROR([Must have a TLS backend (gnutls or openssl)]))

AC_SUBST(TLS_CFLAGS)
AC_SUBST(TLS_LIBS)
AM_CONDITIONAL(USING_OPENSSL, test x$USING_OPENSSL = xyes)

AC_ARG_ENABLE([prefer-stream-ciphers],
  AC_HELP_STRING([--enable-prefer-stream-ciphers],
    [prefer stream ciphers over block ciphers to save bandwidth (at the possible expense of security)]),
    [prefer_stream_ciphers=$enableval], [prefer_stream_ciphers=no])

if test x$prefer_stream_ciphers = xyes; then
  AC_DEFINE(ENABLE_PREFER_STREAM_CIPHERS, [],
      [Prefer stream ciphers over block ones to save bandwidth])
  if test $with_tls = gnutls; then
    # The *-ALL priority strings require gnutls 2.12.0.
    # We do this check here and not earlier to avoid accidentally falling
    # back to openssl because of the use of --enable-prefer-stream-ciphers.
    PKG_CHECK_MODULES(GNUTLS_FOR_STREAM_CIPHERS, [gnutls >= 2.12.0],[],
      AC_MSG_ERROR([gnutls 2.12.0 is needed to use --enable-prefer-stream-ciphers]))
  fi
fi


# -----------------------------------------------------------
# Make CA certificates path configurable
# Stolen from GIO's TLS
# -----------------------------------------------------------
AC_MSG_CHECKING([location of system Certificate Authority list])
AC_ARG_WITH(ca-certificates,
            [AC_HELP_STRING([--with-ca-certificates=@<:@path@:>@],
                            [path to system Certificate Authority list])])
if test "$with_ca_certificates" = "no"; then
    AC_MSG_RESULT([disabled])
else
    if test -z "$with_ca_certificates"; then
        for f in /etc/pki/tls/certs/ca-bundle.crt \
                 /etc/ssl/certs/ca-certificates.crt; do
            if test -f "$f"; then
                with_ca_certificates="$f"
            fi
        done
        if test -z "$with_ca_certificates"; then
            AC_MSG_ERROR([could not find. Use --with-ca-certificates=path to set, or --without-ca-certificates to disable])
        fi
    fi

    AC_MSG_RESULT($with_ca_certificates)
    AC_DEFINE_UNQUOTED([GTLS_SYSTEM_CA_CERTIFICATES], ["$with_ca_certificates"], [path to system Certificate Authority list])
fi

if test -n "$with_ca_certificates"; then
    if ! test -f "$with_ca_certificates"; then
        AC_MSG_WARN([Specified certificate authority file '$with_ca_certificates' does not exist])
    fi
fi


GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
AC_SUBST(GLIB_GENMARSHAL)

dnl Check for libxml2
PKG_CHECK_MODULES(LIBXML2, [libxml-2.0])
AC_SUBST(LIBXML2_CFLAGS)
AC_SUBST(LIBXML2_LIBS)

dnl Check for sqlite
PKG_CHECK_MODULES(SQLITE, [sqlite3])
AC_SUBST(SQLITE_CFLAGS)
AC_SUBST(SQLITE_LIBS)

dnl check for libsasl2 (for sasl test)
dnl must check for headers as well as library (no .pc so can't use pkg-config)
AC_CHECK_LIB(sasl2, sasl_server_new,
    [ AC_CHECK_HEADER(sasl/sasl.h,
        [ LIBSASL2_LIBS="-lsasl2"
          LIBSASL2_CFLAGS=""
          HAVE_LIBSASL2=yes
          AC_DEFINE(HAVE_LIBSASL2, 1, [Define if libsasl2 is available]) ],
        [ AC_MSG_WARN(libsasl2 headers missing: skipping sasl tests)]) ],
    [ AC_MSG_WARN(libsasl2 not found: skipping sasl tests)
      HAVE_LIBSASL2=no
    ])

AC_SUBST(LIBSASL2_LIBS)
AC_SUBST(LIBSASL2_CFLAGS)
AM_CONDITIONAL(HAVE_LIBSASL2, test "x$HAVE_LIBSASL2" = "xyes")

PKG_CHECK_MODULES(LIBIPHB, [libiphb >= 0.61.31],
    [AC_DEFINE(HAVE_IPHB, 1, [libiphb is available])
     have_iphb=yes
    ],
    [have_iphb=no])
AC_SUBST(LIBIPHB_CFLAGS)
AC_SUBST(LIBIPHB_LIBS)

AC_ARG_ENABLE(google-relay,
  AC_HELP_STRING([--disable-google-relay],
                 [disable Google Jingle relay support]),
    [enable_google_relay=$enableval], [enable_google_relay=yes])

if test x$enable_google_relay = xyes; then
  AC_DEFINE(ENABLE_GOOGLE_RELAY, [], [Enable Google Jingle relay support])

  dnl Check for libsoup
  PKG_CHECK_MODULES(SOUP, libsoup-2.4)
fi
AM_CONDITIONAL([ENABLE_GOOGLE_RELAY], [test "x$enable_google_relay" = xyes])

AC_ARG_ENABLE(coverage, AC_HELP_STRING([--enable-coverage],
      [compile with coverage profiling instrumentation (gcc only)]),
    [
      case "${enableval}" in
        "yes"|"no") enable_coverage="${enableval}" ;;
        *)   AC_MSG_ERROR(bad value ${enableval} for --enable-coverage) ;;
      esac
    ]
)

WOCKY_GCOV(${enable_coverage})
WOCKY_LCOV(${enable_coverage})

if test "x$enable_coverage" = "x"; then
  enable_coverage=no
fi

AC_SUBST(PACKAGE_STRING)

dnl To be used by tests and examples
WOCKY_CFLAGS='-I${top_builddir} -I${top_srcdir}'
AC_SUBST(WOCKY_CFLAGS)

GTK_DOC_CHECK([1.17],[--flavour no-tmpl])

AC_OUTPUT( Makefile            \
           wocky/Makefile      \
           wocky/wocky-uninstalled.pc \
           wocky/wocky.pc \
           m4/Makefile         \
           tools/Makefile      \
           examples/Makefile   \
           tests/Makefile      \
           docs/Makefile      \
           docs/reference/Makefile
)

echo "
Configure summary:

        Compiler Flags.......: ${CFLAGS}
        Prefix...............: ${prefix}
        Coverage profiling...: ${enable_coverage}
        Coding style checks..: ${ENABLE_CODING_STYLE_CHECKS}
        Debug................: ${enable_debug}

    Features:
        TLS Backend..........: ${with_tls}
        Prefer stream ciphers: ${prefer_stream_ciphers}
        System CA certs......: ${with_ca_certificates}
        SASL2 Tests..........: ${HAVE_LIBSASL2}
        gtk-doc documentation: ${enable_gtk_doc}
        libiphb integration..: ${have_iphb}
        Google relay support.: ${enable_google_relay}
"