Saturday, March 31, 2007

Building Subversion for OpenSolaris 11

Subversion isn't available from the OpenSolaris install (snv_59), and with the availability of gcc and Sun's cc compilers, building subversion can be rather involved (and there are some gotchas).

Subversion uses APR and APR-UTIL from apache.org. Optionally it can use Berkeley DB and neon for webdav. I chose to enable BDB and NEON.

APR/APR-UTIL are supplied with OpenSolaris, but apr-util is not compiled with Berkely DB, plus apache2 is compile with Sun's cc vs gcc.

OpenSSL is supplied with OpenSolaris, but it's a little old, and linking is a pain, with all the other stuff inside /usr/sfw/lib, so just compile the latest. I tried for hours to get this to link clean, and gave up and built my own openssl libs.

Subversion is available from www.sunfreeware.com, but this should be a more "complete" build, and completely reproducible.

Step 1: Download source
Apache apr and apr-util from http://apr.apache.org/download.cgi
I grabbed apr-1.2.8.tar.gz and apr-util-1.2.8.tar.gz

Berkeley DB from http://www.sleepycat.com/download/index.shtml
I grabbed http://www.oracle.com/technology/software/products/berkeley-db/htdocs/popup/db/4.5.20/db-targz.html (Berkeley DB 4.5.20 with AES encryption)

Neon from: http://www.webdav.org/neon
I grabbed http://www.webdav.org/neon/neon-0.25.5.tar.gz since Subversion wanted that version (looks like it can be overridden as well).

Get the lastest OpenSSL from from http://www.openssl.org/source/
I grabbed openssl-0.9.8e.tar.gz

Subversion from http://subversion.tigris.org/
I grabbed http://subversion.tigris.org/downloads/subversion-1.4.3.tar.gz

Step 2: Setup build environment
Everything that I build goes into /depot, and source goes into /depot-src. I drop the tar files into /depot-src/tarballs.

Additionally, I'm building everything as root in a bash shell.

# convenience vars
export MYSOURCEDIR=/depot-src
export MYOUTPUTDIR=/depot

# extract files
/usr/sfw/bin/gtar xfz $MYSOURCEDIR/tarballs/openssl-0.9.8e.tar.gz
/usr/sfw/bin/gtar xfz $MYSOURCEDIR/tarballs/neon-0.25.5.tar.gz
/usr/sfw/bin/gtar xfz $MYSOURCEDIR/tarballs/db-4.5.20.tar.gz
/usr/sfw/bin/gtar xfz $MYSOURCEDIR/tarballs/apr-util-1.2.8.tar.gz
/usr/sfw/bin/gtar xfz $MYSOURCEDIR/tarballs/apr-1.2.8.tar.gz
/usr/sfw/bin/gtar xfz $MYSOURCEDIR/tarballs/subversion-1.4.3.tar.gz

# Use cc
export PATH=/usr/ccs/bin:$PATH
export CC=cc
export CXX=CC
# 64bit support required
export CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
# needed for apr-util to link berkeley db
export LDFLAGS="-L/$MYOUTPUTDIR/db-4.5.20/lib -R/MYOUTPUTDIR/db-4.5.20/lib"

Step 3: Build Berkeley DB

cd $MYSOURCEDIR/db-4.5.20/build_unix
../dist/configure --prefix=/$MYOUTPUTDIR/db-4.5.20
make
make install

Step 4: Build APR
cd $MYSOURCEDIR/apr-1.2.8
./configure --prefix=/$MYOUTPUTDIR/apr-1.2.8
make
make install

Step 5: Build APR-UTIL
cd $MYSOURCEDIR/apr-util-1.2.8
./configure --prefix=/$MYOUTPUTDIR/apr-util-1.2.8 \
--with-apr=/$MYOUTPUTDIR/apr-1.2.8 \
--with-berkeley-db=/$MYOUTPUTDIR/db-4.5.20
make
make install

Step 6: Build OpenSSL
cd $MYSOURCEDIR/openssl-0.9.8e
./Configure --prefix=/$MYOUTPUTDIR/openssl-0.9.8e solaris-x86-cc
make
make install

Step 7: Build Neon
cd $MYSOURCEDIR/neon-0.25.5
./configure --prefix=/$MYOUTPUTDIR/neon-0.25.5 \
--with-ssl=openssl --with-libs=/$MYOUTPUTDIR/openssl-0.9.8e
make
make install

Step 8: Build Subversion!
cd $MYSOURCEDIR/subversion-1.4.3
./configure --prefix=/$MYOUTPUTDIR/subversion-1.4.3 \
--with-apxs=/usr/apache2/bin/apxs \
--with-apr=/$MYOUTPUTDIR/apr-1.2.8 \
--with-apr-util=/$MYOUTPUTDIR/apr-util-1.2.8 \
--enable-experimental-libtool \
--with-neon=/$MYOUTPUTDIR/neon-0.25.5 \
--disable-nls --enable-ssl \
--with-libs=/$MYOUTPUTDIR/openssl-0.9.8e
make

Have subversion run its tests, if any fail something has gone wrong.
In my build switch_tests.py reported FAILURE /shrug

make check
make install

That's it, subversion is built and running for OpenSolaris x86.