diff --git a/Makefile.am b/Makefile.am index f16ae1d7..09fb9692 100644 --- a/Makefile.am +++ b/Makefile.am @@ -143,8 +143,9 @@ plist_xml_strings.h: plists/get_info_response.xml echo "// Do not edit!" > plist_xml_strings.h echo "// This file is automatically generated from files in the plists folder." >> plist_xml_strings.h echo "" >> plist_xml_strings.h - xxd -i plists/get_info_response.xml >> plist_xml_strings.h + xxd -i $< >> plist_xml_strings.h echo "" >> plist_xml_strings.h + sed -e 's/[^ ]*plists_get_info_response_xml/plists_get_info_response_xml/g' -i plist_xml_strings.h plist_xml_strings.c: plist_xml_strings.h touch plist_xml_strings.c @@ -166,7 +167,7 @@ noinst_HEADERS += $(BUILT_SOURCES) CLEANFILES += $(BUILT_SOURCES) dbus-interface.c: org.gnome.ShairportSync.xml - gdbus-codegen --interface-prefix org.gnome --generate-c-code dbus-interface org.gnome.ShairportSync.xml + gdbus-codegen --interface-prefix org.gnome --generate-c-code dbus-interface $< dbus-interface.h: dbus-interface.c touch dbus-interface.h endif @@ -183,7 +184,7 @@ noinst_HEADERS += $(BUILT_SOURCES) CLEANFILES += $(BUILT_SOURCES) mpris-interface.c: org.mpris.MediaPlayer2.xml - gdbus-codegen --interface-prefix org.mpris --generate-c-code mpris-interface org.mpris.MediaPlayer2.xml + gdbus-codegen --interface-prefix org.mpris --generate-c-code mpris-interface $< mpris-interface.h: mpris-interface.c touch mpris-interface.h endif @@ -204,59 +205,120 @@ shairport_sync_mpris_test_client_SOURCES = shairport-sync-mpris-test-client.c shairport_sync_mpris_test_client_LDADD = lib_mpris_interface.a endif -install-exec-hook: -if BUILD_FOR_LINUX -DBUS_POLICY_DIR=$(DESTDIR)/etc/dbus-1/system.d -else -DBUS_POLICY_DIR=$(DESTDIR)$(sysconfdir)/dbus-1/system.d -endif if INSTALL_CONFIG_FILES - [ -e $(DESTDIR)$(sysconfdir) ] || mkdir $(DESTDIR)$(sysconfdir) - cp scripts/shairport-sync.conf $(DESTDIR)$(sysconfdir)/shairport-sync.conf.sample - [ -f $(DESTDIR)$(sysconfdir)/shairport-sync.conf ] || cp scripts/shairport-sync.conf $(DESTDIR)$(sysconfdir)/shairport-sync.conf + +CONFIG_FILE_INSTALL_TARGET = config-file-install-local +$(CONFIG_FILE_INSTALL_TARGET): scripts/shairport-sync.conf + install -d $(DESTDIR)$(sysconfdir) + install -m 0644 $< $(DESTDIR)$(sysconfdir)/shairport-sync.conf.sample + [ -f $(DESTDIR)$(sysconfdir)/shairport-sync.conf ] || cp $< $(DESTDIR)$(sysconfdir)/shairport-sync.conf + +if BUILD_FOR_LINUX +DBUS_POLICY_DIR = /etc/dbus-1/system.d +else +DBUS_POLICY_DIR = $(sysconfdir)/dbus-1/system.d +endif + if USE_DBUS - [ -e $(DBUS_POLICY_DIR) ] || mkdir -p $(DBUS_POLICY_DIR) + if INSTALL_CYGWIN_SERVICE - cp scripts/shairport-sync-dbus-policy-cygwin.conf $(DBUS_POLICY_DIR)/shairport-sync-dbus.conf +DBUS_POLICY_FILE = scripts/shairport-sync-dbus-policy-cygwin.conf else - cp scripts/shairport-sync-dbus-policy.conf $(DBUS_POLICY_DIR)/shairport-sync-dbus.conf -endif -endif +DBUS_POLICY_FILE = scripts/shairport-sync-dbus-policy.conf +endif # INSTALL_CYGWIN_SERVICE + +DBUS_POLICY_INSTALL_TARGET = dbus-policy-install-local + +$(DBUS_POLICY_INSTALL_TARGET): $(DBUS_POLICY_FILE) + install -d $(DESTDIR)$(DBUS_POLICY_DIR) + install -m 0644 $< $(DESTDIR)$(DBUS_POLICY_DIR)/shairport-sync-dbus.conf + +endif # USE_DBUS + if USE_MPRIS - [ -e $(DBUS_POLICY_DIR) ] || mkdir -p $(DBUS_POLICY_DIR) + if INSTALL_CYGWIN_SERVICE - cp scripts/shairport-sync-mpris-policy-cygwin.conf $(DBUS_POLICY_DIR)/shairport-sync-mpris.conf +MPRIS_POLICY_FILE = scripts/shairport-sync-mpris-policy-cygwin.conf else - cp scripts/shairport-sync-mpris-policy.conf $(DBUS_POLICY_DIR)/shairport-sync-mpris.conf -endif -endif -endif +MPRIS_POLICY_FILE = scripts/shairport-sync-mpris-policy.conf +endif # INSTALL_CYGWIN_SERVICE + +MPRIS_POLICY_INSTALL_TARGET = mpris-policy-install-local + +$(MPRIS_POLICY_INSTALL_TARGET): $(MPRIS_POLICY_FILE) + install -d $(DESTDIR)$(DBUS_POLICY_DIR) + install -m 0644 $< $(DESTDIR)$(DBUS_POLICY_DIR)/shairport-sync-mpris.conf + +endif # USE_MPRIS + +endif # INSTALL_CONFIG_FILES + +INSTALL_GROUP_TARGET = install-group-local + +$(INSTALL_GROUP_TARGET): + getent group shairport-sync &>/dev/null || groupadd -r shairport-sync >/dev/null + +INSTALL_USER_TARGET = install-user-local + +$(INSTALL_USER_TARGET): $(INSTALL_GROUP_TARGET) + getent passwd shairport-sync &> /dev/null || useradd -r -M -g shairport-sync -s /usr/sbin/nologin -G audio shairport-sync >/dev/null + if INSTALL_SYSTEMV - getent group shairport-sync &>/dev/null || groupadd -r shairport-sync >/dev/null - getent passwd shairport-sync &> /dev/null || useradd -r -M -g shairport-sync -s /usr/sbin/nologin -G audio shairport-sync >/dev/null - [ -e $(DESTDIR)$(sysconfdir)/init.d ] || mkdir -p $(DESTDIR)$(sysconfdir)/init.d - [ -e $(DESTDIR)$(sysconfdir)/init.d/shairport-sync ] || cp scripts/shairport-sync $(DESTDIR)$(sysconfdir)/init.d/ -endif + +INSTALL_SYSTEMV_TARGET = install-systemv-local + +$(INSTALL_SYSTEMV_TARGET): scripts/shairport-sync $(INSTALL_USER_TARGET) + install -d $(DESTDIR)$(sysconfdir)/init.d + [ -e $(DESTDIR)$(sysconfdir)/init.d/shairport-sync ] || install -m 0644 $< $(DESTDIR)$(sysconfdir)/init.d + +endif # INSTALL_SYSTEMV + if INSTALL_SYSTEMD - getent group shairport-sync &>/dev/null || groupadd -r shairport-sync >/dev/null - getent passwd shairport-sync &> /dev/null || useradd -r -M -g shairport-sync -s /usr/sbin/nologin -G audio shairport-sync >/dev/null - [ -e $(DESTDIR)$(systemdsystemunitdir) ] || mkdir -p $(DESTDIR)$(systemdsystemunitdir) + if USE_AVAHI - [ -e $(DESTDIR)$(systemdsystemunitdir)/shairport-sync.service ] || cp scripts/shairport-sync.service-avahi $(DESTDIR)$(systemdsystemunitdir)/shairport-sync.service +SYSTEMD_SERVICE = shairport-sync.service-avahi else - [ -e $(DESTDIR)$(systemdsystemunitdir)/shairport-sync.service ] || cp scripts/shairport-sync.service $(DESTDIR)$(systemdsystemunitdir) -endif -endif +SYSTEMD_SERVICE = shairport-sync.service +endif # USE_AVAHI + +INSTALL_SYSTEMD_TARGET = install-systemd-local + +$(INSTALL_SYSTEMD_TARGET): scripts/$(SYSTEMD_SERVICE) $(INSTALL_USER_TARGET) + install -d $(DESTDIR)$(systemdsystemunitdir) + [ -e $(DESTDIR)$(systemdsystemunitdir)/shairport-sync.service ] || install -m 0644 $< $(DESTDIR)$(systemdsystemunitdir)/shairport-sync.service + +endif # INSTALL_SYSTEMD + if INSTALL_FREEBSD_SERVICE - # 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..." + +# 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..." +install-freebsd-user-local: pw showgroup shairport-sync > /dev/null 2>&1 || pw addgroup -n shairport-sync -g 801 > /dev/null 2>&1 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 - [ -e /var/run/shairport-sync ] || mkdir -p /var/run/shairport-sync - chown shairport-sync:shairport-sync /var/run/shairport-sync - # Always update the startup script -- this is different to the Linux systemd situation, where the startup script is untouched if it exists. - cp scripts/shairport-sync.freebsd /usr/local/etc/rc.d/shairport_sync - chmod 555 /usr/local/etc/rc.d/shairport_sync -endif + +INSTALL_FREEBSD_TARGET = install-freebsd-local + +$(INSTALL_FREEBSD_TARGET): scripts/shairport-sync.freebsd install-freebsd-user-local + install -d -o shairport-sync -g shairport-sync $(DESTDIR)/var/run/shairport-sync + install -d $(DESTDIR)/usr/local/etc/rc.d/ + install -m 0555 $< $(DESTDIR)/usr/local/etc/rc.d/shairport_sync + +endif # INSTALL_FREEBSD_SERVICE + if INSTALL_CYGWIN_SERVICE - [ -e /usr/local/bin/shairport-sync-config ] || cp scripts/shairport-sync-config /usr/local/bin -endif + +INSTALL_CYGWIN_TARGET = install-cygwin-local + +$(INSTALL_CYGWIN_TARGET): scripts/shairport-sync-config + install -d $(DESTDIR)/usr/local/bin + [ -e $(DESTDIR)/usr/local/bin/shairport-sync-config ] || install -m 0755 $< $(DESTDIR)/usr/local/bin/ + +endif # INSTALL_CYGWIN_SERVICE + +install-exec-hook: $(CONFIG_FILE_INSTALL_TARGET) \ + $(DBUS_POLICY_INSTALL_TARGET) \ + $(MPRIS_POLICY_INSTALL_TARGET) \ + $(INSTALL_SYSTEMV_TARGET) \ + $(INSTALL_SYSTEMD_TARGET) \ + $(INSTALL_FREEBSD_TARGET) \ + $(INSTALL_CYGWIN_TARGET) diff --git a/configure.ac b/configure.ac index 333f186f..2283689c 100644 --- a/configure.ac +++ b/configure.ac @@ -9,10 +9,10 @@ AC_CONFIG_HEADERS([config.h]) AC_PROG_RANLIB AC_CHECK_PROGS([GIT], [git]) -if test -n "$GIT" && test -e ".git/index" ; then +if test -n "$GIT" && test -e "$srcdir/.git/index" ; then AC_DEFINE([CONFIG_USE_GIT_VERSION_STRING], 1, [Use the version string produced by running 'git describe --dirty'.]) fi -AM_CONDITIONAL([USE_GIT_VERSION], [test -n "$GIT" && test -e ".git/index" ]) +AM_CONDITIONAL([USE_GIT_VERSION], [test -n "$GIT" && test -e "$srcdir/.git/index" ]) # Derived from the Avahi configure.ac file # Specifying the OS type, defaulting to linux.