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

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

VERSION_MAJOR=0
6 7
VERSION_MINOR=21
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.21.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 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 83
## Used for the windows resource file
AC_SUBST(VERSION_MAJOR)
AC_SUBST(VERSION_MINOR)
AC_SUBST(VERSION_REVISION)
AC_SUBST(VERSION_EXTRA)

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

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

96 97
linux_auto=no

98
case "$host_os" in
99 100 101 102 103 104 105
linux-android*)
	host_is_android=yes
	host_is_linux=yes
	linux_auto=auto
	AM_CPPFLAGS="$AM_CPPFLAGS -DANDROID"
	;;

106 107 108
linux*)
	host_is_linux=yes
	linux_auto=auto
109 110 111

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

114
mingw32* | windows*)
115
	AC_CONFIG_FILES([
116
		win32/res/mpd.rc
117 118
	])
	AC_CHECK_TOOL(WINDRES, windres)
119
	AM_CPPFLAGS="$AM_CPPFLAGS -DWIN32_LEAN_AND_MEAN"
120
	AM_CPPFLAGS="$AM_CPPFLAGS -DWINVER=0x0600 -D_WIN32_WINNT=0x0600"
121
	AM_CPPFLAGS="$AM_CPPFLAGS -DSTRICT"
122
	AM_CPPFLAGS="$AM_CPPFLAGS -DUNICODE -D_UNICODE"
123
	LIBS="$LIBS -lws2_32"
124
	host_is_windows=yes
125
	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

AM_CONDITIONAL([ANDROID], [test x$host_is_android = xyes])
142
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
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
165

166 167 168 169 170 171 172 173
	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
			break
		fi
	done
fi
Warren Dukes's avatar
Warren Dukes committed
179

Max Kellermann's avatar
Max Kellermann committed
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
AX_PTHREAD
LIBS="$PTHREAD_LIBS $LIBS"
AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"
AM_CXXFLAGS="$AM_CXXFLAGS $PTHREAD_CFLAGS"

216 217
MPD_WITH_LIBRARY([PTHREAD],
	[AC_CHECK_FUNCS([pthread_setname_np])])
218

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

221 222 223 224
AC_ARG_ENABLE(syslog,
	AS_HELP_STRING([--enable-syslog],
		[enable syslog support (default: auto)]),,
	enable_syslog=auto)
225 226
MPD_AUTO(syslog, [syslog support], [syslog() not available],
	[AC_SEARCH_LIBS([syslog], [bsd socket inet],
227
		[found_syslog=yes],
228
		[found_syslog=no])])
229 230 231
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
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
fi

240
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
AC_CHECK_HEADERS([sys/prctl.h], AC_CHECK_FUNCS([prctl]))

259 260 261 262
dnl ---------------------------------------------------------------------------
dnl Event loop selection
dnl ---------------------------------------------------------------------------

263
MPD_OPTIONAL_FUNC_NODEF(poll, poll)
264 265 266 267

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

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

275 276 277 278 279 280 281
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
282
	else
283
		AC_MSG_ERROR([no poll method is available for your platform])
284 285
	fi
fi
286 287 288
case "$with_pollmethod" in
epoll)
	AC_DEFINE(USE_EPOLL, 1, [Define to poll sockets with epoll])
289
	;;
290 291
poll)
	AC_DEFINE(USE_POLL, 1, [Define to poll sockets with poll])
292
	;;
293 294 295
winselect)
	AC_DEFINE(USE_WINSELECT, 1,
		[Define to poll sockets with Windows select])
296
	;;
297 298
*)
	AC_MSG_ERROR([unknown pollmethod option: $with_pollmethod])
299 300
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
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)
325
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 356 357 358 359 360 361 362 363
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

364 365
AC_ARG_ENABLE(soundcloud,
	AS_HELP_STRING([--enable-soundcloud],
366 367
		[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
		[enable OpenAL support (default: auto)]),,
	enable_openal=auto)
382 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

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

453 454 455
dnl ---------------------------------------------------------------------------
dnl Mandatory Libraries
dnl ---------------------------------------------------------------------------
456

457 458
AX_BOOST_BASE([1.46],, [AC_MSG_ERROR([Boost not found])])

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

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

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

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

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

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

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
#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
516

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

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

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
dnl ---------------------------------------------------------------------------
549
dnl Miscellaneous Libraries
550
dnl ---------------------------------------------------------------------------
551

552
dnl -------------------------------- libmpdclient --------------------------------
553 554 555
MPD_ENABLE_AUTO_PKG_DEPENDS(libmpdclient, LIBMPDCLIENT,
	[libmpdclient >= 2.2],
	[MPD client library], [libmpdclient not found], [],
556
	[enable_database], [Database support is disabled])
557

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

562
dnl --------------------------------- inotify ---------------------------------
563 564 565 566 567 568
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
dnl --------------------------------- libwrap ---------------------------------
572 573
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 597 598 599 600 601 602
	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
603

604 605 606
dnl ---------------------------------------------------------------------------
dnl Metadata Plugins
dnl ---------------------------------------------------------------------------
607

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

613 614 615
dnl ---------------------------------------------------------------------------
dnl Autodiscovery
dnl ---------------------------------------------------------------------------
Max Kellermann's avatar
Max Kellermann committed
616

617 618
dnl --------------------------------- zeroconf --------------------------------

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
dnl ---------------------------------------------------------------------------
dnl Sticker Database
dnl ---------------------------------------------------------------------------
670

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

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

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

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

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

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

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

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

702
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
		[found_soundcloud=no])])
711 712
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
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])

737 738 739 740 741 742
dnl ---------------------------------------------------------------------------
dnl Playlist Plugins
dnl ---------------------------------------------------------------------------

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

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

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

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

768
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 779

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)

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
fi
795

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

798 799
dnl ---------------------------------- libupnp ---------------------------------

800 801
MPD_ENABLE_AUTO_PKG_DEPENDS(upnp, UPNP, [libupnp],
	[UPnP client support], [libupnp not found], [],
802
	[enable_database], [Database support is disabled], [
803 804 805
		MPD_DEPENDS([enable_upnp], [enable_curl],
			[UPnP client support],
			[UPnP requires CURL])
806 807 808 809 810
		MPD_DEPENDS([enable_upnp], [enable_expat],
			[UPnP client support],
			[UPnP requires expat])
	]
)
811

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

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

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

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

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

837 838 839
dnl ---------------------------------------------------------------------------
dnl Decoder Plugins
dnl ---------------------------------------------------------------------------
840

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

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

849 850
dnl ----------------------------------- DSD -----------------------------------

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

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

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

862
dnl ----------------------------------- FLAC ----------------------------------
863

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

867
enable_flac_encoder=$enable_flac
868

869
dnl -------------------------------- FluidSynth -------------------------------
870

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

874
dnl ---------------------------------- libgme ---------------------------------
875 876

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

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

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

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

896 897 898 899 900 901 902 903 904 905 906
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
907

908
AM_CONDITIONAL(ENABLE_MIKMOD_DECODER, test x$enable_mikmod = xyes)
909

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

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

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

923
dnl --------------------------------- musepack --------------------------------
924

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

928
dnl -------------------------------- Ogg Tremor -------------------------------
929

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

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

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

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

	MPD_WITH_LIBRARY([TREMOR],
959 960
		[AC_CHECK_FUNC([ov_read],,
			[AC_MSG_ERROR([libvorbisidec not found])])])
Warren Dukes's avatar
Warren Dukes committed
961

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

970
dnl -------------------------------- Ogg Vorbis -------------------------------
971 972 973

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

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

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

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

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

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

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

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

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

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

AM_CONDITIONAL(ENABLE_SIDPLAY, test x$enable_sidplay = xyes)

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

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

1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057
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
1058
	enable_shine_encoder=no
1059 1060 1061 1062 1063
	enable_wave_encoder=no
	enable_flac_encoder=no
fi

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

Andrée Ekroth's avatar
Andrée Ekroth committed
1067 1068
dnl ------------------------------- Shine Encoder ------------------------------

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

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

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

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

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

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

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

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

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

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

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

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

1131 1132
MPD_DEFINE_CONDITIONAL(enable_fifo, HAVE_FIFO,
	[support for writing audio to a FIFO])
1133

1134
dnl ----------------------------------- SNDIO ----------------------------------
1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154
MPD_ARG_ENABLE([sndio], [SNDIO], [sndio output plugin], [], [
	AC_SUBST([SNDIO_LIBS], [])
	AC_SUBST([SNDIO_CFLAGS], [])

	found_sndio=no
	MPD_AUTO([sndio], [SNDIO], [sndio output plugin],
		[AC_CHECK_HEADER([sndio.h],
			[AC_PREPROC_IFELSE(
				[AC_LANG_PROGRAM([
					#include <sndio.h>
					#ifdef ROAR_VERSION
					#error libroarsndio not supported
					#endif
				])],
				[found_sndio=yes SNDIO_LIBS='-lsndio' SNDIO_CFLAGS=''],
				[AC_MSG_WARN([Found libroarsndio, which is known to be broken; ignoring it.])],
			)]
		)]
	)
])
1155

1156
dnl ----------------------------------- Haiku ---------------------------------
1157 1158 1159 1160
MPD_ENABLE_AUTO_HEADER([haiku], [HAIKU], [media/MediaDefs.h],
	[-lbe -lmedia], [],
	[Haiku output plugin],
	[Haiku headers not found])
1161

1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173
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

1174 1175
MPD_DEFINE_CONDITIONAL(enable_httpd_output, ENABLE_HTTPD_OUTPUT,
	[the HTTP server output])
1176 1177

dnl ----------------------------------- JACK ----------------------------------
1178 1179
MPD_ENABLE_AUTO_PKG(jack, JACK, [jack >= 0.100],
	[JACK output plugin], [libjack not found])
1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191

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 ----------------------------------
1192 1193
MPD_ENABLE_AUTO_PKG(ao, AO, [ao],
	[libao output plugin], [libao not found])
1194 1195 1196 1197 1198

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

1199 1200 1201 1202 1203 1204 1205 1206 1207 1208
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"
1209
	fi
1210 1211 1212 1213 1214
else
	MPD_AUTO_PKG(openal, [OPENAL], [openal],
		[OpenAL output plugin], [OpenAL not found])
fi

1215
MPD_DEFINE_CONDITIONAL(enable_openal, HAVE_OPENAL, [OpenAL support])
1216 1217 1218 1219

dnl ---------------------------- Open Sound System ----------------------------
if test x$enable_oss = xyes; then
	AC_CHECK_HEADER(sys/soundcard.h,
1220
		[enable_oss=yes],
1221 1222 1223 1224
		[AC_MSG_WARN(Soundcard headers not found -- disabling OSS support);
			enable_oss=no])
fi

1225
MPD_DEFINE_CONDITIONAL(enable_oss, HAVE_OSS, [Open Sound System])
1226 1227

dnl ----------------------------------- OSX -----------------------------------
1228 1229 1230 1231
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
1232 1233 1234 1235

AM_CONDITIONAL(HAVE_OSX, test x$enable_osx = xyes)

dnl ------------------------------- Pipe Output -------------------------------
1236 1237
MPD_DEFINE_CONDITIONAL(enable_pipe_output, ENABLE_PIPE_OUTPUT,
		[support for writing audio to a pipe])
1238 1239

dnl -------------------------------- PulseAudio -------------------------------
1240
MPD_ENABLE_AUTO_PKG(pulse, PULSE, [libpulse >= 0.9.16],
1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254
	[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

1255 1256
MPD_DEFINE_CONDITIONAL(enable_recorder_output, ENABLE_RECORDER_OUTPUT,
	[the recorder output])
1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269

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

1270 1271
MPD_DEFINE_CONDITIONAL(enable_shout, HAVE_SHOUT,
	[shoutcast output])
1272 1273

dnl --------------------------------- Solaris ---------------------------------
1274

1275 1276
MPD_DEFINE_CONDITIONAL(enable_solaris_output, ENABLE_SOLARIS_OUTPUT,
	[Solaris /dev/audio support])
1277

1278
dnl --------------------------------- WinMM ---------------------------------
1279

1280 1281 1282 1283 1284 1285 1286
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
1287

1288
AM_CONDITIONAL(ENABLE_WINMM_OUTPUT, test x$enable_winmm_output = xyes)
1289

1290 1291 1292 1293 1294
dnl ---------------------------------------------------------------------------
dnl Option groups
dnl ---------------------------------------------------------------------------

have_ogg=no
1295
if test x$enable_vorbis = xyes || test x$enable_tremor = xyes || test x$enable_opus = xyes || test x$enable_vorbis_encoder = xyes; then
1296 1297 1298 1299
	have_ogg=yes
fi

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

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

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

1311
dnl ---------------------------------------------------------------------------
1312
dnl Documentation
1313
dnl ---------------------------------------------------------------------------
1314 1315
if test x$enable_documentation = xyes; then
	AC_PATH_PROG(XMLTO, xmlto)
1316 1317 1318 1319
	if test x$XMLTO = x; then
		AC_MSG_ERROR([xmlto not found])
	fi

1320
	AC_SUBST(XMLTO)
1321 1322 1323 1324 1325 1326 1327

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

	AC_SUBST(DOXYGEN)
1328 1329
fi

1330
AM_CONDITIONAL(ENABLE_DOCUMENTATION, test x$enable_documentation = xyes)
1331

1332 1333 1334
dnl ---------------------------------------------------------------------------
dnl test suite
dnl ---------------------------------------------------------------------------
1335 1336 1337 1338 1339 1340

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

1341 1342
AM_CONDITIONAL(ENABLE_TEST, test "x$enable_test" = xyes)

1343
dnl ---------------------------------------------------------------------------
1344
dnl CFLAGS
1345
dnl ---------------------------------------------------------------------------
1346

1347 1348 1349 1350 1351 1352 1353
dnl ---------------------------- warnings as errors ---------------------------
if test "x$enable_werror" = xyes; then
	CFLAGS="$CFLAGS -Werror -pedantic-errors"
	CXXFLAGS="$CXXFLAGS -Werror"
fi

dnl ---------------------------- language features ----------------------------
1354
AX_APPEND_COMPILE_FLAGS([-fvisibility=hidden])
1355 1356
AX_APPEND_COMPILE_FLAGS([-ffast-math])
AX_APPEND_COMPILE_FLAGS([-ftree-vectorize])
1357 1358 1359 1360 1361

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

1366
dnl ---------------------------------- debug ----------------------------------
1367 1368
if test "x$enable_debug" = xno; then
	AM_CPPFLAGS="$AM_CPPFLAGS -DNDEBUG"
1369 1370 1371 1372 1373 1374 1375 1376 1377 1378

	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])
1379
fi
1380 1381

dnl ----------------------------------- GCC -----------------------------------
1382 1383
if test x$GCC = xyes
then
1384 1385 1386 1387 1388 1389 1390 1391 1392
	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])
1393 1394 1395 1396 1397 1398 1399 1400 1401 1402

	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])
1403 1404 1405 1406 1407

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

1408
	AC_LANG_POP
1409 1410
fi

1411 1412 1413
dnl ---------------------------------------------------------------------------
dnl Pretty-Print Results
dnl ---------------------------------------------------------------------------
1414 1415
echo ''
echo '########### MPD CONFIGURATION ############'
1416

1417
printf '\nArchive support:\n\t'
1418 1419 1420
results(bzip2,[bzip2])
results(iso9660,[ISO9660])
results(zzip,[ZIP])
1421

1422
if test x$with_zeroconf != xno; then
1423
	printf '\nAutodiscovery support:\n\t'
1424 1425
	results(avahi, [Avahi])
	results(bonjour, [Bonjour])
1426 1427
fi

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

1433 1434 1435 1436
printf '\nStorage support:\n\t'
results(nfs, [NFS])
results(smbclient, [SMB])

1437
printf '\nFile format support:\n\t'
1438
results(aac, [AAC])
1439
results(adplug, [AdPlug])
1440
results(dsd, [DSD])
1441 1442 1443 1444 1445
results(sidplay, [C64 SID])
results(ffmpeg, [FFMPEG])
results(flac, [FLAC])
results(fluidsynth, [FluidSynth])
results(gme, [GME])
1446
printf '\n\t'
1447
results(sndfile, [libsndfile])
1448 1449 1450 1451 1452
results(mikmod, [MikMod])
results(modplug, [MODPLUG])
results(mad, [MAD])
results(mpg123, [MPG123])
results(mpc, [Musepack])
1453
printf '\n\t'
1454
results(opus, [Opus])
1455
results(tremor, [OggTremor])
1456 1457 1458 1459
results(vorbis, [OggVorbis])
results(audiofile, [WAVE])
results(wavpack, [WavPack])
results(wildmidi, [WildMidi])
1460

1461
printf '\nOther features:\n\t'
1462
results(lsr, [libsamplerate])
1463
results(soxr, [libsoxr])
1464
results(libmpdclient, [libmpdclient])
1465
results(inotify, [inotify])
1466
results(sqlite, [SQLite])
1467

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

1471
printf '\nPlayback support:\n\t'
1472 1473
results(alsa,ALSA)
results(fifo,FIFO)
1474
results(sndio,[SNDIO])
1475
results(recorder_output,[File Recorder])
1476
results(haiku,[Haiku])
1477 1478
results(httpd_output,[HTTP Daemon])
results(jack,[JACK])
1479
printf '\n\t'
1480 1481 1482 1483 1484
results(ao,[libao])
results(oss,[OSS])
results(openal,[OpenAL])
results(osx, [OS X])
results(pipe_output, [Pipeline])
1485
printf '\n\t'
1486
results(pulse, [PulseAudio])
1487
results(roar,[ROAR])
1488
results(shout, [SHOUTcast])
1489
results(solaris_output, [Solaris])
1490
results(winmm_output, [WinMM])
Warren Dukes's avatar
Warren Dukes committed
1491

1492 1493
if
	test x$enable_shout = xyes ||
1494
	test x$enable_recorder = xyes ||
1495
	test x$enable_httpd_output = xyes; then
1496
		printf '\nStreaming encoder support:\n\t'
1497 1498
		results(flac_encoder, [FLAC])
		results(lame_encoder, [LAME])
Andrée Ekroth's avatar
Andrée Ekroth committed
1499
		results(shine_encoder, [Shine])
1500
		results(vorbis_encoder, [Ogg Vorbis])
1501
		results(opus, [Opus])
1502 1503
		results(twolame_encoder, [TwoLAME])
		results(wave_encoder, [WAVE])
1504 1505
fi

1506
printf '\nStreaming support:\n\t'
1507
results(cdio_paranoia, [CDIO_PARANOIA])
1508
results(curl,[CURL])
1509
results(smbclient,[SMBCLIENT])
1510 1511
results(soundcloud,[Soundcloud])
printf '\n\t'
1512
results(mms,[MMS])
1513

1514
printf '\nEvent loop:\n\t'
1515
printf $with_pollmethod
1516

1517
printf '\n\n##########################################\n\n'
1518

1519
echo 'Generating files needed for compilation'
1520

1521 1522 1523
dnl ---------------------------------------------------------------------------
dnl Generate files
dnl ---------------------------------------------------------------------------
1524 1525
AC_CONFIG_FILES(Makefile)
AC_CONFIG_FILES(doc/doxygen.conf)
1526
AC_CONFIG_FILES(systemd/system/mpd.service)
1527
AC_CONFIG_FILES(systemd/user/mpd.service)
1528
AC_OUTPUT
1529

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