To compile Subversion 1.8 on Mac OS 10.8 (Mountain Lion) only requires the compilation of one dependency. Prior to 1.8 Subversion used neon for HTTP requests. It now uses Serf. If you access any repositories via HTTP you must first download and compile Serf.
If you compile Subversion without Serf being present and then try to access a repository via HTTP you get an error that looks something like this:
svn: Unrecognized URL scheme for http://www.example.com/svn/some_respository
First you need to download Serf which can be downloaded from http://code.google.com/p/serf/downloads/list. I used version 1.2.1 which was the most recent at the time I compiled it.
Generally compiling something is as easy as ./configure && make && sudo make install; however, for some reason Serf tries to use the wrong compiler by default. I am sure a C programmer could explain why; however, I am not one so I won’t attempt to explain. I will just tell you how to fix it. If you try to run “./configure” you will get the error message:
checking for gcc… /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc
checking whether the C compiler works… no
configure: error: in `/Users/mjparme/temp/serf-1.2.1′:
configure: error: C compiler cannot create executables
See `config.log’ for more details
To fix this you need to create a symbolic link to point it at the correct compiler, so execute this command:
sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain
For Mavericks (10.9) this symbolic link should be
sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain
Now you can run ./configure with no errors.
- Donwload Serf http://code.google.com/p/serf/downloads/list
- Unzip the downloaded file: unzip serf-1.2.1.zip (or “tar xvfz serf-1.2.1.tar.bz2″ if you downloaded the bzip one)
- cd serf-1.2.1
- Execute: ./configure && make -j 5 && sudo make install
Note that the value you pass for the -j parameter should be number of cores + 1 (this is the general consensus and my totally unscientific benchmarking supports the consensus). So if you have a dual-core machine, pass 3, quad-core pass 5, etc.
Also note that newer versions of the tar command can unzip files compressed with bzip2 as well as gzip with the “z” option.
Compile Subversion 1.8
Now since the Serf stuff is taken care of you can compile Subversion 1.8 that includes HTTP support like you would most any other app written in C.
- Download the source here: http://subversion.apache.org/download/
- Unzip the downloaded file: unzip subversion-1.8.0.zip (or “tar xvfz subversion-1.8.0.tar.gz” or “tar xvfz subversion-1.8.0.tar.bz2″ depending on which one you downloaded)
- cd subversion-1.8.0
- ./configure –with-serf=/usr/local/serf && make -j 5 && sudo make install
By default Subversion is installed in /usr/local/bin. Note that Mac OS 10.8 comes with subversion 1.6.18 installed in /usr/bin. To insure your compiled version is the one executed make sure /usr/local/bin appears in your PATH before /usr/bin.
So if you are using bash as your shell, add this to .bashrc in your home directory: