Building GNR on FreeBSD 7.2 i386

General information

Please read GNR_on_FreeBSD_7 for all the details.

This guide describes building GNR-601 on FreeBSD-7.2_i386.

At this point it's good to note that everything should be run as root unless stated otherwise.

Getting the source via Perforce

You need to install Perforce either from /usr/ports:

cd /usr/ports/devel/perforce && make install distclean

or fetch perforce package and its dependency from

pkg_add perforce-08.2_5,1.tbz

If you are using a csh derivate shell, which is the FreeBSD default, run:


Get the source:

setenv P4PORT
mkdir -p /home/public/p4
p4 -u public -P public1234 -c public-view sync -f //depot/zcs/GNR-601/...

The source is about 587 MB so it may take some time if you are sitting in the middle of Alaska.

Getting the source from


mkdir -p /home/public/p4 && cd /home/public/p4
tar xzf GNR-601-src.tar.gz

The unpacked source is about 587 MB so it may take some time if you aren't sitting on gigabit line.

Initial pre-build steps

Let's check our system:

uname -a
FreeBSD 7.2-RELEASE-p4 FreeBSD 7.2-RELEASE-p4 #0: Mon Oct  5 23:15:44 CEST 2009  i386

cat /etc/make.conf
COPTFLAGS= -O2 -pipe
CFLAGS= -O2 -fno-strict-aliasing -pipe

Preparing build enviroment via /usr/ports

I created simple "meta" ports which will take care of everything. Since I am a very very creative person I named those: mail/zimbra-rundeps and mail/zimbra-builddeps.

The first installs all dependencies needed to run GNR-601 while the second installs all dependencies needed to build GNR-601. For reasons vastly uknown the second requires the first one.

cd /usr/ports/mail
fetch && \
    tar xzf usrports_zimbra-rundeps.tar.gz && \
        rm -f usrports_zimbra-rundeps.tar.gz
fetch && \
    tar xzf usrports_zimbra-builddeps.tar.gz && \
        rm -f usrports_zimbra-builddeps.tar.gz
cd /usr/ports/mail/zimbra-rundeps && make config-recursive install distclean
cd /usr/ports/mail/zimbra-builddeps && make config-recursive install distclean

If you are able to use /usr/ports you should be able to figure out the configure options (not that it matters much, mostly unimportant stuff). Be warned that GNR-601 requires jdk15 to build while apache-ant requires jdk16 to run so you will end up having both. Building diablo-jdk requires downloading java stuff. How boring! There are also those 64 perl modules..

If you are using a csh derivate shell, which is the FreeBSD default, run:


Preparing build enviroment via

Since some people like to compile (me me me!) and others like to install-only I built all the neccessary packages.

cd /tmp && mkdir -p DELME && cd DELME && fetch
tar xzf FreeBSD-7.2_i386_packages.tar.gz && cd i386
pkg_add zimbra-builddeps-6.0.1.tbz

You need to accept diablo-jdk license twice (jdk15+jdk16).

If you are using a csh derivate shell, which is the FreeBSD default, run:


Grats, you just saved yourself a lot of time.

Quick-hacks for a better day

Since Zimbra is a Linux lover by nature everything is /bin/bash but guess what.. we have /usr/local/bin/bash:

ln -s /usr/local/bin/bash /bin/bash

Since Zimbra uses gmake and since some ThirdParty does not honor ${MAKE} macro we have to replace make with gmake globally, otherwise some stuff just won't make with weird errors. I have no idea why recursive gmake running make fails but guess there is something deeper behind it:

cp /usr/bin/make /usr/bin/make.orig && cp /usr/local/bin/gmake /usr/bin/make

We need to compile with jdk15 so tell java about it:

setenv JAVA_VERSION 1.5

You should now get something like this:

java -version
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build diablo-1.5.0-b01)
Java HotSpot(TM) Server VM (build diablo-1.5.0_07-b01, mixed mode)

Patching GNR-601 to comply with FreeBSD

Download the patch and patch the source tree:

cd /home/public/p4 && fetch
cd GNR-601
patch -p1 -s < ../GNR-601.FreeBSD.patch

Remove unneccessary files (even those left by developers):

find . -name "*.orig" | xargs -n1 rm -f

Change modes of our new scripts else the build will fail:

chmod 0755 ZimbraBuild/rpmconf/Spec/Scripts/FreeBSD/*

Rest is handled by libexec/zmfixperms after installation.

Patching memcached for FreeBSD 8+

(--Solko 10:36, 28 March 2010 (UTC) fixed in GNR-605 patch by adding MEMCACHED_ADDITIONAL_CFLAGS for FREEBSD_OSVERSION >= 800000)

At the time of writing (using GNR-604), the patch files at do not cater for this (FreeBSD 8) issue, so follow these steps:-

When building memcached (from ThirdParty tools) under FreeBSD 8+, it is necessary to adjust the Makefile so the linker inserts / links against stack protection code (as libgcov makes use of this).

cd ThirdParty/memcached
vi Makefile

Change line 35 of the Makefile from:

CFLAGS="-g -O2" ./configure --prefix=$(ZIMBRA_HOME)/memcached-$(MEMCACHED_VERSION) \


CFLAGS="-g -O2" LDFLAGS="-fstack-protector" ./configure --prefix=$(ZIMBRA_HOME)/memcached-$(MEMCACHED_VERSION) \

Failing to adjust the Makefile will result in an error similair to:-

undefined reference to __stack_chk_fail_local

Return to base directory:

cd ../..

Putting jdk16 into ThirdPartyBuilds

Zimbra requires you to supply jdk16 so we are happy to oblige by using installed version of diablo-jdk16:

mkdir -p ThirdPartyBuilds/FreeBSD_i386/java && cd ThirdPartyBuilds/FreeBSD_i386/java && \
    cp -pr /usr/local/diablo-jdk1.6.0 diablo-jdk1.6.0_07 &&\
        tar zcf diablo-jdk1.6.0_07.tgz diablo-jdk1.6.0_07 && \
            rm -rf diablo-jdk1.6.0_07 && cd ../../../

The destination tarball version must match with ZimbraBuild/defs/ThirdParty/FreeBSD_i386.def!

Building Zimbra Collaboration Suite: GNR-601

Now that's the part where real Zimbra developer's magic kicks in:

cd ZimbraBuild
./ -t

Sample log in already patched source tree.

Replace gmake with make:

cp /usr/bin/make.orig /usr/bin/make && rm /usr/bin/make.orig

You should have a fresh build inside:

cd zcs-6.0.*

Installing Zimbra Collaboration Suite: GNR-601 after a successful build


Further reading


--Solko 13:46, 6 October 2009 (UTC)

Jump to: navigation, search