1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ([2.50])
5AC_INIT([shairport-sync], [3.3.9], [4265913+mikebrady@users.noreply.github.com])
6AM_INIT_AUTOMAKE([subdir-objects])
7AC_CONFIG_SRCDIR([shairport.c])
8AC_CONFIG_HEADERS([config.h])
9AC_PROG_RANLIB
10
11# Derived from the Avahi configure.ac file
12# Specifying the OS type, defaulting to linux.
13#
14AC_ARG_WITH(os, AS_HELP_STRING([--with-os=OSType],[Specify the distribution to target: One of linux freebsd or darwin]))
15if test "z$with_os" = "z"; then
16  with_os="linux"
17fi
18with_os=`echo ${with_os} | tr '[[:upper:]]' '[[:lower:]]' `
19
20if test "x${with_os}" != xlinux && "x${with_os}" != xfreebsd && "x${with_os}" != xdarwin ; then
21	AC_MSG_ERROR(--with-os=<arg> argument must linux, freebsd, openbsd or darwin)
22fi
23
24# Checks for programs.
25AC_PROG_CC
26AC_PROG_CXX
27AC_PROG_INSTALL
28
29PKG_PROG_PKG_CONFIG([0.9.0])
30
31# Checks for libraries.
32if test "x${with_os}" = xlinux -o "x${with_os}" = xfreebsd ; then
33 AC_CHECK_LIB([rt],[clock_gettime], , AC_MSG_ERROR(librt needed))
34fi
35
36if test "x${with_os}" = xopenbsd ; then
37 AC_CHECK_LIB([c],[clock_gettime], , AC_MSG_ERROR(libc needed))
38fi
39
40AM_CONDITIONAL([BUILD_FOR_LINUX], [test "x${with_os}" = xlinux ])
41AM_CONDITIONAL([BUILD_FOR_FREEBSD], [test "x${with_os}" = xfreebsd ])
42AM_CONDITIONAL([BUILD_FOR_OPENBSD], [test "x${with_os}" = xopenbsd ])
43
44
45##### Some build systems are not fully using pkg-config, so we can use the flag ${with_pkg_config} on a case-by-case basis
46##### to control how to deal with them
47##### Note -- this flag is sometimes ignored, especially for newer packages
48
49AC_ARG_WITH([pkg_config],[AS_HELP_STRING([--with-pkg-config],[use pkg-config to find libraries])],[],[with_pkg_config=yes])
50
51##### The following check for the pthreads library doesn't put the compiler into the correct pthread mode
52##### so we add the -pthread compilation flag in AMFLAGS in the Makefile.am as well.
53
54AC_CHECK_LIB([pthread],[pthread_create], , AC_MSG_ERROR(pthread library needed))
55AC_CHECK_LIB([m],[exp], , AC_MSG_ERROR(maths library needed))
56
57if  test "x${with_pkg_config}" = xyes ; then
58  PKG_CHECK_MODULES(
59      [popt], [popt],
60      [CFLAGS="${popt_CFLAGS} ${CFLAGS}"
61      LIBS="${popt_LIBS} ${LIBS}"], AC_MSG_ERROR(libpopt needed))
62else
63  AC_CHECK_LIB([popt],[poptGetContext], , AC_MSG_ERROR(libpopt needed))
64fi
65
66AC_ARG_WITH([dummy],[AS_HELP_STRING([--with-dummy],[include the dummy audio back end])])
67if test "x$with_dummy" = "xyes" ; then
68  AC_MSG_RESULT(include the dummy audio back end)
69  AC_DEFINE([CONFIG_DUMMY], 1, [Include a fake audio backend.])
70fi
71AM_CONDITIONAL([USE_DUMMY], [test "x$with_dummy" = "xyes" ])
72
73AC_ARG_WITH([stdout],[AS_HELP_STRING([--with-stdout],[include the stdout audio back end])])
74if test "x$with_stdout" = "xyes" ; then
75  AC_MSG_RESULT(include the stdout audio back end)
76  AC_DEFINE([CONFIG_STDOUT], 1, [Include an audio backend to output to standard output (stdout).])
77fi
78AM_CONDITIONAL([USE_STDOUT], [test "x$with_stdout" = "xyes"])
79
80AC_ARG_WITH([pipe],[AS_HELP_STRING([--with-pipe],[include the pipe audio back end])])
81if test "x$with_pipe" = "xyes" ; then
82  AC_MSG_RESULT(include the pipe audio back end)
83  AC_DEFINE([CONFIG_PIPE], 1, [Include an audio backend to output to a unix pipe.])
84fi
85AM_CONDITIONAL([USE_PIPE], [test "x$with_pipe" = "xyes" ])
86
87# Check to see if we should include the System V initscript
88
89AC_ARG_WITH([systemv],[AS_HELP_STRING([--with-systemv],[install a System V startup script during a make install])])
90AM_CONDITIONAL([INSTALL_SYSTEMV], [test "x$with_systemv" = "xyes"])
91
92# Check to see if we should include the systemd stuff to define it as a service
93
94AC_ARG_WITH([systemd],[AS_HELP_STRING([--with-systemd],[install a systemd startup script during a make install])])
95AM_CONDITIONAL([INSTALL_SYSTEMD], [test "x$with_systemd" = "xyes"])
96
97AC_ARG_WITH([freebsd-service],[AS_HELP_STRING([--with-freebsd-service],[install a FreeBSD startup script during a make install])])
98AM_CONDITIONAL([INSTALL_FREEBSD_SERVICE], [test "x$with_freebsd_service" = "xyes"])
99
100AC_ARG_WITH([cygwin-service],[AS_HELP_STRING([--with-cygwin-service],[install a CYGWIN config script during a make install])])
101AM_CONDITIONAL([INSTALL_CYGWIN_SERVICE], [test "x$with_cygwin_service" = "xyes"])
102
103AC_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])])
104if  test "x$with_external_mdns" = xyes ; then
105	AC_MSG_RESULT(include external mdns support)
106	AC_DEFINE([CONFIG_EXTERNAL_MDNS], 1, [Use 'avahi-publish-service' or 'mDNSPublish' to advertise.])
107fi
108AM_CONDITIONAL([USE_EXTERNAL_MDNS], [test "x$with_external_mdns" = "xyes" ])
109
110# Add the libconfig package
111if  test "x${with_pkg_config}" = xyes ; then
112  PKG_CHECK_MODULES(
113      [libconfig], [libconfig],
114      [LIBS="${libconfig_LIBS} ${LIBS}"], AC_MSG_ERROR([libconfig library needed]))
115else
116  AC_CHECK_LIB([config],[config_init], , AC_MSG_ERROR([libconfig library needed]))
117fi
118
119AC_ARG_WITH([configfiles],[AS_HELP_STRING([--with-configfiles],[install configuration files during a make install])], ,[with_configfiles=yes])
120AM_CONDITIONAL([INSTALL_CONFIG_FILES], [test "x$with_configfiles" = "xyes"])
121
122# Look for Apple ALAC flag
123AC_ARG_WITH(apple-alac,[AS_HELP_STRING([--with-apple-alac],[include support for the Apple ALAC decoder])])
124if test "x${with_apple_alac}"  = "xyes" ; then
125  AC_DEFINE([CONFIG_APPLE_ALAC], 1, [Include support for using the Apple ALAC Decoder])
126  if  test "x${with_pkg_config}" = xyes ; then
127    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.))
128  else
129    AC_CHECK_LIB([alac], [BitBufferInit], , AC_MSG_ERROR(Apple ALAC Decoder support requires the ALAC library. See https://github.com/mikebrady/alac.))
130  fi
131fi
132AM_CONDITIONAL([USE_APPLE_ALAC], [test "x${with_apple_alac}" = "xyes"])
133
134# Look for piddir flag
135AC_ARG_WITH(piddir, [AS_HELP_STRING([--with-piddir=<pathname>],[Specify a pathname to a directory in which to write the PID file.])])
136if  test "x${with_piddir}" != "x" ; then
137	AC_MSG_CHECKING(--with-piddir argument)
138	if test "x${with_piddir}" = x -o "x${with_piddir}" = xyes ; then
139		AC_MSG_RESULT(not found)
140		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)
141	fi
142	AC_MSG_RESULT(${with_piddir})
143	AC_SUBST(CUSTOM_PID_DIR,["${with_piddir}"])
144	AC_DEFINE([DEFINED_CUSTOM_PID_DIR],1,[Hook up special proc to libdaemon to point to this directory])
145fi
146AM_CONDITIONAL([USE_CUSTOMPIDDIR], [ test "x${with_piddir}" != "x" ])
147
148# Look for libdaemon
149AC_ARG_WITH(libdaemon,[AS_HELP_STRING([--with-libdaemon],[include support for daemonising in non-systemd systems])])
150if test "x$with_libdaemon" = "xyes"; then
151	AC_DEFINE([CONFIG_LIBDAEMON], 1, [Include libdaemon for daemonising in non-systemd systems])
152	if  test "x${with_pkg_config}" = xyes ; then
153		PKG_CHECK_MODULES(
154				[DAEMON], [libdaemon],
155				[LIBS="${DAEMON_LIBS} ${LIBS}"],
156				[AC_MSG_ERROR(the libdaemon library has been selected but is missing -- libdaemon-dev suggested!)])
157	else
158		AC_CHECK_LIB([daemon],[daemon_fork], , AC_MSG_ERROR(the libdaemon library has been selected but is missing -- libdaemon-dev suggested!))
159	fi
160fi
161AM_CONDITIONAL([USE_LIBDAEMON], [test "x$with_libdaemon" = "xyes"])
162
163# Check --with-ssl=argument
164AC_ARG_WITH(ssl, [AS_HELP_STRING([--with-ssl=<argument>],[choose --with-ssl=openssl, --with-ssl=mbedtls or --with-ssl=polarssl (deprecated) for encryption services  ])])
165
166if test "x${with_ssl}" = xopenssl ; then
167	AC_DEFINE([CONFIG_OPENSSL], 1, [Use the OpenSSL libraries for encryption and encoding and decoding])
168	if  test "x${with_pkg_config}" = xyes ; then
169	  PKG_CHECK_MODULES(
170	      [SSL], [libssl,libcrypto],
171	      [LIBS="${SSL_LIBS} ${LIBS}"])
172	else
173	  AC_CHECK_LIB([crypto], [main], , AC_MSG_ERROR(libcrypto selected but the library cannot be found!))
174	  AC_CHECK_LIB([ssl], [main], , AC_MSG_ERROR(libssl selected but the library cannot be found!))
175	fi
176elif test "x${with_ssl}" = xmbedtls ; then
177	AC_DEFINE([CONFIG_MBEDTLS], 1, [Use the mbed TLS libraries for encryption and encoding and decoding])
178	AC_CHECK_LIB([mbedtls],[mbedtls_ssl_init],,
179		[AC_MSG_ERROR([mbed tls support requires the mbedtls library -- libmbedtls-dev suggested],1)])
180	AC_CHECK_LIB([mbedcrypto], [mbedtls_entropy_func],,
181	            [AC_MSG_ERROR([mbed tls support requires the mbedcrypto library -- libmbedcrypto0 suggested],1)])
182	AC_CHECK_LIB([mbedx509], [mbedtls_pk_init],,
183	            [AC_MSG_ERROR([mbed tls support requires the mbedx509 library -- libmbedx509-0 suggested],1)])
184elif test "x${with_ssl}" = xpolarssl ; then
185	AC_DEFINE([CONFIG_POLARSSL], 1, [Use the PolarSSL libraries for encryption and encoding and decoding])
186	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.))
187else
188	AC_MSG_ERROR(specify one of --with-ssl=openssl or --with-ssl=mbedtls or --with-ssl=polarssl)
189fi
190
191# Look for soxr flag
192
193AC_ARG_WITH(soxr, [AS_HELP_STRING([--with-soxr],[choose libsoxr for high-quality interpolation])])
194if test "x$with_soxr" = "xyes" ; then
195  AC_DEFINE([CONFIG_SOXR], 1, [Include support for using the SoX Resampler library for interpolation])
196  if  test "x${with_pkg_config}" = xyes ; then
197    PKG_CHECK_MODULES(
198        [soxr], [soxr],
199        [LIBS="${soxr_LIBS} ${LIBS}"],
200        [AC_MSG_ERROR(soxr support requires the libsoxr library -- libsoxr-dev suggested!)])
201  else
202    AC_CHECK_LIB([avutil],[av_get_cpu_flags])
203    if  test "x${ac_cv_lib_avutil_av_get_cpu_flags}" = xyes ; then
204      # soxr may link against libavutil, depending on the architecture, but for the sake of simplicity link with it if it is found
205      AC_CHECK_LIB([soxr],[soxr_create], , AC_MSG_ERROR(soxr support requires the libsoxr library -- libsoxr-dev suggested!), [-lavutil])
206    else
207      AC_CHECK_LIB([soxr],[soxr_create], , AC_MSG_ERROR(soxr support requires the libsoxr library -- libsoxr-dev suggested!))
208    fi
209  fi
210fi
211
212# Look for metadata flag and resolve it further down the script
213AC_ARG_WITH(metadata,[AS_HELP_STRING([--with-metadata],[include support for a metadata feed])])
214
215# 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
216# and the relevant link files are added.
217
218# Look for avahi flag
219AC_ARG_WITH(avahi, [AS_HELP_STRING([--with-avahi],[choose Avahi-based mDNS support])])
220if test "x$with_avahi" = "xyes" ; then
221  AC_DEFINE([CONFIG_AVAHI], 1, [Include Avahi-based mDNS support.])
222  AC_CHECK_LIB([avahi-client], [avahi_client_new], , AC_MSG_ERROR(Avahi support requires the avahi-client library!))
223  AC_CHECK_LIB([avahi-common],[avahi_strerror], , AC_MSG_ERROR(Avahi support requires the avahi-common library!))
224fi
225AM_CONDITIONAL([USE_AVAHI], [test "x$with_avahi" = "xyes"])
226
227# Look for tinysvcmdns flag
228AC_ARG_WITH(tinysvcmdns, [AS_HELP_STRING([--with-tinysvcmdns],[choose tinysvcmdns-based mDNS support])])
229if test "x$with_tinysvcmdns" = "xyes" ; then
230  AC_DEFINE([CONFIG_TINYSVCMDNS], 1, [Include TinySVCmDNS-based mDNS support])
231fi
232AM_CONDITIONAL([USE_TINYSVCMDNS], [test "x$with_tinysvcmdns" = "xyes"])
233
234# Look for ALSA flag
235AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa],[choose ALSA API support (GNU/Linux only)])])
236if test "x$with_alsa" = "xyes" ; then
237  AC_DEFINE([CONFIG_ALSA], 1, [Needed by the compiler.])
238  if  test "x${with_pkg_config}" = xyes ; then
239    PKG_CHECK_MODULES(
240      [alsa], [alsa],
241      [LIBS="${alsa_LIBS} ${LIBS}"])
242  else
243    AC_CHECK_LIB([asound], [snd_pcm_open], , AC_MSG_ERROR(ALSA support requires the asound library!))
244  fi
245fi
246AM_CONDITIONAL([USE_ALSA], [test "x$with_alsa" = "xyes"])
247
248# Look for jack flag
249AC_ARG_WITH(jack, [AS_HELP_STRING([--with-jack],[include a Jack Audio Connection Kit (jack) backend])])
250if test "x$with_jack" = "xyes" ; then
251  AC_DEFINE([CONFIG_JACK], 1, [Include a Jack Audio Connection Kit (jack) audio backend])
252  if  test "x${with_pkg_config}" = xyes ; then
253    PKG_CHECK_MODULES(
254      [jack], [jack],
255      [LIBS="${jack_LIBS} ${LIBS}"],
256      [AC_MSG_ERROR(Jack Audio Connection Kit support requires the jack library -- libjack-dev suggested!)])
257  else
258    AC_CHECK_LIB([jack], [jack_client_open], , AC_MSG_ERROR(Jack Audio Connection Kit support requires the jack library -- libjack-dev suggested!))
259  fi
260fi
261AM_CONDITIONAL([USE_JACK], [test "x$with_jack" = "xyes"])
262
263# Look for SNDIO flag
264AC_ARG_WITH(sndio, [AS_HELP_STRING([--with-sndio],[choose SNDIO API support])])
265if test "x$with_sndio" = "xyes" ; then
266  AC_DEFINE([CONFIG_SNDIO], 1, [Include a sndio-compatible audio backend.])
267  AC_CHECK_LIB([sndio], [sio_open], , AC_MSG_ERROR(SNDIO support requires the sndio library -- libsndio-dev suggested))
268fi
269AM_CONDITIONAL([USE_SNDIO], [test "x$with_sndio" = "xyes"])
270
271# Look for AO flag
272AC_ARG_WITH(ao, [AS_HELP_STRING([--with-ao],[choose AO (Audio Output?) API support. N.B. no synchronisation -- so underflow or overflow is inevitable!])])
273if test "x$with_ao" = "xyes" ; then
274  AC_DEFINE([CONFIG_AO], 1, [Include an AO-compatible  audio backend.])
275  AC_CHECK_LIB([ao], [ao_initialize], , AC_MSG_ERROR(AO support requires the ao library -- libao-dev suggested))
276fi
277AM_CONDITIONAL([USE_AO], [test "x$with_ao" = "xyes"])
278
279# Look for Soundio flag
280AC_ARG_WITH(soundio, [AS_HELP_STRING([--with-soundio],[choose soundio API support.])])
281if test "x$with_soundio" = "xyes" ; then
282  AC_DEFINE([CONFIG_SOUNDIO], 1, [Include SoundIO Support.])
283  AC_CHECK_LIB([soundio], [soundio_create], , AC_MSG_ERROR(soundio support requires the soundio library -- libsoundio-dev suggested))
284fi
285AM_CONDITIONAL([USE_SOUNDIO], [test "x$with_soundio" = "xyes"])
286
287# Look for pulseaudio flag
288AC_ARG_WITH(pa, [AS_HELP_STRING([--with-pa],[choose PulseAudio support.])])
289if test "x$with_pa" = "xyes" ; then
290  AC_DEFINE([CONFIG_PA], 1, [Include PulseAudio support.])
291  if  test "x${with_pkg_config}" = xyes ; then
292    PKG_CHECK_MODULES(
293      [PULSEAUDIO], [libpulse >= 0.9.2],
294      [LIBS="${PULSEAUDIO_LIBS} ${LIBS}"],[AC_MSG_ERROR(PulseAudio support requires the libpulse-dev library!)])
295  else
296    AC_CHECK_LIB([pulse-simple], [pa_simple_new], , AC_MSG_ERROR(PulseAudio support requires the libpulse library!))
297    AC_CHECK_LIB([pulse], [pa_stream_peek], , AC_MSG_ERROR(PulseAudio support requires the libpulse-dev library.))
298  fi
299fi
300AM_CONDITIONAL([USE_PA], [test "x$with_pa" = "xyes"])
301
302# Look for Convolution flag
303AC_ARG_WITH(convolution, [AS_HELP_STRING([--with-convolution],[choose audio DSP convolution support])])
304if test "x$with_convolution" = "xyes" ; then
305  AC_DEFINE([CONFIG_CONVOLUTION], 1, [Include audio DSP convolution support.])
306  AC_CHECK_LIB([sndfile], [sf_open], , AC_MSG_ERROR(Convolution support requires the sndfile library -- libsndfile1-dev suggested!))
307fi
308AM_CONDITIONAL([USE_CONVOLUTION], [test "x$with_convolution" = "xyes"])
309
310# Look for dns_sd flag
311AC_ARG_WITH(dns_sd, [AS_HELP_STRING([--with-dns_sd],[choose dns_sd mDNS support])])
312if test "x$with_dns_sd" = "xyes" ; then
313  AC_DEFINE([CONFIG_DNS_SD], 1, [Include dns_sd mDNS support.])
314  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.)])
315fi
316AM_CONDITIONAL([USE_DNS_SD], [test "x$with_dns_sd" = "xyes"])
317
318# Look for dbus flag
319AC_ARG_WITH(dbus-interface, [AS_HELP_STRING([--with-dbus-interface],[include support for the native Shairport Sync D-Bus interface])])
320if test "x$with_dbus_interface" = "xyes" ; then
321  AC_DEFINE([CONFIG_DBUS_INTERFACE], 1, [Support the native Shairport Sync D-Bus interface])
322  # remember to include glib, below
323fi
324AM_CONDITIONAL([USE_DBUS], [test "x$with_dbus_interface" = "xyes"])
325
326# Look for dbus test client flag
327AC_ARG_WITH(dbus-test-client, [AS_HELP_STRING([--with-dbus-test-client],[compile a D-Bus test client application])])
328# remember to include glib, below
329AM_CONDITIONAL([USE_DBUS_CLIENT], [test "x$with_dbus_test_client" = "xyes"])
330
331# Look for mpris flag
332AC_ARG_WITH(mpris-interface, [AS_HELP_STRING([--with-mpris-interface],[include support for a D-Bus interface conforming to the MPRIS standard])])
333if test "x$with_mpris_interface" = "xyes" ; then
334  AC_DEFINE([CONFIG_MPRIS_INTERFACE], 1, [Support the MPRIS standard])
335  # remember to include glib, below
336fi
337AM_CONDITIONAL([USE_MPRIS], [test "x$with_mpris_interface" = "xyes"])
338
339# Look for mpris test client flag
340AC_ARG_WITH(mpris-test-client, [AS_HELP_STRING([--with-mpris-test-client],[compile an MPRIS test client application])])
341# remember to include glib, below
342AM_CONDITIONAL([USE_MPRIS_CLIENT], [test "x$with_mpris_test_client" = "xyes"])
343
344if 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
345  PKG_CHECK_MODULES([glib], [gio-unix-2.0 >= 2.30.0],[CFLAGS="${glib_CFLAGS} ${CFLAGS}" LIBS="${glib_LIBS} ${LIBS}"],[AC_MSG_ERROR(MPRIS client support requires the glib 2.0 library -- libglib2.0-dev suggested!)])
346fi
347
348# Look for mqtt flag
349AC_ARG_WITH(mqtt-client, [AS_HELP_STRING([--with-mqtt-client],[include a client for MQTT -- the Message Queuing Telemetry Transport protocol])])
350if test "x$with_mqtt_client" = "xyes" ; then
351  AC_DEFINE([CONFIG_MQTT], 1, [Include a client for MQTT, the Message Queuing Telemetry Transport protocol])
352  AC_CHECK_LIB([mosquitto], [mosquitto_lib_init], , AC_MSG_ERROR(MQTT support requires the mosquitto library -- libmosquitto-dev suggested!))
353fi
354AM_CONDITIONAL([USE_MQTT], [test "x$with_mqtt_client" = "xyes"])
355
356if test "x$with_mqtt_client" = "xyes" && test "x$with_avahi" != "xyes" ; then
357  AC_MSG_WARN([MQTT needs Avahi for remote control functionality. With the current configuration settings, only metadata publishing will be supported.])
358fi
359
360if test "x$with_mpris_interface" = "xyes" || test "x$with_dbus_interface" = "xyes" || test "x$with_mqtt_client" = "xyes" ; then
361  REQUESTED_EXTENDED_METADATA_SUPPORT=1
362  AC_DEFINE([CONFIG_METADATA_HUB], 1, [Needed by the compiler.])
363  AC_DEFINE([CONFIG_DACP_CLIENT], 1, [Needed by the compiler.])
364fi
365AM_CONDITIONAL([USE_METADATA_HUB], [test "x$REQUESTED_EXTENDED_METADATA_SUPPORT" = "x1"])
366AM_CONDITIONAL([USE_DACP_CLIENT], [test "x$REQUESTED_EXTENDED_METADATA_SUPPORT" = "x1"])
367
368if test "x$REQUESTED_EXTENDED_METADATA_SUPPORT" = "x1" || test "x$with_metadata" = "xyes" ; then
369  AC_DEFINE([CONFIG_METADATA], 1, [Needed by the compiler.])
370fi
371AM_CONDITIONAL([USE_METADATA], [test "x$with_metadata" = "xyes"])
372
373if  test "x${with_systemd}" = xyes ; then
374  # Find systemd unit dir
375  AC_ARG_WITH([systemdsystemunitdir],
376       [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
377       [with_systemdsystemunitdir=auto])
378  AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
379       def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
380
381       AS_IF([test "x$def_systemdsystemunitdir" = "x"],
382     [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
383      [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
384      with_systemdsystemunitdir=no],
385     [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
386  AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
387        [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
388fi
389
390# Look for xmltoman
391AC_CHECK_PROGS([XMLTOMAN], [xmltoman])
392if test -z "$XMLTOMAN"; then
393  AC_MSG_WARN([xmltoman not found - not rebuilding man pages])
394fi
395AM_CONDITIONAL([HAVE_XMLTOMAN], [test -n "$XMLTOMAN"])
396
397# Checks for header files.
398AC_HEADER_STDC
399AC_CHECK_HEADERS([getopt_long.h])
400AC_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])
401
402# Checks for typedefs, structures, and compiler characteristics.
403AC_C_INLINE
404AC_TYPE_INT16_T
405AC_TYPE_INT32_T
406AC_TYPE_INT64_T
407AC_TYPE_PID_T
408AC_TYPE_SIZE_T
409AC_TYPE_SSIZE_T
410AC_TYPE_UINT16_T
411AC_TYPE_UINT32_T
412AC_TYPE_UINT64_T
413AC_TYPE_UINT8_T
414
415# Checks for library functions.
416AC_FUNC_ALLOCA
417AC_FUNC_ERROR_AT_LINE
418AC_FUNC_FORK
419AC_CHECK_FUNCS([atexit clock_gettime gethostname inet_ntoa memchr memmove memset mkfifo pow select socket stpcpy strcasecmp strchr strdup strerror strstr strtol strtoul])
420
421AC_CONFIG_FILES([Makefile man/Makefile scripts/shairport-sync.service])
422AC_CONFIG_FILES([scripts/shairport-sync],[chmod +x scripts/shairport-sync])
423AC_OUTPUT
424