configure.ac 38.1 KB
Newer Older
aymeric's avatar
aymeric committed
1
dnl Process this file with autoconf to produce a configure script.
François Grisez's avatar
François Grisez committed
2
AC_INIT([mediastreamer],[2.11.2])
aymeric's avatar
aymeric committed
3 4 5 6

AC_MSG_NOTICE([$PACKAGE_NAME-$PACKAGE_VERSION		A mediastreaming library for telephony application.])
AC_MSG_NOTICE([licensed under the terms of the General Public License (GPL)])

7
dnl do not put anything else before AC_PROG_CC unless checking if macro still work for clang
jehan's avatar
jehan committed
8 9 10
AC_PROG_CXX(["xcrun clang++" g++])
AC_PROG_CC(["xcrun clang" gcc])
AC_PROG_OBJC(["xcrun clang" gcc])
aymeric's avatar
aymeric committed
11 12 13 14 15 16 17 18
AC_CANONICAL_SYSTEM

dnl Source packaging numbers
MEDIASTREAMER_MAJOR_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f1)
MEDIASTREAMER_MINOR_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f2)
MEDIASTREAMER_MICRO_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f3)
MEDIASTREAMER_EXTRA_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f4)

19
LIBMEDIASTREAMER_SO_CURRENT=5 dnl increment this number when you add/change/remove an interface
Simon Morlat's avatar
Simon Morlat committed
20
LIBMEDIASTREAMER_SO_REVISION=0 dnl increment this number when you change source code, without changing interfaces; set to 0 when incrementing CURRENT
aymeric's avatar
aymeric committed
21 22 23 24 25 26 27 28 29
LIBMEDIASTREAMER_SO_AGE=0 dnl increment this number when you add an interface, set to 0 if you remove an interface

LIBMEDIASTREAMER_SO_VERSION=$LIBMEDIASTREAMER_SO_CURRENT:$LIBMEDIASTREAMER_SO_REVISION:$LIBMEDIASTREAMER_SO_AGE
MEDIASTREAMER_VERSION=${MEDIASTREAMER_MAJOR_VERSION}.${MEDIASTREAMER_MINOR_VERSION}.${MEDIASTREAMER_MICRO_VERSION}

if test -n "$MEDIASTREAMER_EXTRA_VERSION" ; then
	MEDIASTREAMER_VERSION="${MEDIASTREAMER_VERSION}.${MEDIASTREAMER_EXTRA_VERSION}"
fi

30
AC_SUBST(LIBMEDIASTREAMER_SO_CURRENT, $LIBMEDIASTREAMER_SO_CURRENT)
aymeric's avatar
aymeric committed
31 32 33 34 35 36 37
AC_SUBST(LIBMEDIASTREAMER_SO_VERSION)
AC_SUBST(MEDIASTREAMER_VERSION)

PACKAGE=mediastreamer

OS=`uname|sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
AC_MSG_RESULT([Building Package on ${OS}])
38
AM_INIT_AUTOMAKE([1.9 tar-pax subdir-objects])
39
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],)
Yann Diorcet's avatar
Yann Diorcet committed
40
AC_SUBST([docdir], [${datadir}/doc])
aymeric's avatar
aymeric committed
41 42 43 44 45 46
AC_CONFIG_HEADERS(mediastreamer-config.h)
AC_DEFINE_UNQUOTED(MEDIASTREAMER_MAJOR_VERSION,$MEDIASTREAMER_MAJOR_VERSION, [major version])
AC_DEFINE_UNQUOTED(MEDIASTREAMER_MINOR_VERSION,$MEDIASTREAMER_MINOR_VERSION, [minor version])
AC_DEFINE_UNQUOTED(MEDIASTREAMER_MICRO_VERSION,$MEDIASTREAMER_MICRO_VERSION, [micro version])
AC_DEFINE_UNQUOTED(MEDIASTREAMER_VERSION,"$MEDIASTREAMER_VERSION",[MEDIASTREAMER version number])

47 48
MS_PUBLIC_CFLAGS=

49 50
gl_LD_OUTPUT_DEF

aymeric's avatar
aymeric committed
51
AC_MSG_CHECKING([warning make an error on compilation])
52

aymeric's avatar
aymeric committed
53
AC_ARG_ENABLE(strict,
54 55 56
	AC_HELP_STRING([--enable-strict], [Build with stricter options @<:@yes@:>@]),
	[strictness="${enableval}"],
	[strictness=yes]
aymeric's avatar
aymeric committed
57
)
58

59 60 61
STRICT_OPTIONS="-Wall -Wuninitialized"
STRICT_OPTIONS_CC="-Wdeclaration-after-statement "
STRICT_OPTIONS_CXX=""
62

jehan's avatar
jehan committed
63 64 65
#for clang

case $CC in
66
	*clang*)
67
		STRICT_OPTIONS="$STRICT_OPTIONS -Qunused-arguments -Wno-unused-function "
68 69 70
		#disabled due to wrong optimization false positive with small string
		#(cf. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35903)
		STRICT_OPTIONS="$STRICT_OPTIONS -Wno-array-bounds "
71
	;;
jehan's avatar
jehan committed
72
esac
aymeric's avatar
aymeric committed
73

74 75 76 77 78 79 80 81 82 83
# because Darwin's gcc is actually clang, we need to check it...
case "$target_os" in
	*darwin*)
	STRICT_OPTIONS="$STRICT_OPTIONS -Wno-error=unknown-warning-option -Qunused-arguments -Wno-tautological-compare -Wno-unused-function "
	#disabled due to wrong optimization false positive with small string
	#(cf. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35903)
	STRICT_OPTIONS="$STRICT_OPTIONS -Wno-array-bounds "
	;;
esac

84 85 86 87
if test "$strictness" = "yes" ; then
	STRICT_OPTIONS="$STRICT_OPTIONS -Werror"
	CFLAGS="$CFLAGS -fno-strict-aliasing"
fi
88
AC_SUBST(STRICT_OPTIONS)
89 90
AC_SUBST(STRICT_OPTIONS_CC)
AC_SUBST(STRICT_OPTIONS_CXX)
aymeric's avatar
aymeric committed
91

92
dnl enable timestamp support
93
AC_ARG_ENABLE(ntp-timestamp,
Yann Diorcet's avatar
Yann Diorcet committed
94 95 96 97 98 99 100 101
	[AS_HELP_STRING([--enable-ntp-timestamp], [Turn on NTP timestamping on received packet (default=no)])],
	[case "${enableval}" in
		yes)	ntptimestamp=true;;
		no)	ntptimestamp=false;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --enable-ntp-timestamp) ;;
	esac],
	[ntptimestamp=false]
)
aymeric's avatar
aymeric committed
102

103

Simon Morlat's avatar
Simon Morlat committed
104 105 106 107 108 109
AC_CONFIG_MACRO_DIR([m4])
LT_INIT([win32-dll shared disable-static])


AC_SUBST([LIBTOOL_DEPS])

aymeric's avatar
aymeric committed
110 111 112 113 114
if test "$GCC" != "yes" ; then
	case $target_os in
		*hpux*)
			dnl we are probably using HPUX cc compiler, so add a +O2 to CFLAGS
			CFLAGS="$CFLAGS +O2 -g "
Yann Diorcet's avatar
Yann Diorcet committed
115
		;;
aymeric's avatar
aymeric committed
116 117
	esac
else
118
	CFLAGS="$CFLAGS -Wall -fdiagnostics-show-option"
119 120
	OBJCFLAGS="$OBJCFLAGS -Wall"
	CXXFLAGS="$CXXFLAGS -Wall"
aymeric's avatar
aymeric committed
121 122
fi

Simon Morlat's avatar
Simon Morlat committed
123
AC_ARG_ENABLE([debug],
Yann Diorcet's avatar
Yann Diorcet committed
124 125 126 127
	AS_HELP_STRING([--enable-debug=@<:@yes/no@:>@],[enables the display of traces showing the execution of the library. @<:@default=yes@:>@]),
	[],
	[enable_debug=no]
)
128

Simon Morlat's avatar
Simon Morlat committed
129 130 131

AS_CASE([$enable_debug],
		[yes],[
132 133 134
			CFLAGS="$CFLAGS -g -O0 -DDEBUG"
			CXXFLAGS="$CXXFLAGS -g -O0 -DDEBUG"
			OBJCFLAGS="$OBJCFLAGS -g -O0 -DDEBUG"
Simon Morlat's avatar
Simon Morlat committed
135 136 137 138 139 140 141
		],
		[no],
		[
			case "$CFLAGS" in
				*-O*)
				;;
				*)
Yann Diorcet's avatar
Yann Diorcet committed
142 143
					CFLAGS="$CFLAGS -O2 -g"
					CXXFLAGS="$CXXFLAGS -O2 -g"
144
					OBJCFLAGS="$OBJCFLAGS -O2 -g"
Simon Morlat's avatar
Simon Morlat committed
145 146 147 148
				;;
			esac
		],
		[AC_MSG_ERROR([Bad value ($enable_debug) for --enable-debug. Valid values are yes or no.])])
aymeric's avatar
aymeric committed
149

Simon Morlat's avatar
Simon Morlat committed
150 151 152 153 154 155 156 157 158 159 160 161
AC_ARG_ENABLE(non-free-codecs,
	AC_HELP_STRING([--enable-non-free-codecs], [Include non-free codecs in build @<:@yes@:>@]),
	[non_free_codecs="${enableval}"],
	[non_free_codecs=yes]
)

if test "$non_free_codecs" = "yes" ; then
	AC_DEFINE(HAVE_NON_FREE_CODECS, 1, [whether non free codecs are allowed in the build])
else
	AC_DEFINE(HAVE_NON_FREE_CODECS, 0, [whether non free codecs are allowed in the build])
fi

aymeric's avatar
aymeric committed
162 163 164 165 166 167 168 169 170 171 172 173 174
dnl Checks for header files.
AC_HEADER_STDC

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_HEADER_TIME
AC_WORDS_BIGENDIAN
if test x$ac_cv_c_bigendian = xyes ; then
	CFLAGS="$CFLAGS -D_BIGENDIAN "
fi

macosx_found=no
Jehan Monnier's avatar
Jehan Monnier committed
175
mingw32ce_found=no
jehan's avatar
jehan committed
176
ios_found=no
aymeric's avatar
aymeric committed
177 178

dnl add thread flags
179
case $host in
180
	i386-apple*|armv6-apple*|armv7-apple*|armv7s-apple*|aarch64-apple*|arm64-apple*|*-darwin.ios)
181
		ios_found=yes
Yann Diorcet's avatar
Yann Diorcet committed
182
	;;
jehan's avatar
jehan committed
183
	x86_64-apple*|i686-apple*)
184
		macosx_found=yes
185
		OBJCFLAGS="$OBJCFLAGS -Wno-error=deprecated-declarations"
186
	;;
187
  	*mingw32ce)
188 189
		CFLAGS="$CFLAGS -D_WIN32_WINNT=0x0501  -D_WIN32_WCE  -DORTP_STATIC"
		CXXFLAGS="$CXXFLAGS -D_WIN32_WINNT=0x0501 -DORTP_STATIC  -D_WIN32_WCE"
190
dnl ORTP_STATIC to tell ortp not to export its variable with dllexport, as if we were building statically, or dynamically on linux
Yann Diorcet's avatar
Yann Diorcet committed
191
	  	LIBS="$LIBS -lws2"
192
		mingw_found=yes
Jehan Monnier's avatar
Jehan Monnier committed
193
		mingw32ce_found=yes
Yann Diorcet's avatar
Yann Diorcet committed
194
	;;
195
	*mingw*)
196 197 198
		dnl Workaround for mingw, whose compiler does not check in /usr/include ...
		CPPFLAGS="$CPPFLAGS -I/usr/include"
		LDFLAGS="$LDFLAGS -L/usr/lib"
199 200
		CFLAGS="$CFLAGS -D_WIN32_WINNT=0x0501 -DORTP_STATIC"
		CXXFLAGS="$CXXFLAGS -D_WIN32_WINNT=0x0501 -DORTP_STATIC"
201 202 203 204
dnl ORTP_STATIC to tell ortp not to export its variable with dllexport, as if we were building statically, or dynamically on linux
		LIBS="$LIBS -lws2_32 -lwinmm "
		mingw_found=yes
	;;
Ghislain MARY's avatar
Ghislain MARY committed
205 206
	*nto-qnx*)
	;;
Yann Diorcet's avatar
Yann Diorcet committed
207 208 209 210 211 212
	*)
		MSPLUGINS_CFLAGS="-pthread"
		MSPLUGINS_LIBS="-shared -pthread"
		CFLAGS="$CFLAGS -pthread -D_REENTRANT"
		LIBS="$LIBS -pthread -lpthread"
	;;
aymeric's avatar
aymeric committed
213 214
esac

215 216 217 218
if test "$macosx_found" == "yes" ; then
	LIBS="$LIBS -framework CoreFoundation -framework AudioToolbox -framework CoreAudio -framework AppKit"
fi
if test "$ios_found" == "yes" ; then
219
	LIBS="$LIBS -framework CoreFoundation -framework AudioToolbox -framework CoreAudio -framework Foundation -framework QuartzCore -framework OpenGLES -framework UIKit -framework AVFoundation"
220
fi
Yann Diorcet's avatar
Yann Diorcet committed
221

Simon Morlat's avatar
Simon Morlat committed
222 223 224 225 226 227
dnl localization tools
IT_PROG_INTLTOOL([0.40], [no-xml])


GETTEXT_PACKAGE="mediastreamer"
AC_SUBST([GETTEXT_PACKAGE])
Yann Diorcet's avatar
Yann Diorcet committed
228
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[name of the gettext domain. Used in the call to 'bindtextdomain()'])
Simon Morlat's avatar
Simon Morlat committed
229 230
if test "$mingw_found" != "yes" ; then
	dnl gettext macro does not work properly under mingw. And we want to use the one provided by GTK.
Yann Diorcet's avatar
Yann Diorcet committed
231
	CPPFLAGS_save=$CPPFLAGS
Simon Morlat's avatar
Simon Morlat committed
232
	AM_GNU_GETTEXT([external])
233
	AC_SUBST(INTLLIBS)
Yann Diorcet's avatar
Yann Diorcet committed
234
	CPPFLAGS=$CPPFLAGS_save
Simon Morlat's avatar
Simon Morlat committed
235 236
	LIBS="$LIBS $LIBINTL"
else
237 238 239
	if test "$USE_NLS" = "yes" ; then
		AC_DEFINE(ENABLE_NLS,1,[Tells whether localisation is possible])
		AC_DEFINE(HAVE_GETTEXT,1,[Tells wheter localisation is possible])
Simon Morlat's avatar
Simon Morlat committed
240
		LIBS="$LIBS -L/usr/lib -lintl"
241
	fi
Simon Morlat's avatar
Simon Morlat committed
242 243
fi

aymeric's avatar
aymeric committed
244
AM_CONDITIONAL(BUILD_MACOSX, test x$macosx_found = xyes)
jehan's avatar
jehan committed
245
AM_CONDITIONAL(BUILD_IOS, test x$ios_found = xyes)
aymeric's avatar
aymeric committed
246

Yann Diorcet's avatar
Yann Diorcet committed
247 248 249 250 251 252 253 254 255 256 257
AC_CONFIG_COMMANDS([libtool-hacking],
	[if test "$mingw_found" = "yes" ; then
		echo "Hacking libtool to work with mingw..."
		sed -e 's/\*\" \$a_deplib \"\*/\*/' < ./libtool > libtool.tmp
		cp -f ./libtool.tmp ./libtool
		rm -f ./libtool.tmp
	else
		echo "No need to hack libtool."
	fi],
	[mingw_found=$mingw_found]
)
258

259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
dnl conditionnal build of tools.
AC_ARG_ENABLE(tools,
	[AS_HELP_STRING([--enable-tools=[yes/no]], [Turn on or off compilation of console interface (default=yes)])],
	[case "${enableval}" in
		yes)	build_tools=true ;;
		no)	build_tools=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --enable-tools) ;;
	esac],
	[build_tools=check]
)
AM_CONDITIONAL(BUILD_TOOLS, test x$build_tools != xfalse)
if test "$build_tools" != "false" ; then
	build_tools=true
	AC_DEFINE(BUILD_TOOLS, 1, [Define if tools enabled] )
fi
274

275 276
dnl prefer fixed point computations
AC_ARG_ENABLE(fixed_point,
Yann Diorcet's avatar
Yann Diorcet committed
277 278 279 280 281 282 283 284 285
	[AS_HELP_STRING([--enable-fixed-point=@<:@yes/no/guess@:>@], [Turn on fixed point computations (default=guess)])],
	[case "${enableval}" in
		yes)	fixed_point=true;;
		no)	fixed_point=false;;
		guess)	fixed_point=guess;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --enable-fixed-point) ;;
	esac],
	[fixed_point=guess]
)
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301

if test "$fixed_point" = "guess" ; then
	AC_MSG_CHECKING([whether fixed point arithmetic is preferred])
	case ${target_cpu}${host_cpu} in
		*bfin*)
			fixed_point=true
		;;
		*arm*)
			fixed_point=true
		;;
		*)
			fixed_point=false
		;;
	esac
	AC_MSG_RESULT([$fixed_point])
fi
302

303

304 305 306 307 308
if test x$fixed_point = xtrue ; then
	MS_PUBLIC_CFLAGS="$MS_PUBLIC_CFLAGS -DMS_FIXED_POINT"
fi


smorlat's avatar
smorlat committed
309 310 311
dnl initialize pkg-config so that we can use it within if else fi statements.
PKG_PROG_PKG_CONFIG()

aymeric's avatar
aymeric committed
312 313 314 315 316 317 318 319 320
AC_SUBST(MSPLUGINS_CFLAGS)
AC_SUBST(MSPLUGINS_LIBS)

dnl	*********************************
dnl	various checks for soundcard apis
dnl	*********************************

found_sound=no

321 322 323 324
if test x$mingw_found = xyes ; then
	found_sound=yes
fi

325
AC_ARG_ENABLE(sound,
Yann Diorcet's avatar
Yann Diorcet committed
326 327 328 329 330 331 332 333
	[AS_HELP_STRING([--disable-sound], [Turn off all possible sound backend (default=no)])],
	[case "${enableval}" in
		yes)	use_sound=true ;;
		no)	use_sound=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --disable-sound) ;;
	esac],
	[use_sound=true]
)
334

smorlat's avatar
smorlat committed
335
AC_ARG_ENABLE(oss,
Yann Diorcet's avatar
Yann Diorcet committed
336 337 338 339 340 341 342 343
	[AS_HELP_STRING([--enable-oss], [Enable oss support])],
	[case "${enableval}" in
		yes)	oss=true ;;
		no)	oss=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --disable-oss) ;;
	esac],
	[oss=$use_sound]
)
smorlat's avatar
smorlat committed
344 345

if "$oss" = "true"; then
Yann Diorcet's avatar
Yann Diorcet committed
346 347 348 349 350 351 352 353 354
	AC_CHECK_HEADERS(soundcard.h sys/soundcard.h machine/soundcard.h sys/audio.h)
	if test "${ac_cv_header_sys_soundcard_h}" = "yes" || \
	   test "${ac_cv_header_soundcard_h}" = "yes" || \
	   test "${ac_cv_header_sys_audio_h}" = "yes" || \
	   test "${ac_cv_header_machine_soundcard_h}" = "yes"; then
		found_sound=yes
	else
		oss=false
	fi
smorlat's avatar
smorlat committed
355
fi
aymeric's avatar
aymeric committed
356

357
AM_CONDITIONAL(BUILD_OSS, test x$oss = xtrue)
aymeric's avatar
aymeric committed
358 359 360

dnl conditionnal build of ALSA support
AC_ARG_ENABLE(alsa,
Yann Diorcet's avatar
Yann Diorcet committed
361 362 363 364 365 366 367 368
	[AS_HELP_STRING([--enable-alsa], [Turn on alsa native support compiling])],
	[case "${enableval}" in
		yes)	alsa=true ;;
		no)	alsa=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --enable-alsa) ;;
	esac],
	[alsa=$use_sound]
)
aymeric's avatar
aymeric committed
369 370 371 372 373 374 375

if test "$alsa" = "true"; then
	AC_CHECK_HEADERS(alsa/asoundlib.h,
		[ AC_CHECK_LIB(asound,snd_pcm_open,
			[ ALSA_LIBS="-lasound"
			  found_sound=yes
			AC_DEFINE(__ALSA_ENABLED__,1,[defined if alsa support is available])
376
			alsa_enabled=true
aymeric's avatar
aymeric committed
377 378 379 380 381 382 383 384
			])
		]
	)
fi
AC_SUBST(ALSA_LIBS)

AM_CONDITIONAL(BUILD_ALSA, test x$alsa_enabled = xtrue)

385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
dnl conditionnal build of QSA support
AC_ARG_ENABLE(qsa,
	[AS_HELP_STRING([--enable-qsa], [Turn on QSA (QNX Sound Architecture) support])],
	[case "${enableval}" in
		yes)	qsa=true ;;
		no)	qsa=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --enable-qsa) ;;
	esac],
	[qsa=$false]
)
if test "$qsa" = "true"; then
	AC_CHECK_HEADERS(sys/asoundlib.h,
		[ AC_CHECK_LIB(asound, snd_pcm_open,
			[ QSA_LIBS="-lasound"
			  found_sound=yes
			AC_DEFINE(__QSA_ENABLED__, 1, [defined if QSA support is available])
			qsa_enabled=true
			])
		]
	)
fi
AC_SUBST(QSA_LIBS)
AM_CONDITIONAL(BUILD_QSA, test x$qsa_enabled = xtrue)

aymeric's avatar
aymeric committed
409 410

AC_ARG_ENABLE(artsc,
Yann Diorcet's avatar
Yann Diorcet committed
411 412 413 414 415 416 417 418
	[AS_HELP_STRING([--enable-artsc], [Turn on artsc (KDE<4) sound input/output (default=no)])],
	[case "${enableval}" in
		yes)	artsc=true ;;
		no)	artsc=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --enable-artsc) ;;
	esac],
	[artsc=false]
)
aymeric's avatar
aymeric committed
419 420 421 422 423 424 425 426 427 428 429 430

arts_enabled=false

if test "$artsc" = "true" ; then
	dnl check for arts (kde sound daemon) support
	PKG_CHECK_MODULES(ARTS, [artsc],[
		dnl New detection
		arts_enabled=true
	],[
		dnl Old detection
		if test x$artsc = xtrue ; then
			AC_CHECK_HEADERS(kde/artsc/artsc.h,
431
				[ AC_CHECK_LIB(artsc,arts_init,
aymeric's avatar
aymeric committed
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
					[ ARTS_LIBS="-lartsc"
					arts_enabled=true
					])
				]
			)
		fi
		AC_SUBST(ARTS_LIBS)
	])
fi

if test x$arts_enabled = xtrue; then
	found_sound=yes
	AC_DEFINE(__ARTS_ENABLED__,1,[defined if arts support is available])
fi

AM_CONDITIONAL(BUILD_ARTS, test x$arts_enabled = xtrue)

AC_ARG_ENABLE(portaudio,
Yann Diorcet's avatar
Yann Diorcet committed
450 451 452 453 454 455 456 457
	[AS_HELP_STRING([--enable-portaudio], [Turn on portaudio native support compiling (default=no)])],
	[case "${enableval}" in
		yes)	portaudio=true ;;
		no)	portaudio=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --enable-portaudio) ;;
	esac],
	[portaudio=false]
)
aymeric's avatar
aymeric committed
458 459 460 461

if test "$portaudio" = "true"; then
	AC_CHECK_HEADERS(portaudio.h,
		[ AC_CHECK_LIB(portaudio,Pa_Initialize,
Yann Diorcet's avatar
Yann Diorcet committed
462 463
			[PORTAUDIO_LIBS="-lportaudio"
			found_sound=yes
aymeric's avatar
aymeric committed
464
			AC_DEFINE(__PORTAUDIO_ENABLED__,1,[defined if portaudio support is available])
Yann Diorcet's avatar
Yann Diorcet committed
465 466
			portaudio_enabled=true]
			)
aymeric's avatar
aymeric committed
467 468 469 470 471 472 473 474
		]
	)
fi

AC_SUBST(PORTAUDIO_LIBS)
AM_CONDITIONAL(BUILD_PORTAUDIO, test x$portaudio_enabled = xtrue)

AC_ARG_ENABLE(macsnd,
Yann Diorcet's avatar
Yann Diorcet committed
475 476 477 478 479 480 481 482
	[AS_HELP_STRING([--enable-macsnd], [Turn on MAC OS X Audio Units sound support])],
	[case "${enableval}" in
		yes)	macsnd=true ;;
		no)	macsnd=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --enable-macsnd) ;;
	esac],
	[macsnd=$use_sound]
)
aymeric's avatar
aymeric committed
483

Simon Morlat's avatar
Simon Morlat committed
484
macaqsnd_default=no
485 486 487
if test "$ios_found" = "yes" ; then
	macaqsnd_default=true;
fi
Simon Morlat's avatar
Simon Morlat committed
488

aymeric's avatar
aymeric committed
489
AC_ARG_ENABLE(macaqsnd,
Yann Diorcet's avatar
Yann Diorcet committed
490 491 492 493 494 495 496 497
	[AS_HELP_STRING([--enable-macaqsnd], [Turn on native MAC OS X Audio Queue sound support (default=no)])],
	[case "${enableval}" in
		yes)	macaqsnd=true ;;
		no)	macaqsnd=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --enable-macaqsnd) ;;
	esac],
	[macaqsnd=$macaqsnd_default]
)
498 499 500 501 502

if test "$macosx_found" = "yes" ; then
	if test "$macsnd" = "true"; then
		AC_DEFINE(__MACSND_ENABLED__,1,[defined if native macosx sound support is available])
		macsnd_enabled=true
jehan's avatar
jehan committed
503
		LIBS="$LIBS -framework Carbon -framework AudioUnit"
504 505
		found_sound=yes
	fi
aymeric's avatar
aymeric committed
506 507
fi

508 509
if test "$macaqsnd" = "true"; then
	AC_DEFINE(__MAC_AQ_ENABLED__,1,[defined if native macosx AQ sound support is available])
510
	found_sound=yes
511
	macaqsnd=true
512 513
fi

514
AM_CONDITIONAL(BUILD_MACSND, test x$macsnd_enabled = xtrue)
515
AM_CONDITIONAL(BUILD_MACAQSND, test x$macaqsnd = xtrue)
516
AM_CONDITIONAL(BUILD_IOSIOUNIT, test x$ios_found = xyes)
smorlat's avatar
smorlat committed
517

518
AC_ARG_ENABLE(pulseaudio,
Yann Diorcet's avatar
Yann Diorcet committed
519 520 521 522 523 524 525 526
	[AS_HELP_STRING([--disable-pulseaudio], [Disable pulseaudio support])],
	[case "${enableval}" in
		yes)	pulseaudio=true ;;
		no)	pulseaudio=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --disable-pulseaudio) ;;
	esac],
	[pulseaudio=$use_sound]
)
527 528 529 530


if test x$pulseaudio = xtrue ; then
	PKG_CHECK_MODULES(LIBPULSE, libpulse >= 0.9.21,
Yann Diorcet's avatar
Yann Diorcet committed
531 532 533 534
		[AC_DEFINE(__PULSEAUDIO_ENABLED__,1,[Pulse audio support])
		found_sound=yes],
		[pulseaudio=false]
	)
535 536 537 538 539
fi

AM_CONDITIONAL(BUILD_PULSEAUDIO,test x$pulseaudio = xtrue)


540 541
if test "${found_sound}${use_sound}" = "noyes"; then
	AC_MSG_ERROR([Could not find a support sound driver API. Use --disable-sound if you don't care about having sound.])
aymeric's avatar
aymeric committed
542 543 544 545 546 547 548
fi


dnl	*************************************
dnl	check for various codecs libraries
dnl	*************************************

smorlat's avatar
smorlat committed
549
AC_ARG_ENABLE(speex,
Yann Diorcet's avatar
Yann Diorcet committed
550 551 552 553 554 555 556
	[AS_HELP_STRING([--disable-speex], [Disable speex support])],
	[case "${enableval}" in
		yes)	speex=true ;;
		no)	speex=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --disable-speex) ;;
	esac],
	[speex=true]
aymeric's avatar
aymeric committed
557
)
smorlat's avatar
smorlat committed
558

Yann Diorcet's avatar
Yann Diorcet committed
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
if test x$speex = xtrue; then
	dnl check for installed version of speex
	PKG_CHECK_MODULES(SPEEX, speex >= 1.2beta3,
		[ AC_DEFINE(HAVE_SPEEX_NOISE,1,[tells whether the noise arg of speex_echo_cancel can be used]) ],
		[try_other_speex=yes]
	)
	PKG_CHECK_MODULES(SPEEX, speex >= 1.2beta3, build_speex=yes)
	build_resample=false
	PKG_CHECK_MODULES(SPEEXDSP, speexdsp >= 1.2beta3,
		[SPEEX_LIBS="$SPEEX_LIBS $SPEEXDSP_LIBS"
		AC_DEFINE(HAVE_SPEEXDSP,1,[have speexdsp library])
		build_resample=yes],
		[AC_MSG_ERROR([No libspeexdsp library found.])]
	)
	AC_SUBST(SPEEX_CFLAGS)
	AC_SUBST(SPEEX_LIBS)
smorlat's avatar
smorlat committed
575 576
fi

aymeric's avatar
aymeric committed
577
AM_CONDITIONAL(BUILD_SPEEX, test x$build_speex = xyes )
578
AM_CONDITIONAL(BUILD_RESAMPLE, test x$build_resample = xyes )
aymeric's avatar
aymeric committed
579

smorlat's avatar
smorlat committed
580
AC_ARG_ENABLE(gsm,
Yann Diorcet's avatar
Yann Diorcet committed
581 582 583 584 585 586 587 588
	[AS_HELP_STRING([--disable-gsm], [Disable gsm support])],
	[case "${enableval}" in
		yes)	gsm=true ;;
		no)	gsm=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --disable-gsm) ;;
	esac],
	[gsm=auto]
)
589

590
if test x$gsm != xfalse; then
smorlat's avatar
smorlat committed
591

aymeric's avatar
aymeric committed
592 593
dnl check for gsm
build_gsm=no
Yann Diorcet's avatar
Yann Diorcet committed
594 595 596 597 598
AC_ARG_WITH(gsm,
	[  --with-gsm		Sets the installation prefix of gsm codec library [default=/usr] ],
	[ gsmdir=${withval}],
	[ gsmdir=/usr ]
)
aymeric's avatar
aymeric committed
599 600 601 602 603 604 605

if test x"$gsmdir" != xno ; then
	test x"$gmsdir" = xyes && gsmdir=/usr
	MS_CHECK_DEP([gsm codec],[GSM],[${gsmdir}/include],
		[${gsmdir}/lib],[gsm/gsm.h],[gsm],[gsm_create])
	if test "$GSM_found" = "yes" ; then
		build_gsm=yes
606
	elif test "$gsm" = "true"; then
607
		AC_MSG_ERROR([Could not locate gsm headers or library.])
aymeric's avatar
aymeric committed
608 609 610 611
	fi
else
	build_gsm=no
fi
smorlat's avatar
smorlat committed
612 613 614

fi

615 616 617 618 619 620 621 622 623 624 625



dnl check for matroska file support
AC_ARG_ENABLE(matroska,
	[AS_HELP_STRING([--enable-matroska], [Enable mkv file support])],
	[case "${enableval}" in
		yes)	matroska=true ;;
		no)	matroska=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --enable-matroska) ;;
	esac],
Simon Morlat's avatar
Simon Morlat committed
626
	[matroska=guess]
627 628 629 630 631 632 633 634 635 636 637 638
)
AC_ARG_WITH(ebml,
	[AS_HELP_STRING([--with-ebml],[Sets the installation prefix of ebml library (v2) [default=/usr]])],
	[ ebmldir=${withval} ],
	[ ebmldir=/usr ]
)
AC_ARG_WITH(matroska,
	[AS_HELP_STRING([--with-matroska],[Sets the installation prefix of matroska library (v2) [default=/usr]])],
	[ matroskadir=${withval} ],
	[ matroskadir=/usr ]
)

Simon Morlat's avatar
Simon Morlat committed
639
if test x$matroska != xfalse ; then
640 641 642

build_matroska=yes
if test x"$ebmldir" != xno ; then
Simon Morlat's avatar
Simon Morlat committed
643 644
	MS_CHECK_DEP([ebml library],[EBML],[${ebmldir}/include],
		[${ebmldir}/lib],[ebml/ebml.h],[ebml2],[EBML_ElementRender])
645
	if test "$EBML_found" = "no" ; then
646
		build_matroska=no
647 648 649
		if test "$matroska" = "true" ; then
			AC_MSG_ERROR([Could not locate ebml headers or library.])
		fi
650 651 652 653 654 655
	fi
else
	build_matroska=no
fi

if test x"$matroskadir" != xno ; then
656
	MS_CHECK_DEP([matroska library],[MATROSKA],[${matroskadir}/include],
Simon Morlat's avatar
Simon Morlat committed
657
		[${matroskadir}/lib],[matroska/matroska.h],[matroska2],[MATROSKA_BlockReleaseData],[-lebml2])
658
	if test "$MATROSKA_found" = "trueno" ; then
659
		build_matroska=no
660 661 662
		if test "$matroska" = "true" ; then
			AC_MSG_ERROR([Could not locate matroska headers or library.])
		fi
663 664 665 666 667 668 669 670 671
	fi
else
	build_matroska=no
fi

fi



672 673
dnl check for spandsp support to bring up g726 codec
AC_ARG_ENABLE(spandsp,
Yann Diorcet's avatar
Yann Diorcet committed
674 675 676 677 678 679 680
	[AS_HELP_STRING([--disable-spandsp], [Disable spandsp support])],
	[case "${enableval}" in
		yes)	spandsp=true ;;
		no)	spandsp=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --disable-spandsp) ;;
	esac],
	[spandsp=true]
681 682
)

Yann Diorcet's avatar
Yann Diorcet committed
683 684 685 686 687 688 689 690 691
if test x$spandsp = xtrue; then
	dnl check for installed version of speex
	PKG_CHECK_MODULES(SPANDSP, spandsp >= 0.0.6,
		[ AC_DEFINE(HAVE_SPANDSP,1,[tells whether spandsp can be used])
		have_spandsp=true ],
		[have_spandsp=false]
	)
	AC_SUBST(SPANDSP_CFLAGS)
	AC_SUBST(SPANDSP_LIBS)
692 693
fi

694 695
dnl check for installed version of libupnp
AC_ARG_ENABLE(upnp,
Yann Diorcet's avatar
Yann Diorcet committed
696 697 698 699 700 701 702 703
	[AS_HELP_STRING([--disable-upnp], [Disable uPnP support])],
	[case "${enableval}" in
		yes)	build_upnp=true ;;
		no)	build_upnp=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --disable-upnp) ;;
	esac],
	[build_upnp=auto]
)
704 705

if test "$build_upnp" != "false" ; then
706
	PKG_CHECK_MODULES([LIBUPNP], [libupnp],
Yann Diorcet's avatar
Yann Diorcet committed
707 708
		[if  pkg-config --atleast-version=1.6 "libupnp < 1.7"; then
			build_upnp=true
709
			old_CFLAGS="$CFLAGS"
Simon Morlat's avatar
Simon Morlat committed
710
			CFLAGS="$CFLAGS $LIBUPNP_CFLAGS -Werror -Wno-error=unused-variable"
711 712 713
			AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
				#include <upnp.h>
			]], [[
Simon Morlat's avatar
Simon Morlat committed
714
				struct Upnp_Action_Complete aa={0};
715 716 717
				char *url = aa.CtrlUrl;
			]])],,
			AC_DEFINE(USE_PATCHED_UPNP, 1, [Define if upnp is patched]))
718
			CFLAGS="$old_CFLAGS"
Yann Diorcet's avatar
Yann Diorcet committed
719 720 721 722
		else
			AC_MSG_ERROR([libupnp >= 1.6 < 1.5 required.])
		fi],
		[if test "$build_upnp" == "true" ; then
723 724 725
			AC_MSG_ERROR([libupnp not found.])
		else
			build_upnp=false
Yann Diorcet's avatar
Yann Diorcet committed
726 727
		fi]
	)
728 729

fi
730

Ghislain MARY's avatar
Ghislain MARY committed
731 732 733 734 735 736 737 738 739 740 741 742
dnl check for opus codec support
AC_ARG_ENABLE(opus,
	[AS_HELP_STRING([--disable-opus], [Disable opus codec support])],
	[case "${enableval}" in
		yes) opus=true ;;
		no) opus=false ;;
		*) AC_MSG_ERROR(bad value ${enableval} for --disable-opus) ;;
	esac], [opus=true])
if test x$opus = xtrue; then
PKG_CHECK_MODULES(OPUS, opus >= 0.9.0,
	[AC_DEFINE(HAVE_OPUS, 1, [Tells whether opus can be used])
	have_opus=true],
743
	[have_opus=false]
Ghislain MARY's avatar
Ghislain MARY committed
744 745 746 747 748
)
AC_SUBST(OPUS_CFLAGS)
AC_SUBST(OPUS_LIBS)
fi

749
AM_CONDITIONAL(BUILD_OPUS, test x$have_opus = xtrue)
aymeric's avatar
aymeric committed
750
AM_CONDITIONAL(BUILD_GSM, test x$build_gsm = xyes )
751
AM_CONDITIONAL(BUILD_MATROSKA, test x$build_matroska = xyes )
752
AM_CONDITIONAL(BUILD_G726, test "$have_spandsp" = "true" )
aymeric's avatar
aymeric committed
753 754 755 756

MS_CHECK_VIDEO
AM_CONDITIONAL(BUILD_VIDEO, test "$video" = "true")
AM_CONDITIONAL(BUILD_THEORA, test "$have_theora" = "yes")
757
AM_CONDITIONAL(BUILD_VP8, test "$have_vp8" = "yes")
758
AM_CONDITIONAL(BUILD_WIN32, test "$mingw_found" = "yes")
Jehan Monnier's avatar
Jehan Monnier committed
759
AM_CONDITIONAL(BUILD_WIN32_WCE, test "$mingw32ce_found" = "yes")
760 761
AM_CONDITIONAL(BUILD_AVCODEC, test x$avcodec_found = xyes)
AM_CONDITIONAL(BUILD_SWSCALE, test x$swscale_found = xyes)
Simon Morlat's avatar
Simon Morlat committed
762 763
AM_CONDITIONAL(BUILD_SDL,test "$sdl_found" = "true" )
AM_CONDITIONAL(BUILD_X11_XV, test "$enable_xv" = "true" )
764
AM_CONDITIONAL(BUILD_X11_GL, test "$enable_glx" = "true" )
765
AM_CONDITIONAL(BUILD_UPNP, test "$build_upnp" = "true" )
766 767 768 769 770 771 772 773 774 775 776

dnl	*********************************************
dnl	Enable/disable oRTP dependency
dnl	*********************************************
AC_ARG_ENABLE(ortp,
	[AS_HELP_STRING([--disable-ortp], [Disable usage of the oRTP library (default=no)])],
	[case "${enableval}" in
		yes)	ortp_enabled=true ;;
		no)	ortp_enabled=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --disable-ortp) ;;
	esac],
Yann Diorcet's avatar
Yann Diorcet committed
777 778
	[ortp_enabled=true]
)
779
AM_CONDITIONAL(ORTP_ENABLED, test x$ortp_enabled = xtrue)
780 781


aymeric's avatar
aymeric committed
782 783 784 785
dnl	*********************************************
dnl	setup oRTP dependency
dnl	*********************************************
AC_ARG_ENABLE(external-ortp,
Yann Diorcet's avatar
Yann Diorcet committed
786 787 788 789 790 791 792 793
	[AS_HELP_STRING([--enable-external-ortp], [Use external oRTP library (default=no)])],
	[case "${enableval}" in
		yes)	external_ortp=true ;;
		no)	external_ortp=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --enable-external-ortp) ;;
	esac],
	[external_ortp=false]
)
aymeric's avatar
aymeric committed
794

795 796
if test "$ortp_enabled" = 'true'; then
	if test "$external_ortp" = 'false'; then
797
		if test -e ../oRTP/ortp.defs ; then
798 799
			echo "building from linphone source tree, using ../oRTP/include/ortp/ortp.h"
			ORTP_CFLAGS="-I\$(top_srcdir)/../oRTP/include"
800 801
			ORTP_DEFS=`cat ../oRTP/ortp.defs`
			ORTP_CFLAGS="$ORTP_CFLAGS $ORTP_DEFS"
802 803 804 805 806 807 808 809 810
			ORTP_LIBS="\$(top_builddir)/../oRTP/src/libortp.la"
			if test x$ac_cv_c_bigendian = xyes ; then
				ORTP_CFLAGS="$ORTP_CFLAGS -DORTP_BIGENDIAN"
			fi
			if test x$ntptimestamp = xtrue ; then
				ORTP_CFLAGS="$ORTP_CFLAGS -DORTP_TIMESTAMP"
			fi
		else
			external_ortp=true
aymeric's avatar
aymeric committed
811 812
		fi
	fi
813
	if test "$external_ortp" = 'true'; then
814
		PKG_CHECK_MODULES(ORTP, ortp >= 0.24.0, ,
815 816
			[ AC_MSG_ERROR([Couldn't find ortp library]) ] )
	fi
817 818 819
else
	AC_CHECK_HEADERS(sys/shm.h)
	ORTP_CFLAGS="-Iortp-deps"
aymeric's avatar
aymeric committed
820
fi
821 822
AC_SUBST(ORTP_CFLAGS)
AC_SUBST(ORTP_LIBS)
aymeric's avatar
aymeric committed
823 824


825 826 827 828 829 830 831 832 833 834
dnl	*********************************************
dnl	Enable/disable mediastreamer2 filters
dnl	*********************************************
AC_ARG_ENABLE(filters,
	[AS_HELP_STRING([--disable-filters], [Disable compilation of filters (default=no)])],
	[case "${enableval}" in
		yes)	filters=true ;;
		no)	filters=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --disable-filters) ;;
	esac],
Yann Diorcet's avatar
Yann Diorcet committed
835 836
	[filters=true]
)
837
AM_CONDITIONAL(MS2_FILTERS, test x$filters = xtrue)
838

839
AM_CONDITIONAL(BUILD_VOIP_LIBRARY, test x$ortp_enabled = xtrue)
840 841


aymeric's avatar
aymeric committed
842 843 844 845 846 847 848 849 850 851 852
dnl check dlopen support in headers and libraries, so that we can use mediastreamer plugins
AC_CHECK_HEADERS(dlfcn.h)
have_dlopen=false
AC_CHECK_LIB(dl,dlopen,[LIBS="$LIBS -ldl"; have_dlopen=true])
AC_CHECK_FUNC(dlopen,[have_dlopen=true])
if test "$have_dlopen" = "true" ; then
	AC_DEFINE(HAVE_DLOPEN,1,[Defined if dlopen() is availlable])
fi

dnl check various things
AC_FUNC_ALLOCA
853
AC_ARG_ENABLE(relativeprefix,
Yann Diorcet's avatar
Yann Diorcet committed
854 855 856 857 858 859 860 861
	[AS_HELP_STRING([--enable-relativeprefix], [Build a linphone that finds its resources relatively to the directory where it is installed])],
	[case "${enableval}" in
		yes)	relativeprefix=yes ;;
		no)	relativeprefix=no ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --enable-relativeprefix) ;;
	esac],
	[relativeprefix=guess]
)
aymeric's avatar
aymeric committed
862

smorlat's avatar
smorlat committed
863
if test "x${prefix}" = "xNONE"; then
simorl's avatar
simorl committed
864 865 866 867 868
	package_prefix=${ac_default_prefix}
else
	package_prefix=${prefix}
fi

869 870


871
if test x$mingw_found = xyes || test x$relativeprefix = xyes ; then
simorl's avatar
simorl committed
872
	package_prefix="."
873
	PACKAGE_PLUGINS_DIR="./lib/mediastreamer/plugins"
874
else
Yann Diorcet's avatar
Yann Diorcet committed
875
	PACKAGE_PLUGINS_DIR="\$(libdir)/mediastreamer/plugins"
smorlat's avatar
smorlat committed
876 877
fi

aymeric's avatar
aymeric committed
878
dnl define path of plugins:
879

aymeric's avatar
aymeric committed
880 881
AC_SUBST(PACKAGE_PLUGINS_DIR)

smorlat's avatar
smorlat committed
882
PACKAGE_DATA_DIR="$prefix/share"
simorl's avatar
simorl committed
883
AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR,  "${package_prefix}/share" ,[path of data])
aymeric's avatar
aymeric committed
884 885 886 887
AC_SUBST(PACKAGE_DATA_DIR)

dnl check for video4linux headers
AC_CHECK_HEADERS(linux/videodev.h linux/videodev2.h)
888 889
if test "${ac_cv_header_linux_videodev_h}" = "yes" ; then
	found_v4l1=yes
890
else
891 892 893 894 895 896
	found_v4l1=no
fi
if test "${ac_cv_header_linux_videodev2_h}" = "yes" ; then
	found_v4l2=yes
else
	found_v4l2=no
897 898
fi

899 900 901 902
AM_CONDITIONAL(BUILD_V4L1, test x$found_v4l1 = xyes )
AM_CONDITIONAL(BUILD_V4L2, test x$found_v4l2 = xyes )

AC_ARG_ENABLE(libv4l1,
Yann Diorcet's avatar
Yann Diorcet committed
903 904 905 906 907 908 909 910
	[AS_HELP_STRING([--disable-libv4l1], [Disable usage of libv4l1, really discouraged])],
	[case "${enableval}" in
		yes)	libv4l1=yes ;;
		no)	libv4l1=no ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --disable-libv4l1) ;;
	esac],
	[libv4l1=yes]
)
911

912
AC_ARG_ENABLE(libv4l2,
Yann Diorcet's avatar
Yann Diorcet committed
913 914 915 916 917 918 919 920
	[AS_HELP_STRING([--disable-libv4l2], [Disable usage of libv4l2, really discouraged])],
	[case "${enableval}" in
		yes)	libv4l2=yes ;;
		no)	libv4l2=no ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --disable-libv4l2) ;;
	esac],
	[libv4l2=yes]
)
921

922
PKG_CHECK_MODULES(LIBV4L2, libv4l2,
923
	[AC_DEFINE(HAVE_LIBV4L2,1,[Defined if we have libv4l2])
Yann Diorcet's avatar
Yann Diorcet committed
924 925
	have_libv4l2=yes],
	[echo "No libv4l2 found."]
926 927
)
PKG_CHECK_MODULES(LIBV4L1, libv4l1,
928
	[AC_DEFINE(HAVE_LIBV4L1,1,[Defined if we have libv4l1])
Yann Diorcet's avatar
Yann Diorcet committed
929 930
	have_libv4l1=yes],
	[echo "No libv4l1 found."]
931
)
932 933 934 935 936
PKG_CHECK_MODULES(LIBV4LCONVERT, libv4lconvert,
	[AC_DEFINE(HAVE_LIBV4LCONVERT,1,[Defined if we have libv4lconvert])
	have_libv4lconvert=yes],
	[echo "No libv4lconvert found."]
)
aymeric's avatar
aymeric committed
937

938 939
if test "$found_v4l2" = "yes" && test "$have_libv4l2" != "yes" ; then
	if test "$video" = "true" && test "$libv4l2" = "yes" ; then
Yann Diorcet's avatar
Yann Diorcet committed
940
		AC_MSG_ERROR([
941 942 943
Missing libv4l2. It is highly recommended to build with
libv4l2 headers and library. Many camera will won't work or will crash
your application if libv4l2 is not installed.
944
If you know what you are doing, you can use --disable-libv4l2 to disable
945
this check.
Yann Diorcet's avatar
Yann Diorcet committed
946
		])
947 948 949
	fi
fi

950

Ghislain MARY's avatar
Ghislain MARY committed
951 952
AC_PATH_PROG(PCAP,pcap-config,false)
AM_CONDITIONAL(HAVE_PCAP, test $PCAP != false)
953 954 955
AC_ARG_ENABLE(pcap,
	[AS_HELP_STRING([--enable-pcap], [Enable pcap library (default=no)])],
	[case "${enableval}" in
Yann Diorcet's avatar
Yann Diorcet committed
956 957 958 959 960 961
		yes)	enable_pcap=yes ;;
		no)	enable_pcap=no ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --enable-pcap) ;;
	esac],
	[enable_pcap=no]
)
962 963
AM_CONDITIONAL(ENABLE_PCAP, test x$enable_pcap = xyes)
if test x$enable_pcap == xyes ; then
964 965 966 967 968
	if test $PCAP != false ; then
		PCAP_LIBS=`pcap-config --libs`
		PCAP_CFLAGS=`pcap-config --cflags`
		AC_SUBST(PCAP_LIBS)
		AC_SUBST(PCAP_CFLAGS)
969
		AC_DEFINE(HAVE_PCAP,1,[whether we compile with libpcap support])
970
	fi
971

972
fi
Ghislain MARY's avatar
Ghislain MARY committed
973 974


975
AC_ARG_ENABLE(tests,
Yann Diorcet's avatar
Yann Diorcet committed
976 977 978 979 980 981 982 983
	[AS_HELP_STRING([--enable-tests], [Enable compilation of tests (default=yes)])],
	[case "${enableval}" in
		yes)	tests=yes ;;
		no)	tests=no  ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --enable-tests) ;;
	esac],
	[tests=yes]
)
984
AM_CONDITIONAL(ENABLE_TESTS, test x$tests = xyes)
985 986


Ghislain MARY's avatar
Ghislain MARY committed
987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026
dnl ##################################################
dnl # Check for CUnit
dnl ##################################################

PKG_CHECK_MODULES(CUNIT, cunit, [found_cunit=yes],[found_cunit=no])

if test "$found_cunit" = "no" ; then
	AC_CHECK_HEADERS(CUnit/CUnit.h,
		[
			AC_CHECK_LIB(cunit,CU_add_suite,[
				found_cunit=yes
				CUNIT_LIBS+=" -lcunit"
			])
		])
fi
case "$target_os" in
	*darwin*)
		#hack for macport
		CUNIT_LIBS+=" -lncurses"
	;;
	*mingw*)
		CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0501"
		LIBS="$LIBS -lws2_32 -liphlpapi"
		LDFLAGS="$LDFLAGS -Wl,--export-all-symbols"
	;;
esac

if test "$found_cunit" = "no" ; then
	AC_MSG_WARN([Could not find cunit framework, tests are not compiled.])
else
	AC_CHECK_LIB(cunit,CU_get_suite,[
					AC_DEFINE(HAVE_CU_GET_SUITE,1,[defined when CU_get_suite is available])
					],[foo=bar],[$CUNIT_LIBS])
	AC_CHECK_LIB(cunit,CU_curses_run_tests,[
					AC_DEFINE(HAVE_CU_CURSES,1,[defined when CU_curses_run_tests is available])
					],[foo=bar],[$CUNIT_LIBS])
fi

AM_CONDITIONAL(BUILD_TESTS,test x$found_cunit = xyes)

1027 1028 1029 1030 1031 1032
case "$target_os" in
	*linux*)
		# Eliminate -lstdc++ addition to postdeps for cross compiles.
		postdeps_CXX=`echo " $postdeps_CXX " | sed 's, -lstdc++ ,,g'`
	;;
esac
Ghislain MARY's avatar
Ghislain MARY committed
1033

1034 1035 1036 1037
dnl check for libsrtp support (secure rtp)
AC_ARG_WITH(srtp,
	AC_HELP_STRING([--with-srtp], [Set prefix where libsrtp can be found or "none" to disable (ex:/usr or /usr/local) [[default=/usr]]]),
	[srtp_prefix=$withval],
1038
	[if test "$prefix" != "NONE"; then
1039 1040 1041 1042 1043
		srtp_prefix=$prefix
	 else
		srtp_prefix="/usr"
	 fi])

1044
if test "${srtp_prefix}" != "none" ; then
1045
	if test "${srtp_prefix}" != "/usr" ; then
1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060
		SRTP_CFLAGS="-I${srtp_prefix}/include -I${srtp_prefix}/include/srtp"
		SRTP_LIBS="-L${srtp_prefix}/lib"
	fi
	SRTP_LIBS="$SRTP_LIBS -lsrtp"

	dnl check srtp headers
	CPPFLAGS_save=$CPPFLAGS
	CPPFLAGS="$CPPFLAGS $SRTP_CFLAGS"
	AC_CHECK_HEADER([srtp/srtp.h],have_srtp_headers=yes)
	CPPFLAGS=$CPPFLAGS_save

	dnl check for srtp lib
	LDFLAGS_save=$LDFLAGS
	LDFLAGS="$LDFLAGS $SRTP_LIBS"
	LIBS_save=$LIBS
1061
	AC_CHECK_LIB(srtp,[srtp_init, crypto_policy_set_aes_cm_256_hmac_sha1_80, crypto_policy_set_aes_cm_256_hmac_sha1_32], have_srtp_lib=yes)
1062 1063 1064 1065
	LDFLAGS=$LDFLAGS_save
	LIBS=$LIBS_save

	if test "$have_srtp_headers$have_srtp_lib" = "yesyes" ; then
1066 1067
		LDFLAGS_save=$LDFLAGS
		LIBS_save=$LIBS
1068 1069 1070 1071 1072 1073 1074 1075 1076
		LDFLAGS="$LDFLAGS $SRTP_LIBS"
		AC_CHECK_LIB(
			srtp,
			sha1_update,[
				AC_MSG_WARN([This libsrtp version exports symbols conflicting with polarssl, resulting in a bad execution path. libsrtp will be statically linked])
				srtp_polarssl_conflict=yes
			],
			srtp_polarssl_conflict=no
		)
1077 1078 1079 1080
		LDFLAGS=$LDFLAGS_save
		LIBS=$LIBS_save

		if test "$srtp_polarssl_conflict" = "yes"; then
1081 1082
			srtp_static_lib="${srtp_prefix}/lib/libsrtp.a"
			if test -f $srtp_static_lib -a -r $srtp_static_lib; then
1083
				SRTP_LIBS="${srtp_prefix}/lib/libsrtp.a -Bsymbolic -Wl,--version-script=\$(top_srcdir)/src/libsrtp.map"
1084
				AC_DEFINE(HAVE_SRTP, 1, [Defined when srtp support is compiled])
Simon Morlat's avatar
Simon Morlat committed
1085
				have_srtp=true
1086 1087 1088 1089
			else
				AC_MSG_WARN([Could not access to $srtp_static_lib. Please use --with-srtp=PREFIX to specify the prefix where libsrtp.a has been installed])
				SRTP_CFLAGS=
				SRTP_LIBS=
Simon Morlat's avatar
Simon Morlat committed
1090
				have_srtp=true
1091 1092 1093
			fi
		else
			AC_DEFINE(HAVE_SRTP, 1, [Defined when srtp support is compiled])
1094
			have_srtp=true
1095
		fi
1096

1097 1098
	else
		AC_MSG_NOTICE([Could not find libsrtp headers or lib, cryto transport disabled.])
Simon Morlat's avatar
Simon Morlat committed
1099
		have_srtp=false
1100 1101 1102 1103 1104 1105 1106
		SRTP_CFLAGS=
		SRTP_LIBS=
	fi

	AC_SUBST(SRTP_CFLAGS)
	AC_SUBST(SRTP_LIBS)
else
Simon Morlat's avatar
Simon Morlat committed
1107
	have_srtp=false
1108 1109 1110 1111 1112
	SRTP_CFLAGS=
	SRTP_LIBS=
fi


1113 1114
dnl check for libzrtp support (RFC 6189: Media Path Key Agreement for Unicast Secure RTP)
AC_ARG_ENABLE(zrtp,
Simon Morlat's avatar
Simon Morlat committed
1115
	[AS_HELP_STRING([--enable-zrtp], [Turn on or off compilation of zrtp (default=detect)])],
1116 1117 1118 1119 1120
	[case "${enableval}" in
		yes)	zrtp=true ;;
		no)	zrtp=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --enable-zrtp) ;;
	esac],
Simon Morlat's avatar
Simon Morlat committed
1121
	[zrtp=detect]
1122 1123
)

Simon Morlat's avatar
Simon Morlat committed
1124 1125 1126 1127 1128 1129
if test "$zrtp" != "false" ; then
	PKG_CHECK_MODULES(LIBBZRTP, libbzrtp >= 1.0.0, found_zrtp=true, found_zrtp=false)
	if test "$zrtp$found_zrtp" = "truefalse" ; then
		AC_MSG_ERROR("Cound not find bZRTP library.")
	fi
	if test "$found_zrtp" = "true" ; then
Simon Morlat's avatar
Simon Morlat committed
1130
		if test "$have_srtp" = "false" ; then
1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141
			if test "$zrtp" = "true" ; then
				AC_MSG_ERROR("ZRTP requires SRTP")
			else
				AC_MSG_WARN("ZRTP requires SRTP")
				zrtp=false
			fi
		else
			AC_DEFINE(HAVE_ZRTP, 1, [Defined when zrtp support is compiled])
			LIBS="$LIBS $LIBBZRTP_LIBS"
			CFLAGS="$CFLAGS $LIBBZRTP_CFLAGS"
			zrtp=true
Simon Morlat's avatar
Simon Morlat committed
1142 1143 1144
		fi
	else
		zrtp=false
1145 1146
	fi
fi
1147

1148 1149
AM_CONDITIONAL(LIBBZRTP,test x$zrtp != xfalse)

johan's avatar
johan committed
1150 1151
dnl Polarssl lib is requested for DTLS
AC_ARG_WITH( polarssl,
1152 1153 1154 1155 1156 1157
      [  --with-polarssl      Set prefix where polarssl can be found (ex:/usr, /usr/local)[[default=PREFIX or /usr if NONE]] ],
      [ polarssl_prefix=${withval}],[ if test "$prefix" != "NONE"; then
					polarssl_prefix=${prefix}
				      else
					polarssl_prefix="/usr"
				      fi ])
johan's avatar
johan committed
1158

1159 1160
found_polarssl=no

1161
if test "$polarssl_prefix" != "none" ; then
jehan's avatar
jehan committed
1162 1163 1164 1165
	if test "$polarssl_prefix" != "/usr" ; then
		POLARSSL_CFLAGS="-I${polarssl_prefix}/include"
		POLARSSL_LIBS="-L${polarssl_prefix}/lib"
	fi
johan's avatar
johan committed
1166

1167 1168
	CPPFLAGS_save=$CPPFLAGS
	LIBS_save=$LIBS
1169

1170 1171
	CPPFLAGS="$CPPFLAGS $POLARSSL_CFLAGS"
	LIBS="$LIBS $POLARSSL_LIBS"
1172 1173
	AC_CHECK_LIB(mbedtls, sha1_update , [found_polarssl=yes POLARSSL_LIBS="$POLARSSL_LIBS -lmbedtls"],
					 [AC_CHECK_LIB(polarssl, sha1_update, [found_polarssl=yes POLARSSL_LIBS="$POLARSSL_LIBS -lpolarssl"],[AC_MSG_NOTICE([polarssl library not found !])])])
1174
 
1175 1176 1177
	if test "x$found_polarssl" == "xyes" ; then
		AC_CHECK_HEADERS(polarssl/ssl.h, [found_polarssl=yes],[found_polarssl=no POLARSSL_CFLAGS="" POLARSSL_LIBS=""])
	fi
1178 1179 1180
	CPPFLAGS=$CPPFLAGS_save
	LIBS=$LIBS_save
fi
johan's avatar
johan committed
1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193

dnl check for DTLS-SRTP support, need polarssl version >= 1.4
AC_ARG_ENABLE(dtls,
	[AS_HELP_STRING([--enable-dtls], [Turn on or off compilation of dtls (default=no)])],
	[case "${enableval}" in
		yes)	dtls=true ;;
		no)	dtls=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --enable-dtls) ;;
	esac],
	[dtls=false]
)

if test "$dtls" = "true" ; then
Simon Morlat's avatar
Simon Morlat committed
1194
	if test "$have_srtp" = "false" ; then
johan's avatar
johan committed
1195 1196 1197
		AC_MSG_ERROR("DTLS-SRTP requires SRTP")
	fi

1198 1199 1200
	if test "x$found_polarssl" != "xyes" ; then
		AC_MSG_ERROR("DTLS-SRTP requires POLARSSL")
	fi
johan's avatar
johan committed
1201 1202 1203 1204 1205 1206
	dnl check for polarssl presence and support for DTLS
	CPPFLAGS_save=$CPPFLAGS
	LIBS_save=$LIBS

	CPPFLAGS="$CPPFLAGS $POLARSSL_CFLAGS"
	LIBS="$LIBS $POLARSSL_LIBS"
1207 1208 1209
	AC_LINK_IFELSE([AC_LANG_PROGRAM([[
		#include <polarssl/ssl.h>
		]],
1210 1211 1212
		[[ssl_set_dtls_srtp_protection_profiles(0,0,0)]])],
		[AC_DEFINE(HAVE_DTLS, 1, [Defined when dtls support is compiled])
		AC_MSG_NOTICE([polarssl usable for DTLS-SRTP])],[AC_MSG_ERROR([polarssl not usable for DTLS-SRTP])])
johan's avatar
johan committed
1213 1214 1215 1216 1217 1218 1219

	CPPFLAGS=$CPPFLAGS_save
	LIBS=$LIBS_save
else
	echo "DTLS-SRTP compilation is disabled."
fi

1220 1221
AC_SUBST(POLARSSL_CFLAGS)
AC_SUBST(POLARSSL_LIBS)
1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245

dnl check for bcg729 annexB presence to use for VAD/DTX (RFC3389 : Real-time Transport Protocol (RTP) Payload for Comfort Noise (CN))
AC_ARG_ENABLE(g729bCN,
	[AS_HELP_STRING([--enable-g729bCN], [Turn on or off usage of G729AnnexB in RFC3389 implementation of Comfort Noise Payload (default=no)])],
	[case "${enableval}" in
		yes)	g729bCN=true ;;
		no)	g729bCN=false ;;
		*)	AC_MSG_ERROR(bad value ${enableval} for --enable-g729bCN) ;;
	esac],
	[g729bCN=false]
)

if test "$g729bCN" = "true" ; then
	PKG_CHECK_MODULES(LIBBCG729, libbcg729 >= 1.0)

	AC_DEFINE(HAVE_G729B, 1, [Defined when use of g729AnnexB Comfort Noise and RFC3389 support is compiled])

	LIBS="$LIBS $LIBBCG729_LIBS"
	CFLAGS="$CFLAGS $LIBBCG729_CFLAGS"
else
	echo "G729 AnnexB in RFC3389 is disabled."
fi
AM_CONDITIONAL(LIBBCG729,test x$g729bCN != xfalse)

smorlat's avatar
smorlat committed
1246 1247 1248 1249
dnl ##################################################
dnl # Check for doxygen
dnl ##################################################

1250 1251
AC_ARG_ENABLE(documentation,
	[AS_HELP_STRING([--enable-documentation], [Documentation generation using doxygen (default=yes)])],
1252 1253 1254
	[case "${enableval}" in
		yes)	documentation_enabled=yes;;
		no)		documentation_enabled=no;;
1255
		*)		AC_MSG_ERROR("Bad value for --enable-documentation");;
1256 1257 1258 1259 1260 1261 1262 1263
	esac],
	[documentation_enabled=yes]
)
if test "$documentation_enabled" = "yes" ; then
	AC_CHECK_PROG(DOXYGEN,doxygen,doxygen,false)
else
	DOXYGEN=false
fi
Simon Morlat's avatar
Simon Morlat committed
1264
AC_CHECK_PROG(DOXYGEN,doxygen,doxygen,false)
1265
AM_CONDITIONAL(HAVE_DOXYGEN, test "$DOXYGEN" != "false")
smorlat's avatar
smorlat committed
1266

aymeric's avatar
aymeric committed
1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277

dnl ##################################################
dnl # Check for ESP Packager
dnl ##################################################

AC_PATH_PROG(EPM,epm,false)
AC_PATH_PROG(MKEPMLIST,mkepmlist,false)
AC_PATH_PROG(EPMINSTALL,epminstall,false)
AM_CONDITIONAL(WITH_EPM,test $EPM != false && test $MKEPMLIST != false && test $EPMINSTALL != false)


1278 1279 1280
dnl Check for xxd
AC_CHECK_PROG(xxd_found, xxd, yes)
if test "$xxd_found" != yes ;then
1281
 	AC_MSG_ERROR("xxd is required (provided by vim package)")
1282 1283
fi

aymeric's avatar
aymeric committed
1284 1285
# Preferred packaging system, as per EPM terminology
case $target in
Yann Diorcet's avatar
Yann Diorcet committed
1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298
	*-*-linux*)
		if test -f /etc/debian_version ; then
			EPM_PKG_EXT=deb
		else
			EPM_PKG_EXT=rpm
		fi
	;;
	*-hp-hpux*)
		EPM_PKG_EXT=depot.gz
	;;
	*-dec-osf*)
		EPM_PKG_EXT=setld
	;;
aymeric's avatar
aymeric committed
1299 1300 1301 1302 1303
esac
AC_SUBST(EPM_PKG_EXT)

# System software User & Group names
case $target in
Yann Diorcet's avatar
Yann Diorcet committed
1304 1305 1306
	*-*-linux*)
		SYS_USER=root
		SYS_GROUP=root
aymeric's avatar
aymeric committed
1307
	;;
Yann Diorcet's avatar
Yann Diorcet committed
1308 1309 1310
	*-*-hpux*|*-dec-osf*)
		SYS_USER=bin
		SYS_GROUP=bin
aymeric's avatar
aymeric committed
1311 1312 1313 1314 1315 1316 1317
	;;
esac
AC_SUBST(SYS_USER)
AC_SUBST(SYS_GROUP)

# CPU Architecture
case $target_cpu in
Yann Diorcet's avatar
Yann Diorcet committed
1318 1319 1320 1321 1322 1323
	i?86)
		ARCH=i386
	;;
	*)
		ARCH=$target_cpu
	;;
aymeric's avatar
aymeric committed
1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339
esac
AC_SUBST(ARCH)

# Various other packaging variables, that can be over-ridden ad `make
# package' time
SUMMARY="A mediastreaming library."
AC_SUBST(SUMMARY)
PACKAGER=anonymous
AC_SUBST(PACKAGER)
LICENSE=GPL
AC_SUBST(LICENSE)
VENDOR=Linphone
AC_SUBST(VENDOR)
RELEASE=1
AC_SUBST(RELEASE)

1340
CFLAGS="$CFLAGS $MS_PUBLIC_CFLAGS"
Simon Morlat's avatar
Simon Morlat committed
1341
CXXFLAGS="$CXXFLAGS $MS_PUBLIC_CFLAGS "
1342 1343
dnl: these ones gets exported in pkgconfig file.
AC_SUBST(MS_PUBLIC_CFLAGS)
aymeric's avatar
aymeric committed
1344

Simon Morlat's avatar
Simon Morlat committed
1345
AC_CONFIG_FILES(
Yann Diorcet's avatar
Yann Diorcet committed
1346 1347 1348 1349 1350 1351
	Makefile
	po/Makefile.in
	m4/Makefile
	include/Makefile
	include/mediastreamer2/Makefile
	src/Makefile
Ghislain MARY's avatar
Ghislain MARY committed
1352
	tools/Makefile
Yann Diorcet's avatar
Yann Diorcet committed
1353 1354 1355 1356 1357 1358 1359 1360 1361 1362
	build/Makefile
	build/win32native/Makefile
	build/win32native/mediastream/Makefile
	build/win32-novideo/Makefile
	build/wince/Makefile
	build/winmob/Makefile
	mediastreamer.pc
	mediastreamer2.spec
	help/Makefile
	help/Doxyfile
Ghislain MARY's avatar
Ghislain MARY committed
1363
	tester/Makefile
aymeric's avatar
aymeric committed
1364
)
1365

Simon Morlat's avatar
Simon Morlat committed
1366
AC_OUTPUT
Simon Morlat's avatar
Simon Morlat committed
1367 1368 1369 1370

echo "Mediastreamer2 build configuration ended."
echo "Summary of build options:"
printf "* %-30s %s\n" "Video support"		$video
Simon Morlat's avatar
Simon Morlat committed
1371
printf "* %-30s %s\n" "sRTP encryption"		$have_srtp
Simon Morlat's avatar
Simon Morlat committed
1372
printf "* %-30s %s\n" "zRTP encryption"		$zrtp
Simon Morlat's avatar
Simon Morlat committed
1373
printf "* %-30s %s\n" "SRTP-DTLS encryption"	$dtls
Simon Morlat's avatar
Simon Morlat committed
1374 1375
printf "* %-30s %s\n" "Non-free codecs" 	$non_free_codecs