configure.ac 45.6 KB
Newer Older
1
AC_PREREQ(2.60)
2

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

VERSION_MAJOR=0
6
VERSION_MINOR=20
7
VERSION_REVISION=19
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 14
AM_SILENT_RULES
AC_CONFIG_HEADERS(config.h)
15 16
AC_CONFIG_MACRO_DIR([m4])

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 ---------------------------------------------------------------------------
27 28
AC_PROG_CC_C99
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 37 38
AC_PROG_INSTALL
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
AC_ARG_WITH([systemdsystemunitdir],
	    AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
	    [], [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
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 58 59 60 61 62 63 64 65 66 67 68 69 70
AC_ARG_WITH([systemduserunitdir],
	    AS_HELP_STRING([--with-systemduserunitdir=DIR], [Directory for systemd service files]),
	    [], [with_systemduserunitdir=no])
if test "x$with_systemduserunitdir" = xyes; then
	AC_MSG_CHECKING(for systemd)
	with_systemduserunitdir=$($PKG_CONFIG --variable=systemduserunitdir systemd)
	if test -z "$with_systemduserunitdir"; then
		AC_MSG_ERROR([Failed to detect systemd])
	fi
	AC_MSG_RESULT([$with_systemduserunitdir])
fi
if test "x$with_systemduserunitdir" != xno; then
	AC_SUBST([systemduserunitdir], [$with_systemduserunitdir])
fi
AM_CONDITIONAL(HAVE_SYSTEMD_USER, [test -n "$with_systemduserunitdir" -a "x$with_systemduserunitdir" != xno ])

71 72 73
dnl ---------------------------------------------------------------------------
dnl Declare Variables
dnl ---------------------------------------------------------------------------
74
AC_SUBST(AM_CPPFLAGS,"")
75
AC_SUBST(AM_CFLAGS,"")
76
AC_SUBST(AM_CXXFLAGS,"")
77

78 79 80 81 82
## Used for the windows resource file
AC_SUBST(VERSION_MAJOR)
AC_SUBST(VERSION_MINOR)
AC_SUBST(VERSION_REVISION)
AC_SUBST(VERSION_EXTRA)
83

84 85 86
dnl ---------------------------------------------------------------------------
dnl OS Specific Defaults
dnl ---------------------------------------------------------------------------
87 88
AC_CANONICAL_HOST

89 90 91
host_is_unix=yes
host_is_linux=no
host_is_android=no
92
host_is_darwin=no
93 94 95 96
host_is_solaris=no
host_is_windows=no

linux_auto=no
97

98
case "$host_os" in
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
linux-android*)
	host_is_android=yes
	host_is_linux=yes
	linux_auto=auto
	AM_CPPFLAGS="$AM_CPPFLAGS -DANDROID"
	;;

linux*)
	host_is_linux=yes
	linux_auto=auto

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

114
mingw32* | windows*)
115
	AC_CONFIG_FILES([
116
		win32/res/mpd.rc
117 118
	])
	AC_CHECK_TOOL(WINDRES, windres)
119 120
	AM_CPPFLAGS="$AM_CPPFLAGS -DWIN32_LEAN_AND_MEAN"
	AM_CPPFLAGS="$AM_CPPFLAGS -DWINVER=0x0600 -D_WIN32_WINNT=0x0600"
121 122
	AM_CPPFLAGS="$AM_CPPFLAGS -DSTRICT"
	AM_CPPFLAGS="$AM_CPPFLAGS -DUNICODE -D_UNICODE"
123
	LIBS="$LIBS -lws2_32"
124 125
	host_is_windows=yes
	host_is_unix=no
126
	;;
127 128 129 130

darwin*)
	host_is_darwin=yes
	;;
131 132 133 134

solaris*)
	host_is_solaris=yes
	;;
135 136 137 138
haiku*)
	AC_CHECK_TOOL(RC, rc)
	AC_CHECK_TOOL(XRES, xres)
	;;
139
esac
140 141 142

AM_CONDITIONAL([ANDROID], [test x$host_is_android = xyes])
AM_CONDITIONAL([HAVE_WINDOWS], [test x$host_is_windows = xyes])
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173

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

	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
174
			CPPFLAGS="$CPPFLAGS -I$d"
175 176 177 178 179
			break
		fi
	done
fi

180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
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])

201 202 203 204
dnl ---------------------------------------------------------------------------
dnl Language Checks
dnl ---------------------------------------------------------------------------

205
AX_CXX_COMPILE_STDCXX_14([noext], [mandatory])
206

207 208 209
dnl ---------------------------------------------------------------------------
dnl Header/Library Checks
dnl ---------------------------------------------------------------------------
210

211 212 213 214 215 216 217 218
AX_PTHREAD
LIBS="$PTHREAD_LIBS $LIBS"
AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"
AM_CXXFLAGS="$AM_CXXFLAGS $PTHREAD_CFLAGS"

MPD_WITH_LIBRARY([PTHREAD],
	[AC_CHECK_FUNCS([pthread_setname_np])])

219
AC_SEARCH_LIBS([clock_gettime], [rt])
220

221 222 223 224 225 226 227 228 229 230 231
AC_ARG_ENABLE(syslog,
	AS_HELP_STRING([--enable-syslog],
		[enable syslog support (default: auto)]),,
	enable_syslog=auto)
MPD_AUTO(syslog, [syslog support], [syslog() not available],
	[AC_SEARCH_LIBS([syslog], [bsd socket inet],
		[found_syslog=yes],
		[found_syslog=no])])
if test x$enable_syslog = xyes; then
	AC_DEFINE(HAVE_SYSLOG, 1, [Define if syslog() is available])
fi
232

233
AC_SEARCH_LIBS([socket], [network socket])
234
AC_SEARCH_LIBS([gethostbyname], [nsl])
235

236
if test x$host_is_linux = xyes; then
237
	AC_CHECK_FUNCS(pipe2 accept4 linkat)
238 239 240
fi

AC_CHECK_FUNCS(getpwnam_r getpwuid_r)
241
AC_CHECK_FUNCS(initgroups)
242
AC_CHECK_FUNCS(fnmatch)
243
AC_CHECK_FUNCS(strndup)
244
AC_CHECK_FUNCS(strcasestr)
245 246 247 248 249

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

251 252
AC_SEARCH_LIBS([exp], [m],,
	[AC_MSG_ERROR([exp() not found])])
253 254 255 256

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

257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
AC_CHECK_HEADERS([sys/prctl.h], AC_CHECK_FUNCS([prctl]))

dnl ---------------------------------------------------------------------------
dnl Event loop selection
dnl ---------------------------------------------------------------------------

MPD_OPTIONAL_FUNC_NODEF(poll, poll)

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

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

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
	else
		AC_MSG_ERROR([no poll method is available for your platform])
	fi
fi
case "$with_pollmethod" in
epoll)
	AC_DEFINE(USE_EPOLL, 1, [Define to poll sockets with epoll])
	;;
poll)
	AC_DEFINE(USE_POLL, 1, [Define to poll sockets with poll])
	;;
winselect)
	AC_DEFINE(USE_WINSELECT, 1,
		[Define to poll sockets with Windows select])
	;;
*)
	AC_MSG_ERROR([unknown pollmethod option: $with_pollmethod])
esac

301 302 303
dnl ---------------------------------------------------------------------------
dnl Allow tools to be specifically built
dnl ---------------------------------------------------------------------------
304

305 306 307 308
AC_ARG_ENABLE(database,
	AS_HELP_STRING([--enable-database],
		[enable support for the music database]),,
	enable_database=yes)
309 310
MPD_DEFINE_CONDITIONAL(enable_database, ENABLE_DATABASE,
	[the music database])
311 312 313 314 315 316
if test x$enable_database = xyes; then
	database_auto=auto
else
	database_auto=no
fi

317 318 319 320 321 322 323 324 325
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)
MPD_DEFINE_CONDITIONAL(enable_daemon, ENABLE_DAEMON, [Enable daemonization?])
326

327 328 329 330 331 332 333 334 335 336
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])

337 338 339 340 341
AC_ARG_ENABLE(dsd,
	AS_HELP_STRING([--enable-dsd],
		[enable DSD decoder (default: enable)]),,
	[enable_dsd=yes])

342 343 344 345 346 347 348 349 350 351 352 353 354 355
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])
356 357 358 359 360 361

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

362 363
AC_SYS_LARGEFILE

364 365 366 367
AC_ARG_ENABLE(soundcloud,
	AS_HELP_STRING([--enable-soundcloud],
		[enable support for soundcloud.com]),,
	[enable_soundcloud=auto])
368 369 370 371 372 373 374 375 376 377 378 379

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],
380 381 382
		[enable OpenAL support (default: auto)]),,
	enable_openal=auto)

383 384 385 386 387
AC_ARG_ENABLE(oss,
	AS_HELP_STRING([--disable-oss],
		[disable OSS support (default: enable)]),,
	enable_oss=yes)

388 389 390 391 392
AC_ARG_ENABLE(osx,
	AS_HELP_STRING([--enable-osx],
		[enable the OS X output plugin - unsupported! (default: disable)]),,
	enable_osx=no)

393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
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])

413 414 415
AC_ARG_ENABLE(solaris_output,
	AS_HELP_STRING([--enable-solaris-output],
		[enables the Solaris /dev/audio output]),,
416
	[enable_solaris_output=$host_is_solaris])
417

418 419 420 421 422 423 424 425 426 427 428 429 430
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)]),,
431
	[enable_un=$host_is_unix])
432 433

AC_ARG_ENABLE(vorbis,
434 435 436
	AS_HELP_STRING([--enable-vorbis],
		[enable Ogg Vorbis decoder]),,
	enable_vorbis=auto)
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455

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")

dnl ---------------------------------------------------------------------------
dnl Mandatory Libraries
dnl ---------------------------------------------------------------------------
456

457
AX_BOOST_BASE([1.54],, [AC_MSG_ERROR([Boost not found])])
458 459 460

AC_ARG_ENABLE(icu,
	AS_HELP_STRING([--enable-icu],
461 462
		[enable libicu for Unicode (default: auto)]),,
	enable_icu=auto)
463

464 465
MPD_AUTO_PKG(icu, ICU, [icu-i18n], [libicu], [libicu not found])
MPD_DEFINE_CONDITIONAL(enable_icu, HAVE_ICU, [libicu])
466

467 468 469 470
AC_ARG_ENABLE(iconv,
	AS_HELP_STRING([--enable-iconv],
		[enable iconv for character set conversion (default: auto)]),,
	enable_iconv=yes)
471

472 473 474 475
if test x$enable_icu = xyes; then
	dnl We don't need iconv() if we have libicu
	enable_iconv=no
fi
476

477 478
if test x$enable_iconv = xyes; then
	AC_CHECK_FUNCS(iconv)
479 480
fi

481 482 483 484
dnl ---------------------------------------------------------------------------
dnl Protocol Options
dnl ---------------------------------------------------------------------------

485 486 487 488 489 490 491 492 493 494
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>
495
#ifdef _WIN32
496 497
#include <winsock2.h>
#else
498
#include <sys/socket.h>
499
#endif
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522
#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

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

523 524 525 526 527 528
dnl --------------------------- Post Protocol Tests ---------------------------
if
	test x$enable_tcp = xno &&
	test x$enable_un = xno; then
	AC_MSG_ERROR([No client interfaces configured!])
fi
529

530 531 532 533 534 535 536 537 538 539
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])])
])
540

541 542 543 544 545 546
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
547

548 549 550 551
dnl ---------------------------------------------------------------------------
dnl Miscellaneous Libraries
dnl ---------------------------------------------------------------------------

552
dnl -------------------------------- libmpdclient --------------------------------
553 554 555 556
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])
557

558
dnl -------------------------------- expat --------------------------------
559
MPD_ENABLE_AUTO_PKG(expat, EXPAT, [expat],
560 561
	[expat XML parser], [expat not found])

562 563 564 565 566 567 568
dnl --------------------------------- inotify ---------------------------------
AC_CHECK_FUNCS(inotify_init inotify_init1)

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

569
MPD_DEFINE_CONDITIONAL(enable_inotify, ENABLE_INOTIFY, [inotify support])
570 571 572 573

dnl --------------------------------- libwrap ---------------------------------
if test x$enable_libwrap != xno; then
	AC_CHECK_LIBWRAP(found_libwrap=yes, found_libwrap=no)
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594

	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

595 596
	MPD_AUTO_RESULT(libwrap, libwrap, [libwrap not found])
fi
597

598 599 600 601 602 603 604 605 606 607 608
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

dnl ---------------------------------------------------------------------------
dnl Metadata Plugins
dnl ---------------------------------------------------------------------------

dnl -------------------------------- libid3tag --------------------------------
609 610 611
MPD_ENABLE_AUTO_PKG_LIB(id3, ID3TAG,
	id3tag, id3tag, id3_file_open, [-lid3tag -lz], [],
	[ID3 support using libid3tag], [libid3tag not found])
612 613 614 615 616 617

dnl ---------------------------------------------------------------------------
dnl Autodiscovery
dnl ---------------------------------------------------------------------------

dnl --------------------------------- zeroconf --------------------------------
618 619

case $with_zeroconf in
620 621
no|bonjour)
	enable_avahi=no
622
	;;
623 624 625 626 627

avahi)
	enable_avahi=yes
	;;

628 629
*)
	with_zeroconf=auto
630
	enable_avahi=auto
631 632 633
	;;
esac

634
MPD_AUTO_PKG(avahi, AVAHI, [avahi-client dbus-1],
635
	[avahi client library], [avahi-client not found])
636 637 638
if test x$enable_avahi = xyes; then
	with_zeroconf=avahi
fi
639

640
MPD_DEFINE_CONDITIONAL(enable_avahi, HAVE_AVAHI, [Avahi Zeroconf])
641

642 643
enable_bounjour=no
if test x$with_zeroconf != xno; then
644 645
	if test x$with_zeroconf = xbonjour || test x$with_zeroconf = xauto; then
		AC_CHECK_HEADER(dns_sd.h,
646
			[enable_bonjour=yes;AC_DEFINE([HAVE_BONJOUR], 1, [Define to enable Bonjour Zeroconf support])])
647
		AC_CHECK_LIB([dns_sd], [DNSServiceRegister])
648 649
	fi

650
	if test x$enable_bonjour = xyes; then
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666
		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)

667 668 669 670 671
dnl ---------------------------------------------------------------------------
dnl Sticker Database
dnl ---------------------------------------------------------------------------

dnl ---------------------------------- sqlite ---------------------------------
672

673 674 675
MPD_ENABLE_AUTO_PKG(sqlite, SQLITE, [sqlite3 >= 3.7.3],
	[SQLite database support], [sqlite not found],
	[$database_auto])
676

677 678 679
dnl ---------------------------------------------------------------------------
dnl Converter Plugins
dnl ---------------------------------------------------------------------------
680

681
dnl ------------------------------ libsamplerate ------------------------------
682
MPD_ENABLE_AUTO_PKG(lsr, LIBSAMPLERATE, [samplerate >= 0.1.3],
683
	[libsamplerate resampling], [libsamplerate not found])
684

685
dnl ------------------------------ libsoxr ------------------------------------
686
MPD_ENABLE_AUTO_PKG(soxr, SOXR, [soxr],
687
	[libsoxr resampler], [libsoxr not found])
688

689 690 691 692 693
dnl ---------------------------------------------------------------------------
dnl Input Plugins
dnl ---------------------------------------------------------------------------

dnl ----------------------------------- CURL ----------------------------------
694
MPD_ENABLE_AUTO_PKG(curl, CURL, [libcurl >= 7.18],
695 696
	[libcurl HTTP streaming], [libcurl not found])

697
dnl ----------------------------------- smbclient -----------------------------
698
MPD_ENABLE_AUTO_PKG_LIB(smbclient, SMBCLIENT, [smbclient >= 0.2],
699 700 701 702
	[smbclient], [smbc_init], [-lsmbclient], [],
	[smbclient input plugin], [libsmbclient not found])

dnl ----------------------------------- NFS -----------------------------
703
MPD_ENABLE_AUTO_PKG(nfs, NFS, [libnfs],
704 705
	[NFS input plugin], [libnfs not found])

706
dnl --------------------------------- Soundcloud ------------------------------
707 708
MPD_AUTO([soundcloud], [soundcloud.com support], [libyajl not found],
	[PKG_CHECK_MODULES([YAJL], [yajl >= 2.0],
709
		[found_soundcloud=yes],
710 711 712
		[found_soundcloud=no])])
MPD_DEFINE_CONDITIONAL(enable_soundcloud, ENABLE_SOUNDCLOUD,
	[soundcloud.com support])
713 714

dnl ---------------------------------- cdio ---------------------------------
715 716
MPD_ENABLE_AUTO_PKG(cdio_paranoia, CDIO_PARANOIA, [libcdio_paranoia],
	[libcdio_paranoia input plugin], [libcdio_paranoia not found])
717
if test x$enable_cdio_paranoia = xyes; then
718
	AC_CHECK_HEADERS(cdio/paranoia/paranoia.h)
719 720
fi

721
MPD_ENABLE_AUTO_PKG(mms, MMS, [libmms >= 0.4],
722
	[libmms mms:// protocol support], [libmms not found])
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741

dnl ---------------------------------------------------------------------------
dnl Storage Plugins
dnl ---------------------------------------------------------------------------

MPD_ENABLE_AUTO(webdav, WEBDAV, [WebDAV storage plugin],
	[WebDAV requires libcurl and libexpat],
	[auto],
	[if test x$enable_curl = xyes && test x$enable_expat = xyes; then
		found_webdav=yes
	else
		found_webdav=no
	fi])

dnl ---------------------------------------------------------------------------
dnl Playlist Plugins
dnl ---------------------------------------------------------------------------

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

743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760
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
	if test x$enable_upnp = xyes; then
		enable_neighbor_plugins=yes
	fi
fi

761 762
MPD_DEFINE_CONDITIONAL(enable_neighbor_plugins, ENABLE_NEIGHBOR_PLUGINS,
	[neighbor discovery])
763

764 765 766 767 768
dnl ---------------------------------------------------------------------------
dnl Archive Plugins
dnl ---------------------------------------------------------------------------

dnl --------------------------------- iso9660 ---------------------------------
769 770
MPD_ENABLE_AUTO_PKG(iso9660, ISO9660, [libiso9660],
	[libiso9660 archive plugin], [libiso9660 not found])
771

772 773 774 775 776 777 778
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)
779

780 781
dnl ---------------------------------- zlib ---------------------------------

782
MPD_ENABLE_AUTO_PKG(zlib, ZLIB, [zlib],
783 784
	[zlib support], [zlib not found])

785
dnl ---------------------------------- libbz2 ---------------------------------
786

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

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

796
AM_CONDITIONAL(ENABLE_BZIP2_TEST, test x$BZIP2 != xno)
797

798 799 800 801 802 803 804 805 806 807 808
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

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

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

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

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

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

836
MPD_DEFINE_CONDITIONAL(enable_archive, ENABLE_ARCHIVE, [the archive API])
837

838 839 840
dnl ---------------------------------------------------------------------------
dnl Decoder Plugins
dnl ---------------------------------------------------------------------------
841

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

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

850 851
dnl ----------------------------------- DSD -----------------------------------

852
MPD_DEFINE_CONDITIONAL(enable_dsd, ENABLE_DSD, [DSD decoder])
853

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

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

863
dnl ----------------------------------- FLAC ----------------------------------
864

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

868 869 870
enable_flac_encoder=$enable_flac

dnl -------------------------------- FluidSynth -------------------------------
871

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

dnl ---------------------------------- libgme ---------------------------------
876 877 878 879

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

881
dnl ---------------------------------- libmad ---------------------------------
882
MPD_ENABLE_AUTO_PKG_LIB(mad, MAD, [mad],
883
	mad, mad_stream_init, [-lmad], [],
884 885
	[libmad MP3 decoder plugin], [libmad not found])

886 887 888 889 890 891 892 893
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

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

897
dnl -------------------------------- libmikmod --------------------------------
898 899 900 901 902 903 904 905 906 907 908 909 910
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

AM_CONDITIONAL(ENABLE_MIKMOD_DECODER, test x$enable_mikmod = xyes)

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

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

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

924
dnl --------------------------------- musepack --------------------------------
925

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

929
dnl -------------------------------- Ogg Tremor -------------------------------
930 931 932 933 934 935 936 937 938

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

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

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

947
if test x$enable_tremor = xyes; then
948
	if test x$TREMOR_CFLAGS = x && test x$tremor_prefix != x; then
949 950
		TREMOR_CFLAGS="-I$tremor_prefix/include"
	fi
951 952 953 954 955 956 957 958 959 960 961
	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

	MPD_WITH_LIBRARY([TREMOR],
		[AC_CHECK_FUNC([ov_read],,
			[AC_MSG_ERROR([libvorbisidec not found])])])
962 963 964

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

971
dnl -------------------------------- Ogg Vorbis -------------------------------
972 973 974

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

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

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

991
AM_CONDITIONAL(ENABLE_VORBIS_DECODER, test x$enable_vorbis = xyes || test x$enable_tremor = xyes)
992

993 994
dnl --------------------------------- sidplay ---------------------------------
if test x$enable_sidplay != xno; then
995
	dnl Check for libsidplayfp first
996
	PKG_CHECK_MODULES([SIDPLAY], [libsidplayfp],
997 998 999 1000 1001 1002 1003 1004 1005
		[found_sidplayfp=yes],
		[found_sidplayfp=no])
	found_sidplay=$found_sidplayfp
fi

if test x$enable_sidplay != xno && test x$found_sidplayfp = xno; then
	PKG_CHECK_MODULES([SIDPLAY], [libsidplay2 libsidutils],
		[found_sidplay=yes],
		[found_sidplay=no])
1006

1007 1008
	MPD_AUTO_PRE(sidplay, [sidplay decoder plugin],
		[libsidplay2 not found])
1009 1010
fi

1011
if test x$enable_sidplay != xno && test x$found_sidplayfp = xno; then
1012
	AC_CHECK_LIB([resid-builder], [main],
1013 1014 1015
		[found_sidplay=yes], [found_sidplay=no])

	MPD_AUTO_RESULT(sidplay, [sidplay decoder plugin],
1016
		[libresid-builder not found])
1017 1018
fi

1019
if test x$enable_sidplay = xyes; then
1020
	SIDPLAY_LIBS="$SIDPLAY_LIBS -lresid-builder"
1021
	AC_DEFINE(ENABLE_SIDPLAY, 1, [Define for libsidplay2 support])
1022 1023 1024
	if test x$found_sidplayfp = xyes; then
		AC_DEFINE(HAVE_SIDPLAYFP, 1, [Define if libsidplayfp is used instead of libsidplay2])
	fi
1025 1026
fi

1027
AM_CONDITIONAL(ENABLE_SIDPLAY, test x$enable_sidplay = xyes)
1028

1029
dnl --------------------------------- wavpack ---------------------------------
1030
MPD_ENABLE_AUTO_PKG(wavpack, WAVPACK, [wavpack],
1031 1032 1033
	[WavPack decoder plugin], [libwavpack not found])

dnl --------------------------------- WildMidi --------------------------------
1034 1035
MPD_ENABLE_AUTO_LIB(wildmidi, WILDMIDI, WildMidi, WildMidi_Init, [-lWildMidi], [],
	[WildMidi decoder plugin], [libwildmidi not found])
1036

1037 1038 1039
dnl ---------------------------------------------------------------------------
dnl Encoders for Streaming Audio Output Plugins
dnl ---------------------------------------------------------------------------
1040

1041 1042 1043 1044
dnl ------------------------------- Encoder API -------------------------------
if test x$enable_shout = xyes || \
	test x$enable_recorder_output = xyes || \
	test x$enable_httpd_output = xyes; then
1045 1046
	# at least one output using encoders is explicitly enabled
	need_encoder=yes
1047 1048 1049
elif test x$enable_shout = xauto || \
	test x$enable_recorder_output = xauto || \
	test x$enable_httpd_output = xauto; then
1050 1051 1052 1053 1054 1055 1056 1057
	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
1058
	enable_twolame_encoder=no
1059
	enable_shine_encoder=no
1060 1061
	enable_wave_encoder=no
	enable_flac_encoder=no
1062 1063
fi

1064
dnl ------------------------------- FLAC Encoder ------------------------------
1065 1066
MPD_DEFINE_CONDITIONAL(enable_flac_encoder, ENABLE_FLAC_ENCODER,
	[FLAC encoder plugin])
1067

1068 1069
dnl ------------------------------- Shine Encoder ------------------------------

1070
MPD_ENABLE_AUTO_PKG(shine_encoder, SHINE, [shine >= 3.1],
1071 1072
	[shine encoder], [libshine not found])

1073
dnl ---------------------------- Ogg Vorbis Encoder ---------------------------
1074
MPD_ENABLE_AUTO_PKG(vorbis_encoder, VORBISENC, [vorbisenc vorbis ogg],
1075
	[Ogg Vorbis encoder], [libvorbisenc not found])
1076

1077
dnl ------------------------------- LAME Encoder ------------------------------
1078

1079 1080
MPD_ENABLE_AUTO_LIB(lame_encoder, LAME, mp3lame, lame_init, [-lmp3lame], [],
	[LAME encoder plugin], [libmp3lame not found])
1081

1082
dnl ----------------------------- TwoLAME Encoder -----------------------------
1083 1084
MPD_ENABLE_AUTO_PKG(twolame_encoder, TWOLAME, [twolame],
	[TwoLAME encoder plugin], [libtwolame not found])
1085

1086
dnl ------------------------------- WAVE Encoder ------------------------------
1087 1088
MPD_DEFINE_CONDITIONAL(enable_wave_encoder, ENABLE_WAVE_ENCODER,
	[PCM wave encoder plugin])
1089

1090 1091
dnl --------------------------- encoder plugins test --------------------------
if test x$enable_vorbis_encoder != xno ||
1092
	test x$enable_opus != xno ||
1093 1094 1095
	test x$enable_lame_encoder != xno ||
	test x$enable_twolame_encoder != xno ||
	test x$enable_flac_encoder != xno ||
1096
	test x$enable_shine_encoder != xno ||
1097 1098 1099 1100 1101 1102
	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
1103

1104 1105 1106
	if test x$need_encoder = xyes; then
		AC_MSG_ERROR([No encoder plugin found])
	fi
1107 1108
fi

1109 1110
MPD_DEFINE_CONDITIONAL(enable_encoder, ENABLE_ENCODER,
		[the encoder plugins])
1111

1112 1113 1114
dnl ---------------------------------------------------------------------------
dnl Audio Output Plugins
dnl ---------------------------------------------------------------------------
1115

1116
dnl ----------------------------------- ALSA ----------------------------------
1117 1118 1119
MPD_ENABLE_AUTO_PKG(alsa, ALSA, [alsa >= 0.9.0],
	[ALSA output plugin], [libasound not found],
	[$linux_auto])
1120

1121
dnl ----------------------------------- ROAR ----------------------------------
1122 1123
MPD_ENABLE_AUTO_PKG(roar, ROAR, [libroar >= 0.4.0],
	[RoarAudio output plugin], [libroar not found])
1124

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

1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145
MPD_DEFINE_CONDITIONAL(enable_fifo, HAVE_FIFO,
	[support for writing audio to a FIFO])

dnl ----------------------------------- SNDIO ----------------------------------
MPD_ENABLE_AUTO_HEADER([sndio], [SNDIO], [sndio.h],
	[-lsndio], [],
	[sndio output plugin],
	[libsndio not found])

dnl ----------------------------------- Haiku ---------------------------------
MPD_ENABLE_AUTO_HEADER([haiku], [HAIKU], [media/MediaDefs.h],
	[-lbe -lmedia], [],
	[Haiku output plugin],
	[Haiku headers not found])
1146

1147 1148 1149 1150 1151 1152 1153 1154 1155 1156
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
1157 1158
fi

1159 1160
MPD_DEFINE_CONDITIONAL(enable_httpd_output, ENABLE_HTTPD_OUTPUT,
	[the HTTP server output])
1161

1162
dnl ----------------------------------- JACK ----------------------------------
1163
MPD_ENABLE_AUTO_PKG(jack, JACK, [jack >= 0.100],
1164
	[JACK output plugin], [libjack not found])
1165

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

1171
	AC_CHECK_FUNCS(jack_set_info_function)
1172

1173
	LIBS=$old_LIBS
1174 1175
fi

1176
dnl ---------------------------------- libao ----------------------------------
1177
MPD_ENABLE_AUTO_PKG(ao, AO, [ao],
1178
	[libao output plugin], [libao not found])
1179

1180 1181 1182
dnl ---------------------------------- OpenAL ---------------------------------
AC_SUBST(OPENAL_CFLAGS,"")
AC_SUBST(OPENAL_LIBS,"")
1183

1184 1185 1186 1187 1188 1189 1190 1191 1192 1193
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"
1194
	fi
1195 1196 1197 1198 1199
else
	MPD_AUTO_PKG(openal, [OPENAL], [openal],
		[OpenAL output plugin], [OpenAL not found])
fi

1200
MPD_DEFINE_CONDITIONAL(enable_openal, HAVE_OPENAL, [OpenAL support])
1201

1202 1203 1204
dnl ---------------------------- Open Sound System ----------------------------
if test x$enable_oss = xyes; then
	AC_CHECK_HEADER(sys/soundcard.h,
1205
		[enable_oss=yes],
1206 1207
		[AC_MSG_WARN(Soundcard headers not found -- disabling OSS support);
			enable_oss=no])
1208 1209
fi

1210
MPD_DEFINE_CONDITIONAL(enable_oss, HAVE_OSS, [Open Sound System])
1211

1212
dnl ----------------------------------- OSX -----------------------------------
1213 1214 1215 1216
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
1217

1218
AM_CONDITIONAL(HAVE_OSX, test x$enable_osx = xyes)
1219

1220
dnl ------------------------------- Pipe Output -------------------------------
1221 1222
MPD_DEFINE_CONDITIONAL(enable_pipe_output, ENABLE_PIPE_OUTPUT,
		[support for writing audio to a pipe])
1223

1224
dnl -------------------------------- PulseAudio -------------------------------
1225
MPD_ENABLE_AUTO_PKG(pulse, PULSE, [libpulse >= 0.9.16],
1226
	[PulseAudio output plugin], [libpulse not found])
1227

1228 1229 1230 1231 1232 1233 1234 1235 1236 1237
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
1238 1239
fi

1240 1241
MPD_DEFINE_CONDITIONAL(enable_recorder_output, ENABLE_RECORDER_OUTPUT,
	[the recorder output])
1242

1243 1244 1245 1246 1247 1248
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
1249
	else
1250 1251
		AC_MSG_WARN([No encoder plugin -- disabling the shout output plugin])
		enable_shout=no
1252 1253 1254
	fi
fi

1255 1256
MPD_DEFINE_CONDITIONAL(enable_shout, HAVE_SHOUT,
	[shoutcast output])
1257

1258
dnl --------------------------------- Solaris ---------------------------------
1259

1260 1261
MPD_DEFINE_CONDITIONAL(enable_solaris_output, ENABLE_SOLARIS_OUTPUT,
	[Solaris /dev/audio support])
1262 1263 1264

dnl --------------------------------- WinMM ---------------------------------

1265 1266 1267 1268 1269 1270 1271
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
1272

1273
AM_CONDITIONAL(ENABLE_WINMM_OUTPUT, test x$enable_winmm_output = xyes)
1274

1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295
dnl ---------------------------------------------------------------------------
dnl Option groups
dnl ---------------------------------------------------------------------------

have_ogg=no
if test x$enable_vorbis = xyes || test x$enable_tremor = xyes || test x$enable_opus = xyes || test x$enable_vorbis_encoder = xyes; then
	have_ogg=yes
fi

have_xiph=no
if test x$have_ogg = xyes || test x$enable_flac = xyes || test x$enable_flac_encoder = xyes; then
	have_xiph=yes
fi

if test x$have_ogg = xyes; then
	PKG_CHECK_MODULES([OGG], [ogg],, [AC_MSG_ERROR([libogg not found])])
fi

AM_CONDITIONAL(HAVE_OGG, test x$have_ogg = xyes)
AM_CONDITIONAL(HAVE_XIPH, test x$have_xiph = xyes)

1296 1297 1298 1299 1300
dnl ---------------------------------------------------------------------------
dnl Documentation
dnl ---------------------------------------------------------------------------
if test x$enable_documentation = xyes; then
	AC_PATH_PROG(XMLTO, xmlto)
1301 1302 1303 1304
	if test x$XMLTO = x; then
		AC_MSG_ERROR([xmlto not found])
	fi

1305
	AC_SUBST(XMLTO)
1306

1307 1308 1309 1310
	AC_PATH_PROG(DOXYGEN, doxygen)
	if test x$DOXYGEN = x; then
		AC_MSG_ERROR([doxygen not found])
	fi
1311

1312
	AC_SUBST(DOXYGEN)
1313 1314
fi

1315
AM_CONDITIONAL(ENABLE_DOCUMENTATION, test x$enable_documentation = xyes)
1316

1317 1318 1319
dnl ---------------------------------------------------------------------------
dnl test suite
dnl ---------------------------------------------------------------------------
1320 1321 1322 1323 1324 1325

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

1326
AM_CONDITIONAL(ENABLE_TEST, test "x$enable_test" = xyes)
1327

1328 1329 1330
dnl ---------------------------------------------------------------------------
dnl CFLAGS
dnl ---------------------------------------------------------------------------
1331

1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350
dnl ---------------------------- warnings as errors ---------------------------
if test "x$enable_werror" = xyes; then
	CFLAGS="$CFLAGS -Werror -pedantic-errors"
	CXXFLAGS="$CXXFLAGS -Werror"
fi

dnl ---------------------------- language features ----------------------------
AX_APPEND_COMPILE_FLAGS([-fvisibility=hidden])
AX_APPEND_COMPILE_FLAGS([-ffast-math])
AX_APPEND_COMPILE_FLAGS([-ftree-vectorize])

AC_LANG_PUSH([C++])
AX_APPEND_COMPILE_FLAGS([-fvisibility=hidden])
AX_APPEND_COMPILE_FLAGS([-fno-threadsafe-statics])
AX_APPEND_COMPILE_FLAGS([-fmerge-all-constants])
AX_APPEND_COMPILE_FLAGS([-ffast-math])
AX_APPEND_COMPILE_FLAGS([-ftree-vectorize])
AC_LANG_POP

1351
dnl ---------------------------------- debug ----------------------------------
1352 1353
if test "x$enable_debug" = xno; then
	AM_CPPFLAGS="$AM_CPPFLAGS -DNDEBUG"
1354 1355 1356 1357 1358 1359 1360 1361 1362 1363

	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])
1364
fi
1365

1366 1367 1368
dnl ----------------------------------- GCC -----------------------------------
if test x$GCC = xyes
then
1369 1370 1371 1372 1373 1374 1375 1376 1377
	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])
1378

1379 1380 1381 1382 1383 1384 1385 1386 1387
	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])
1388 1389 1390 1391 1392

	dnl This GCC8 warning for C++17 ABI compatibility is of no
	dnl interest for us, because we're not a shared library.
	AX_APPEND_COMPILE_FLAGS([-Wno-noexcept-type])

1393
	AC_LANG_POP
1394 1395
fi

1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406
dnl ---------------------------------------------------------------------------
dnl Pretty-Print Results
dnl ---------------------------------------------------------------------------
echo ''
echo '########### MPD CONFIGURATION ############'

printf '\nArchive support:\n\t'
results(bzip2,[bzip2])
results(iso9660,[ISO9660])
results(zzip,[ZIP])

1407
if test x$with_zeroconf != xno; then
1408 1409 1410 1411 1412 1413 1414 1415 1416 1417
	printf '\nAutodiscovery support:\n\t'
	results(avahi, [Avahi])
	results(bonjour, [Bonjour])
fi

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

1418 1419 1420 1421
printf '\nStorage support:\n\t'
results(nfs, [NFS])
results(smbclient, [SMB])

1422 1423
printf '\nFile format support:\n\t'
results(aac, [AAC])
1424
results(adplug, [AdPlug])
1425
results(dsd, [DSD])
1426 1427 1428 1429 1430 1431
results(sidplay, [C64 SID])
results(ffmpeg, [FFMPEG])
results(flac, [FLAC])
results(fluidsynth, [FluidSynth])
results(gme, [GME])
printf '\n\t'
1432
results(sndfile, [libsndfile])
1433 1434 1435 1436 1437 1438
results(mikmod, [MikMod])
results(modplug, [MODPLUG])
results(mad, [MAD])
results(mpg123, [MPG123])
results(mpc, [Musepack])
printf '\n\t'
1439
results(opus, [Opus])
1440 1441 1442 1443 1444 1445 1446 1447
results(tremor, [OggTremor])
results(vorbis, [OggVorbis])
results(audiofile, [WAVE])
results(wavpack, [WavPack])
results(wildmidi, [WildMidi])

printf '\nOther features:\n\t'
results(lsr, [libsamplerate])
1448
results(soxr, [libsoxr])
1449
results(libmpdclient, [libmpdclient])
1450 1451 1452 1453 1454 1455 1456 1457 1458
results(inotify, [inotify])
results(sqlite, [SQLite])

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

printf '\nPlayback support:\n\t'
results(alsa,ALSA)
results(fifo,FIFO)
1459
results(sndio,[SNDIO])
1460
results(recorder_output,[File Recorder])
1461
results(haiku,[Haiku])
1462 1463
results(httpd_output,[HTTP Daemon])
results(jack,[JACK])
1464
printf '\n\t'
1465 1466 1467 1468 1469
results(ao,[libao])
results(oss,[OSS])
results(openal,[OpenAL])
results(osx, [OS X])
results(pipe_output, [Pipeline])
1470
printf '\n\t'
1471
results(pulse, [PulseAudio])
1472
results(roar,[ROAR])
1473
results(shout, [SHOUTcast])
1474
results(solaris_output, [Solaris])
1475
results(winmm_output, [WinMM])
1476

1477 1478 1479 1480 1481 1482 1483
if
	test x$enable_shout = xyes ||
	test x$enable_recorder = xyes ||
	test x$enable_httpd_output = xyes; then
		printf '\nStreaming encoder support:\n\t'
		results(flac_encoder, [FLAC])
		results(lame_encoder, [LAME])
1484
		results(shine_encoder, [Shine])
1485
		results(vorbis_encoder, [Ogg Vorbis])
1486
		results(opus, [Opus])
1487 1488
		results(twolame_encoder, [TwoLAME])
		results(wave_encoder, [WAVE])
1489 1490
fi

1491
printf '\nStreaming support:\n\t'
1492
results(cdio_paranoia, [CDIO_PARANOIA])
1493
results(curl,[CURL])
1494
results(smbclient,[SMBCLIENT])
1495 1496
results(soundcloud,[Soundcloud])
printf '\n\t'
1497
results(mms,[MMS])
1498

1499 1500 1501
printf '\nEvent loop:\n\t'
printf $with_pollmethod

1502
printf '\n\n##########################################\n\n'
1503

1504
echo 'Generating files needed for compilation'
1505

1506 1507 1508
dnl ---------------------------------------------------------------------------
dnl Generate files
dnl ---------------------------------------------------------------------------
1509 1510
AC_CONFIG_FILES(Makefile)
AC_CONFIG_FILES(doc/doxygen.conf)
1511 1512
AC_CONFIG_FILES(systemd/system/mpd.service)
AC_CONFIG_FILES(systemd/user/mpd.service)
1513
AC_OUTPUT
1514

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