# How to use distcc/ccache with generate-release.sh?



## fizk (Jun 9, 2016)

I'm trying to build FreeBSD across my three servers, but I'm struggling to get the /usr/src/release/generate-release.sh script to use distcc and ccache. Any help would be appreciated!

distcc/ccache actually works for a few minutes, but beginning with buildworld, distcc/ccache is not used.

What I've tried so far:

- Installed sysutils/bsdadminscripts

- Added the following to /usr/local/etc/distcc/hosts:

```
--randomize localhost fbsd2 fbsd3
```

- Added the following to /etc/make.conf

```
WITH_CCACHE_BUILD="YES"
OPTIONS_UNSET=X11

WRKDIRPREFIX=           /var/ports
DISTDIR=                /var/ports/distfiles
PACKAGES=               /var/ports/packages
INDEXDIR=               /var/ports

BUILDFLAGS= /usr/local/share/bsdadminscripts/buildflags.mk
.if exists(${BUILDFLAGS})
.include "${BUILDFLAGS}"
.endif
```

- Edited /usr/src/release/generate-release.sh to change NWMAKE to:

```
NWMAKE="${WMAKE} MAKECONF=/etc/make.conf __MAKE_CONF=/etc/make.conf SRCCONF=/dev/null"
```

the lines 105 and 106 to:

```
${SETENV} DISTCC_DIR=/usr/local/etc/distcc CCACHE_DIR=/var/tmp/ccache CCACHE_LOGFILE=/var/log/ccache.log ${NWMAKE} -C ${CHROOTDIR}/usr/src ${WORLD_FLAGS} buildworld
${SETENV} DISTCC_DIR=/usr/local/etc/distcc CCACHE_DIR=/var/tmp/ccache CCACHE_LOGFILE=/var/log/ccache.log ${NWMAKE} -C ${CHROOTDIR}/usr/src installworld distribution DESTDIR=${CHROOTDIR}
```

and lines 125-128 to:

```
${CHROOT_CMD} ${SETENV} ${CROSSENV} DISTCC_DIR=/usr/local/etc/distcc CCACHE_DIR=/var/tmp/ccache CCACHE_LOGFILE=/var/log/ccache.log ${WMAKE} buildworld
${CHROOT_CMD} ${SETENV} ${CROSSENV} DISTCC_DIR=/usr/local/etc/distcc CCACHE_DIR=/var/tmp/ccache CCACHE_LOGFILE=/var/log/ccache.log ${KMAKE} buildkernel
${CHROOT_CMD} ${SETENV} ${CROSSENV} DISTCC_DIR=/usr/local/etc/distcc CCACHE_DIR=/var/tmp/ccache CCACHE_LOGFILE=/var/log/ccache.log ${RMAKE} release
${CHROOT_CMD} ${SETENV} ${CROSSENV} DISTCC_DIR=/usr/local/etc/distcc CCACHE_DIR=/var/tmp/ccache CCACHE_LOGFILE=/var/log/ccache.log ${RMAKE} install DESTDIR=/R
```

- Edited /usr/src/release/release.sh to change MAKE_CONF on line 87 to:

```
MAKE_CONF="/etc/make.conf"
        . /etc/make.conf
```

and added the following to line 392:

```
if [ -z "${RELEASECONF}" ]; then
                RELEASECONF="/usr/src/release/release.conf"
        fi
```


----------

