]> git.ipfire.org Git - thirdparty/shairport-sync.git/blame - configure.ac
Update check_classic_mac_basic.yml
[thirdparty/shairport-sync.git] / configure.ac
CommitLineData
9d450966
MB
1# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ([2.50])
2ed5d998 5AC_INIT([shairport-sync], [4.3.2], [4265913+mikebrady@users.noreply.github.com])
424cc398 6AM_INIT_AUTOMAKE([subdir-objects])
9d450966
MB
7AC_CONFIG_SRCDIR([shairport.c])
8AC_CONFIG_HEADERS([config.h])
b91df8ec 9AC_PROG_RANLIB
9d450966 10
2203d6a3 11AC_CHECK_PROGS([GIT], [git])
40e28ba2 12if test -n "$GIT" && test -e "$srcdir/.git/index" ; then
2203d6a3
MB
13 AC_DEFINE([CONFIG_USE_GIT_VERSION_STRING], 1, [Use the version string produced by running 'git describe --dirty'.])
14fi
40e28ba2 15AM_CONDITIONAL([USE_GIT_VERSION], [test -n "$GIT" && test -e "$srcdir/.git/index" ])
2203d6a3 16
60c3d6cf 17# Derived from the Avahi configure.ac file
60c3d6cf
MB
18# Specifying the OS type, defaulting to linux.
19#
7693b4ae 20AC_ARG_WITH(os, AS_HELP_STRING([--with-os=OSType],[Specify the distribution to target: One of linux, freebsd, openbsd or darwin]))
f6eca4ca
MB
21if test "z$with_os" = "z"; then
22 with_os="linux"
60c3d6cf 23fi
f6eca4ca 24with_os=`echo ${with_os} | tr '[[:upper:]]' '[[:lower:]]' `
5aeb4ab9
AL
25case "x${with_os}" in
26xlinux|xfreebsd|xopenbsd|xdarwin)
27 ;;
28*)
29 AC_MSG_ERROR([--with-os=<arg> argument must be one of linux, freebsd, openbsd or darwin])
30 ;;
31esac
26ff0c20 32
9d450966
MB
33# Checks for programs.
34AC_PROG_CC
b7723d3a 35AC_PROG_CXX
9f8b360c 36AC_CHECK_TOOL(AR, ar, :)
9d450966
MB
37AC_PROG_INSTALL
38
2a430ec4
YM
39PKG_PROG_PKG_CONFIG([0.9.0])
40
9d450966 41# Checks for libraries.
f6eca4ca 42if test "x${with_os}" = xlinux -o "x${with_os}" = xfreebsd ; then
563d4c87
MB
43 AC_CHECK_LIB([rt],[clock_gettime], , AC_MSG_ERROR(librt needed))
44fi
45
1c045979
MB
46if test "x${with_os}" = xopenbsd ; then
47 AC_CHECK_LIB([c],[clock_gettime], , AC_MSG_ERROR(libc needed))
48fi
49
e925e196 50# Pass the conditionals to automake
4aea4cc5 51AM_CONDITIONAL([BUILD_FOR_LINUX], [test "x${with_os}" = xlinux ])
f6eca4ca 52AM_CONDITIONAL([BUILD_FOR_FREEBSD], [test "x${with_os}" = xfreebsd ])
1c045979 53AM_CONDITIONAL([BUILD_FOR_OPENBSD], [test "x${with_os}" = xopenbsd ])
074457c8 54AM_CONDITIONAL([BUILD_FOR_DARWIN], [test "x${with_os}" = xdarwin ])
1c045979 55
282f79c9
MB
56##### Some build systems are not fully using pkg-config, so we can use the flag ${with_pkg_config} on a case-by-case basis
57##### to control how to deal with them
26ff0c20 58##### Note -- this flag is sometimes ignored, especially for newer packages
282f79c9 59
72176a95 60AC_ARG_WITH([pkg_config],[AS_HELP_STRING([--with-pkg-config],[use pkg-config to find libraries])],[],[with_pkg_config=yes])
282f79c9 61
9264f3a8
MB
62##### The following check for the pthreads library doesn't put the compiler into the correct pthread mode
63##### so we add the -pthread compilation flag in AMFLAGS in the Makefile.am as well.
64
9f46038d
MB
65AC_CHECK_LIB([pthread],[pthread_create], , AC_MSG_ERROR(pthread library needed))
66AC_CHECK_LIB([m],[exp], , AC_MSG_ERROR(maths library needed))
e73657d6 67
670dd933 68if test "x${with_pkg_config}" = xyes ; then
282f79c9 69 PKG_CHECK_MODULES(
72176a95
MB
70 [popt], [popt],
71 [CFLAGS="${popt_CFLAGS} ${CFLAGS}"
72 LIBS="${popt_LIBS} ${LIBS}"], AC_MSG_ERROR(libpopt needed))
282f79c9
MB
73else
74 AC_CHECK_LIB([popt],[poptGetContext], , AC_MSG_ERROR(libpopt needed))
75fi
85ca9317 76
2538e46a 77AC_ARG_WITH([dummy],[AS_HELP_STRING([--with-dummy],[include the dummy audio back end])])
72176a95 78if test "x$with_dummy" = "xyes" ; then
ca40780a 79 AC_DEFINE([CONFIG_DUMMY], 1, [Include a fake audio backend.])
72176a95 80fi
670dd933 81AM_CONDITIONAL([USE_DUMMY], [test "x$with_dummy" = "xyes" ])
a090a14c 82
2538e46a 83AC_ARG_WITH([stdout],[AS_HELP_STRING([--with-stdout],[include the stdout audio back end])])
72176a95 84if test "x$with_stdout" = "xyes" ; then
ca40780a 85 AC_DEFINE([CONFIG_STDOUT], 1, [Include an audio backend to output to standard output (stdout).])
72176a95
MB
86fi
87AM_CONDITIONAL([USE_STDOUT], [test "x$with_stdout" = "xyes"])
a090a14c 88
2538e46a 89AC_ARG_WITH([pipe],[AS_HELP_STRING([--with-pipe],[include the pipe audio back end])])
72176a95 90if test "x$with_pipe" = "xyes" ; then
ca40780a 91 AC_DEFINE([CONFIG_PIPE], 1, [Include an audio backend to output to a unix pipe.])
72176a95 92fi
26ff0c20 93AM_CONDITIONAL([USE_PIPE], [test "x$with_pipe" = "xyes" ])
670dd933
MB
94
95# Check to see if we should include the System V initscript
96
2538e46a 97AC_ARG_WITH([systemv],[AS_HELP_STRING([--with-systemv],[install a System V startup script during a make install])])
670dd933 98AM_CONDITIONAL([INSTALL_SYSTEMV], [test "x$with_systemv" = "xyes"])
a090a14c 99
670dd933 100# Check to see if we should include the systemd stuff to define it as a service
2de9a580 101
2538e46a 102AC_ARG_WITH([systemd],[AS_HELP_STRING([--with-systemd],[install a systemd startup script during a make install])])
670dd933
MB
103AM_CONDITIONAL([INSTALL_SYSTEMD], [test "x$with_systemd" = "xyes"])
104
2538e46a 105AC_ARG_WITH([freebsd-service],[AS_HELP_STRING([--with-freebsd-service],[install a FreeBSD startup script during a make install])])
f6eca4ca 106AM_CONDITIONAL([INSTALL_FREEBSD_SERVICE], [test "x$with_freebsd_service" = "xyes"])
670dd933 107
2538e46a 108AC_ARG_WITH([cygwin-service],[AS_HELP_STRING([--with-cygwin-service],[install a CYGWIN config script during a make install])])
623b9b4b
MB
109AM_CONDITIONAL([INSTALL_CYGWIN_SERVICE], [test "x$with_cygwin_service" = "xyes"])
110
26ff0c20
MB
111AC_ARG_WITH([external-mdns],[AS_HELP_STRING([--with-external-mdns],[support the use of 'avahi-publish-service' or 'mDNSPublish' to advertise the service on Bonjour/ZeroConf])])
112if test "x$with_external_mdns" = xyes ; then
113 AC_MSG_RESULT(include external mdns support)
114 AC_DEFINE([CONFIG_EXTERNAL_MDNS], 1, [Use 'avahi-publish-service' or 'mDNSPublish' to advertise.])
115fi
3162977c
MB
116AM_CONDITIONAL([USE_EXTERNAL_MDNS], [test "x$with_external_mdns" = "xyes" ])
117
670dd933
MB
118# Add the libconfig package
119if test "x${with_pkg_config}" = xyes ; then
120 PKG_CHECK_MODULES(
2538e46a
MB
121 [libconfig], [libconfig],
122 [LIBS="${libconfig_LIBS} ${LIBS}"], AC_MSG_ERROR([libconfig library needed]))
670dd933
MB
123else
124 AC_CHECK_LIB([config],[config_init], , AC_MSG_ERROR([libconfig library needed]))
e73657d6 125fi
f29792d9 126
2538e46a 127AC_ARG_WITH([configfiles],[AS_HELP_STRING([--with-configfiles],[install configuration files during a make install])], ,[with_configfiles=yes])
670dd933 128AM_CONDITIONAL([INSTALL_CONFIG_FILES], [test "x$with_configfiles" = "xyes"])
f29792d9 129
b7723d3a 130# Look for Apple ALAC flag
2538e46a 131AC_ARG_WITH(apple-alac,[AS_HELP_STRING([--with-apple-alac],[include support for the Apple ALAC decoder])])
72176a95 132if test "x${with_apple_alac}" = "xyes" ; then
c9b3d2a2 133 AC_DEFINE([CONFIG_APPLE_ALAC], 1, [Include support for using the Apple ALAC Decoder])
b7723d3a 134 if test "x${with_pkg_config}" = xyes ; then
106d0b32 135 PKG_CHECK_MODULES([alac], [alac], [LIBS="${alac_LIBS} ${LIBS}"], AC_MSG_ERROR(Apple ALAC Decoder support requires the ALAC library. See https://github.com/mikebrady/alac.))
b7723d3a 136 else
106d0b32 137 AC_CHECK_LIB([alac], [BitBufferInit], , AC_MSG_ERROR(Apple ALAC Decoder support requires the ALAC library. See https://github.com/mikebrady/alac.))
72176a95
MB
138 fi
139fi
140AM_CONDITIONAL([USE_APPLE_ALAC], [test "x${with_apple_alac}" = "xyes"])
270d2920 141
043363fb 142# Look for piddir flag
26ff0c20
MB
143AC_ARG_WITH(piddir, [AS_HELP_STRING([--with-piddir=<pathname>],[Specify a pathname to a directory in which to write the PID file.])])
144if test "x${with_piddir}" != "x" ; then
043363fb
MB
145 AC_MSG_CHECKING(--with-piddir argument)
146 if test "x${with_piddir}" = x -o "x${with_piddir}" = xyes ; then
147 AC_MSG_RESULT(not found)
148 AC_MSG_ERROR(when you use the --with-piddir directive you must specify the pathname of the directory into which the PID file will be written)
149 fi
150 AC_MSG_RESULT(${with_piddir})
26ff0c20
MB
151 AC_SUBST(CUSTOM_PID_DIR,["${with_piddir}"])
152 AC_DEFINE([DEFINED_CUSTOM_PID_DIR],1,[Hook up special proc to libdaemon to point to this directory])
153fi
154AM_CONDITIONAL([USE_CUSTOMPIDDIR], [ test "x${with_piddir}" != "x" ])
6d088ac4
MB
155
156# Look for libdaemon
26ff0c20 157AC_ARG_WITH(libdaemon,[AS_HELP_STRING([--with-libdaemon],[include support for daemonising in non-systemd systems])])
23ac1e31 158if test "x$with_libdaemon" = "xyes"; then
ca40780a 159 AC_DEFINE([CONFIG_LIBDAEMON], 1, [Include libdaemon for daemonising in non-systemd systems])
6d088ac4
MB
160 if test "x${with_pkg_config}" = xyes ; then
161 PKG_CHECK_MODULES(
162 [DAEMON], [libdaemon],
23ac1e31
MB
163 [LIBS="${DAEMON_LIBS} ${LIBS}"],
164 [AC_MSG_ERROR(the libdaemon library has been selected but is missing -- libdaemon-dev suggested!)])
6d088ac4 165 else
23ac1e31 166 AC_CHECK_LIB([daemon],[daemon_fork], , AC_MSG_ERROR(the libdaemon library has been selected but is missing -- libdaemon-dev suggested!))
6d088ac4
MB
167 fi
168fi
23ac1e31 169AM_CONDITIONAL([USE_LIBDAEMON], [test "x$with_libdaemon" = "xyes"])
12f26893 170
9cafb4b4 171# Check --with-ssl=argument
26ff0c20
MB
172AC_ARG_WITH(ssl, [AS_HELP_STRING([--with-ssl=<argument>],[choose --with-ssl=openssl, --with-ssl=mbedtls or --with-ssl=polarssl (deprecated) for encryption services ])])
173
174if test "x${with_ssl}" = xopenssl ; then
175 AC_DEFINE([CONFIG_OPENSSL], 1, [Use the OpenSSL libraries for encryption and encoding and decoding])
176 if test "x${with_pkg_config}" = xyes ; then
177 PKG_CHECK_MODULES(
178 [SSL], [libssl,libcrypto],
179 [LIBS="${SSL_LIBS} ${LIBS}"])
180 else
181 AC_CHECK_LIB([crypto], [main], , AC_MSG_ERROR(libcrypto selected but the library cannot be found!))
182 AC_CHECK_LIB([ssl], [main], , AC_MSG_ERROR(libssl selected but the library cannot be found!))
183 fi
184elif test "x${with_ssl}" = xmbedtls ; then
185 AC_DEFINE([CONFIG_MBEDTLS], 1, [Use the mbed TLS libraries for encryption and encoding and decoding])
186 AC_CHECK_LIB([mbedtls],[mbedtls_ssl_init],,
fe202167 187 [AC_MSG_ERROR([mbed tls support requires the mbedtls library -- libmbedtls-dev suggested],1)])
26ff0c20
MB
188 AC_CHECK_LIB([mbedcrypto], [mbedtls_entropy_func],,
189 [AC_MSG_ERROR([mbed tls support requires the mbedcrypto library -- libmbedcrypto0 suggested],1)])
190 AC_CHECK_LIB([mbedx509], [mbedtls_pk_init],,
191 [AC_MSG_ERROR([mbed tls support requires the mbedx509 library -- libmbedx509-0 suggested],1)])
192elif test "x${with_ssl}" = xpolarssl ; then
193 AC_DEFINE([CONFIG_POLARSSL], 1, [Use the PolarSSL libraries for encryption and encoding and decoding])
106d0b32 194 AC_CHECK_LIB([polarssl],[ssl_init], , AC_MSG_ERROR(PolarSSL is selected but the library libpolarssl-dev does not seem to be installed and is deprecated. Consider selecting mbedtls instead using --with-ssl=mbedtls.))
26ff0c20
MB
195else
196 AC_MSG_ERROR(specify one of --with-ssl=openssl or --with-ssl=mbedtls or --with-ssl=polarssl)
197fi
2de9a580
MB
198
199# Look for soxr flag
26ff0c20
MB
200
201AC_ARG_WITH(soxr, [AS_HELP_STRING([--with-soxr],[choose libsoxr for high-quality interpolation])])
202if test "x$with_soxr" = "xyes" ; then
6cbaa15b 203 AC_DEFINE([CONFIG_SOXR], 1, [Include support for using the SoX Resampler library for interpolation])
5101ab2d
MB
204 if test "x${with_pkg_config}" = xyes ; then
205 PKG_CHECK_MODULES(
2538e46a
MB
206 [soxr], [soxr],
207 [LIBS="${soxr_LIBS} ${LIBS}"],
4f9730e3 208 [AC_MSG_ERROR(soxr support requires the libsoxr library -- libsoxr-dev suggested!)])
5101ab2d
MB
209 else
210 AC_CHECK_LIB([avutil],[av_get_cpu_flags])
211 if test "x${ac_cv_lib_avutil_av_get_cpu_flags}" = xyes ; then
212 # soxr may link against libavutil, depending on the architecture, but for the sake of simplicity link with it if it is found
4f9730e3 213 AC_CHECK_LIB([soxr],[soxr_create], , AC_MSG_ERROR(soxr support requires the libsoxr library -- libsoxr-dev suggested!), [-lavutil])
5101ab2d 214 else
4f9730e3 215 AC_CHECK_LIB([soxr],[soxr_create], , AC_MSG_ERROR(soxr support requires the libsoxr library -- libsoxr-dev suggested!))
5101ab2d
MB
216 fi
217 fi
26ff0c20 218fi
5f3b96f0 219
69642bb7 220# Look for metadata flag and resolve it further down the script
26ff0c20 221AC_ARG_WITH(metadata,[AS_HELP_STRING([--with-metadata],[include support for a metadata feed])])
75f3f912 222
5f3b96f0 223# What follows is a bit messy, because if the relevant library is requested, a compiler flag is defined, a file is included in the compilation
9d450966
MB
224# and the relevant link files are added.
225
226# Look for avahi flag
26ff0c20
MB
227AC_ARG_WITH(avahi, [AS_HELP_STRING([--with-avahi],[choose Avahi-based mDNS support])])
228if test "x$with_avahi" = "xyes" ; then
ca40780a 229 AC_DEFINE([CONFIG_AVAHI], 1, [Include Avahi-based mDNS support.])
9d450966 230 AC_CHECK_LIB([avahi-client], [avahi_client_new], , AC_MSG_ERROR(Avahi support requires the avahi-client library!))
26ff0c20 231 AC_CHECK_LIB([avahi-common],[avahi_strerror], , AC_MSG_ERROR(Avahi support requires the avahi-common library!))
38bbad6f
MB
232 AC_CONFIG_FILES([scripts/shairport-sync.service-avahi])
233else
234 AC_CONFIG_FILES([scripts/shairport-sync.service])
26ff0c20
MB
235fi
236AM_CONDITIONAL([USE_AVAHI], [test "x$with_avahi" = "xyes"])
9d450966 237
2de9a580 238# Look for tinysvcmdns flag
26ff0c20
MB
239AC_ARG_WITH(tinysvcmdns, [AS_HELP_STRING([--with-tinysvcmdns],[choose tinysvcmdns-based mDNS support])])
240if test "x$with_tinysvcmdns" = "xyes" ; then
241 AC_DEFINE([CONFIG_TINYSVCMDNS], 1, [Include TinySVCmDNS-based mDNS support])
242fi
243AM_CONDITIONAL([USE_TINYSVCMDNS], [test "x$with_tinysvcmdns" = "xyes"])
2de9a580 244
9d450966 245# Look for ALSA flag
26ff0c20
MB
246AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa],[choose ALSA API support (GNU/Linux only)])])
247if test "x$with_alsa" = "xyes" ; then
9d450966 248 AC_DEFINE([CONFIG_ALSA], 1, [Needed by the compiler.])
8e8a0ee7 249 if test "x${with_pkg_config}" = xyes ; then
5f919264 250 PKG_CHECK_MODULES(
2538e46a
MB
251 [alsa], [alsa],
252 [LIBS="${alsa_LIBS} ${LIBS}"])
5f919264
MB
253 else
254 AC_CHECK_LIB([asound], [snd_pcm_open], , AC_MSG_ERROR(ALSA support requires the asound library!))
26ff0c20 255 fi
23ac1e31 256fi
26ff0c20 257AM_CONDITIONAL([USE_ALSA], [test "x$with_alsa" = "xyes"])
9d450966 258
8cabb16f 259# Look for jack flag
26ff0c20
MB
260AC_ARG_WITH(jack, [AS_HELP_STRING([--with-jack],[include a Jack Audio Connection Kit (jack) backend])])
261if test "x$with_jack" = "xyes" ; then
ca40780a 262 AC_DEFINE([CONFIG_JACK], 1, [Include a Jack Audio Connection Kit (jack) audio backend])
8cabb16f
MB
263 if test "x${with_pkg_config}" = xyes ; then
264 PKG_CHECK_MODULES(
2538e46a
MB
265 [jack], [jack],
266 [LIBS="${jack_LIBS} ${LIBS}"],
69642bb7 267 [AC_MSG_ERROR(Jack Audio Connection Kit support requires the jack library -- libjack-dev suggested!)])
8cabb16f
MB
268 else
269 AC_CHECK_LIB([jack], [jack_client_open], , AC_MSG_ERROR(Jack Audio Connection Kit support requires the jack library -- libjack-dev suggested!))
26ff0c20
MB
270 fi
271fi
272AM_CONDITIONAL([USE_JACK], [test "x$with_jack" = "xyes"])
9d450966
MB
273
274# Look for SNDIO flag
26ff0c20
MB
275AC_ARG_WITH(sndio, [AS_HELP_STRING([--with-sndio],[choose SNDIO API support])])
276if test "x$with_sndio" = "xyes" ; then
ca40780a 277 AC_DEFINE([CONFIG_SNDIO], 1, [Include a sndio-compatible audio backend.])
26ff0c20
MB
278 AC_CHECK_LIB([sndio], [sio_open], , AC_MSG_ERROR(SNDIO support requires the sndio library -- libsndio-dev suggested))
279fi
280AM_CONDITIONAL([USE_SNDIO], [test "x$with_sndio" = "xyes"])
270d2920 281
9d450966 282# Look for AO flag
26ff0c20
MB
283AC_ARG_WITH(ao, [AS_HELP_STRING([--with-ao],[choose AO (Audio Output?) API support. N.B. no synchronisation -- so underflow or overflow is inevitable!])])
284if test "x$with_ao" = "xyes" ; then
ca40780a 285 AC_DEFINE([CONFIG_AO], 1, [Include an AO-compatible audio backend.])
26ff0c20
MB
286 AC_CHECK_LIB([ao], [ao_initialize], , AC_MSG_ERROR(AO support requires the ao library -- libao-dev suggested))
287fi
288AM_CONDITIONAL([USE_AO], [test "x$with_ao" = "xyes"])
9d450966 289
b7723d3a 290# Look for Soundio flag
26ff0c20
MB
291AC_ARG_WITH(soundio, [AS_HELP_STRING([--with-soundio],[choose soundio API support.])])
292if test "x$with_soundio" = "xyes" ; then
293 AC_DEFINE([CONFIG_SOUNDIO], 1, [Include SoundIO Support.])
294 AC_CHECK_LIB([soundio], [soundio_create], , AC_MSG_ERROR(soundio support requires the soundio library -- libsoundio-dev suggested))
295fi
296AM_CONDITIONAL([USE_SOUNDIO], [test "x$with_soundio" = "xyes"])
b7723d3a 297
9d450966 298# Look for pulseaudio flag
26ff0c20
MB
299AC_ARG_WITH(pa, [AS_HELP_STRING([--with-pa],[choose PulseAudio support.])])
300if test "x$with_pa" = "xyes" ; then
ca40780a 301 AC_DEFINE([CONFIG_PA], 1, [Include PulseAudio support.])
b3ae05ea
MB
302 if test "x${with_pkg_config}" = xyes ; then
303 PKG_CHECK_MODULES(
304 [PULSEAUDIO], [libpulse >= 0.9.2],
305 [LIBS="${PULSEAUDIO_LIBS} ${LIBS}"],[AC_MSG_ERROR(PulseAudio support requires the libpulse-dev library!)])
306 else
307 AC_CHECK_LIB([pulse-simple], [pa_simple_new], , AC_MSG_ERROR(PulseAudio support requires the libpulse library!))
308 AC_CHECK_LIB([pulse], [pa_stream_peek], , AC_MSG_ERROR(PulseAudio support requires the libpulse-dev library.))
26ff0c20
MB
309 fi
310fi
311AM_CONDITIONAL([USE_PA], [test "x$with_pa" = "xyes"])
b3ae05ea 312
ec232363
LR
313# Look for pipewire flag
314AC_ARG_WITH(pw, [AS_HELP_STRING([--with-pw],[choose Pipewire support.])])
315if test "x$with_pw" = "xyes" ; then
316 AC_DEFINE([CONFIG_PW], 1, [Include Pipewire support.])
317 if test "x${with_pkg_config}" = xyes ; then
318 PKG_CHECK_MODULES(
319 [PIPEWIRE], [libpipewire-0.3 >= 0.3.24],
320 [CFLAGS="${PIPEWIRE_CFLAGS} ${CFLAGS} -Wno-missing-field-initializers" LIBS="${PIPEWIRE_LIBS} ${LIBS}"],
fd880056 321 [AC_MSG_ERROR(Pipewire support requires the libpipewire library -- libpipewire-0.3-dev suggested!)])
ec232363 322 else
fd880056 323 AC_CHECK_LIB([pipewire], [pw_stream_queue_buffer], , AC_MSG_ERROR(Pipewire support requires the libpipewire library -- libpipewire-0.3-dev suggested!))
ec232363
LR
324 fi
325fi
326AM_CONDITIONAL([USE_PW], [test "x$with_pw" = "xyes"])
327
7b9cd28e 328# Look for Convolution flag
ca40780a
MB
329AC_ARG_WITH(convolution, [AS_HELP_STRING([--with-convolution],[choose audio DSP convolution support])])
330if test "x$with_convolution" = "xyes" ; then
ca40780a 331 AC_DEFINE([CONFIG_CONVOLUTION], 1, [Include audio DSP convolution support.])
246f26af
FF
332 if test "x${with_pkg_config}" = xyes ; then
333 PKG_CHECK_MODULES(
334 [sndfile], [sndfile],
335 [CFLAGS="${sndfile_CFLAGS} ${CFLAGS}"
336 LIBS="${sndfile_LIBS} ${LIBS}"], AC_MSG_ERROR(Convolution support requires the sndfile library -- libsndfile1-dev suggested!))
337 else
338 AC_CHECK_LIB([sndfile], [sf_open], , AC_MSG_ERROR(Convolution support requires the sndfile library -- libsndfile1-dev suggested!))
339 fi
ca40780a
MB
340fi
341AM_CONDITIONAL([USE_CONVOLUTION], [test "x$with_convolution" = "xyes"])
7b9cd28e 342
9d450966 343# Look for dns_sd flag
ca40780a
MB
344AC_ARG_WITH(dns_sd, [AS_HELP_STRING([--with-dns_sd],[choose dns_sd mDNS support])])
345if test "x$with_dns_sd" = "xyes" ; then
346 AC_DEFINE([CONFIG_DNS_SD], 1, [Include dns_sd mDNS support.])
106d0b32 347 AC_SEARCH_LIBS([DNSServiceRefDeallocate], [dns_sd], , [AC_MSG_ERROR(dns_sd support requires the dns_sd library. Originally in Apple's mDNSResponder but also in libavahi-compat-libdnssd-dev.)])
ca40780a
MB
348fi
349AM_CONDITIONAL([USE_DNS_SD], [test "x$with_dns_sd" = "xyes"])
9d450966 350
1e07e1e0 351# Look for dbus flag
ca40780a 352AC_ARG_WITH(dbus-interface, [AS_HELP_STRING([--with-dbus-interface],[include support for the native Shairport Sync D-Bus interface])])
23ac1e31 353if test "x$with_dbus_interface" = "xyes" ; then
ca40780a
MB
354 AC_DEFINE([CONFIG_DBUS_INTERFACE], 1, [Support the native Shairport Sync D-Bus interface])
355 # remember to include glib, below
356fi
357AM_CONDITIONAL([USE_DBUS], [test "x$with_dbus_interface" = "xyes"])
1e07e1e0
MB
358
359# Look for dbus test client flag
ca40780a
MB
360AC_ARG_WITH(dbus-test-client, [AS_HELP_STRING([--with-dbus-test-client],[compile a D-Bus test client application])])
361# remember to include glib, below
362AM_CONDITIONAL([USE_DBUS_CLIENT], [test "x$with_dbus_test_client" = "xyes"])
1e07e1e0 363
74f41a17 364# Look for mpris flag
ca40780a
MB
365AC_ARG_WITH(mpris-interface, [AS_HELP_STRING([--with-mpris-interface],[include support for a D-Bus interface conforming to the MPRIS standard])])
366if test "x$with_mpris_interface" = "xyes" ; then
367 AC_DEFINE([CONFIG_MPRIS_INTERFACE], 1, [Support the MPRIS standard])
368 # remember to include glib, below
369fi
370AM_CONDITIONAL([USE_MPRIS], [test "x$with_mpris_interface" = "xyes"])
74f41a17 371
df7c48f0 372# Look for mpris test client flag
ca40780a
MB
373AC_ARG_WITH(mpris-test-client, [AS_HELP_STRING([--with-mpris-test-client],[compile an MPRIS test client application])])
374# remember to include glib, below
375AM_CONDITIONAL([USE_MPRIS_CLIENT], [test "x$with_mpris_test_client" = "xyes"])
376
377if test "x$with_mpris_test_client" = "xyes" || test "x$with_dbus_test_client" = "xyes" || test "x$with_mpris_interface" = "xyes" || test "x$with_dbus_interface" = "xyes" ; then
5a23ff52 378 PKG_CHECK_MODULES([glib], [gio-unix-2.0 >= 2.30.0],[CFLAGS="${glib_CFLAGS} ${CFLAGS}" LIBS="${glib_LIBS} ${LIBS}"],[AC_MSG_ERROR(the glib 2.0 library is required -- libglib2.0-dev suggested!)])
ca40780a 379fi
df7c48f0 380
02694948 381# Look for mqtt flag
ca40780a
MB
382AC_ARG_WITH(mqtt-client, [AS_HELP_STRING([--with-mqtt-client],[include a client for MQTT -- the Message Queuing Telemetry Transport protocol])])
383if test "x$with_mqtt_client" = "xyes" ; then
c9b3d2a2 384 AC_DEFINE([CONFIG_MQTT], 1, [Include a client for MQTT, the Message Queuing Telemetry Transport protocol])
820486ad 385 AC_CHECK_LIB([mosquitto], [mosquitto_lib_init], , AC_MSG_ERROR(MQTT support requires the mosquitto library -- libmosquitto-dev suggested!))
ca40780a
MB
386fi
387AM_CONDITIONAL([USE_MQTT], [test "x$with_mqtt_client" = "xyes"])
02694948 388
ca40780a
MB
389if test "x$with_mqtt_client" = "xyes" && test "x$with_avahi" != "xyes" ; then
390 AC_MSG_WARN([MQTT needs Avahi for remote control functionality. With the current configuration settings, only metadata publishing will be supported.])
60b9347a 391fi
065eada6 392
ca40780a 393if test "x$with_mpris_interface" = "xyes" || test "x$with_dbus_interface" = "xyes" || test "x$with_mqtt_client" = "xyes" ; then
69642bb7
MB
394 REQUESTED_EXTENDED_METADATA_SUPPORT=1
395 AC_DEFINE([CONFIG_METADATA_HUB], 1, [Needed by the compiler.])
396 AC_DEFINE([CONFIG_DACP_CLIENT], 1, [Needed by the compiler.])
065eada6 397fi
69642bb7
MB
398AM_CONDITIONAL([USE_METADATA_HUB], [test "x$REQUESTED_EXTENDED_METADATA_SUPPORT" = "x1"])
399AM_CONDITIONAL([USE_DACP_CLIENT], [test "x$REQUESTED_EXTENDED_METADATA_SUPPORT" = "x1"])
065eada6 400
26ff0c20 401if test "x$REQUESTED_EXTENDED_METADATA_SUPPORT" = "x1" || test "x$with_metadata" = "xyes" ; then
69642bb7
MB
402 AC_DEFINE([CONFIG_METADATA], 1, [Needed by the compiler.])
403fi
26ff0c20 404AM_CONDITIONAL([USE_METADATA], [test "x$with_metadata" = "xyes"])
74f41a17 405
8110851d
MB
406# Look for AirPlay 2 flag
407AC_ARG_WITH(airplay-2, [AS_HELP_STRING([--with-airplay-2],[Build for AirPlay 2])])
408if test "x$with_airplay_2" = "xyes" ; then
409 AC_DEFINE([CONFIG_AIRPLAY_2], 1, [Build for AirPlay 2])
885377ca
MB
410 AC_CHECK_PROG(XXD_CHECK,xxd,yes)
411 AS_IF([test x"$XXD_CHECK" != x"yes"], [AC_MSG_ERROR([xxd can not be found. Please install xxd for building for AirPlay 2.])])
7f05e613
MR
412 LIBPLIST_PACKAGE=libplist
413 PKG_CHECK_EXISTS(libplist-2.0, LIBPLIST_PACKAGE=libplist-2.0)
bd848a75 414 PKG_CHECK_MODULES(
7f05e613 415 [libplist], [${LIBPLIST_PACKAGE} >= 2.3.0],
bd848a75
MR
416 [CFLAGS="${libplist_CFLAGS} ${CFLAGS}" LIBS="${libplist_LIBS} ${LIBS}" AC_DEFINE([HAVE_LIBPLIST_GE_2_3_0], 1, [libplist >= 2.3.0])],
417 [PKG_CHECK_MODULES(
7f05e613
MR
418 [libplist], [${LIBPLIST_PACKAGE} >= 2.0.0],
419 [CFLAGS="${libplist_CFLAGS} ${CFLAGS}" LIBS="${libplist_LIBS} ${LIBS}"],
420 [AC_MSG_ERROR(AirPlay 2 support requires libplist 2.0.0 or later -- search for pkg libplist-dev on Debian or libplist-2.2.0 or later on FreeBSD!)]
bd848a75
MR
421 )]
422 )
423 PKG_CHECK_MODULES(
424 [libsodium], [libsodium],
425 [CFLAGS="${libsodium_CFLAGS} ${CFLAGS}" LIBS="${libsodium_LIBS} ${LIBS}"],
426 [AC_MSG_ERROR(AirPlay 2 support requires libsodium -- libsodium-dev suggested)]
427 )
428 PKG_CHECK_MODULES(
429 [libgcrypt], [libgcrypt],
430 [CFLAGS="${libgcrypt_CFLAGS} ${CFLAGS}" LIBS="${libgcrypt_LIBS} ${LIBS}"],
431 [AC_CHECK_LIB(
432 [gcrypt], [gcry_control],
433 [],
434 [AC_MSG_ERROR([Airplay 2 support requires libgcrypt -- libgcrypt-dev suggested])]
435 )
f1f59099 436 ])
bd848a75
MR
437 PKG_CHECK_MODULES(
438 [libavutil], [libavutil],
439 [CFLAGS="${libavutil_CFLAGS} ${CFLAGS}" LIBS="${libavutil_LIBS} ${LIBS}"],
440 [AC_MSG_ERROR(AirPlay 2 support requires libavutil -- libavutil-dev suggested)]
441 )
442 PKG_CHECK_MODULES(
443 [libavcodec], [libavcodec],
444 [CFLAGS="${libavcodec_CFLAGS} ${CFLAGS}" LIBS="${libavcodec_LIBS} ${LIBS}"],
445 [AC_CHECK_LIB(
446 [avcodec], [avcodec_find_decoder],
447 [],
448 [AC_MSG_ERROR(AirPlay 2 support requires libavcodec -- libavcodec-dev suggested)]
449 )]
450 )
451 PKG_CHECK_MODULES(
452 [libavformat], [libavformat],
453 [CFLAGS="${libavformat_CFLAGS} ${CFLAGS}" LIBS="${libavformat_LIBS} ${LIBS}"],
454 [AC_CHECK_LIB(
455 [avformat], [avformat_new_stream],
456 [],
457 [AC_MSG_ERROR([AirPlay 2 support requires libavformat -- libavformat-dev suggested])]
458 )]
459 )
460 PKG_CHECK_MODULES(
461 [libswresample], [libswresample],
462 [CFLAGS="${libswresample_CFLAGS} ${CFLAGS}" LIBS="${libswresample_LIBS} ${LIBS}"],
463 [AC_CHECK_LIB(
464 [swresample], [swr_convert],
465 [],
466 [AC_MSG_ERROR([AirPlay 2 support requires libswresample -- libswresample-dev suggested])]
467 )]
468 )
469 PKG_CHECK_MODULES(
470 [libuuid], [uuid],
471 [CFLAGS="${libuuid_CFLAGS} ${CFLAGS}" LIBS="${libuuid_LIBS} ${LIBS}"],
472 [AC_CHECK_LIB(
473 [uuid], [uuid_generate],
474 [],
475 [AC_MSG_ERROR([AirPlay 2 support requires the uuid library -- uuid-dev suggested])]
476 )]
477 )
8110851d
MB
478fi
479AM_CONDITIONAL([USE_AIRPLAY_2], [test "x$with_airplay_2" = "xyes"])
480
b7723d3a
MB
481if test "x${with_systemd}" = xyes ; then
482 # Find systemd unit dir
483 AC_ARG_WITH([systemdsystemunitdir],
484 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
485 [with_systemdsystemunitdir=auto])
486 AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
487 def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
488
489 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
490 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
491 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
492 with_systemdsystemunitdir=no],
493 [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
494 AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
495 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
b7723d3a 496fi
0ad11fb1 497
9d450966 498# Checks for header files.
9d450966 499AC_CHECK_HEADERS([getopt_long.h])
04aa3261 500AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h mach/mach.h memory.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h syslog.h unistd.h])
9d450966
MB
501
502# Checks for typedefs, structures, and compiler characteristics.
5bdc16e3
MB
503AC_C_INLINE
504AC_TYPE_INT16_T
505AC_TYPE_INT32_T
506AC_TYPE_INT64_T
507AC_TYPE_PID_T
508AC_TYPE_SIZE_T
509AC_TYPE_SSIZE_T
510AC_TYPE_UINT16_T
511AC_TYPE_UINT32_T
512AC_TYPE_UINT64_T
513AC_TYPE_UINT8_T
9d450966
MB
514
515# Checks for library functions.
04aa3261 516AC_FUNC_ALLOCA
5bdc16e3
MB
517AC_FUNC_ERROR_AT_LINE
518AC_FUNC_FORK
04aa3261 519AC_CHECK_FUNCS([atexit clock_gettime gethostname inet_ntoa memchr memmove memset mkfifo pow select socket stpcpy strcasecmp strchr strdup strerror strstr strtol strtoul])
9d450966 520
38bbad6f 521# Note -- there are AC_CONFIG_FILES directives further back, conditional on Avahi
86a52964 522AC_CONFIG_FILES([Makefile])
93516018 523AC_CONFIG_FILES([scripts/shairport-sync],[chmod +x scripts/shairport-sync])
9d450966 524AC_OUTPUT