Only customise libdaemon if localstatedir option is really chosen.

This commit is contained in:
Mike Brady
2014-10-18 16:00:33 +01:00
parent edde8d8a42
commit 12f26893b7
3 changed files with 26 additions and 9 deletions
+8 -3
View File
@@ -1,9 +1,10 @@
bin_PROGRAMS = shairport-sync
shairport_sync_SOURCES = shairport.c rtsp.c mdns.c mdns_external.c common.c rtp.c player.c alac.c audio.c audio_dummy.c audio_pipe.c
install-exec-hook:
[ -f /etc/init.d/shairport-sync ] || cp scripts/shairport-sync /etc/init.d/
update-rc.d shairport-sync defaults 90 10
if USE_CUSTOMLOCALSTATEDIR
AM_CFLAGS= \
-DLOCALSTATEDIR=\"$(CUSTOM_LOCAL_STATE_DIR)\"
endif
if USE_AVAHI
shairport_sync_SOURCES += mdns_avahi.c
@@ -32,3 +33,7 @@ endif
if USE_DNS_SD
shairport_sync_SOURCES += mdns_dns_sd.c
endif
install-exec-hook:
[ -f /etc/init.d/shairport-sync ] || cp scripts/shairport-sync /etc/init.d/
update-rc.d shairport-sync defaults 90 10
+7 -2
View File
@@ -28,13 +28,18 @@ if test "x${with_os_type}" = xlinux; then
AC_CHECK_LIB([rt],[clock_gettime], , AC_MSG_ERROR(librt needed))
fi
AC_DEFINE_UNQUOTED([OURRUNSTATEDIR],["${localstatedir}/run"],[Needed for libdaemon])
AC_CHECK_LIB([daemon],[daemon_log], , AC_MSG_ERROR(libdaemon needed))
AC_CHECK_LIB([pthread],[pthread_create], , AC_MSG_ERROR(pthread library needed))
AC_CHECK_LIB([m],[exp], , AC_MSG_ERROR(maths library needed))
AC_CHECK_LIB([popt],[poptGetContext], , AC_MSG_ERROR(libpopt needed))
# Look for localstatedir flag
AC_ARG_WITH(localstatedir, [ --with-localstatedir = choose where to place the run directory containing the PID file], [
HAS_CUSTOMLOCALSTATEDIR=1
AC_SUBST(CUSTOM_LOCAL_STATE_DIR,["${with_localstatedir}"])
AC_DEFINE([USE_CUSTOM_LOCAL_STATE_DIR],1,[Hook up special proc to libdaemon])], )
AM_CONDITIONAL([USE_CUSTOMLOCALSTATEDIR], [test "x$HAS_CUSTOMLOCALSTATEDIR" = "x1"])
# Look for polarssl flag
AC_ARG_WITH(polarssl, [ --with-polarssl = choose polarssl for encryption services (choose this or --with-openssl)], [
AC_MSG_RESULT(>>Including polarssl)
+11 -4
View File
@@ -321,19 +321,23 @@ void shairport_startup_complete(void) {
}
}
#ifdef USE_CUSTOM_LOCAL_STATE_DIR
const char *pid_file_proc(void) {
#ifdef HAVE_ASPRINTF
static char *fn = NULL;
free(fn);
asprintf(&fn, "%s/%s.pid", OURRUNSTATEDIR, daemon_pid_file_ident ? daemon_pid_file_ident : "unknown");
debug(1,"Checking PID file location 1.");
asprintf(&fn, "%s/run/%s.pid", LOCALSTATEDIR, daemon_pid_file_ident ? daemon_pid_file_ident : "unknown");
#else
static char fn[8192];
snprintf(fn, sizeof(fn), "%s/%s.pid", OURRUNSTATEDIR, daemon_pid_file_ident ? daemon_pid_file_ident : "unknown");
snprintf(fn, sizeof(fn), "%s/run/%s.pid", LOCALSTATEDIR, daemon_pid_file_ident ? daemon_pid_file_ident : "unknown");
debug(1,"Checking PID file location 2.");
#endif
return fn;
}
#endif
int main(int argc, char **argv) {
@@ -365,9 +369,12 @@ int main(int argc, char **argv) {
return 1;
}
/* Point to a function to help locate where the PID file will go */
#if USE_CUSTOM_LOCAL_STATE_DIR
debug(1,"Locating localstatedir at \"%s\"",LOCALSTATEDIR);
/* Point to a function to help locate where the PID file will go */
daemon_pid_file_proc = pid_file_proc;
#endif
/* Set indentification string for the daemon for both syslog and PID file */
daemon_pid_file_ident = daemon_log_ident = daemon_ident_from_argv0(argv[0]);