1SUBDIRS = man
2ARFLAGS = cr
3lib_dbus_interface_a_CFLAGS = -pthread
4lib_mpris_interface_a_CFLAGS = -pthread
5
6
7bin_PROGRAMS = shairport-sync
8
9# See below for the flags for the test client program
10
11shairport_sync_SOURCES = shairport.c rtsp.c mdns.c common.c rtp.c player.c alac.c audio.c loudness.c activity_monitor.c
12
13if BUILD_FOR_FREEBSD
14  AM_CXXFLAGS = -I/usr/local/include -Wno-multichar -Wall -Wextra -pthread -DSYSCONFDIR=\"$(sysconfdir)\"
15  AM_CFLAGS = -Wno-multichar -Wall -Wextra -pthread -DSYSCONFDIR=\"$(sysconfdir)\"
16else
17if BUILD_FOR_OPENBSD
18  AM_CXXFLAGS = -I/usr/local/include -Wno-multichar -Wall -Wextra -pthread -DSYSCONFDIR=\"$(sysconfdir)\"
19  AM_CFLAGS = -Wno-multichar -Wall -Wextra -pthread -DSYSCONFDIR=\"$(sysconfdir)\"
20else
21  AM_CXXFLAGS = -fno-common -Wno-multichar -Wall -Wextra -pthread -DSYSCONFDIR=\"$(sysconfdir)\"
22  AM_CFLAGS = -fno-common -Wno-multichar -Wall -Wextra -pthread -DSYSCONFDIR=\"$(sysconfdir)\"
23endif
24endif
25
26if USE_APPLE_ALAC
27  shairport_sync_SOURCES += apple_alac.cpp
28endif
29
30if USE_CUSTOMPIDDIR
31AM_CFLAGS+= \
32	-DPIDDIR=\"$(CUSTOM_PID_DIR)\"
33endif
34
35if USE_AVAHI
36shairport_sync_SOURCES += mdns_avahi.c
37endif
38
39if USE_TINYSVCMDNS
40shairport_sync_SOURCES += mdns_tinysvcmdns.c tinysvcmdns.c
41endif
42
43if USE_EXTERNAL_MDNS
44shairport_sync_SOURCES += mdns_external.c
45endif
46
47if USE_ALSA
48shairport_sync_SOURCES += audio_alsa.c
49endif
50
51if USE_JACK
52shairport_sync_SOURCES += audio_jack.c
53endif
54
55if USE_SNDIO
56shairport_sync_SOURCES += audio_sndio.c
57endif
58
59if USE_STDOUT
60shairport_sync_SOURCES += audio_stdout.c
61endif
62
63if USE_PIPE
64shairport_sync_SOURCES += audio_pipe.c
65endif
66
67if USE_DUMMY
68shairport_sync_SOURCES += audio_dummy.c
69endif
70
71if USE_AO
72shairport_sync_SOURCES += audio_ao.c
73endif
74
75if USE_SOUNDIO
76shairport_sync_SOURCES += audio_soundio.c
77endif
78
79if USE_PA
80shairport_sync_SOURCES += audio_pa.c
81endif
82
83if USE_CONVOLUTION
84shairport_sync_SOURCES += FFTConvolver/AudioFFT.cpp FFTConvolver/FFTConvolver.cpp FFTConvolver/Utilities.cpp FFTConvolver/convolver.cpp
85AM_CXXFLAGS += -std=c++11
86endif
87
88if USE_DNS_SD
89shairport_sync_SOURCES += mdns_dns_sd.c
90endif
91
92if USE_METADATA_HUB
93shairport_sync_SOURCES += metadata_hub.c
94endif
95
96if USE_MQTT
97shairport_sync_SOURCES += mqtt.c
98endif
99
100if USE_DACP_CLIENT
101shairport_sync_SOURCES += dacp.c tinyhttp/chunk.c tinyhttp/header.c tinyhttp/http.c
102endif
103
104BUILT_SOURCES =
105noinst_HEADERS =
106CLEANFILES =
107shairport_sync_LDADD =
108noinst_LIBRARIES =
109
110if USE_DBUS
111shairport_sync_LDADD += lib_dbus_interface.a
112noinst_LIBRARIES += lib_dbus_interface.a
113lib_dbus_interface_a_SOURCES = dbus-interface.c
114shairport_sync_SOURCES += dbus-service.c
115BUILT_SOURCES += dbus-interface.h dbus-interface.c
116# We don't want to install this header
117noinst_HEADERS += $(BUILT_SOURCES)
118# Correctly clean the generated headers, but keep the xml description
119CLEANFILES += $(BUILT_SOURCES)
120
121dbus-interface.c:  org.gnome.ShairportSync.xml
122	gdbus-codegen --interface-prefix org.gnome --generate-c-code dbus-interface org.gnome.ShairportSync.xml
123dbus-interface.h: dbus-interface.c
124	touch dbus-interface.h
125endif
126
127if USE_MPRIS
128shairport_sync_LDADD += lib_mpris_interface.a
129noinst_LIBRARIES += lib_mpris_interface.a
130lib_mpris_interface_a_SOURCES = mpris-interface.c
131shairport_sync_SOURCES += mpris-service.c
132BUILT_SOURCES += mpris-interface.h mpris-interface.c
133# We don't want to install this header
134noinst_HEADERS += $(BUILT_SOURCES)
135# Correctly clean the generated headers, but keep the xml description
136CLEANFILES += $(BUILT_SOURCES)
137
138mpris-interface.c:  org.mpris.MediaPlayer2.xml
139	gdbus-codegen --interface-prefix org.mpris --generate-c-code mpris-interface org.mpris.MediaPlayer2.xml
140mpris-interface.h: mpris-interface.c
141	touch mpris-interface.h
142endif
143
144noinst_PROGRAMS =
145
146if USE_DBUS_CLIENT
147 #Make it, but don't install it anywhere
148noinst_PROGRAMS += shairport-sync-dbus-test-client
149shairport_sync_dbus_test_client_SOURCES = shairport-sync-dbus-test-client.c
150shairport_sync_dbus_test_client_LDADD = lib_dbus_interface.a
151endif
152
153if USE_MPRIS_CLIENT
154 #Make it, but don't install it anywhere
155noinst_PROGRAMS += shairport-sync-mpris-test-client
156shairport_sync_mpris_test_client_SOURCES = shairport-sync-mpris-test-client.c
157shairport_sync_mpris_test_client_LDADD = lib_mpris_interface.a
158endif
159
160install-exec-hook:
161if BUILD_FOR_LINUX
162DBUS_POLICY_DIR=$(DESTDIR)/etc/dbus-1/system.d
163else
164DBUS_POLICY_DIR=$(DESTDIR)$(sysconfdir)/dbus-1/system.d
165endif
166if INSTALL_CONFIG_FILES
167	[ -e $(DESTDIR)$(sysconfdir) ] || mkdir $(DESTDIR)$(sysconfdir)
168	cp scripts/shairport-sync.conf $(DESTDIR)$(sysconfdir)/shairport-sync.conf.sample
169	[ -f $(DESTDIR)$(sysconfdir)/shairport-sync.conf ] || cp scripts/shairport-sync.conf $(DESTDIR)$(sysconfdir)/shairport-sync.conf
170if USE_DBUS
171	[ -e $(DBUS_POLICY_DIR) ] || mkdir -p $(DBUS_POLICY_DIR)
172if INSTALL_CYGWIN_SERVICE
173	cp scripts/shairport-sync-dbus-policy-cygwin.conf $(DBUS_POLICY_DIR)/shairport-sync-dbus.conf
174else
175	cp scripts/shairport-sync-dbus-policy.conf $(DBUS_POLICY_DIR)/shairport-sync-dbus.conf
176endif
177endif
178if USE_MPRIS
179	[ -e $(DBUS_POLICY_DIR) ] || mkdir -p $(DBUS_POLICY_DIR)
180if INSTALL_CYGWIN_SERVICE
181	cp scripts/shairport-sync-mpris-policy-cygwin.conf $(DBUS_POLICY_DIR)/shairport-sync-mpris.conf
182else
183	cp scripts/shairport-sync-mpris-policy.conf $(DBUS_POLICY_DIR)/shairport-sync-mpris.conf
184endif
185endif
186endif
187if INSTALL_SYSTEMV
188	getent group shairport-sync &>/dev/null || groupadd -r shairport-sync >/dev/null
189	getent passwd shairport-sync &> /dev/null || useradd -r -M -g shairport-sync -s /usr/bin/nologin -G audio shairport-sync >/dev/null
190	[ -e $(DESTDIR)$(sysconfdir)/init.d ] || mkdir -p $(DESTDIR)$(sysconfdir)/init.d
191	[ -f $(DESTDIR)$(sysconfdir)/init.d/shairport-sync ] || cp scripts/shairport-sync $(DESTDIR)$(sysconfdir)/init.d/
192endif
193if INSTALL_SYSTEMD
194	getent group shairport-sync &>/dev/null || groupadd -r shairport-sync >/dev/null
195	getent passwd shairport-sync &> /dev/null || useradd -r -M -g shairport-sync -s /usr/bin/nologin -G audio shairport-sync >/dev/null
196	[ -e $(DESTDIR)$(systemdsystemunitdir) ] || mkdir -p $(DESTDIR)$(systemdsystemunitdir)
197	[ -f $(DESTDIR)$(systemdsystemunitdir)/shairport-sync.service ] || cp scripts/shairport-sync.service $(DESTDIR)$(systemdsystemunitdir)
198endif
199if INSTALL_FREEBSD_SERVICE
200  # Choose a uid and gid of 801 completely arbitrarity, except that it should be below 1000. FreeBSD doesn't seem to allow you to say "an ID in the range of..."
201	pw showgroup shairport-sync > /dev/null 2>&1 || pw addgroup -n shairport-sync -g 801 > /dev/null 2>&1
202	pw showuser shairport-sync > /dev/null 2>&1 || pw adduser -c "shairport-sync unprivileged user" -n shairport-sync -u 801 -s /usr/sbin/nologin -d /nonexistent > /dev/null 2>&1
203	[ -e /var/run/shairport-sync ] || mkdir -p /var/run/shairport-sync
204	chown shairport-sync:shairport-sync /var/run/shairport-sync
205	[ -f /usr/local/etc/rc.d/shairport_sync ] || cp scripts/shairport-sync.freebsd /usr/local/etc/rc.d/shairport_sync
206	chmod 555 /usr/local/etc/rc.d/shairport_sync
207endif
208if INSTALL_CYGWIN_SERVICE
209	cp scripts/shairport-sync-config /usr/local/bin
210endif
211