Imported Upstream version 0.1.17
[platform/upstream/libnice.git] / configure.ac
1
2 AC_PREREQ(2.62)
3
4 dnl Always compile with -Wall; if --enable-compile-warnings=error is passed,
5 dnl also use -Werror. git and pre-releases default to -Werror
6
7 dnl use a three digit version number for releases, and four for cvs/prerelease
8 AC_INIT([libnice],[0.1.17])
9 LIBNICE_RELEASE="yes"
10
11 AC_CANONICAL_TARGET
12
13 AC_CONFIG_SRCDIR([agent/agent.c])
14 AC_CONFIG_HEADERS([config.h])
15 AM_INIT_AUTOMAKE([1.12 -Wall -Wno-portability subdir-objects])
16
17 AC_CONFIG_FILES([
18         Makefile
19         agent/Makefile
20         stun/Makefile
21         stun/tests/Makefile
22         stun/tools/Makefile
23         socket/Makefile
24         nice/Makefile
25         nice/nice.pc
26         random/Makefile
27         gst/Makefile
28         docs/Makefile
29         docs/reference/Makefile
30         docs/reference/libnice/Makefile
31         tests/Makefile
32         examples/Makefile
33         ])
34
35 # Set the libtool C/A/R version info
36 #    If the source code was changed, but there were no interface changes:
37 #      Increment REVISION.
38 #    If there was a compatible interface change:
39 #      Increment CURRENT and AGE. Set REVISION to 0
40 #    If there was an incompatible interface change:
41 #      Increment CURRENT. Set AGE and REVISION to 0
42 LIBNICE_CURRENT=20
43 LIBNICE_REVISION=0
44 LIBNICE_AGE=10
45 LIBNICE_LIBVERSION=${LIBNICE_CURRENT}:${LIBNICE_REVISION}:${LIBNICE_AGE}
46 LIBNICE_LT_LDFLAGS="-version-info ${LIBNICE_LIBVERSION} -no-undefined"
47 AC_SUBST(LIBNICE_LT_LDFLAGS)
48
49 dnl use pretty build output
50 AM_SILENT_RULES([yes])
51
52
53 # Checks for programs.
54
55 AC_USE_SYSTEM_EXTENSIONS
56 AC_PROG_CC
57 AM_PROG_AR
58 LT_PREREQ([2.2.6])
59 LT_INIT([dlopen win32-dll disable-static])
60 AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums])
61
62 # Check Operating System
63 AC_MSG_CHECKING([operating system])
64 case "$host" in
65         *-*-*mingw*|*-*-*cygwin*)
66                 platform=win32
67                 AC_MSG_RESULT($platform)
68                 ;;
69         *)
70                 platform=linux/other
71                 AC_MSG_RESULT($platform)
72                 ;;
73 esac
74
75 AM_CONDITIONAL([WINDOWS], [test "$platform" = "win32"])
76
77 # Checks for compiler features
78
79 AC_C_RESTRICT
80 AC_C_VARARRAYS
81 AC_HEADER_ASSERT
82 AC_HEADER_STDBOOL
83 AH_VERBATIM([_FORTIFY_SOURCE], 
84 [/* Define to `2' to get GNU/libc warnings. */
85 /* Only define if -O1 or more is enabled */
86 #if defined __OPTIMIZE__ && __OPTIMIZE__ > 0
87 # define _FORTIFY_SOURCE 2
88 #endif])
89 AC_DEFINE([NICEAPI_EXPORT], [ ], [Public library function implementation])
90 AC_CHECK_HEADERS([arpa/inet.h net/in.h netdb.h])
91 AC_CHECK_HEADERS([ifaddrs.h],
92                 [AC_CHECK_FUNCS([getifaddrs],
93                         [AC_DEFINE(HAVE_GETIFADDRS, [1],
94                                 [Whether getifaddrs() is available on the system])])])
95 AC_CHECK_TYPES([size_t, ssize_t])
96
97 # Also put matching version in LIBNICE_CFLAGS
98 GLIB_REQ=2.54
99
100 LIBNICE_CFLAGS="-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_54 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_54"
101
102 dnl Support different levels of compiler error reporting.
103 dnl This configure flag is designed to mimic one from gnome-common,
104 dnl Defaults to "error" except for releases where it defaults to "yes"
105 AC_ARG_ENABLE(compile-warnings,
106               AS_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@],
107                              [Enable different levels of compiler warnings]),,
108               [AS_IF([test "$LIBNICE_RELEASE" = "yes"],
109                   [enable_compile_warnings="yes"],
110                   [enable_compile_warnings="error"])])
111
112 AC_DEFUN([NICE_ADD_FLAG],
113   AS_COMPILER_FLAG([-Werror $1], LIBNICE_CFLAGS="$LIBNICE_CFLAGS $1", [])
114 )
115
116 NICE_ADD_FLAG([-fno-strict-aliasing])
117
118 AS_IF([test "$enable_compile_warnings" != "no"],[
119     NICE_ADD_FLAG([-Wall])
120 ])
121 AS_IF([test "x$enable_compile_warnings" != "xno" -a \
122             "x$enable_compile_warnings" != "xminimum"],[
123     NICE_ADD_FLAG([-Wextra])
124     NICE_ADD_FLAG([-Wundef])
125     NICE_ADD_FLAG([-Wnested-externs])
126     NICE_ADD_FLAG([-Wwrite-strings])
127     NICE_ADD_FLAG([-Wpointer-arith])
128     NICE_ADD_FLAG([-Wmissing-declarations])
129     NICE_ADD_FLAG([-Wmissing-prototypes])
130     NICE_ADD_FLAG([-Wstrict-prototypes])
131     NICE_ADD_FLAG([-Wredundant-decls])
132     NICE_ADD_FLAG([-Wno-unused-parameter])
133     NICE_ADD_FLAG([-Wno-missing-field-initializers])
134     NICE_ADD_FLAG([-Wdeclaration-after-statement])
135     NICE_ADD_FLAG([-Wformat=2])
136     NICE_ADD_FLAG([-Wold-style-definition])
137     NICE_ADD_FLAG([-Wcast-align])
138     NICE_ADD_FLAG([-Wformat-nonliteral])
139     NICE_ADD_FLAG([-Wformat-security])
140     NICE_ADD_FLAG([-Wno-cast-function-type])
141 ])
142 AS_IF([test "$enable_compile_warnings" = "yes" -o \
143             "$enable_compile_warnings" = "maximum" -o \
144             "$enable_compile_warnings" = "error"],[
145     NICE_ADD_FLAG([-Wsign-compare])
146     NICE_ADD_FLAG([-Wstrict-aliasing])
147     NICE_ADD_FLAG([-Wshadow])
148     NICE_ADD_FLAG([-Winline])
149     NICE_ADD_FLAG([-Wpacked])
150     NICE_ADD_FLAG([-Wmissing-format-attribute])
151     NICE_ADD_FLAG([-Winit-self])
152     NICE_ADD_FLAG([-Wredundant-decls])
153     NICE_ADD_FLAG([-Wmissing-include-dirs])
154     NICE_ADD_FLAG([-Wunused-but-set-variable])
155     NICE_ADD_FLAG([-Warray-bounds])
156 ])
157 AS_IF([test "$enable_compile_warnings" = "maximum" -o \
158             "$enable_compile_warnings" = "error"],[
159     NICE_ADD_FLAG([-Wswitch-default])
160     NICE_ADD_FLAG([-Waggregate-return])
161 ])
162 AS_IF([test "x$enable_compile_warnings" = "xerror"],[
163     NICE_ADD_FLAG([-Werror])
164     NICE_ADD_FLAG([-Wno-suggest-attribute=format])
165 ])
166
167 #
168 # Fixes for Solaris
169 #
170 AC_SEARCH_LIBS([inet_pton],[nsl])
171 AC_SEARCH_LIBS([socket],[socket inet])
172 case $host in
173         *-*-solaris* )
174         AC_DEFINE(_XOPEN_SOURCE,          600, Needed to get declarations for msg_control and msg_controllen on Solaris)
175         AC_DEFINE(__EXTENSIONS__,         1, Needed to get declarations for msg_control and msg_controllen on Solaris)
176      ;;
177 esac
178
179 AC_SUBST(LIBNICE_CFLAGS)
180 AC_MSG_NOTICE([set LIBNICE_CFLAGS to $LIBNICE_CFLAGS])
181
182 # Checks for libraries.
183 AC_CHECK_LIB(rt, clock_gettime, [LIBRT="-lrt"], [LIBRT=""])
184 AC_CHECK_FUNCS([poll])
185 AC_SUBST(LIBRT)
186
187 # Dependencies
188
189 NICE_PACKAGES_PUBLIC="glib-2.0 >= $GLIB_REQ gio-2.0 >= $GLIB_REQ gobject-2.0 >= $GLIB_REQ"
190 NICE_PACKAGES_PRIVATE="gthread-2.0"
191
192 PKG_CHECK_MODULES(GLIB, [$NICE_PACKAGES_PUBLIC $NICE_PACKAGES_PRIVATE])
193
194 AC_ARG_WITH(crypto-library,
195         AS_HELP_STRING([--with-crypto-library=\{gnutls,openssl,auto\}],[select Crypto library (gnutls or openssl)]),
196         [with_crypto_library=${withval}],
197         [with_crypto_library=auto])
198
199
200 AS_IF([test "$with_crypto_library" != "openssl"],
201         [
202         GNUTLS_PACKAGES_PRIVATE="gnutls >= 2.12.0"
203         PKG_CHECK_MODULES(GNUTLS, [$GNUTLS_PACKAGES_PRIVATE],
204                 [
205                 AC_DEFINE([HAVE_GNUTLS], [1], [Use GnuTLS])
206                 GNUTLS_FOUND=yes
207                 NICE_PACKAGES_PRIVATE="$NICE_PACKAGES_PRIVATE $GNUTLS_PACKAGES_PRIVATE"
208                 ],
209                 [
210                 AS_IF([test "$with_crypto_library" == "gnutls"],
211                         [
212                         AC_MSG_ERROR([Neither GnuTLS is not available])
213                         ]
214                 )
215                 ]
216         )
217         ]
218 )
219
220 AS_IF([test "x${GNUTLS_FOUND}" != "xyes"],
221         [
222         AX_CHECK_OPENSSL(
223                 [
224                 AC_DEFINE([HAVE_OPENSSL], [1], [Use OpenSSL])
225                 NICE_PACKAGES_PRIVATE="$NICE_PACKAGES_PRIVATE libcrypto"
226                 AC_MSG_NOTICE([OpenSSL selected])
227                 ],
228                 [
229                 AC_MSG_ERROR([Neither GnuTLS or OpenSSL is available])
230                 ]
231         )
232         ],
233         [
234                 AC_MSG_NOTICE([GnuTLS selected])
235         ]
236 )
237
238 AC_SUBST([NICE_PACKAGES_PUBLIC])
239 AC_SUBST([NICE_PACKAGES_PRIVATE])
240
241
242 AC_ARG_WITH(gstreamer, 
243         AS_HELP_STRING([--with-gstreamer],[build GStreamer plugin]),
244         [with_gstreamer=${withval}],
245         [with_gstreamer=auto])
246
247 AC_ARG_WITH(gstreamer-0.10, 
248         AS_HELP_STRING([--with-gstreamer-0.10],[build GStreamer 0.10 plugin]),
249         [with_gstreamer010=${withval}],
250         [with_gstreamer010=auto])
251
252 AS_IF([test "$with_gstreamer" != no], [
253
254         PKG_CHECK_MODULES(GST, [
255                 gstreamer-1.0 >= 0.11.91
256                 gstreamer-base-1.0 >= 0.11.91
257                 ],
258                 [
259                 with_gstreamer=yes
260                 GST_MAJORMINOR=1.0
261                 gstplugindir="\$(libdir)/gstreamer-$GST_MAJORMINOR"
262                 ],
263                 [
264                 AS_IF([test "$with_gstreamer" = yes], [
265                         AC_MSG_ERROR([GStreamer 1.0 support was requested but GStreamer 1.0 libraries are not available])
266                 ])
267
268                 with_gstreamer=no
269                 ])
270
271         PKG_CHECK_MODULES(GST_CHECK, [
272                 gstreamer-check-1.0 >= 0.11.91
273                 ],
274                 [
275                 have_gst_check=yes
276                 ],
277                 [
278                 have_gst_check=no
279                 ])
280 ])
281
282 AS_IF([test "$with_gstreamer010" != no], [
283   
284         PKG_CHECK_MODULES(GST010, [
285                 gstreamer-0.10 >= 0.10.10
286                 gstreamer-base-0.10 >= 0.10.10
287                 ],
288                 [
289                 with_gstreamer010=yes
290                 GST_MAJORMINOR=0.10
291                 gstplugin010dir="\$(libdir)/gstreamer-$GST_MAJORMINOR"
292                 ],
293                 [
294                 AS_IF([test "$with_gstreamer010" = yes], [
295                         AC_MSG_ERROR([GStreamer 0.10 support was requested but GStreamer 0.10 libraries are not available])
296                 ])
297
298                 with_gstreamer010=no
299                 ])
300 ])
301
302 AC_SUBST(gstplugindir)
303 AC_SUBST(gstplugin010dir)
304
305 AM_CONDITIONAL(WITH_GSTREAMER, test "$with_gstreamer" = yes)
306 AM_CONDITIONAL(HAVE_GST_CHECK, test "$have_gst_check" = yes)
307 AM_CONDITIONAL(WITH_GSTREAMER010, test "$with_gstreamer010" = yes)
308
309 GUPNP_IGD_REQUIRED=0.2.4
310
311 AC_ARG_ENABLE([gupnp],
312         AS_HELP_STRING([--disable-gupnp],[Disable GUPnP IGD support]),
313         [case "${enableval}" in
314             yes) WANT_GUPNP=yes ;;
315             no)  WANT_GUPNP=no ;;
316             *) AC_MSG_ERROR(bad value ${enableval} for --enable-gupnp) ;;
317         esac],
318         WANT_GUPNP=test)
319
320 GUPNP_PACKAGES_PUBLIC=""
321 GUPNP_PACKAGES_PRIVATE="gupnp-igd-1.0 >= $GUPNP_IGD_REQUIRED"
322 GUPNP_PACKAGES="$GUPNP_PACKAGES_PUBLIC $GUPNP_PACKAGES_PRIVATE"
323
324 HAVE_GUPNP=no
325 if test "x$WANT_GUPNP" != "xno"; then
326    PKG_CHECK_MODULES(GUPNP, [$GUPNP_PACKAGES],
327     [ HAVE_GUPNP=yes ],
328     [ HAVE_GUPNP=no ])
329 fi
330 if test "x$WANT_GUPNP" = "xyes" && test "x$HAVE_GUPNP" = "xno"; then
331    AC_MSG_ERROR([Requested GUPnP IGD, but it is not available])
332 fi
333
334 if test "x$HAVE_GUPNP" = "xyes"; then
335    AC_DEFINE(HAVE_GUPNP,,[Have the GUPnP IGD library])
336   UPNP_ENABLED="true"
337 else
338   GUPNP_PACKAGES_PUBLIC=""
339   GUPNP_PACKAGES_PRIVATE=""
340   GUPNP_PACKAGES=""
341 fi
342
343 AC_SUBST([GUPNP_PACKAGES_PUBLIC])
344 AC_SUBST([GUPNP_PACKAGES_PRIVATE])
345 AC_SUBST([GUPNP_PACKAGES])
346
347 AC_SUBST(HAVE_GUPNP)
348 AC_SUBST([UPNP_ENABLED])
349
350 dnl Test coverage
351 AC_ARG_ENABLE([coverage],
352         [AS_HELP_STRING([--enable-coverage],
353                 [build for test coverage (default disabled)])],,
354         [enable_coverage="no"])
355 AS_IF([test "${enable_coverage}" != "no"], [
356         CFLAGS="${CFLAGS} -g -O0 -fprofile-arcs -ftest-coverage"
357         LDFLAGS="-lgcov"
358         CCACHE_DISABLE=1
359 ])
360 AC_SUBST(CCACHE_DISABLE)
361
362 dnl build static plugins or not
363 AC_MSG_CHECKING([whether to build static plugins or not])
364 AC_ARG_ENABLE(
365   static-plugins,
366   AC_HELP_STRING(
367     [--enable-static-plugins],
368     [build static plugins @<:@default=no@:>@]),
369   [AS_CASE(
370     [$enableval], [no], [], [yes], [],
371     [AC_MSG_ERROR([bad value "$enableval" for --enable-static-plugins])])],
372   [enable_static_plugins=no])
373 AC_MSG_RESULT([$enable_static_plugins])
374 if test "x$enable_static_plugins" = xyes; then
375   AC_DEFINE(GST_PLUGIN_BUILD_STATIC, 1,
376     [Define if static plugins should be built])
377 fi
378 AM_CONDITIONAL(GST_PLUGIN_BUILD_STATIC, test "x$enable_static_plugins" = "xyes")
379
380 case $host_os in
381   solaris*)
382     LDFLAGS="$LDFLAGS -lsocket -lnsl"
383     ;;
384   *)
385     ;;
386 esac
387
388 # check for gtk-doc
389 m4_ifdef([GTK_DOC_CHECK], [
390 GTK_DOC_CHECK([1.10],[--flavour no-tmpl])
391 ],[
392 AM_CONDITIONAL([ENABLE_GTK_DOC], false)
393 ])
394
395 # GObject introspection
396 GOBJECT_INTROSPECTION_CHECK([1.30.0])
397
398 dnl Ignore specific network interface name prefixes from the connection check
399 AC_MSG_CHECKING([whether to ignore specific network interface name prefixes])
400 AC_ARG_WITH([ignored-network-interface-prefix],
401   [AS_HELP_STRING([--with-ignored-network-interface-prefix=string@<:@,string...@:>@],
402     [Ignore network interfaces whose name starts with a string from this list in the ICE connection
403      check algorithm. For example, interfaces "virbr" in the case of the virtual bridge
404      handled by libvirtd, do not help in finding connectivity.])],
405     [interface_prefix="$withval"],
406     [interface_prefix="docker,veth,virbr,vnet"])
407 AS_IF([test -n "$interface_prefix" && test "x$interface_prefix" != "xno"],
408   [[interface_prefix_list=`echo $interface_prefix | sed 's/,/","/g'`]
409    AC_DEFINE_UNQUOTED([IGNORED_IFACE_PREFIX],["$interface_prefix_list"],
410     [Ignore this network interface prefix from the connection check])
411    AC_MSG_RESULT([yes, $interface_prefix])],
412   [AC_MSG_RESULT([no])])
413
414 AC_CONFIG_MACRO_DIR(m4)
415
416 AC_OUTPUT
417