Merge pull request #1493 from lrusak/autoconf-build-dir

Makefile.am: allow building and installing from a separate build directory.
This commit is contained in:
Mike Brady
2022-07-10 19:38:15 +01:00
committed by GitHub
2 changed files with 87 additions and 43 deletions
+5
View File
@@ -50,3 +50,8 @@ shairport-sync.xcodeproj
# version string generation
gitversion.h
# separate build directory
build
# vscode
.vscode
+82 -43
View File
@@ -161,7 +161,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
@@ -178,7 +178,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
@@ -199,59 +199,98 @@ 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
configdir = $(sysconfdir)
config_DATA = scripts/shairport-sync.conf
if BUILD_FOR_LINUX
dbusdir = /etc/dbus-1/system.d
else
dbusdir = $(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_DATA = 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_DATA = scripts/shairport-sync-dbus-policy.conf
endif # INSTALL_CYGWIN_SERVIC
endif # USE_DBUS
if USE_MPRIS
[ -e $(DBUS_POLICY_DIR) ] || mkdir -p $(DBUS_POLICY_DIR)
mprisdir = $(dbusdir)
if INSTALL_CYGWIN_SERVICE
cp scripts/shairport-sync-mpris-policy-cygwin.conf $(DBUS_POLICY_DIR)/shairport-sync-mpris.conf
mpris_DATA = 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_DATA = scripts/shairport-sync-mpris-policy.conf
endif # INSTALL_CYGWIN_SERVICE
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
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)
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
cygwindir = /usr/local/bin
cygwin_DATA = scripts/shairport-sync-config
endif # INSTALL_CYGWIN_SERVICE
install-exec-hook: $(INSTALL_SYSTEMV_TARGET) \
$(INSTALL_SYSTEMD_TARGET) \
$(INSTALL_FREEBSD_TARGET)