configure.ac 11.4 KB
Newer Older
dafydd.harries's avatar
dafydd.harries committed
1

2
AC_PREREQ(2.62)
3

4 5 6
dnl Always compile with -Wall; if --enable-compile-warnings=error is passed,
dnl also use -Werror. git and pre-releases default to -Werror

7
dnl use a three digit version number for releases, and four for cvs/prerelease
Olivier Crête's avatar
Olivier Crête committed
8
AC_INIT([libnice],[0.1.15.1])
Olivier Crête's avatar
Olivier Crête committed
9
LIBNICE_RELEASE="no"
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 18
AC_CONFIG_FILES([
	Makefile
19
	agent/Makefile
20
	stun/Makefile
21
	stun/tests/Makefile
22
	stun/tools/Makefile
23
	socket/Makefile
Dafydd Harries's avatar
Dafydd Harries committed
24
	nice/Makefile
25
	nice/nice.pc
26
	random/Makefile
27
	gst/Makefile
Youness Alaoui's avatar
Youness Alaoui committed
28 29 30
	docs/Makefile
	docs/reference/Makefile
	docs/reference/libnice/Makefile
31
	tests/Makefile
32
	examples/Makefile
33
	])
dafydd.harries's avatar
dafydd.harries committed
34

35
# Set the libtool C/A/R version info
Youness Alaoui's avatar
Youness Alaoui committed
36 37 38 39 40 41
#    If the source code was changed, but there were no interface changes:
#      Increment REVISION.
#    If there was a compatible interface change:
#      Increment CURRENT and AGE. Set REVISION to 0
#    If there was an incompatible interface change:
#      Increment CURRENT. Set AGE and REVISION to 0
Olivier Crête's avatar
Olivier Crête committed
42
LIBNICE_CURRENT=18
Olivier Crête's avatar
Olivier Crête committed
43
LIBNICE_REVISION=0
Olivier Crête's avatar
Olivier Crête committed
44
LIBNICE_AGE=8
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

Olivier Crête's avatar
Olivier Crête committed
49 50
dnl use pretty build output
AM_SILENT_RULES([yes])
51 52


dafydd.harries's avatar
dafydd.harries committed
53 54
# Checks for programs.

55
AC_USE_SYSTEM_EXTENSIONS
dafydd.harries's avatar
dafydd.harries committed
56
AC_PROG_CC
57
AM_PROG_AR
58 59
LT_PREREQ([2.2.6])
LT_INIT([dlopen win32-dll disable-static])
60
AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums])
dafydd.harries's avatar
dafydd.harries committed
61

62 63 64 65 66 67 68 69 70 71 72 73 74 75
# Check Operating System
AC_MSG_CHECKING([operating system])
case "$host" in
	*-*-*mingw*|*-*-*cygwin*)
		platform=win32
		AC_MSG_RESULT($platform)
		;;
	*)
		platform=linux/other
		AC_MSG_RESULT($platform)
		;;
esac

AM_CONDITIONAL([WINDOWS], [test "$platform" = "win32"])
76

77 78 79
# Checks for compiler features

AC_C_RESTRICT
80
AC_C_VARARRAYS
81 82
AC_HEADER_ASSERT
AC_HEADER_STDBOOL
83 84 85 86 87 88
AH_VERBATIM([_FORTIFY_SOURCE], 
[/* Define to `2' to get GNU/libc warnings. */
/* Only define if -O1 or more is enabled */
#if defined __OPTIMIZE__ && __OPTIMIZE__ > 0
# define _FORTIFY_SOURCE 2
#endif])
89
AC_DEFINE([NICEAPI_EXPORT], [ ], [Public library function implementation])
90
AC_CHECK_HEADERS([arpa/inet.h net/in.h netdb.h])
91 92 93 94
AC_CHECK_HEADERS([ifaddrs.h],
		[AC_CHECK_FUNCS([getifaddrs],
			[AC_DEFINE(HAVE_GETIFADDRS, [1],
				[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.48
99

100
LIBNICE_CFLAGS="-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_44 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_44"
101 102 103 104 105 106 107 108 109 110

dnl Support different levels of compiler error reporting.
dnl This configure flag is designed to mimic one from gnome-common,
dnl Defaults to "error" except for releases where it defaults to "yes"
AC_ARG_ENABLE(compile-warnings,
              AS_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@],
                             [Enable different levels of compiler warnings]),,
              [AS_IF([test "$LIBNICE_RELEASE" = "yes"],
                  [enable_compile_warnings="yes"],
                  [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 122
AS_IF([test "x$enable_compile_warnings" != "xno" -a \
	    "x$enable_compile_warnings" != "xminimum"],[
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
    NICE_ADD_FLAG([-Wextra])
    NICE_ADD_FLAG([-Wundef])
    NICE_ADD_FLAG([-Wnested-externs])
    NICE_ADD_FLAG([-Wwrite-strings])
    NICE_ADD_FLAG([-Wpointer-arith])
    NICE_ADD_FLAG([-Wmissing-declarations])
    NICE_ADD_FLAG([-Wmissing-prototypes])
    NICE_ADD_FLAG([-Wstrict-prototypes])
    NICE_ADD_FLAG([-Wredundant-decls])
    NICE_ADD_FLAG([-Wno-unused-parameter])
    NICE_ADD_FLAG([-Wno-missing-field-initializers])
    NICE_ADD_FLAG([-Wdeclaration-after-statement])
    NICE_ADD_FLAG([-Wformat=2])
    NICE_ADD_FLAG([-Wold-style-definition])
    NICE_ADD_FLAG([-Wcast-align])
    NICE_ADD_FLAG([-Wformat-nonliteral])
    NICE_ADD_FLAG([-Wformat-security])
140
    NICE_ADD_FLAG([-Wno-cast-function-type])
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
])
AS_IF([test "$enable_compile_warnings" = "yes" -o \
            "$enable_compile_warnings" = "maximum" -o \
            "$enable_compile_warnings" = "error"],[
    NICE_ADD_FLAG([-Wsign-compare])
    NICE_ADD_FLAG([-Wstrict-aliasing])
    NICE_ADD_FLAG([-Wshadow])
    NICE_ADD_FLAG([-Winline])
    NICE_ADD_FLAG([-Wpacked])
    NICE_ADD_FLAG([-Wmissing-format-attribute])
    NICE_ADD_FLAG([-Winit-self])
    NICE_ADD_FLAG([-Wredundant-decls])
    NICE_ADD_FLAG([-Wmissing-include-dirs])
    NICE_ADD_FLAG([-Wunused-but-set-variable])
    NICE_ADD_FLAG([-Warray-bounds])
])
AS_IF([test "$enable_compile_warnings" = "maximum" -o \
            "$enable_compile_warnings" = "error"],[
    NICE_ADD_FLAG([-Wswitch-default])
    NICE_ADD_FLAG([-Waggregate-return])
161 162 163
])
AS_IF([test "x$enable_compile_warnings" = "xerror"],[
    NICE_ADD_FLAG([-Werror])
164
    NICE_ADD_FLAG([-Wno-suggest-attribute=format])
165
])
166

167 168 169 170 171 172 173 174 175 176 177
#
# Fixes for Solaris
#
AC_SEARCH_LIBS([inet_pton],[nsl])
AC_SEARCH_LIBS([socket],[socket inet])
case $host in
	*-*-solaris* )
	AC_DEFINE(_XOPEN_SOURCE,          600, Needed to get declarations for msg_control and msg_controllen on Solaris)
	AC_DEFINE(__EXTENSIONS__,         1, Needed to get declarations for msg_control and msg_controllen on Solaris)
     ;;
esac
178

179 180
AC_SUBST(LIBNICE_CFLAGS)
AC_MSG_NOTICE([set LIBNICE_CFLAGS to $LIBNICE_CFLAGS])
181

dafydd.harries's avatar
dafydd.harries committed
182
# Checks for libraries.
183
AC_CHECK_LIB(rt, clock_gettime, [LIBRT="-lrt"], [LIBRT=""])
184
AC_CHECK_FUNCS([poll])
185 186
AC_SUBST(LIBRT)

187
# Dependencies
188

189 190
NICE_PACKAGES_PUBLIC="glib-2.0 >= $GLIB_REQ gio-2.0 >= $GLIB_REQ gobject-2.0 >= $GLIB_REQ"
NICE_PACKAGES_PRIVATE="gthread-2.0"
191 192 193

PKG_CHECK_MODULES(GLIB, [$NICE_PACKAGES_PUBLIC $NICE_PACKAGES_PRIVATE])

194 195 196 197 198 199 200
AC_ARG_WITH(crypto-library,
	AS_HELP_STRING([--with-crypto-library=\{gnutls,openssl,auto\}],[select Crypto library (gnutls or openssl)]),
	[with_crypto_library=${withval}],
	[with_crypto_library=auto])


AS_IF([test "$with_crypto_library" != "openssl"],
201
	[
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
	GNUTLS_PACKAGES_PRIVATE="gnutls >= 2.12.0"
	PKG_CHECK_MODULES(GNUTLS, [$GNUTLS_PACKAGES_PRIVATE],
		[
		AC_DEFINE([HAVE_GNUTLS], [1], [Use GnuTLS])
		GNUTLS_FOUND=yes
		NICE_PACKAGES_PRIVATE="$NICE_PACKAGES_PRIVATE $GNUTLS_PACKAGES_PRIVATE"
		],
		[
		AS_IF([test "$with_crypto_library" == "gnutls"],
			[
			AC_MSG_ERROR([Neither GnuTLS is not available])
			]
		)
		]
	)
	]
)

AS_IF([test "x${GNUTLS_FOUND}" != "xyes"],
        [
222 223 224 225
	AX_CHECK_OPENSSL(
		[
		AC_DEFINE([HAVE_OPENSSL], [1], [Use OpenSSL])
		NICE_PACKAGES_PRIVATE="$NICE_PACKAGES_PRIVATE libcrypto"
226
		AC_MSG_NOTICE([OpenSSL selected])
227 228 229 230
		],
		[
		AC_MSG_ERROR([Neither GnuTLS or OpenSSL is available])
		]
231 232 233 234 235
	)
	],
	[
		AC_MSG_NOTICE([GnuTLS selected])
	]
236
)
237

238 239 240
AC_SUBST([NICE_PACKAGES_PUBLIC])
AC_SUBST([NICE_PACKAGES_PRIVATE])

dafydd.harries's avatar
dafydd.harries committed
241

242
AC_ARG_WITH(gstreamer, 
243
	AS_HELP_STRING([--with-gstreamer],[build GStreamer plugin]),
244 245 246
	[with_gstreamer=${withval}],
	[with_gstreamer=auto])

247
AC_ARG_WITH(gstreamer-0.10, 
248
	AS_HELP_STRING([--with-gstreamer-0.10],[build GStreamer 0.10 plugin]),
249 250 251
	[with_gstreamer010=${withval}],
	[with_gstreamer010=auto])

252
AS_IF([test "$with_gstreamer" != no], [
253

254
	PKG_CHECK_MODULES(GST, [
255 256
		gstreamer-1.0 >= 0.11.91
		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 269

		with_gstreamer=no
		])
270 271 272 273 274 275 276 277 278 279

	PKG_CHECK_MODULES(GST_CHECK, [
		gstreamer-check-1.0 >= 0.11.91
		],
		[
		have_gst_check=yes
		],
		[
		have_gst_check=no
		])
280
])
281

282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
AS_IF([test "$with_gstreamer010" != no], [
  
	PKG_CHECK_MODULES(GST010, [
		gstreamer-0.10 >= 0.10.10
		gstreamer-base-0.10 >= 0.10.10
		],
		[
		with_gstreamer010=yes
		GST_MAJORMINOR=0.10
		gstplugin010dir="\$(libdir)/gstreamer-$GST_MAJORMINOR"
		],
		[
		AS_IF([test "$with_gstreamer010" = yes], [
			AC_MSG_ERROR([GStreamer 0.10 support was requested but GStreamer 0.10 libraries are not available])
		])

		with_gstreamer010=no
		])
])

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 314 315 316 317 318 319
        [case "${enableval}" in
            yes) WANT_GUPNP=yes ;;
            no)  WANT_GUPNP=no ;;
            *) AC_MSG_ERROR(bad value ${enableval} for --enable-gupnp) ;;
        esac],
        WANT_GUPNP=test)

320 321 322 323
GUPNP_PACKAGES_PUBLIC=""
GUPNP_PACKAGES_PRIVATE="gupnp-igd-1.0 >= $GUPNP_IGD_REQUIRED"
GUPNP_PACKAGES="$GUPNP_PACKAGES_PUBLIC $GUPNP_PACKAGES_PRIVATE"

324 325
HAVE_GUPNP=no
if test "x$WANT_GUPNP" != "xno"; then
326
   PKG_CHECK_MODULES(GUPNP, [$GUPNP_PACKAGES],
327 328 329 330
    [ HAVE_GUPNP=yes ],
    [ HAVE_GUPNP=no ])
fi
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 333 334 335
fi

if test "x$HAVE_GUPNP" = "xyes"; then
   AC_DEFINE(HAVE_GUPNP,,[Have the GUPnP IGD library])
336
  UPNP_ENABLED="true"
337 338 339 340
else
  GUPNP_PACKAGES_PUBLIC=""
  GUPNP_PACKAGES_PRIVATE=""
  GUPNP_PACKAGES=""
341 342
fi

343 344 345 346
AC_SUBST([GUPNP_PACKAGES_PUBLIC])
AC_SUBST([GUPNP_PACKAGES_PRIVATE])
AC_SUBST([GUPNP_PACKAGES])

347
AC_SUBST(HAVE_GUPNP)
348
AC_SUBST([UPNP_ENABLED])
349

350 351 352 353 354 355 356 357 358 359 360 361
dnl Test coverage
AC_ARG_ENABLE([coverage],
	[AS_HELP_STRING([--enable-coverage],
		[build for test coverage (default disabled)])],,
	[enable_coverage="no"])
AS_IF([test "${enable_coverage}" != "no"], [
	CFLAGS="${CFLAGS} -g -O0 -fprofile-arcs -ftest-coverage"
	LDFLAGS="-lgcov"
	CCACHE_DISABLE=1
])
AC_SUBST(CCACHE_DISABLE)

362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
dnl build static plugins or not
AC_MSG_CHECKING([whether to build static plugins or not])
AC_ARG_ENABLE(
  static-plugins,
  AC_HELP_STRING(
    [--enable-static-plugins],
    [build static plugins @<:@default=no@:>@]),
  [AS_CASE(
    [$enableval], [no], [], [yes], [],
    [AC_MSG_ERROR([bad value "$enableval" for --enable-static-plugins])])],
  [enable_static_plugins=no])
AC_MSG_RESULT([$enable_static_plugins])
if test "x$enable_static_plugins" = xyes; then
  AC_DEFINE(GST_PLUGIN_BUILD_STATIC, 1,
    [Define if static plugins should be built])
fi
AM_CONDITIONAL(GST_PLUGIN_BUILD_STATIC, test "x$enable_static_plugins" = "xyes")

380 381
case $host_os in
  solaris*)
382
    LDFLAGS="$LDFLAGS -lsocket -lnsl"
383 384 385 386 387
    ;;
  *)
    ;;
esac

Youness Alaoui's avatar
Youness Alaoui committed
388
# check for gtk-doc
389
m4_ifdef([GTK_DOC_CHECK], [
390
GTK_DOC_CHECK([1.10],[--flavour no-tmpl])
391 392 393
],[
AM_CONDITIONAL([ENABLE_GTK_DOC], false)
])
394 395 396 397

# GObject introspection
GOBJECT_INTROSPECTION_CHECK([1.30.0])

398 399 400 401 402 403 404 405 406 407 408 409 410 411
dnl Ignore a specific network interface name prefix from the connection check
AC_MSG_CHECKING([whether to ignore a specific network interface name prefix])
AC_ARG_WITH([ignored-network-interface-prefix],
  [AS_HELP_STRING([--with-ignored-network-interface-prefix=string],
    [Ignore network interfaces whose name starts with "string" from the ICE connection
     check algorithm. For example, interfaces "virbr" in the case of the virtual bridge
     handled by libvirtd, do not help in finding connectivity.])],
    [interface_prefix="$withval"])
AS_IF([test -n "$interface_prefix"],
  [AC_DEFINE_UNQUOTED([IGNORED_IFACE_PREFIX],["$interface_prefix"],
    [Ignore this network interface prefix from the connection check])
   AC_MSG_RESULT([yes, $interface_prefix])],
  [AC_MSG_RESULT([no])])

Youness Alaoui's avatar
Youness Alaoui committed
412
AC_CONFIG_MACRO_DIR(m4)
413

dafydd.harries's avatar
dafydd.harries committed
414 415
AC_OUTPUT