Introduction

The process described here is one of many ways to set up a KDE development environment on Mac OS X. It sets up a MacPorts installation to provide the required dependencies and uses this to then build a KDE trunk development environment. This approach has the big advantage of using MacPorts to build, install and keep updated the base system and libraries required with minimal effort and without touching the base OSX system install.

It also gives you the choice of installing and running the latest stable KDE SC for everyday use while still developing on the unstable trunk.

The main disadvantage is compiling all the MacPort dependencies takes longer than binary installs, but the ease of maintenance is worth it.

OS X for Linux developers

One point to remember is that OS X is a customised version of BSD, so while it feels fairly familiar to a Linux developer, there are the occasional banana skins to slip you up.

Install XCode and X11.

If you are running Tiger you will also need to install Apple's X11 from your OS X Install disks. Snow Leopard and Leopard come with it installed by default.

Once installed, perform an OS X Software Update to ensure your system is fully up-to-date and reboot if required.

MacPorts.

"The MacPorts Project is an open-source community initiative to design an easy-to-use system for compiling, installing, and upgrading either command-line, X11 or Aqua based open-source software on the Mac OS X operating system."

MacPorts installs everything into /opt/local and so doesn't interfere with the base OS X install or any other local installs you have. This enables you to control the environment search hierarchy for different purposes.

Applications installed via MacPorts can be run from the command line or from the /Applications/MacPorts folder in the finder.

Install MacPorts.

It is recommended to initially install MacPorts using the package installer as this will automatically set-up your required $PATH.

Using MacPorts.

MacPorts should be very easy to use for anyone used to Linux-style package management.

Update MacPorts and the list of available ports, you should do this first whenever you work with the port command:

sudo port selfupdate

List all available packages, this will be very long:

port list

List all installed packages:

port installed

Search for a package:

port search <package>

Show information about a package:

port info <package>

Install a package, the -v is needed to see the build output:

sudo port -v install <package>

List the contents of an installed package

port contents <package>

List all installed packages with available updates:

port outdated

Upgrade a package and uninstall the old version (omit the -u to just disable the old version, useful when the new version may break things):

sudo port -u -v upgrade <package>

Switch to a different installed version of a package:

sudo port -v activate <package> <version>

Upgrade all outdated packages with new versions and uninstall the old versions:

Installing the base requirements

You can choose to find and install each requirement on your own, or if you have less time and plenty of disk space you can just install the stable KDE SC and let it pull all the dependencies in for you.

If you have plenty of time, just choose to install one of the major KDE packages and leave it running for 24-48 hours, kdesdk4 seems the obvious choice:

sudo port -v install kdesdk4

This will resolve all the dependencies and compile and install everything you need including development tools like subversion and cmake.

You may prefer to break it up into smaller chunks, although the Qt build will still take a long time.

Use makeobj instead of make, to automatically switch to the build dir.

If you don't have makeobj, install the package named kdesdk-scripts or

kdesdk, or check out kdesdk/scripts from svn, or just don't set the alias

yet.

alias make=makeobj

A function to easily build the current directory of KDE.

This builds only the sources in the current ~/{src,build}/KDE subdirectory.

Usage: cs KDE/kdebase && cmakekde

will build/rebuild the sources in ~/src/KDE/kdebase

function cmakekde {

if test -n "$1"; then
# srcFolder is defined via command line argument
srcFolder="$1"
else
# get srcFolder for current dir
srcFolder=`pwd | sed -e s,$KDE_BUILD,$KDE_SRC,`
fi
# we are in the src folder, change to build directory
# Alternatively, we could just use makeobj in the commands below...
current=`pwd`
if [ "$srcFolder" = "$current" ]; then
cb
fi
# to enable tests, add -DKDE4_BUILD_TESTS=TRUE to the next line.
# you can also change "debugfull" to "debug" to save disk space.
# added "nice make..." to allow the user to work on the box while
# compiling
cmake "$srcFolder" -GKDevelop3 -DCMAKE_INSTALL_PREFIX=$KDEDIR \
-DKDE4_BUILD_TESTS=TRUE \
-DCMAKE_BUILD_TYPE=debugfull

# uncomment the following two lines to make builds wait after
# configuration step, so that the user can check configure output
echo "Press <ENTER> to continue..."
read userinput

Close your Terminal and open a new Terminal to have the .profile changes take effect, you should hopefully not see any error messages.

Configure svn+ssh

If using svn+ssh for subversion access, copy your key into ~/.ssh and set its permissions to 400.

Create KDE directories

Choose you KDE development base directory where the KDE source, build and installation will be kept. In this example the base directory is ~/kde but it could be anywhere with sufficient space and permissions. Create the following set of directories: