summaryrefslogtreecommitdiff
path: root/meta/recipes-devtools/distcc
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/distcc')
-rw-r--r--meta/recipes-devtools/distcc/distcc_3.2.bb (renamed from meta/recipes-devtools/distcc/distcc_2.18.3.bb)46
-rw-r--r--meta/recipes-devtools/distcc/files/0001-zeroconf-Include-fcntl.h.patch29
-rw-r--r--meta/recipes-devtools/distcc/files/default5
-rwxr-xr-xmeta/recipes-devtools/distcc/files/distcc15
-rw-r--r--meta/recipes-devtools/distcc/files/distcc-avahi.patch1738
-rw-r--r--meta/recipes-devtools/distcc/files/distcc.service11
-rw-r--r--meta/recipes-devtools/distcc/files/makefile-param-order.patch20
-rw-r--r--meta/recipes-devtools/distcc/files/separatebuilddir.patch21
8 files changed, 104 insertions, 1781 deletions
diff --git a/meta/recipes-devtools/distcc/distcc_2.18.3.bb b/meta/recipes-devtools/distcc/distcc_3.2.bb
index bd2af4a1b5..ea3d7c10be 100644
--- a/meta/recipes-devtools/distcc/distcc_2.18.3.bb
+++ b/meta/recipes-devtools/distcc/distcc_3.2.bb
@@ -4,31 +4,29 @@ compilation of C/C++/ObjC code across machines on a network."
SECTION = "devel"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f"
-PR = "r9"
-DEPENDS = "avahi"
+DEPENDS = "avahi binutils"
-GTKCONFIG = "gtk"
-GTKCONFIG_libc-uclibc = ""
-
-PACKAGECONFIG ??= "${@base_contains('DISTRO_FEATURES', 'x11', '${GTKCONFIG}', '', d)}"
+PACKAGECONFIG ??= "popt"
PACKAGECONFIG[gtk] = "--with-gtk,--without-gtk --without-gnome,gtk+"
+# use system popt by default
+PACKAGECONFIG[popt] = "--without-included-popt,--with-included-popt,popt"
RRECOMMENDS_${PN} = "avahi-daemon"
-# Upstream change this patch periodically so store locally
-# http://0pointer.de/public/distcc-avahi.patch
-SRC_URI = "http://distcc.googlecode.com/files/${BPN}-${PV}.tar.bz2 \
- file://distcc-avahi.patch \
- file://makefile-param-order.patch \
- file://default \
- file://distccmon-gnome.desktop \
- file://distcc"
+SRC_URI = "git://github.com/distcc/distcc.git;branch=${PV} \
+ file://separatebuilddir.patch \
+ file://0001-zeroconf-Include-fcntl.h.patch \
+ file://default \
+ file://distccmon-gnome.desktop \
+ file://distcc \
+ file://distcc.service"
+SRCREV = "d8b18df3e9dcbe4f092bed565835d3975e99432c"
+S = "${WORKDIR}/git"
-SRC_URI[md5sum] = "0d6b80a1efc3a3d816c4f4175f63eaa2"
-SRC_URI[sha256sum] = "6500f1bc2a30b1f044ebed79c6ce15457d1712263e65f0db7d6046af262ba434"
+inherit autotools pkgconfig update-rc.d useradd systemd
-inherit autotools pkgconfig update-rc.d useradd
+EXTRA_OECONF += "--disable-Werror PYTHON='' --disable-pump-mode"
USERADD_PACKAGES = "${PN}"
USERADD_PARAM_${PN} = "--system \
@@ -39,11 +37,17 @@ USERADD_PARAM_${PN} = "--system \
INITSCRIPT_NAME = "distcc"
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE_${PN} = "distcc.service"
+
do_install_append() {
install -d ${D}${sysconfdir}/init.d/
install -d ${D}${sysconfdir}/default
install -m 0755 ${WORKDIR}/distcc ${D}${sysconfdir}/init.d/
install -m 0755 ${WORKDIR}/default ${D}${sysconfdir}/default/distcc
+ install -d ${D}${systemd_unitdir}/system/
+ install -m 0644 ${WORKDIR}/distcc.service ${D}${systemd_unitdir}/system
+ sed -i -e 's,@BINDIR@,${bindir},g' ${D}${systemd_unitdir}/system/distcc.service
${DESKTOPINSTALL}
}
DESKTOPINSTALL = ""
@@ -55,11 +59,9 @@ PACKAGES += "distcc-distmon-gnome"
FILES_${PN} = " ${sysconfdir} \
${bindir}/distcc \
+ ${bindir}/lsdistcc \
${bindir}/distccd \
- ${bindir}/distccmon-text"
+ ${bindir}/distccmon-text \
+ ${systemd_unitdir}/system/distcc.service"
FILES_distcc-distmon-gnome = " ${bindir}/distccmon-gnome \
${datadir}/distcc"
-
-pkg_postrm_${PN} () {
- deluser distcc || true
-}
diff --git a/meta/recipes-devtools/distcc/files/0001-zeroconf-Include-fcntl.h.patch b/meta/recipes-devtools/distcc/files/0001-zeroconf-Include-fcntl.h.patch
new file mode 100644
index 0000000000..b17ec9c959
--- /dev/null
+++ b/meta/recipes-devtools/distcc/files/0001-zeroconf-Include-fcntl.h.patch
@@ -0,0 +1,29 @@
+From 8331fc4759d809512f404e7a27f817ad6d616450 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Mon, 13 Apr 2015 18:00:33 -0700
+Subject: [PATCH] zeroconf: Include fcntl.h
+
+We need it for getting deinitions for O_* e.g. O_CREAT
+
+Upstream-Status: Pending
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ src/zeroconf.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/zeroconf.c b/src/zeroconf.c
+index 414ddc4..31bd33f 100644
+--- a/src/zeroconf.c
++++ b/src/zeroconf.c
+@@ -33,6 +33,7 @@
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <limits.h>
++#include <fcntl.h>
+
+ #include <avahi-common/domain.h>
+ #include <avahi-common/error.h>
+--
+2.1.4
+
diff --git a/meta/recipes-devtools/distcc/files/default b/meta/recipes-devtools/distcc/files/default
index 95290f8488..63c4159b9d 100644
--- a/meta/recipes-devtools/distcc/files/default
+++ b/meta/recipes-devtools/distcc/files/default
@@ -17,3 +17,8 @@ STARTDISTCC="true"
# ALLOWEDNETS="127.0.0.1"
ALLOWEDNETS="192.168.7.0/24"
+
+#
+# OPTIONS is used for the systemd service file
+#
+OPTIONS="--allow 192.168.7.0/24"
diff --git a/meta/recipes-devtools/distcc/files/distcc b/meta/recipes-devtools/distcc/files/distcc
index 513bc483ea..e36f0fa695 100755
--- a/meta/recipes-devtools/distcc/files/distcc
+++ b/meta/recipes-devtools/distcc/files/distcc
@@ -35,6 +35,9 @@ test -x $DAEMON || exit 0
set -e
+# Source function library.
+. /etc/init.d/functions
+
# construct access list
ALLOW=""
for net in $ALLOWEDNETS
@@ -48,6 +51,9 @@ should_start() {
echo "$DAEMON not starting"
exit 0
fi
+ # we need permission to write to the pid file
+ touch /var/run/$NAME.pid
+ chown distcc /var/run/$NAME.pid
}
case "$1" in
@@ -72,6 +78,7 @@ case "$1" in
echo "$0: stop failed with error code $code" >&2
exit $code
}
+ rm -f /var/run/$NAME.pid >/dev/null 2>&1
echo "."
;;
restart|force-reload)
@@ -89,14 +96,20 @@ case "$1" in
--exec $DAEMON -- $DAEMON_ARGS $ALLOW ||
{
code=$?
+ rm -f /var/run/$NAME.pid >/dev/null 2>&1
echo "$0: restart failed with error code $code" >&2
exit $code
}
echo "."
;;
+
+ status)
+ status $DAEMON
+ exit $?
+ ;;
*)
N=/etc/init.d/$NAME
- echo "Usage: $N {start|stop|restart|force-reload}" >&2
+ echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac
diff --git a/meta/recipes-devtools/distcc/files/distcc-avahi.patch b/meta/recipes-devtools/distcc/files/distcc-avahi.patch
deleted file mode 100644
index 1f15d4b82a..0000000000
--- a/meta/recipes-devtools/distcc/files/distcc-avahi.patch
+++ /dev/null
@@ -1,1738 +0,0 @@
-Upstream-Status: Pending
-
---- upstream/aclocal.m4 1970-01-01 01:00:00.000000000 +0100
-+++ lennart/aclocal.m4 2005-11-18 04:19:18.000000000 +0100
-@@ -0,0 +1,171 @@
-+# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
-+
-+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-+# 2005 Free Software Foundation, Inc.
-+# This file is free software; the Free Software Foundation
-+# gives unlimited permission to copy and/or distribute it,
-+# with or without modifications, as long as this notice is preserved.
-+
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-+# PARTICULAR PURPOSE.
-+
-+# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
-+#
-+# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
-+#
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 2 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful, but
-+# WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-+# General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program; if not, write to the Free Software
-+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-+#
-+# As a special exception to the GNU General Public License, if you
-+# distribute this file as part of a program that contains a
-+# configuration script generated by Autoconf, you may include it under
-+# the same distribution terms that you use for the rest of that program.
-+
-+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
-+# ----------------------------------
-+AC_DEFUN([PKG_PROG_PKG_CONFIG],
-+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
-+m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
-+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
-+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
-+ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
-+fi
-+if test -n "$PKG_CONFIG"; then
-+ _pkg_min_version=m4_default([$1], [0.9.0])
-+ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
-+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
-+ AC_MSG_RESULT([yes])
-+ else
-+ AC_MSG_RESULT([no])
-+ PKG_CONFIG=""
-+ fi
-+
-+fi[]dnl
-+])# PKG_PROG_PKG_CONFIG
-+
-+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-+#
-+# Check to see whether a particular set of modules exists. Similar
-+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
-+#
-+#
-+# Similar to PKG_CHECK_MODULES, make sure that the first instance of
-+# this or PKG_CHECK_MODULES is called, or make sure to call
-+# PKG_CHECK_EXISTS manually
-+# --------------------------------------------------------------
-+AC_DEFUN([PKG_CHECK_EXISTS],
-+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
-+if test -n "$PKG_CONFIG" && \
-+ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
-+ m4_ifval([$2], [$2], [:])
-+m4_ifvaln([$3], [else
-+ $3])dnl
-+fi])
-+
-+
-+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
-+# ---------------------------------------------
-+m4_define([_PKG_CONFIG],
-+[if test -n "$PKG_CONFIG"; then
-+ if test -n "$$1"; then
-+ pkg_cv_[]$1="$$1"
-+ else
-+ PKG_CHECK_EXISTS([$3],
-+ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
-+ [pkg_failed=yes])
-+ fi
-+else
-+ pkg_failed=untried
-+fi[]dnl
-+])# _PKG_CONFIG
-+
-+# _PKG_SHORT_ERRORS_SUPPORTED
-+# -----------------------------
-+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
-+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
-+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
-+ _pkg_short_errors_supported=yes
-+else
-+ _pkg_short_errors_supported=no
-+fi[]dnl
-+])# _PKG_SHORT_ERRORS_SUPPORTED
-+
-+
-+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
-+# [ACTION-IF-NOT-FOUND])
-+#
-+#
-+# Note that if there is a possibility the first call to
-+# PKG_CHECK_MODULES might not happen, you should be sure to include an
-+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
-+#
-+#
-+# --------------------------------------------------------------
-+AC_DEFUN([PKG_CHECK_MODULES],
-+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
-+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
-+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
-+
-+pkg_failed=no
-+AC_MSG_CHECKING([for $1])
-+
-+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
-+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
-+
-+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
-+and $1[]_LIBS to avoid the need to call pkg-config.
-+See the pkg-config man page for more details.])
-+
-+if test $pkg_failed = yes; then
-+ _PKG_SHORT_ERRORS_SUPPORTED
-+ if test $_pkg_short_errors_supported = yes; then
-+ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
-+ else
-+ $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
-+ fi
-+ # Put the nasty error message in config.log where it belongs
-+ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
-+
-+ ifelse([$4], , [AC_MSG_ERROR(dnl
-+[Package requirements ($2) were not met:
-+
-+$$1_PKG_ERRORS
-+
-+Consider adjusting the PKG_CONFIG_PATH environment variable if you
-+installed software in a non-standard prefix.
-+
-+_PKG_TEXT
-+])],
-+ [$4])
-+elif test $pkg_failed = untried; then
-+ ifelse([$4], , [AC_MSG_FAILURE(dnl
-+[The pkg-config script could not be found or is too old. Make sure it
-+is in your PATH or set the PKG_CONFIG environment variable to the full
-+path to pkg-config.
-+
-+_PKG_TEXT
-+
-+To get pkg-config, see <http://www.freedesktop.org/software/pkgconfig>.])],
-+ [$4])
-+else
-+ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
-+ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
-+ AC_MSG_RESULT([yes])
-+ ifelse([$3], , :, [$3])
-+fi[]dnl
-+])# PKG_CHECK_MODULES
-+
-+m4_include([acinclude.m4])
---- upstream/Makefile.in 2005-11-18 16:15:40.000000000 +0100
-+++ lennart/Makefile.in 2005-11-18 01:14:43.000000000 +0100
-@@ -171,6 +171,7 @@
- src/ssh.o src/state.o src/strip.o \
- src/timefile.o src/traceenv.o \
- src/where.o \
-+ @ZEROCONF_DISTCC_OBJS@ \
- $(common_obj)
-
- distccd_obj = src/access.o \
-@@ -178,6 +179,7 @@
- src/ncpus.o \
- src/prefork.o \
- src/serve.o src/setuid.o src/srvnet.o src/srvrpc.o src/state.o \
-+ @ZEROCONF_DISTCCD_OBJS@ \
- $(common_obj) @BUILD_POPT@
-
- # Objects that need to be linked in to build monitors
---- upstream/src/distcc.c 2005-11-18 16:15:40.000000000 +0100
-+++ lennart/src/distcc.c 2005-11-18 01:14:43.000000000 +0100
-@@ -83,6 +83,9 @@
- " COMPILER defaults to \"cc\"\n"
- " --help explain usage and exit\n"
- " --version show version and exit\n"
-+" --show-hosts show host list and exit\n"
-+" -j calculate the concurrency level from\n"
-+" the host list.\n"
- "\n"
- "Environment variables:\n"
- " See the manual page for a complete list.\n"
-@@ -135,7 +138,46 @@
- signal(SIGHUP, &dcc_client_signalled);
- }
-
-+static void dcc_free_hostlist(struct dcc_hostdef *list) {
-+ while (list) {
-+ struct dcc_hostdef *l = list;
-+ list = list->next;
-+ dcc_free_hostdef(l);
-+ }
-+}
-+
-+static void dcc_show_hosts(void) {
-+ struct dcc_hostdef *list, *l;
-+ int nhosts;
-+
-+ if (dcc_get_hostlist(&list, &nhosts) != 0) {
-+ rs_log_crit("Failed to get host list");
-+ return;
-+ }
-+
-+ for (l = list; l; l = l->next)
-+ printf("%s\n", l->hostdef_string);
-+
-+ dcc_free_hostlist(list);
-+}
-+
-+static void dcc_concurrency_level(void) {
-+ struct dcc_hostdef *list, *l;
-+ int nhosts;
-+ int nslots = 0;
-+
-+ if (dcc_get_hostlist(&list, &nhosts) != 0) {
-+ rs_log_crit("Failed to get host list");
-+ return;
-+ }
-+
-+ for (l = list; l; l = l->next)
-+ nslots += l->n_slots;
-
-+ dcc_free_hostlist(list);
-+
-+ printf("%i\n", nslots);
-+}
-
- /**
- * distcc client entry point.
-@@ -182,6 +224,18 @@
- ret = 0;
- goto out;
- }
-+
-+ if (!strcmp(argv[1], "--show-hosts")) {
-+ dcc_show_hosts();
-+ ret = 0;
-+ goto out;
-+ }
-+
-+ if (!strcmp(argv[1], "-j")) {
-+ dcc_concurrency_level();
-+ ret = 0;
-+ goto out;
-+ }
-
- dcc_find_compiler(argv, &compiler_args);
- /* compiler_args is now respectively either "cc -c hello.c" or
---- upstream/src/distcc.h 2005-11-18 16:15:40.000000000 +0100
-+++ lennart/src/distcc.h 2005-11-18 01:14:43.000000000 +0100
-@@ -112,7 +112,7 @@
- int *ret_nhosts);
- int dcc_parse_hosts(const char *where, const char *source_name,
- struct dcc_hostdef **ret_list,
-- int *ret_nhosts);
-+ int *ret_nhosts, struct dcc_hostdef **ret_prev);
-
- /* ncpu.c */
- int dcc_ncpus(int *);
-@@ -226,6 +226,7 @@
- int dcc_make_tmpnam(const char *, const char *suffix, char **);
-
- int dcc_mkdir(const char *path) WARN_UNUSED;
-+int dcc_get_subdir(const char *name, char **path_ret) WARN_UNUSED;
- int dcc_get_lock_dir(char **path_ret) WARN_UNUSED;
- int dcc_get_state_dir(char **path_ret) WARN_UNUSED;
- int dcc_get_top_dir(char **path_ret) WARN_UNUSED;
---- upstream/src/dopt.c 2005-11-18 16:15:40.000000000 +0100
-+++ lennart/src/dopt.c 2005-11-18 04:14:26.000000000 +0100
-@@ -93,6 +93,10 @@
- opt_log_level
- };
-
-+#ifdef HAVE_AVAHI
-+/* Flag for enabling/disabling Zeroconf using Avahi */
-+int opt_zeroconf = 0;
-+#endif
-
- const struct poptOption options[] = {
- { "allow", 'a', POPT_ARG_STRING, 0, 'a', 0, 0 },
-@@ -115,6 +119,9 @@
- { "verbose", 0, POPT_ARG_NONE, 0, 'v', 0, 0 },
- { "version", 0, POPT_ARG_NONE, 0, 'V', 0, 0 },
- { "wizard", 'W', POPT_ARG_NONE, 0, 'W', 0, 0 },
-+#ifdef HAVE_AVAHI
-+ { "zeroconf", 0, POPT_ARG_NONE, &opt_zeroconf, 0, 0, 0 },
-+#endif
- { 0, 0, 0, 0, 0, 0, 0 }
- };
-
-@@ -137,6 +144,9 @@
- " -p, --port PORT TCP port to listen on\n"
- " --listen ADDRESS IP address to listen on\n"
- " -a, --allow IP[/BITS] client address access control\n"
-+#ifdef HAVE_AVAHI
-+" --zeroconf register via mDNS/DNS-SD\n"
-+#endif
- " Debug and trace:\n"
- " --log-level=LEVEL set detail level for log file\n"
- " levels: critical, error, warning, notice, info, debug\n"
---- upstream/src/dopt.h 2005-11-18 16:15:40.000000000 +0100
-+++ lennart/src/dopt.h 2005-11-18 02:27:45.000000000 +0100
-@@ -38,3 +38,7 @@
- extern int opt_lifetime;
- extern char *opt_listen_addr;
- extern int opt_niceness;
-+
-+#ifdef HAVE_AVAHI
-+extern int opt_zeroconf;
-+#endif
---- upstream/src/dparent.c 2005-11-18 16:15:40.000000000 +0100
-+++ lennart/src/dparent.c 2005-11-18 04:13:23.000000000 +0100
-@@ -70,6 +70,7 @@
- #include "types.h"
- #include "daemon.h"
- #include "netutil.h"
-+#include "zeroconf.h"
-
- static void dcc_nofork_parent(int listen_fd) NORETURN;
- static void dcc_detach(void);
-@@ -94,6 +95,9 @@
- int listen_fd;
- int n_cpus;
- int ret;
-+#ifdef HAVE_AVAHI
-+ void *avahi = NULL;
-+#endif
-
- if ((ret = dcc_socket_listen(arg_port, &listen_fd, opt_listen_addr)) != 0)
- return ret;
-@@ -131,6 +135,14 @@
- /* Don't catch signals until we've detached or created a process group. */
- dcc_daemon_catch_signals();
-
-+#ifdef HAVE_AVAHI
-+ /* Zeroconf registration */
-+ if (opt_zeroconf) {
-+ if (!(avahi = dcc_zeroconf_register((uint16_t) arg_port, n_cpus)))
-+ return EXIT_CONNECT_FAILED;
-+ }
-+#endif
-+
- /* This is called in the master daemon, whether that is detached or
- * not. */
- dcc_master_pid = getpid();
-@@ -138,10 +150,21 @@
- if (opt_no_fork) {
- dcc_log_daemon_started("non-forking daemon");
- dcc_nofork_parent(listen_fd);
-+ ret = 0;
- } else {
- dcc_log_daemon_started("preforking daemon");
-- return dcc_preforking_parent(listen_fd);
-+ ret = dcc_preforking_parent(listen_fd);
- }
-+
-+#ifdef HAVE_AVAHI
-+ /* Remove zeroconf registration */
-+ if (opt_zeroconf) {
-+ if (dcc_zeroconf_unregister(avahi) != 0)
-+ return EXIT_CONNECT_FAILED;
-+ }
-+#endif
-+
-+ return ret;
- }
-
-
---- upstream/src/help.c 2005-11-18 16:15:40.000000000 +0100
-+++ lennart/src/help.c 2005-11-18 02:27:45.000000000 +0100
-@@ -62,6 +62,9 @@
- "distcc comes with ABSOLUTELY NO WARRANTY. distcc is free software, and\n"
- "you may use, modify and redistribute it under the terms of the GNU \n"
- "General Public License version 2 or later.\n"
-+#ifdef HAVE_AVAHI
-+"\nBuilt with Zeroconf support.\n"
-+#endif
- "\n"
- ,
- prog, PACKAGE_VERSION, GNU_HOST, DISTCC_DEFAULT_PORT,
---- upstream/src/hostfile.c 2005-11-18 16:15:40.000000000 +0100
-+++ lennart/src/hostfile.c 2005-11-18 01:14:43.000000000 +0100
-@@ -59,7 +59,7 @@
- if ((ret = dcc_load_file_string(fname, &body)) != 0)
- return ret;
-
-- ret = dcc_parse_hosts(body, fname, ret_list, ret_nhosts);
-+ ret = dcc_parse_hosts(body, fname, ret_list, ret_nhosts, NULL);
-
- free(body);
-
---- upstream/src/hosts.c 2005-11-18 16:15:40.000000000 +0100
-+++ lennart/src/hosts.c 2005-11-18 02:27:45.000000000 +0100
-@@ -96,6 +96,10 @@
- #include "hosts.h"
- #include "exitcode.h"
- #include "snprintf.h"
-+#ifdef HAVE_AVAHI
-+#include "zeroconf.h"
-+#define ZEROCONF_MAGIC "+zeroconf"
-+#endif
-
- const int dcc_default_port = DISTCC_DEFAULT_PORT;
-
-@@ -134,9 +138,12 @@
- char *path, *top;
- int ret;
-
-+ *ret_list = NULL;
-+ *ret_nhosts = 0;
-+
- if ((env = getenv("DISTCC_HOSTS")) != NULL) {
- rs_trace("read hosts from environment");
-- return dcc_parse_hosts(env, "$DISTCC_HOSTS", ret_list, ret_nhosts);
-+ return dcc_parse_hosts(env, "$DISTCC_HOSTS", ret_list, ret_nhosts, NULL);
- }
-
- /* $DISTCC_DIR or ~/.distcc */
-@@ -163,7 +170,7 @@
- rs_trace("not reading %s: %s", path, strerror(errno));
- free(path);
- }
--
-+
- /* FIXME: Clearer message? */
- rs_log_warning("no hostlist is set; can't distribute work");
-
-@@ -346,17 +353,19 @@
- **/
- int dcc_parse_hosts(const char *where, const char *source_name,
- struct dcc_hostdef **ret_list,
-- int *ret_nhosts)
-+ int *ret_nhosts, struct dcc_hostdef **ret_prev)
- {
- int ret;
-- struct dcc_hostdef *prev, *curr;
-+ struct dcc_hostdef *curr, *_prev;
-+
-+ if (!ret_prev) {
-+ ret_prev = &_prev;
-+ _prev = NULL;
-+ }
-
- /* TODO: Check for '/' in places where it might cause trouble with
- * a lock file name. */
-
-- prev = NULL;
-- *ret_list = NULL;
-- *ret_nhosts = 0;
- /* A simple, hardcoded scanner. Some of the GNU routines might be
- * useful here, but they won't work on less capable systems.
- *
-@@ -390,6 +399,15 @@
- token_start = where;
- token_len = strcspn(where, " #\t\n\f\r");
-
-+#ifdef HAVE_AVAHI
-+ if (token_len == sizeof(ZEROCONF_MAGIC)-1 &&
-+ !strncmp(token_start, ZEROCONF_MAGIC, (unsigned) token_len)) {
-+ if ((ret = dcc_zeroconf_add_hosts(ret_list, ret_nhosts, 4, ret_prev) != 0))
-+ return ret;
-+ goto skip;
-+ }
-+#endif
-+
- /* Allocate new list item */
- curr = calloc(1, sizeof(struct dcc_hostdef));
- if (!curr) {
-@@ -404,8 +422,8 @@
- }
-
- /* Link into list */
-- if (prev) {
-- prev->next = curr;
-+ if (*ret_prev) {
-+ (*ret_prev)->next = curr;
- } else {
- *ret_list = curr; /* first */
- }
-@@ -434,10 +452,15 @@
- return ret;
- }
-
-+ (*ret_nhosts)++;
-+ *ret_prev = curr;
-+
-+#ifdef HAVE_AVAHI
-+ skip:
-+#endif
-+
- /* continue to next token if any */
- where = token_start + token_len;
-- prev = curr;
-- (*ret_nhosts)++;
- }
-
- if (*ret_nhosts) {
---- upstream/src/io.c 2005-11-18 16:15:40.000000000 +0100
-+++ lennart/src/io.c 2005-11-18 01:14:43.000000000 +0100
-@@ -163,7 +163,7 @@
- return ret;
- else
- continue;
-- } else if (r == -1 && errno == EAGAIN) {
-+ } else if (r == -1 && errno == EINTR) {
- continue;
- } else if (r == -1) {
- rs_log_error("failed to read: %s", strerror(errno));
-@@ -205,9 +205,6 @@
- } else if (r == -1) {
- rs_log_error("failed to write: %s", strerror(errno));
- return EXIT_IO_ERROR;
-- } else if (r == 0) {
-- rs_log_error("unexpected eof on fd%d", fd);
-- return EXIT_TRUNCATED;
- } else {
- buf = &((char *) buf)[r];
- len -= r;
---- upstream/src/tempfile.c 2005-11-18 16:15:40.000000000 +0100
-+++ lennart/src/tempfile.c 2005-11-18 01:14:43.000000000 +0100
-@@ -161,7 +161,7 @@
- * Return a subdirectory of the DISTCC_DIR of the given name, making
- * sure that the directory exists.
- **/
--static int dcc_get_subdir(const char *name,
-+int dcc_get_subdir(const char *name,
- char **dir_ret)
- {
- int ret;
---- upstream/configure.ac 2005-11-18 16:15:40.000000000 +0100
-+++ lennart/configure.ac 2005-11-18 04:18:07.000000000 +0100
-@@ -388,6 +388,23 @@
- AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [define if you have struct sockaddr_storage]),,
- [#include <sys/socket.h>])
-
-+dnl check for avahi
-+PKG_CHECK_MODULES(AVAHI, [avahi-client >= 0.6],
-+[AC_DEFINE(HAVE_AVAHI, 1, [defined if Avahi is available])
-+CFLAGS="$CFLAGS $AVAHI_CFLAGS"
-+LIBS="$LIBS $AVAHI_LIBS"
-+ZEROCONF_DISTCC_OBJS="src/zeroconf.o"
-+ZEROCONF_DISTCCD_OBJS="src/zeroconf-reg.o"],
-+[ZEROCONF_DISTCC_OBJS=""
-+ZEROCONF_DISTCCD_OBJS=""])
-+AC_SUBST(ZEROCONF_DISTCC_OBJS)
-+AC_SUBST(ZEROCONF_DISTCCD_OBJS)
-+
-+ACX_PTHREAD
-+LIBS="$PTHREAD_LIBS $LIBS"
-+CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-+CC="$PTHREAD_CC"
-+
- dnl ##### Output
- AC_SUBST(docdir)
- AC_SUBST(CFLAGS)
---- upstream/acinclude.m4 1970-01-01 01:00:00.000000000 +0100
-+++ lennart/acinclude.m4 2005-11-18 04:17:08.000000000 +0100
-@@ -0,0 +1,235 @@
-+dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
-+dnl
-+dnl This macro figures out how to build C programs using POSIX threads.
-+dnl It sets the PTHREAD_LIBS output variable to the threads library and
-+dnl linker flags, and the PTHREAD_CFLAGS output variable to any special
-+dnl C compiler flags that are needed. (The user can also force certain
-+dnl compiler flags/libs to be tested by setting these environment
-+dnl variables.)
-+dnl
-+dnl Also sets PTHREAD_CC to any special C compiler that is needed for
-+dnl multi-threaded programs (defaults to the value of CC otherwise).
-+dnl (This is necessary on AIX to use the special cc_r compiler alias.)
-+dnl
-+dnl NOTE: You are assumed to not only compile your program with these
-+dnl flags, but also link it with them as well. e.g. you should link
-+dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
-+dnl $LIBS
-+dnl
-+dnl If you are only building threads programs, you may wish to use
-+dnl these variables in your default LIBS, CFLAGS, and CC:
-+dnl
-+dnl LIBS="$PTHREAD_LIBS $LIBS"
-+dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-+dnl CC="$PTHREAD_CC"
-+dnl
-+dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
-+dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
-+dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
-+dnl
-+dnl ACTION-IF-FOUND is a list of shell commands to run if a threads
-+dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
-+dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
-+dnl default action will define HAVE_PTHREAD.
-+dnl
-+dnl Please let the authors know if this macro fails on any platform, or
-+dnl if you have any other suggestions or comments. This macro was based
-+dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with
-+dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros
-+dnl posted by Alejandro Forero Cuervo to the autoconf macro repository.
-+dnl We are also grateful for the helpful feedback of numerous users.
-+dnl
-+dnl @category InstalledPackages
-+dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
-+dnl @version 2005-01-14
-+dnl @license GPLWithACException
-+
-+AC_DEFUN([ACX_PTHREAD], [
-+AC_REQUIRE([AC_CANONICAL_HOST])
-+AC_LANG_SAVE
-+AC_LANG_C
-+acx_pthread_ok=no
-+
-+# We used to check for pthread.h first, but this fails if pthread.h
-+# requires special compiler flags (e.g. on True64 or Sequent).
-+# It gets checked for in the link test anyway.
-+
-+# First of all, check if the user has set any of the PTHREAD_LIBS,
-+# etcetera environment variables, and if threads linking works using
-+# them:
-+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
-+ save_CFLAGS="$CFLAGS"
-+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-+ save_LIBS="$LIBS"
-+ LIBS="$PTHREAD_LIBS $LIBS"
-+ AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
-+ AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
-+ AC_MSG_RESULT($acx_pthread_ok)
-+ if test x"$acx_pthread_ok" = xno; then
-+ PTHREAD_LIBS=""
-+ PTHREAD_CFLAGS=""
-+ fi
-+ LIBS="$save_LIBS"
-+ CFLAGS="$save_CFLAGS"
-+fi
-+
-+# We must check for the threads library under a number of different
-+# names; the ordering is very important because some systems
-+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
-+# libraries is broken (non-POSIX).
-+
-+# Create a list of thread flags to try. Items starting with a "-" are
-+# C compiler flags, and other items are library names, except for "none"
-+# which indicates that we try without any flags at all, and "pthread-config"
-+# which is a program returning the flags for the Pth emulation library.
-+
-+acx_pthread_flags="pthreads pthread none -Kthread -kthread lthread -pthread -pthreads -mthreads --thread-safe -mt pthread-config"
-+
-+# The ordering *is* (sometimes) important. Some notes on the
-+# individual items follow:
-+
-+# pthreads: AIX (must check this before -lpthread)
-+# none: in case threads are in libc; should be tried before -Kthread and
-+# other compiler flags to prevent continual compiler warnings
-+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
-+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
-+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
-+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
-+# -pthreads: Solaris/gcc
-+# -mthreads: Mingw32/gcc, Lynx/gcc
-+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
-+# doesn't hurt to check since this sometimes defines pthreads too;
-+# also defines -D_REENTRANT)
-+# pthread: Linux, etcetera
-+# --thread-safe: KAI C++
-+# pthread-config: use pthread-config program (for GNU Pth library)
-+
-+case "${host_cpu}-${host_os}" in
-+ *solaris*)
-+
-+ # On Solaris (at least, for some versions), libc contains stubbed
-+ # (non-functional) versions of the pthreads routines, so link-based
-+ # tests will erroneously succeed. (We need to link with -pthread or
-+ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
-+ # a function called by this macro, so we could check for that, but
-+ # who knows whether they'll stub that too in a future libc.) So,
-+ # we'll just look for -pthreads and -lpthread first:
-+
-+ acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags"
-+ ;;
-+esac
-+
-+if test x"$acx_pthread_ok" = xno; then
-+for flag in $acx_pthread_flags; do
-+
-+ case $flag in
-+ none)
-+ AC_MSG_CHECKING([whether pthreads work without any flags])
-+ ;;
-+
-+ -*)
-+ AC_MSG_CHECKING([whether pthreads work with $flag])
-+ PTHREAD_CFLAGS="$flag"
-+ ;;
-+
-+ pthread-config)
-+ AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
-+ if test x"$acx_pthread_config" = xno; then continue; fi
-+ PTHREAD_CFLAGS="`pthread-config --cflags`"
-+ PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
-+ ;;
-+
-+ *)
-+ AC_MSG_CHECKING([for the pthreads library -l$flag])
-+ PTHREAD_LIBS="-l$flag"
-+ ;;
-+ esac
-+
-+ save_LIBS="$LIBS"
-+ save_CFLAGS="$CFLAGS"
-+ LIBS="$PTHREAD_LIBS $LIBS"
-+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-+
-+ # Check for various functions. We must include pthread.h,
-+ # since some functions may be macros. (On the Sequent, we
-+ # need a special flag -Kthread to make this header compile.)
-+ # We check for pthread_join because it is in -lpthread on IRIX
-+ # while pthread_create is in libc. We check for pthread_attr_init
-+ # due to DEC craziness with -lpthreads. We check for
-+ # pthread_cleanup_push because it is one of the few pthread
-+ # functions on Solaris that doesn't have a non-functional libc stub.
-+ # We try pthread_create on general principles.
-+ AC_TRY_LINK([#include <pthread.h>],
-+ [pthread_t th; pthread_join(th, 0);
-+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
-+ pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
-+ [acx_pthread_ok=yes])
-+
-+ LIBS="$save_LIBS"
-+ CFLAGS="$save_CFLAGS"
-+
-+ AC_MSG_RESULT($acx_pthread_ok)
-+ if test "x$acx_pthread_ok" = xyes; then
-+ break;
-+ fi
-+
-+ PTHREAD_LIBS=""
-+ PTHREAD_CFLAGS=""
-+done
-+fi
-+
-+# Various other checks:
-+if test "x$acx_pthread_ok" = xyes; then
-+ save_LIBS="$LIBS"
-+ LIBS="$PTHREAD_LIBS $LIBS"
-+ save_CFLAGS="$CFLAGS"
-+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-+
-+ # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
-+ AC_MSG_CHECKING([for joinable pthread attribute])
-+ attr_name=unknown
-+ for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
-+ AC_TRY_LINK([#include <pthread.h>], [int attr=$attr;],
-+ [attr_name=$attr; break])
-+ done
-+ AC_MSG_RESULT($attr_name)
-+ if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
-+ AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
-+ [Define to necessary symbol if this constant
-+ uses a non-standard name on your system.])
-+ fi
-+
<