You need to sign in or sign up before continuing.
configure.ac 44.4 KB
Newer Older
1
AC_PREREQ(2.60)
2

3
AC_INIT(mpd, 0.20, musicpd-dev-team@lists.sourceforge.net)
4 5

VERSION_MAJOR=0
6 7
VERSION_MINOR=20
VERSION_REVISION=0
8 9
VERSION_EXTRA=0

10
AC_CONFIG_SRCDIR([src/Main.cxx])
11
AC_CONFIG_AUX_DIR(build)
12
AM_INIT_AUTOMAKE([foreign 1.11 dist-xz subdir-objects])
13
AM_SILENT_RULES
14
AC_CONFIG_HEADERS(config.h)
15
AC_CONFIG_MACRO_DIR([m4])
Warren Dukes's avatar
Warren Dukes committed
16

17
AC_DEFINE(PROTOCOL_VERSION, "0.20.0", [The MPD protocol version])
18

19 20 21 22
GIT_COMMIT=`GIT_DIR="$srcdir/.git" git describe --dirty --always 2>/dev/null`
if test x$GIT_COMMIT != x; then
	AC_DEFINE_UNQUOTED(GIT_COMMIT, ["$GIT_COMMIT"], [The current git commit])
fi
23

24 25 26
dnl ---------------------------------------------------------------------------
dnl Programs
dnl ---------------------------------------------------------------------------
Max Kellermann's avatar
Max Kellermann committed
27
AC_PROG_CC_C99
28
AC_PROG_CXX
29
AC_PROG_RANLIB
30

31 32 33 34 35
AN_MAKEVAR([AR], [AC_PROG_AR])
AN_PROGRAM([ar], [AC_PROG_AR])
AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)])
AC_PROG_AR

36
AC_PROG_INSTALL
37
AC_PROG_MAKE_SET
38
PKG_PROG_PKG_CONFIG
39 40
AC_ARG_WITH([systemdsystemunitdir],
	    AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
41 42 43 44 45 46 47 48 49
	    [], [with_systemdsystemunitdir=no])
if test "x$with_systemdsystemunitdir" = xyes; then
	AC_MSG_CHECKING(for systemd)
	with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
	if test -z "$with_systemdsystemunitdir"; then
		AC_MSG_ERROR([Failed to detect systemd])
	fi
	AC_MSG_RESULT([$with_systemdsystemunitdir])
fi
50 51 52 53
if test "x$with_systemdsystemunitdir" != xno; then
	AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
fi
AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
54

55 56 57
dnl ---------------------------------------------------------------------------
dnl Declare Variables
dnl ---------------------------------------------------------------------------
58
AC_SUBST(AM_CPPFLAGS,"")
59
AC_SUBST(AM_CFLAGS,"")
60
AC_SUBST(AM_CXXFLAGS,"")
61

62 63 64 65 66 67
## Used for the windows resource file
AC_SUBST(VERSION_MAJOR)
AC_SUBST(VERSION_MINOR)
AC_SUBST(VERSION_REVISION)
AC_SUBST(VERSION_EXTRA)

68 69 70
dnl ---------------------------------------------------------------------------
dnl OS Specific Defaults
dnl ---------------------------------------------------------------------------
71 72
AC_CANONICAL_HOST

73
host_is_unix=yes
74
host_is_linux=no
75
host_is_android=no
76
host_is_darwin=no
77
host_is_solaris=no
78
host_is_windows=no
79

80 81
linux_auto=no

82
case "$host_os" in
83 84 85 86 87 88 89
linux-android*)
	host_is_android=yes
	host_is_linux=yes
	linux_auto=auto
	AM_CPPFLAGS="$AM_CPPFLAGS -DANDROID"
	;;

90 91 92
linux*)
	host_is_linux=yes
	linux_auto=auto
93 94 95

	dnl allow using all glibc features
	CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
96 97
	;;

98
mingw32* | windows*)
99
	AC_CONFIG_FILES([
100
		win32/res/mpd.rc
101 102
	])
	AC_CHECK_TOOL(WINDRES, windres)
103
	AM_CPPFLAGS="$AM_CPPFLAGS -DWIN32_LEAN_AND_MEAN"
104
	AM_CPPFLAGS="$AM_CPPFLAGS -DWINVER=0x0600 -D_WIN32_WINNT=0x0600"
105
	AM_CPPFLAGS="$AM_CPPFLAGS -DSTRICT"
106
	AM_CPPFLAGS="$AM_CPPFLAGS -DUNICODE -D_UNICODE"
107
	LIBS="$LIBS -lws2_32"
108
	host_is_windows=yes
109
	host_is_unix=no
110
	;;
111 112 113 114

darwin*)
	host_is_darwin=yes
	;;
115 116 117 118

solaris*)
	host_is_solaris=yes
	;;
119
esac
120 121

AM_CONDITIONAL([ANDROID], [test x$host_is_android = xyes])
122
AM_CONDITIONAL([HAVE_WINDOWS], [test x$host_is_windows = xyes])
123

124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
if test -z "$prefix" || test "x$prefix" = xNONE; then
	local_lib=
	local_include=

	# aren't autotools supposed to be smart enough to figure this out?  oh
	# well, the git-core Makefile managed to do some of the work for us :)
	case "$host_os" in
	darwin*)
		local_lib='/sw/lib /opt/local/lib'
		local_include='/sw/include /opt/local/include'
		;;
	freebsd* | openbsd*)
		local_lib=/usr/local/lib
		local_include=/usr/local/include
		;;
	netbsd*)
		local_lib=/usr/pkg/lib
		local_include=/usr/pkg/include
		LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/pkg/lib"
		;;
	esac
145

146 147 148 149 150 151 152 153
	for d in $local_lib; do
		if test -d "$d"; then
			LDFLAGS="$LDFLAGS -L$d"
			break
		fi
	done
	for d in $local_include; do
		if test -d "$d"; then
154
			CPPFLAGS="$CPPFLAGS -I$d"
155 156 157 158
			break
		fi
	done
fi
Warren Dukes's avatar
Warren Dukes committed
159

Max Kellermann's avatar
Max Kellermann committed
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
dnl ---------------------------------------------------------------------------
dnl Android
dnl ---------------------------------------------------------------------------

AC_ARG_WITH([android-sdk],
	AS_HELP_STRING([--with-android-sdk=DIR],
		[Directory for Android SDK]),
		[], [with_android_sdk=no])

if test x$host_is_android = xyes; then
	if test x$with_android_sdk = xno; then
		AC_MSG_ERROR([Android build requires option --with-android-sdk=DIR])
	fi

	if ! test -x $with_android_sdk/tools/android; then
		AC_MSG_ERROR([Android SDK not found in $with_android_sdk])
	fi
fi

AC_SUBST(ANDROID_SDK, [$with_android_sdk])

181 182 183 184 185 186 187 188 189 190 191 192 193
dnl ---------------------------------------------------------------------------
dnl Language Checks
dnl ---------------------------------------------------------------------------

AC_CXX_COMPILE_STDCXX_0X
if test "$ax_cv_cxx_compile_cxx0x_native" != yes; then
	if test "$ax_cv_cxx_compile_cxx0x_gxx" = yes; then
	   	AM_CXXFLAGS="$AM_CXXFLAGS -std=gnu++0x"
	elif test "$ax_cv_cxx_compile_cxx0x_cxx" = yes; then
	   	AM_CXXFLAGS="$AM_CXXFLAGS -std=c++0x"
	fi
fi

194 195 196
dnl ---------------------------------------------------------------------------
dnl Header/Library Checks
dnl ---------------------------------------------------------------------------
197

198 199 200 201 202
AX_PTHREAD
LIBS="$PTHREAD_LIBS $LIBS"
AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"
AM_CXXFLAGS="$AM_CXXFLAGS $PTHREAD_CFLAGS"

203 204
MPD_WITH_LIBRARY([PTHREAD],
	[AC_CHECK_FUNCS([pthread_setname_np])])
205

206 207
AC_SEARCH_LIBS([clock_gettime], [rt])

208 209 210 211
AC_ARG_ENABLE(syslog,
	AS_HELP_STRING([--enable-syslog],
		[enable syslog support (default: auto)]),,
	enable_syslog=auto)
212 213
MPD_AUTO(syslog, [syslog support], [syslog() not available],
	[AC_SEARCH_LIBS([syslog], [bsd socket inet],
214
		[found_syslog=yes],
215
		[found_syslog=no])])
216 217 218
if test x$enable_syslog = xyes; then
	AC_DEFINE(HAVE_SYSLOG, 1, [Define if syslog() is available])
fi
Max Kellermann's avatar
Max Kellermann committed
219

220 221
AC_SEARCH_LIBS([socket], [socket])
AC_SEARCH_LIBS([gethostbyname], [nsl])
222

223
if test x$host_is_linux = xyes; then
224
	AC_CHECK_FUNCS(pipe2 accept4 linkat)
225 226
fi

227
AC_CHECK_FUNCS(getpwnam_r getpwuid_r)
228
AC_CHECK_FUNCS(strndup)
229 230 231 232 233

if test x$host_is_linux = xyes; then
	MPD_OPTIONAL_FUNC(eventfd, eventfd, USE_EVENTFD)
	MPD_OPTIONAL_FUNC(signalfd, signalfd, USE_SIGNALFD)
fi
234

235 236
AC_SEARCH_LIBS([exp], [m],,
	[AC_MSG_ERROR([exp() not found])])
237 238 239 240

AC_CHECK_HEADERS(locale.h)
AC_CHECK_HEADERS(valgrind/memcheck.h)

241 242
AC_CHECK_HEADERS([sys/prctl.h], AC_CHECK_FUNCS([prctl]))

243 244 245 246
dnl ---------------------------------------------------------------------------
dnl Event loop selection
dnl ---------------------------------------------------------------------------

247
MPD_OPTIONAL_FUNC_NODEF(poll, poll)
248 249 250 251

if test x$host_is_linux = xyes; then
	MPD_OPTIONAL_FUNC_NODEF(epoll, epoll_create1)
fi
252 253 254

AC_ARG_WITH(pollmethod,
	AS_HELP_STRING(
255
		[--with-pollmethod=@<:@epoll|poll|winselect|auto@:>@],
256 257 258
		[specify poll method for internal event loop (default=auto)]),,
	[with_pollmethod=auto])

259 260 261 262 263 264 265
if test "x$with_pollmethod" = xauto; then
	if test "x$enable_epoll" = xyes; then
		with_pollmethod=epoll
	elif test "x$enable_poll" = xyes; then
		with_pollmethod=poll
	elif test "x$host_is_windows" = xyes; then
		with_pollmethod=winselect
266
	else
267
		AC_MSG_ERROR([no poll method is available for your platform])
268 269
	fi
fi
270 271 272
case "$with_pollmethod" in
epoll)
	AC_DEFINE(USE_EPOLL, 1, [Define to poll sockets with epoll])
273
	;;
274 275
poll)
	AC_DEFINE(USE_POLL, 1, [Define to poll sockets with poll])
276
	;;
277 278 279
winselect)
	AC_DEFINE(USE_WINSELECT, 1,
		[Define to poll sockets with Windows select])
280
	;;
281 282
*)
	AC_MSG_ERROR([unknown pollmethod option: $with_pollmethod])
283 284
esac

285 286 287
dnl ---------------------------------------------------------------------------
dnl Allow tools to be specifically built
dnl ---------------------------------------------------------------------------
288

289 290 291 292
AC_ARG_ENABLE(database,
	AS_HELP_STRING([--enable-database],
		[enable support for the music database]),,
	enable_database=yes)
293 294
MPD_DEFINE_CONDITIONAL(enable_database, ENABLE_DATABASE,
	[the music database])
295 296 297 298 299 300
if test x$enable_database = xyes; then
	database_auto=auto
else
	database_auto=no
fi

301 302 303 304 305 306 307 308
default_enable_daemon=yes
if test x$host_is_android = xyes || test x$host_is_android = xyes; then
	default_enable_daemon=no
fi
AC_ARG_ENABLE(daemon,
	AS_HELP_STRING([--enable-daemon],
		[enable daemonization (default: enabled)]),,
	enable_daemon=$default_enable_daemon)
309
MPD_DEFINE_CONDITIONAL(enable_daemon, ENABLE_DAEMON, [Enable daemonization?])
310

311 312 313 314 315 316 317 318 319 320
AC_ARG_ENABLE(debug,
	AS_HELP_STRING([--enable-debug],
		[enable debugging (default: disabled)]),,
	enable_debug=no)

AC_ARG_ENABLE(documentation,
	AS_HELP_STRING([--enable-documentation],
		[build documentation (default: disable)]),,
	[enable_documentation=no])

321 322 323 324 325
AC_ARG_ENABLE(dsd,
	AS_HELP_STRING([--enable-dsd],
		[enable DSD decoder (default: enable)]),,
	[enable_dsd=yes])

326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
AC_ARG_ENABLE(fifo,
	AS_HELP_STRING([--disable-fifo],
		[disable support for writing audio to a FIFO (default: enable)]),,
	enable_fifo=yes)

AC_ARG_ENABLE(httpd-output,
	AS_HELP_STRING([--enable-httpd-output],
		[enables the HTTP server output]),,
	[enable_httpd_output=auto])

AC_ARG_ENABLE(inotify,
	AS_HELP_STRING([--disable-inotify],
		[disable support Inotify automatic database update (default: enabled) ]),,
	[enable_inotify=yes])

AC_ARG_ENABLE(ipv6,
	AS_HELP_STRING([--disable-ipv6],
		[disable IPv6 support (default: enable)]),,
	[enable_ipv6=yes])

AC_SYS_LARGEFILE

348 349
AC_ARG_ENABLE(soundcloud,
	AS_HELP_STRING([--enable-soundcloud],
350 351
		[enable support for soundcloud.com]),,
	[enable_soundcloud=auto])
352

353 354 355 356 357 358 359 360 361 362 363
AC_ARG_ENABLE([libwrap],
	AS_HELP_STRING([--enable-libwrap], [use libwrap]),,
	[enable_libwrap=auto])

AC_ARG_ENABLE(mikmod,
	AS_HELP_STRING([--enable-mikmod],
		[enable the mikmod decoder (default: disable)]),,
	enable_mikmod=no)

AC_ARG_ENABLE(openal,
	AS_HELP_STRING([--enable-openal],
364 365
		[enable OpenAL support (default: auto)]),,
	enable_openal=auto)
366 367 368 369 370 371

AC_ARG_ENABLE(oss,
	AS_HELP_STRING([--disable-oss],
		[disable OSS support (default: enable)]),,
	enable_oss=yes)

372 373 374 375 376
AC_ARG_ENABLE(osx,
	AS_HELP_STRING([--enable-osx],
		[enable the OS X output plugin - unsupported! (default: disable)]),,
	enable_osx=no)

377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
AC_ARG_ENABLE(pipe-output,
	AS_HELP_STRING([--enable-pipe-output],
		[enable support for writing audio to a pipe (default: disable)]),,
	enable_pipe_output=no)

AC_ARG_ENABLE(recorder-output,
	AS_HELP_STRING([--enable-recorder-output],
		[enables the recorder file output plugin (default: disable)]),,
	[enable_recorder_output=auto])

AC_ARG_ENABLE(sidplay,
	AS_HELP_STRING([--enable-sidplay],
		[enable C64 SID support via libsidplay2]),,
	enable_sidplay=auto)

AC_ARG_ENABLE(shout,
	AS_HELP_STRING([--enable-shout],
		[enables the shoutcast streaming output]),,
	[enable_shout=auto])

397 398 399
AC_ARG_ENABLE(solaris_output,
	AS_HELP_STRING([--enable-solaris-output],
		[enables the Solaris /dev/audio output]),,
400
	[enable_solaris_output=$host_is_solaris])
401

402 403 404 405 406 407 408 409 410 411 412 413 414
AC_ARG_ENABLE(tcp,
	AS_HELP_STRING([--disable-tcp],
		[disable support for clients connecting via TCP (default: enable)]),,
	[enable_tcp=yes])

AC_ARG_ENABLE(test,
	AS_HELP_STRING([--enable-test],
		[build the test programs (default: disabled)]),,
	enable_test=no)

AC_ARG_ENABLE(un,
	AS_HELP_STRING([--disable-un],
		[disable support for clients connecting via unix domain sockets (default: enable)]),,
415
	[enable_un=$host_is_unix])
416 417

AC_ARG_ENABLE(vorbis,
418 419 420
	AS_HELP_STRING([--enable-vorbis],
		[enable Ogg Vorbis decoder]),,
	enable_vorbis=auto)
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436

AC_ARG_ENABLE(wave-encoder,
	AS_HELP_STRING([--enable-wave-encoder],
		[enable the PCM wave encoder]),,
	enable_wave_encoder=yes)

AC_ARG_ENABLE(werror,
	AS_HELP_STRING([--enable-werror],
		[treat warnings as errors (default: disabled)]),,
	enable_werror=no)

AC_ARG_WITH(zeroconf,
	AS_HELP_STRING([--with-zeroconf=@<:@auto|avahi|bonjour|no@:>@],
		[enable zeroconf backend (default=auto)]),,
	with_zeroconf="auto")

437 438 439
dnl ---------------------------------------------------------------------------
dnl Mandatory Libraries
dnl ---------------------------------------------------------------------------
440

441 442
no_exceptions=yes

443 444
AX_BOOST_BASE([1.46],, [AC_MSG_ERROR([Boost not found])])

445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461
dnl Don't disable exceptions on Boost older than 1.54, because
dnl Boost.Intrusive supports this compiler mode only since 1.54;
dnl see https://svn.boost.org/trac/boost/ticket/7849
CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@%:@include <boost/version.hpp>
]], [[
#if BOOST_VERSION < 105400
#error detected Boost older than 1.54
#endif
]])],, [no_exceptions=no])
AC_LANG_POP([C++])
CPPFLAGS="$CPPFLAGS_SAVED"

462 463 464 465 466 467 468 469 470
AC_ARG_ENABLE(icu,
	AS_HELP_STRING([--enable-icu],
		[enable libicu for Unicode (default: enabled)]),,
	enable_icu=yes)

if test x$enable_icu = xyes; then
	PKG_CHECK_MODULES([ICU], [icu-i18n],,
		[AC_MSG_ERROR([libicu not found])])
fi
471 472

MPD_DEFINE_CONDITIONAL(enable_icu, HAVE_ICU, [libicu])
473

474 475
AC_ARG_ENABLE(glib,
	AS_HELP_STRING([--enable-glib],
476 477
		[enable GLib (default: auto)]),,
	enable_glib=auto)
478

479
if test x$enable_glib != xno; then
480
	PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.32],
481 482 483 484 485
		[found_glib=yes],
		[found_glib=no])

	MPD_AUTO_RESULT([glib], [Glib], [GLib not found])
fi
486

487
if test x$enable_glib = xyes; then
488 489 490 491
	if test x$GCC = xyes; then
		# suppress warnings in the GLib headers
		GLIB_CFLAGS=`echo $GLIB_CFLAGS |sed -e 's,-I/,-isystem /,g'`
	fi
492
fi
493

494
MPD_DEFINE_CONDITIONAL(enable_glib, HAVE_GLIB, [GLib])
495

496 497 498
dnl ---------------------------------------------------------------------------
dnl Protocol Options
dnl ---------------------------------------------------------------------------
499

500 501 502 503 504 505 506 507 508 509
if test x$enable_tcp = xno; then
	# if we don't support TCP, we don't need IPv6 either
	enable_ipv6=no
fi

if test x$enable_ipv6 = xyes; then
	AC_MSG_CHECKING(for ipv6)
	AC_EGREP_CPP([AP_maGiC_VALUE],
	[
#include <sys/types.h>
510 511 512
#ifdef WIN32
#include <winsock2.h>
#else
513
#include <sys/socket.h>
514
#endif
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530
#include <netdb.h>
#ifdef PF_INET6
#ifdef AF_INET6
AP_maGiC_VALUE
#endif
#endif
	],
	AC_DEFINE(HAVE_IPV6, 1, [Define if IPv6 support present])
	AC_MSG_RESULT([yes]),
	AC_MSG_RESULT([no])
)
fi

if test x$enable_tcp = xyes; then
	AC_DEFINE(HAVE_TCP, 1, [Define if TCP socket support is enabled])
fi
531

532 533 534
if test x$enable_un = xyes; then
	AC_DEFINE(HAVE_UN, 1, [Define if unix domain socket support is enabled])
	STRUCT_UCRED
535
	AC_CHECK_FUNCS(getpeereid)
536 537
fi

538 539 540 541 542 543 544
dnl --------------------------- Post Protocol Tests ---------------------------
if
	test x$enable_tcp = xno &&
	test x$enable_un = xno; then
	AC_MSG_ERROR([No client interfaces configured!])
fi

545 546 547 548 549 550 551 552 553 554
MPD_ENABLE_AUTO(systemd_daemon, SYSTEMD_DAEMON, [systemd socket activation],
	[libsystemd not found], [$linux_auto], [
	dnl Check for libsystemd and fall back to (the older)
	dnl libsystemd-daemon
	PKG_CHECK_MODULES([SYSTEMD_DAEMON], [libsystemd],
		[found_systemd_daemon=yes],
		[PKG_CHECK_MODULES([SYSTEMD_DAEMON], [libsystemd-daemon],
			[found_systemd_daemon=yes],
			[found_systemd_daemon=no])])
])
555

556 557 558 559 560 561
dnl ---------------------------------------------------------------------------
dnl LIBC Features
dnl ---------------------------------------------------------------------------
if test x$enable_largefile != xno; then
	AC_DEFINE([ENABLE_LARGEFILE], 1, [Define if large file support is enabled])
fi
562

563
dnl ---------------------------------------------------------------------------
564
dnl Miscellaneous Libraries
565
dnl ---------------------------------------------------------------------------
566

567
dnl -------------------------------- libmpdclient --------------------------------
568 569 570 571
MPD_ENABLE_AUTO_PKG_DEPENDS(libmpdclient, LIBMPDCLIENT,
	[libmpdclient >= 2.2],
	[MPD client library], [libmpdclient not found], [],
	[enable_database], [Cannot use --enable-libmpdclient with --disable-database])
572

573
dnl -------------------------------- expat --------------------------------
574
MPD_ENABLE_AUTO_PKG(expat, EXPAT, [expat],
575 576
	[expat XML parser], [expat not found])

577
dnl --------------------------------- inotify ---------------------------------
578 579 580 581 582 583
AC_CHECK_FUNCS(inotify_init inotify_init1)

if test x$ac_cv_func_inotify_init = xno; then
	enable_inotify=no
fi

584
MPD_DEFINE_CONDITIONAL(enable_inotify, ENABLE_INOTIFY, [inotify support])
585

586
dnl --------------------------------- libwrap ---------------------------------
587 588
if test x$enable_libwrap != xno; then
	AC_CHECK_LIBWRAP(found_libwrap=yes, found_libwrap=no)
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609

	if test x$found_libwrap = xyes; then
		dnl  See if libwrap is compatible with C++; it is
		dnl  broken on many systems
		AC_MSG_CHECKING(whether libwrap is compatible with C++)
		AC_LANG_PUSH([C++])
		AC_COMPILE_IFELSE([AC_LANG_SOURCE([
			#include <tcpd.h>
			bool CheckLibWrap(int fd, const char &progname) {
				struct request_info req;
				request_init(&req, RQ_FILE, fd, RQ_DAEMON, progname, 0);
				fromhost(&req);
				return hosts_access(&req);
			}
			])],
			AC_MSG_RESULT([yes]),
			[found_libwrap=no; AC_MSG_RESULT([no]);
			AC_MSG_WARN([Your version of libwrap is broken with C++])])
		AC_LANG_POP
	fi

610 611 612 613 614 615 616 617
	MPD_AUTO_RESULT(libwrap, libwrap, [libwrap not found])
fi

if test x$enable_libwrap = xyes; then
	AC_SUBST(LIBWRAP_CFLAGS)
	AC_SUBST(LIBWRAP_LDFLAGS)
	AC_DEFINE(HAVE_LIBWRAP, 1, [define to enable libwrap library])
fi
618

619 620 621
dnl ---------------------------------------------------------------------------
dnl Metadata Plugins
dnl ---------------------------------------------------------------------------
622

623
dnl -------------------------------- libid3tag --------------------------------
624 625
MPD_ENABLE_AUTO_PKG_LIB(id3, ID3TAG,
	id3tag, id3tag, id3_file_open, [-lid3tag -lz], [],
626
	[ID3 support using libid3tag], [libid3tag not found])
627

628 629 630
dnl ---------------------------------------------------------------------------
dnl Autodiscovery
dnl ---------------------------------------------------------------------------
Max Kellermann's avatar
Max Kellermann committed
631

632 633
dnl --------------------------------- zeroconf --------------------------------

634
case $with_zeroconf in
635 636
no|bonjour)
	enable_avahi=no
637
	;;
638 639 640 641 642

avahi)
	enable_avahi=yes
	;;

643 644
*)
	with_zeroconf=auto
645
	enable_avahi=auto
646 647 648
	;;
esac

649
MPD_AUTO_PKG(avahi, AVAHI, [avahi-client dbus-1],
650
	[avahi client library], [avahi-client not found])
651 652 653
if test x$enable_avahi = xyes; then
	with_zeroconf=avahi
fi
654

655
MPD_DEFINE_CONDITIONAL(enable_avahi, HAVE_AVAHI, [Avahi Zeroconf])
656

657 658
enable_bounjour=no
if test x$with_zeroconf != xno; then
659 660
	if test x$with_zeroconf = xbonjour || test x$with_zeroconf = xauto; then
		AC_CHECK_HEADER(dns_sd.h,
661
			[enable_bonjour=yes;AC_DEFINE([HAVE_BONJOUR], 1, [Define to enable Bonjour Zeroconf support])])
662
		AC_CHECK_LIB([dns_sd], [DNSServiceRegister])
663 664
	fi

665
	if test x$enable_bonjour = xyes; then
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681
		with_zeroconf=bonjour
	elif test x$with_zeroconf = xbonjour; then
		AC_MSG_ERROR([Bonjour support requested but not found])
	fi

	if test x$with_zeroconf = xauto; then
		AC_MSG_WARN([No supported Zeroconf backend found, disabling Zeroconf])
		with_zeroconf=no
	else
		AC_DEFINE([HAVE_ZEROCONF], 1, [Define to enable Zeroconf support])
	fi
fi

AM_CONDITIONAL(HAVE_ZEROCONF, test x$with_zeroconf != xno)
AM_CONDITIONAL(HAVE_BONJOUR, test x$with_zeroconf = xbonjour)

682 683 684
dnl ---------------------------------------------------------------------------
dnl Sticker Database
dnl ---------------------------------------------------------------------------
685

686 687
dnl ---------------------------------- sqlite ---------------------------------

688
MPD_ENABLE_AUTO_PKG(sqlite, SQLITE, [sqlite3 >= 3.7.3],
689 690
	[SQLite database support], [sqlite not found],
	[$database_auto])
691

692 693 694 695 696
dnl ---------------------------------------------------------------------------
dnl Converter Plugins
dnl ---------------------------------------------------------------------------

dnl ------------------------------ libsamplerate ------------------------------
697
MPD_ENABLE_AUTO_PKG(lsr, LIBSAMPLERATE, [samplerate >= 0.1.3],
698 699
	[libsamplerate resampling], [libsamplerate not found])

700
dnl ------------------------------ libsoxr ------------------------------------
701
MPD_ENABLE_AUTO_PKG(soxr, SOXR, [soxr],
702 703
	[libsoxr resampler], [libsoxr not found])

704 705 706
dnl ---------------------------------------------------------------------------
dnl Input Plugins
dnl ---------------------------------------------------------------------------
707

708
dnl ----------------------------------- CURL ----------------------------------
709
MPD_ENABLE_AUTO_PKG(curl, CURL, [libcurl >= 7.18],
710
	[libcurl HTTP streaming], [libcurl not found])
711

712
dnl ----------------------------------- smbclient -----------------------------
713
MPD_ENABLE_AUTO_PKG_LIB(smbclient, SMBCLIENT, [smbclient >= 0.2],
714
	[smbclient], [smbc_init], [-lsmbclient], [],
715 716
	[smbclient input plugin], [libsmbclient not found])

717
dnl ----------------------------------- NFS -----------------------------
718
MPD_ENABLE_AUTO_PKG(nfs, NFS, [libnfs],
719 720
	[NFS input plugin], [libnfs not found])

721
dnl --------------------------------- Soundcloud ------------------------------
722 723
MPD_AUTO([soundcloud], [soundcloud.com support], [libyajl not found],
	[PKG_CHECK_MODULES([YAJL], [yajl >= 2.0],
724
		[found_soundcloud=yes],
725
		[found_soundcloud=no])])
726 727
MPD_DEFINE_CONDITIONAL(enable_soundcloud, ENABLE_SOUNDCLOUD,
	[soundcloud.com support])
728

729
dnl ---------------------------------- cdio ---------------------------------
730 731
MPD_ENABLE_AUTO_PKG(cdio_paranoia, CDIO_PARANOIA, [libcdio_paranoia],
	[libcdio_paranoia input plugin], [libcdio_paranoia not found])
732
if test x$enable_cdio_paranoia = xyes; then
733
	AC_CHECK_HEADERS(cdio/paranoia/paranoia.h)
734 735
fi

736
MPD_ENABLE_AUTO_PKG(mms, MMS, [libmms >= 0.4],
737
	[libmms mms:// protocol support], [libmms not found])
738

739 740 741 742 743 744
dnl ---------------------------------------------------------------------------
dnl Playlist Plugins
dnl ---------------------------------------------------------------------------

MPD_ARG_ENABLE(cue, CUE, [CUE sheet parser], yes)

745 746 747 748 749 750 751 752 753 754 755 756 757
dnl ---------------------------------------------------------------------------
dnl Neighbor Plugins
dnl ---------------------------------------------------------------------------

AC_ARG_ENABLE(neighbor-plugins,
	AS_HELP_STRING([--enable-neighbor-plugins],
		[enable support for neighbor discovery (default: auto)]),,
	[enable_neighbor_plugins=auto])

if test x$enable_neighbor_plugins = xauto; then
	if test x$enable_smbclient = xyes; then
		enable_neighbor_plugins=yes
	fi
758 759 760
	if test x$enable_upnp = xyes; then
		enable_neighbor_plugins=yes
	fi
761 762
fi

763 764
MPD_DEFINE_CONDITIONAL(enable_neighbor_plugins, ENABLE_NEIGHBOR_PLUGINS,
	[neighbor discovery])
765

766 767 768
dnl ---------------------------------------------------------------------------
dnl Archive Plugins
dnl ---------------------------------------------------------------------------
769

770
dnl --------------------------------- iso9660 ---------------------------------
771 772
MPD_ENABLE_AUTO_PKG(iso9660, ISO9660, [libiso9660],
	[libiso9660 archive plugin], [libiso9660 not found])
773 774 775 776 777 778 779 780 781

if test x$enable_iso9660 = xyes; then
	AC_PATH_PROG(MKISOFS, mkisofs, no)
else
	MKISOFS="no"
fi

AM_CONDITIONAL(ENABLE_ISO9660_TEST, test x$MKISOFS != xno)

782 783
dnl ---------------------------------- zlib ---------------------------------

784
MPD_ENABLE_AUTO_PKG(zlib, ZLIB, [zlib],
785 786
	[zlib support], [zlib not found])

787
dnl ---------------------------------- libbz2 ---------------------------------
788

789 790
MPD_ENABLE_AUTO_LIB(bzip2, BZ2, bz2, BZ2_bzDecompressInit, [-lbz2], [],
	[bzip2 archive plugin], [libbz2 not found])
791

792
if test x$enable_bzip2 = xyes; then
793 794 795
	AC_PATH_PROG(BZIP2, bzip2, no)
else
	BZIP2="no"
796
fi
797

798 799
AM_CONDITIONAL(ENABLE_BZIP2_TEST, test x$BZIP2 != xno)

800 801 802 803 804 805 806 807 808 809 810
dnl ---------------------------------- libupnp ---------------------------------

if test x$enable_expat = xno; then
	if test x$enable_upnp = xauto; then
		AC_MSG_WARN([expat disabled -- disabling UPnP])
		enable_upnp=no
	elif test x$enable_upnp = xyes; then
		AC_MSG_ERROR([expat disabled -- required for UPnP])
	fi
fi

811 812 813
MPD_ENABLE_AUTO_PKG_DEPENDS(upnp, UPNP, [libupnp],
	[UPnP client support], [libupnp not found], [],
	[enable_database], [Cannot use --enable-upnp with --disable-database])
814

815
dnl --------------------------------- libzzip ---------------------------------
816 817 818
MPD_ENABLE_AUTO_PKG(zzip, ZZIP, [zziplib >= 0.13],
	[libzzip archive library], [libzzip not found],
	[no])
819

820
if test x$enable_zzip = xyes; then
821 822 823
	AC_PATH_PROG(ZIP, zip, no)
else
	ZIP="no"
824
fi
825

826 827
AM_CONDITIONAL(ENABLE_ZZIP_TEST, test x$ZIP != xno)

828
dnl ------------------------------- Archive API -------------------------------
829
if
830
	test x$enable_bzip2 = xyes ||
831
	test x$enable_zzip = xyes ||
832
	test x$enable_iso9660 = xyes; then
833
		enable_archive=yes
834 835 836 837
else
	enable_archive=no
fi

838
MPD_DEFINE_CONDITIONAL(enable_archive, ENABLE_ARCHIVE, [the archive API])
839

840 841 842
dnl ---------------------------------------------------------------------------
dnl Decoder Plugins
dnl ---------------------------------------------------------------------------
843

844
dnl -------------------------------- libadplug --------------------------------
845
MPD_ENABLE_AUTO_PKG(adplug, ADPLUG, [adplug],
846 847
	[AdPlug decoder plugin], [libadplug not found])

848
dnl -------------------------------- audiofile --------------------------------
849
MPD_ENABLE_AUTO_PKG(audiofile, AUDIOFILE, [audiofile >= 0.3],
850
	[audiofile decoder plugin], [libaudiofile not found])
851

852 853
dnl ----------------------------------- DSD -----------------------------------

854
MPD_DEFINE_CONDITIONAL(enable_dsd, ENABLE_DSD, [DSD decoder])
855

856
dnl ----------------------------------- FAAD ----------------------------------
857 858
MPD_ENABLE_AUTO_LIB(aac, FAAD, faad, NeAACDecOpen, [-lfaad], [],
	[FAAD decoder plugin], [libfaad not found])
859

860
dnl ---------------------------------- ffmpeg ---------------------------------
861 862
MPD_ENABLE_AUTO_PKG(ffmpeg, FFMPEG,
	[libavformat >= 53.17 libavcodec >= 53.25 libavutil >= 51.17],
863 864
	[ffmpeg decoder library], [libavformat+libavcodec+libavutil not found])

865
dnl ----------------------------------- FLAC ----------------------------------
866

867
MPD_ENABLE_AUTO_PKG(flac, FLAC, [flac >= 1.2],
868 869
	[FLAC decoder], [libFLAC not found])

870
enable_flac_encoder=$enable_flac
871

872
dnl -------------------------------- FluidSynth -------------------------------
873

874 875
MPD_ENABLE_AUTO_PKG(fluidsynth, FLUIDSYNTH, [fluidsynth >= 1.1],
	[fluidsynth MIDI decoder plugin], [fluidsynth not found])
876

877
dnl ---------------------------------- libgme ---------------------------------
878 879 880 881

MPD_ENABLE_AUTO_PKG_LIB(gme, GME, [libgme],
	gme, gme_open_file, [-lgme -lstdc++], [],
	[Game Music Emulator decoder plugin], [libgme not found])
882

883
dnl ---------------------------------- libmad ---------------------------------
884
MPD_ENABLE_AUTO_PKG_LIB(mad, MAD, [mad],
885
	mad, mad_stream_init, [-lmad], [],
886
	[libmad MP3 decoder plugin], [libmad not found])
887 888 889 890 891 892 893 894

enable_shout2="$enable_shout"
MPD_AUTO_PKG(shout, SHOUT, [shout],
	[shout output plugin], [libshout not found])
if test x$enable_shout = xyes && test x$enable_shout2 = xauto; then
	enable_shout=auto
fi

895
dnl -------------------------------- libmpg123 --------------------------------
896
MPD_ENABLE_AUTO_PKG(mpg123, MPG123, [libmpg123],
897
	[libmpg123 decoder plugin], [libmpg123 not found])
898

899 900 901 902 903 904 905 906 907 908 909
dnl -------------------------------- libmikmod --------------------------------
if test x$enable_mikmod = xyes; then
	AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config)
	if test x$LIBMIKMOD_CONFIG != x ; then
		AC_SUBST(LIBMIKMOD_CFLAGS, `$LIBMIKMOD_CONFIG --cflags`)
		AC_SUBST(LIBMIKMOD_LIBS, `$LIBMIKMOD_CONFIG --libs`)
		AC_DEFINE(ENABLE_MIKMOD_DECODER, 1, [Define for mikmod support])
	else
		enable_mikmod=no
	fi
fi
910

911
AM_CONDITIONAL(ENABLE_MIKMOD_DECODER, test x$enable_mikmod = xyes)
912

913
dnl -------------------------------- libmodplug -------------------------------
914
MPD_ENABLE_AUTO_PKG(modplug, MODPLUG, [libmodplug],
915
	[modplug decoder plugin], [libmodplug not found])
916

917
dnl -------------------------------- libopus ----------------------------------
918
MPD_ENABLE_AUTO_PKG(opus, OPUS, [opus ogg],
919 920
	[opus decoder plugin], [libopus not found])

921
dnl -------------------------------- libsndfile -------------------------------
922
dnl See above test, which may disable this.
923
MPD_ENABLE_AUTO_PKG(sndfile, SNDFILE, [sndfile],
924 925
	[libsndfile decoder plugin], [libsndfile not found])

926
dnl --------------------------------- musepack --------------------------------
927

928 929
MPD_ENABLE_AUTO_LIB(mpc, MPCDEC, mpcdec, mpc_demux_init, [-lmpcdec], [],
	[Musepack decoder plugin], [libmpcdec not found])
930

931
dnl -------------------------------- Ogg Tremor -------------------------------
932

933 934 935 936 937
AC_ARG_WITH(tremor,
	AS_HELP_STRING([--with-tremor=PFX],
		[use Tremor (vorbisidec) integer Ogg Vorbis decoder (with optional prefix)]),,
	with_tremor=no)

938 939 940
AC_ARG_VAR([TREMOR_CFLAGS], [C compiler flags for Tremor])
AC_ARG_VAR([TREMOR_LIBS], [linker flags for Tremor])

941
if test x$with_tremor = xyes || test x$with_tremor = xno; then
942
	enable_tremor="$with_tremor"
943
	tremor_prefix=""
944 945
else
	tremor_prefix="$with_tremor"
946
	enable_tremor=yes
947
fi
948

949
if test x$enable_tremor = xyes; then
950
	if test x$TREMOR_CFLAGS = x && test x$tremor_prefix != x; then
951 952
		TREMOR_CFLAGS="-I$tremor_prefix/include"
	fi
953 954 955 956 957 958 959
	if test x$TREMOR_LIBS = x; then
		TREMOR_LIBS="-lvorbisidec"

		if test x$tremor_prefix != x; then
			TREMOR_LIBS="-L$tremor_prefix/lib $TREMOR_LIBS"
		fi
	fi
960 961

	MPD_WITH_LIBRARY([TREMOR],
962 963
		[AC_CHECK_FUNC([ov_read],,
			[AC_MSG_ERROR([libvorbisidec not found])])])
Warren Dukes's avatar
Warren Dukes committed
964

965 966
	AC_DEFINE(HAVE_TREMOR,1,
		[Define to use tremor (libvorbisidec) for ogg support])
967
	AC_DEFINE(ENABLE_VORBIS_DECODER, 1, [Define for Ogg Vorbis support])
968 969 970
else
	TREMOR_CFLAGS=
	TREMOR_LIBS=
971
fi
972

973
dnl -------------------------------- Ogg Vorbis -------------------------------
974 975 976

if test x$enable_tremor = xyes; then
	if test x$enable_vorbis = xyes; then
977
		AC_MSG_WARN(["OggTremor detected, could not enable Vorbis."])
978
	fi
979
	enable_vorbis=no
980 981 982 983 984

	if test x$enable_vorbis_encoder = xauto; then
		AC_MSG_WARN([OggTremor detected, disabling the Vorbis encoder plugin.])
		enable_vorbis_encoder=no
	fi
985 986
fi

987
MPD_AUTO_PKG(vorbis, VORBIS, [vorbisfile vorbis ogg],
988 989 990
	[Ogg Vorbis decoder], [libvorbis not found])
if test x$enable_vorbis = xyes; then
	AC_DEFINE(ENABLE_VORBIS_DECODER, 1, [Define for Ogg Vorbis support])
991 992
fi

993
AM_CONDITIONAL(ENABLE_VORBIS_DECODER, test x$enable_vorbis = xyes || test x$enable_tremor = xyes)
994

995 996 997 998
dnl --------------------------------- sidplay ---------------------------------
if test x$enable_sidplay != xno; then
	# we're not using pkg-config here
	# because libsidplay2's .pc file requires libtool
999 1000
	AC_CHECK_LIB([sidplay2],[main],[found_sidplay=yes],[found_sidplay=no],[])

1001 1002 1003 1004 1005
	MPD_AUTO_PRE(sidplay, [sidplay decoder plugin],
		[libsidplay2 not found])
fi

if test x$enable_sidplay != xno; then
1006
	AC_CHECK_LIB([resid-builder], [main],
1007 1008 1009
		[found_sidplay=yes], [found_sidplay=no])

	if test x$found_sidplay = xyes; then
1010
		AC_CHECK_LIB([sidutils],[main],[:],[found_sidplay=no],[])
1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025
	fi

	MPD_AUTO_RESULT(sidplay, [sidplay decoder plugin],
		[libresid-builder or libsidutils not found])
fi

if test x$enable_sidplay = xyes; then
	AC_SUBST(SIDPLAY_LIBS,"-lsidplay2 -lresid-builder -lsidutils")
	AC_SUBST(SIDPLAY_CFLAGS,)

	AC_DEFINE(ENABLE_SIDPLAY, 1, [Define for libsidplay2 support])
fi

AM_CONDITIONAL(ENABLE_SIDPLAY, test x$enable_sidplay = xyes)

1026
dnl --------------------------------- wavpack ---------------------------------
1027
MPD_ENABLE_AUTO_PKG(wavpack, WAVPACK, [wavpack],
1028 1029
	[WavPack decoder plugin], [libwavpack not found])

1030
dnl --------------------------------- WildMidi --------------------------------
1031 1032
MPD_ENABLE_AUTO_LIB(wildmidi, WILDMIDI, WildMidi, WildMidi_Init, [-lWildMidi], [],
	[WildMidi decoder plugin], [libwildmidi not found])
1033

1034 1035
dnl ------------------------ Post Decoder Plugins Tests -----------------------

1036
AM_CONDITIONAL(HAVE_XIPH,
1037
	test x$enable_vorbis = xyes || test x$enable_tremor = xyes || test x$enable_flac = xyes || test x$enable_opus = xyes)
1038

1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060
dnl ---------------------------------------------------------------------------
dnl Encoders for Streaming Audio Output Plugins
dnl ---------------------------------------------------------------------------

dnl ------------------------------- Encoder API -------------------------------
if test x$enable_shout = xyes || \
	test x$enable_recorder_output = xyes || \
	test x$enable_httpd_output = xyes; then
	# at least one output using encoders is explicitly enabled
	need_encoder=yes
elif test x$enable_shout = xauto || \
	test x$enable_recorder_output = xauto || \
	test x$enable_httpd_output = xauto; then
	need_encoder=auto
else
	# all outputs using encoders are disabled
	need_encoder=no

	# don't bother to check for encoder plugins
	enable_vorbis_encoder=no
	enable_lame_encoder=no
	enable_twolame_encoder=no
Andrée Ekroth's avatar
Andrée Ekroth committed
1061
	enable_shine_encoder=no
1062 1063 1064 1065 1066
	enable_wave_encoder=no
	enable_flac_encoder=no
fi

dnl ------------------------------- FLAC Encoder ------------------------------
1067 1068
MPD_DEFINE_CONDITIONAL(enable_flac_encoder, ENABLE_FLAC_ENCODER,
	[FLAC encoder plugin])
1069

Andrée Ekroth's avatar
Andrée Ekroth committed
1070 1071
dnl ------------------------------- Shine Encoder ------------------------------

1072
MPD_ENABLE_AUTO_PKG(shine_encoder, SHINE, [shine >= 3.1],
Andrée Ekroth's avatar
Andrée Ekroth committed
1073 1074
	[shine encoder], [libshine not found])

1075
dnl ---------------------------- Ogg Vorbis Encoder ---------------------------
1076 1077
MPD_ENABLE_AUTO_PKG(vorbis_encoder, VORBISENC, [vorbisenc vorbis ogg],
	[Ogg Vorbis encoder], [libvorbisenc not found])
1078 1079 1080

dnl ------------------------------- LAME Encoder ------------------------------

1081 1082
MPD_ENABLE_AUTO_LIB(lame_encoder, LAME, mp3lame, lame_init, [-lmp3lame], [],
	[LAME encoder plugin], [libmp3lame not found])
1083 1084

dnl ----------------------------- TwoLAME Encoder -----------------------------
1085 1086
MPD_ENABLE_AUTO_PKG(twolame_encoder, TWOLAME, [twolame],
	[TwoLAME encoder plugin], [libtwolame not found])
1087 1088

dnl ------------------------------- WAVE Encoder ------------------------------
1089 1090
MPD_DEFINE_CONDITIONAL(enable_wave_encoder, ENABLE_WAVE_ENCODER,
	[PCM wave encoder plugin])
1091 1092 1093

dnl --------------------------- encoder plugins test --------------------------
if test x$enable_vorbis_encoder != xno ||
1094
	test x$enable_opus != xno ||
1095 1096 1097
	test x$enable_lame_encoder != xno ||
	test x$enable_twolame_encoder != xno ||
	test x$enable_flac_encoder != xno ||
Andrée Ekroth's avatar
Andrée Ekroth committed
1098
	test x$enable_shine_encoder != xno ||
1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110
	test x$enable_wave_encoder != xno; then
	# at least one encoder plugin is enabled
	enable_encoder=yes
else
	# no encoder plugin is enabled: disable the whole encoder API
	enable_encoder=no

	if test x$need_encoder = xyes; then
		AC_MSG_ERROR([No encoder plugin found])
	fi
fi

1111 1112 1113
MPD_DEFINE_CONDITIONAL(enable_encoder, ENABLE_ENCODER,
		[the encoder plugins])

1114
AM_CONDITIONAL(HAVE_OGG_ENCODER, test x$enable_vorbis_encoder = xyes || test x$enable_opus = xyes)
1115 1116 1117 1118 1119 1120

dnl ---------------------------------------------------------------------------
dnl Audio Output Plugins
dnl ---------------------------------------------------------------------------

dnl ----------------------------------- ALSA ----------------------------------
1121 1122 1123
MPD_ENABLE_AUTO_PKG(alsa, ALSA, [alsa >= 0.9.0],
	[ALSA output plugin], [libasound not found],
	[$linux_auto])
1124

1125
dnl ----------------------------------- ROAR ----------------------------------
1126 1127
MPD_ENABLE_AUTO_PKG(roar, ROAR, [libroar >= 0.4.0],
	[RoarAudio output plugin], [libroar not found])
1128

1129 1130 1131
dnl ----------------------------------- FIFO ----------------------------------
if test x$enable_fifo = xyes; then
	AC_CHECK_FUNC([mkfifo],
1132
		[enable_fifo=yes],
1133 1134 1135
		[enable_fifo=no;AC_MSG_WARN([mkfifo not found -- disabling support for writing audio to a FIFO])])
fi

1136 1137
MPD_DEFINE_CONDITIONAL(enable_fifo, HAVE_FIFO,
	[support for writing audio to a FIFO])
1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150

dnl ------------------------------- HTTPD Output ------------------------------
if test x$enable_httpd_output = xauto; then
	# handle HTTPD auto-detection: disable if no encoder is
	# available
	if test x$enable_encoder = xyes; then
		enable_httpd_output=yes
	else
		AC_MSG_WARN([No encoder plugin -- disabling the HTTP output plugin])
		enable_httpd_output=no
	fi
fi

1151 1152
MPD_DEFINE_CONDITIONAL(enable_httpd_output, ENABLE_HTTPD_OUTPUT,
	[the HTTP server output])
1153 1154

dnl ----------------------------------- JACK ----------------------------------
1155 1156
MPD_ENABLE_AUTO_PKG(jack, JACK, [jack >= 0.100],
	[JACK output plugin], [libjack not found])
1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168

if test x$enable_jack = xyes; then
	# check whether jack_set_info_function() is available
	old_LIBS=$LIBS
	LIBS="$LIBS $JACK_LIBS"

	AC_CHECK_FUNCS(jack_set_info_function)

	LIBS=$old_LIBS
fi

dnl ---------------------------------- libao ----------------------------------
1169 1170
MPD_ENABLE_AUTO_PKG(ao, AO, [ao],
	[libao output plugin], [libao not found])
1171 1172 1173 1174 1175

dnl ---------------------------------- OpenAL ---------------------------------
AC_SUBST(OPENAL_CFLAGS,"")
AC_SUBST(OPENAL_LIBS,"")

1176 1177 1178 1179 1180 1181 1182 1183 1184 1185
if test x$host_is_darwin = xyes; then
	if test x$enable_openal != xno; then
		AC_CHECK_HEADERS([OpenAL/al.h OpenAL/alc.h],
			[found_openal=yes], [found_openal=no])
	fi

	MPD_AUTO_RESULT(openal, [OpenAL output plugin], [OpenAL not found])

	if test x$enable_openal = xyes; then
		OPENAL_LIBS="-framework OpenAL"
1186
	fi
1187 1188 1189 1190 1191
else
	MPD_AUTO_PKG(openal, [OPENAL], [openal],
		[OpenAL output plugin], [OpenAL not found])
fi

1192
MPD_DEFINE_CONDITIONAL(enable_openal, HAVE_OPENAL, [OpenAL support])
1193 1194 1195 1196

dnl ---------------------------- Open Sound System ----------------------------
if test x$enable_oss = xyes; then
	AC_CHECK_HEADER(sys/soundcard.h,
1197
		[enable_oss=yes],
1198 1199 1200 1201
		[AC_MSG_WARN(Soundcard headers not found -- disabling OSS support);
			enable_oss=no])
fi

1202
MPD_DEFINE_CONDITIONAL(enable_oss, HAVE_OSS, [Open Sound System])
1203 1204

dnl ----------------------------------- OSX -----------------------------------
1205 1206 1207 1208
if test x$enable_osx = xyes; then
	AC_DEFINE(HAVE_OSX, 1, [Define for compiling OS X support])
	LIBS="$LIBS -framework AudioUnit -framework CoreAudio -framework CoreServices"
fi
1209 1210 1211 1212

AM_CONDITIONAL(HAVE_OSX, test x$enable_osx = xyes)

dnl ------------------------------- Pipe Output -------------------------------
1213 1214
MPD_DEFINE_CONDITIONAL(enable_pipe_output, ENABLE_PIPE_OUTPUT,
		[support for writing audio to a pipe])
1215 1216

dnl -------------------------------- PulseAudio -------------------------------
1217
MPD_ENABLE_AUTO_PKG(pulse, PULSE, [libpulse >= 0.9.16],
1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231
	[PulseAudio output plugin], [libpulse not found])

dnl --------------------------------- Recorder --------------------------------
if test x$enable_recorder_output = xauto; then
	# handle recorder auto-detection: disable if no encoder is
	# available
	if test x$enable_encoder = xyes; then
		enable_recorder_output=yes
	else
		AC_MSG_WARN([No encoder plugin -- disabling the recorder output plugin])
		enable_recorder_output=no
	fi
fi

1232 1233
MPD_DEFINE_CONDITIONAL(enable_recorder_output, ENABLE_RECORDER_OUTPUT,
	[the recorder output])
1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246

dnl -------------------------------- SHOUTcast --------------------------------
if test x$enable_shout = xauto; then
	# handle shout auto-detection: disable if no encoder is
	# available
	if test x$enable_encoder = xyes; then
		enable_shout=yes
	else
		AC_MSG_WARN([No encoder plugin -- disabling the shout output plugin])
		enable_shout=no
	fi
fi

1247 1248
MPD_DEFINE_CONDITIONAL(enable_shout, HAVE_SHOUT,
	[shoutcast output])
1249 1250

dnl --------------------------------- Solaris ---------------------------------
1251

1252 1253
MPD_DEFINE_CONDITIONAL(enable_solaris_output, ENABLE_SOLARIS_OUTPUT,
	[Solaris /dev/audio support])
1254

1255
dnl --------------------------------- WinMM ---------------------------------
1256

1257 1258 1259 1260 1261 1262 1263
if test "x$host_is_windows" = xyes; then
	AC_DEFINE(ENABLE_WINMM_OUTPUT, 1, [Define to enable WinMM support])
	enable_winmm_output=yes
	LIBS="$LIBS -lwinmm"
else
	enable_winmm_output=no
fi
1264

1265
AM_CONDITIONAL(ENABLE_WINMM_OUTPUT, test x$enable_winmm_output = xyes)
1266

1267
dnl ---------------------------------------------------------------------------
1268
dnl Documentation
1269
dnl ---------------------------------------------------------------------------
1270 1271
if test x$enable_documentation = xyes; then
	AC_PATH_PROG(XMLTO, xmlto)
1272 1273 1274 1275
	if test x$XMLTO = x; then
		AC_MSG_ERROR([xmlto not found])
	fi

1276
	AC_SUBST(XMLTO)
1277 1278 1279 1280 1281 1282 1283

	AC_PATH_PROG(DOXYGEN, doxygen)
	if test x$DOXYGEN = x; then
		AC_MSG_ERROR([doxygen not found])
	fi

	AC_SUBST(DOXYGEN)
1284 1285
fi

1286
AM_CONDITIONAL(ENABLE_DOCUMENTATION, test x$enable_documentation = xyes)
1287

1288 1289 1290
dnl ---------------------------------------------------------------------------
dnl test suite
dnl ---------------------------------------------------------------------------
1291 1292 1293 1294 1295 1296

if test "x$enable_test" = xyes; then
	PKG_CHECK_MODULES([CPPUNIT], [cppunit],,
		[AC_MSG_ERROR([cppunit not found])])
fi

1297 1298
AM_CONDITIONAL(ENABLE_TEST, test "x$enable_test" = xyes)

1299
dnl ---------------------------------------------------------------------------
1300
dnl CFLAGS
1301
dnl ---------------------------------------------------------------------------
1302

1303 1304 1305 1306 1307 1308 1309
dnl ---------------------------- warnings as errors ---------------------------
if test "x$enable_werror" = xyes; then
	CFLAGS="$CFLAGS -Werror -pedantic-errors"
	CXXFLAGS="$CXXFLAGS -Werror"
fi

dnl ---------------------------- language features ----------------------------
1310
AX_APPEND_COMPILE_FLAGS([-fvisibility=hidden])
1311 1312
AX_APPEND_COMPILE_FLAGS([-ffast-math])
AX_APPEND_COMPILE_FLAGS([-ftree-vectorize])
1313 1314 1315 1316 1317

AC_LANG_PUSH([C++])
AX_APPEND_COMPILE_FLAGS([-fvisibility=hidden])
AX_APPEND_COMPILE_FLAGS([-fno-threadsafe-statics])
AX_APPEND_COMPILE_FLAGS([-fmerge-all-constants])
1318 1319 1320 1321 1322 1323

if test x$no_exceptions = xyes; then
	AX_APPEND_COMPILE_FLAGS([-fno-exceptions])
	AX_APPEND_COMPILE_FLAGS([-fno-rtti])
fi

1324 1325
AX_APPEND_COMPILE_FLAGS([-ffast-math])
AX_APPEND_COMPILE_FLAGS([-ftree-vectorize])
1326 1327
AC_LANG_POP

1328
dnl ---------------------------------- debug ----------------------------------
1329 1330
if test "x$enable_debug" = xno; then
	AM_CPPFLAGS="$AM_CPPFLAGS -DNDEBUG"
1331 1332 1333 1334 1335 1336 1337 1338 1339 1340

	AX_APPEND_COMPILE_FLAGS([-ffunction-sections])
	AX_APPEND_COMPILE_FLAGS([-fdata-sections])

	AC_LANG_PUSH([C++])
	AX_APPEND_COMPILE_FLAGS([-ffunction-sections])
	AX_APPEND_COMPILE_FLAGS([-fdata-sections])
	AC_LANG_POP

	AX_APPEND_LINK_FLAGS([-Wl,--gc-sections])
1341
fi
1342 1343

dnl ----------------------------------- GCC -----------------------------------
1344 1345
if test x$GCC = xyes
then
1346 1347 1348 1349 1350 1351 1352 1353 1354
	AX_APPEND_COMPILE_FLAGS([-Wall])
	AX_APPEND_COMPILE_FLAGS([-Wextra])
	AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes])
	AX_APPEND_COMPILE_FLAGS([-Wshadow])
	AX_APPEND_COMPILE_FLAGS([-Wpointer-arith])
	AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes])
	AX_APPEND_COMPILE_FLAGS([-Wcast-qual])
	AX_APPEND_COMPILE_FLAGS([-Wwrite-strings])
	AX_APPEND_COMPILE_FLAGS([-pedantic])
1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365

	AC_LANG_PUSH([C++])
	AX_APPEND_COMPILE_FLAGS([-Wall])
	AX_APPEND_COMPILE_FLAGS([-Wextra])
	AX_APPEND_COMPILE_FLAGS([-Wmissing-declarations])
	AX_APPEND_COMPILE_FLAGS([-Wshadow])
	AX_APPEND_COMPILE_FLAGS([-Wpointer-arith])
	AX_APPEND_COMPILE_FLAGS([-Wcast-qual])
	AX_APPEND_COMPILE_FLAGS([-Wwrite-strings])
	AX_APPEND_COMPILE_FLAGS([-Wsign-compare])
	AC_LANG_POP
1366 1367
fi

1368 1369 1370
dnl ---------------------------------------------------------------------------
dnl Pretty-Print Results
dnl ---------------------------------------------------------------------------
1371 1372
echo ''
echo '########### MPD CONFIGURATION ############'
1373

1374
printf '\nArchive support:\n\t'
1375 1376 1377
results(bzip2,[bzip2])
results(iso9660,[ISO9660])
results(zzip,[ZIP])
1378

1379
if test x$with_zeroconf != xno; then
1380
	printf '\nAutodiscovery support:\n\t'
1381 1382
	results(avahi, [Avahi])
	results(bonjour, [Bonjour])
1383 1384
fi

1385
printf '\nClient support:\n\t'
1386 1387 1388
results(ipv6, "IPv6")
results(tcp, "TCP")
results(un,[UNIX Domain Sockets])
1389

1390 1391 1392 1393
printf '\nStorage support:\n\t'
results(nfs, [NFS])
results(smbclient, [SMB])

1394
printf '\nFile format support:\n\t'
1395
results(aac, [AAC])
1396
results(adplug, [AdPlug])
1397
results(dsd, [DSD])
1398 1399 1400 1401 1402
results(sidplay, [C64 SID])
results(ffmpeg, [FFMPEG])
results(flac, [FLAC])
results(fluidsynth, [FluidSynth])
results(gme, [GME])
1403
printf '\n\t'
1404
results(sndfile, [libsndfile])
1405 1406 1407 1408 1409
results(mikmod, [MikMod])
results(modplug, [MODPLUG])
results(mad, [MAD])
results(mpg123, [MPG123])
results(mpc, [Musepack])
1410
printf '\n\t'
1411
results(opus, [Opus])
1412
results(tremor, [OggTremor])
1413 1414 1415 1416
results(vorbis, [OggVorbis])
results(audiofile, [WAVE])
results(wavpack, [WavPack])
results(wildmidi, [WildMidi])
1417

1418
printf '\nOther features:\n\t'
1419
results(lsr, [libsamplerate])
1420
results(soxr, [libsoxr])
1421
results(libmpdclient, [libmpdclient])
1422
results(inotify, [inotify])
1423
results(sqlite, [SQLite])
1424

1425
printf '\nMetadata support:\n\t'
1426 1427
results(id3,[ID3])

1428
printf '\nPlayback support:\n\t'
1429 1430 1431 1432 1433
results(alsa,ALSA)
results(fifo,FIFO)
results(recorder_output,[File Recorder])
results(httpd_output,[HTTP Daemon])
results(jack,[JACK])
1434
printf '\n\t'
1435 1436 1437 1438 1439
results(ao,[libao])
results(oss,[OSS])
results(openal,[OpenAL])
results(osx, [OS X])
results(pipe_output, [Pipeline])
1440
printf '\n\t'
1441
results(pulse, [PulseAudio])
1442
results(roar,[ROAR])
1443
results(shout, [SHOUTcast])
1444
results(solaris_output, [Solaris])
1445
results(winmm_output, [WinMM])
Warren Dukes's avatar
Warren Dukes committed
1446

1447 1448
if
	test x$enable_shout = xyes ||
1449
	test x$enable_recorder = xyes ||
1450
	test x$enable_httpd_output = xyes; then
1451
		printf '\nStreaming encoder support:\n\t'
1452 1453
		results(flac_encoder, [FLAC])
		results(lame_encoder, [LAME])
Andrée Ekroth's avatar
Andrée Ekroth committed
1454
		results(shine_encoder, [Shine])
1455
		results(vorbis_encoder, [Ogg Vorbis])
1456
		results(opus, [Opus])
1457 1458
		results(twolame_encoder, [TwoLAME])
		results(wave_encoder, [WAVE])
1459 1460
fi

1461
printf '\nStreaming support:\n\t'
1462
results(cdio_paranoia, [CDIO_PARANOIA])
1463
results(curl,[CURL])
1464
results(smbclient,[SMBCLIENT])
1465 1466
results(soundcloud,[Soundcloud])
printf '\n\t'
1467
results(mms,[MMS])
1468

1469
printf '\nEvent loop:\n\t'
1470
printf $with_pollmethod
1471

1472
printf '\n\n##########################################\n\n'
1473

1474
echo 'Generating files needed for compilation'
1475

1476 1477 1478
dnl ---------------------------------------------------------------------------
dnl Generate files
dnl ---------------------------------------------------------------------------
1479 1480
AC_CONFIG_FILES(Makefile)
AC_CONFIG_FILES(doc/doxygen.conf)
1481
AC_CONFIG_FILES(systemd/mpd.service)
1482
AC_OUTPUT
1483

1484
echo 'MPD is ready for compilation, type "make" to begin.'