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.
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.
The OS X filesystem, despite appearances, is by default not case sensitive, so KDE == kde == kDe.
It would appear all bash customisations need to go in ~/.profile rather than ~/.bashrc.
My pet hate is how useless Finder is for file management, particularly with hidden .files. You will be glad when you get Dolphin and Krusader installed :-)
Install Apple's XCode developer tools either from your OS X install disks or download from http://developer.apple.com/technologies/xcode.html.
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.
"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.
It is recommended to initially install MacPorts using the package installer as this will automatically set-up your required $PATH.
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, note however that keeping the old version around may confuse the KDE build):
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:
sudo port -u -v upgrade outdated
Upgrade all installed packages and uninstall the old versions:
sudo port -u -v upgrade installed
Uninstall a package:
sudo port uninstall <package>
See the MacPorts documentation for more advanced options.
GUI frontends are available if you prefer.
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.
sudo port -v install cmake sudo port -v install qt4-mac sudo port -v install kdelibs4 etc...
Feel free to install all the modules you later intend to build trunk for to ensure you have all your requirements.
At time of writing (10 Aug 2010) the following KDE SC 4.4.5 packages were available:
kdebase4 kdebase4-runtime kdeedu4 kdegames4 kdegraphics4 kdelibs4 kdemultimedia4 kdenetwork4 kdepim4 kdepimlibs4 kdesdk4 kdetoys4 kdeutils4 amarok digikam kipi-plugins kdesvn kdenlive kile konversation krusader ktorrent
Once everything is built you should be able to run the stable apps from /Applications/MacPorts/KDE4 or just search for them using Spotlight.
Programs will not start until you run the command, replacing $USER with your username:
sudo chown -R $USER ~/Library/Preferences/KDE
Don't forget that dbus needs to be started as the local user (not with sudo) before any KDE programs will launch. To start it run the following commands:
sudo launchctl load -w /Library/LaunchDaemons/org.freedesktop.dbus-system.plist launchctl load -w /Library/LaunchAgents/org.freedesktop.dbus-session.plist
Yes, ignore what the KDE packages say, these are the correct commands needed now. After rebooting these should auto-start.
You may want to install teh following extra packages to enable more features:
ffmpeg polkit-qt
From this point on, the process is very similar to a standard KDE development build using dfaure's scripts. An alternative option might be the kdesrc-build script.
Fire up a Terminal and perform the following steps.
Create a home bin directory and create a new script in it called findup:
cd ~ mkdir bin cd bin vim findup
Copy the following into findup:
#!/bin/sh
arg="$1"
if test -z "$arg"; then exit 1; fi
while ! test -e "$arg"; do
cd .. if test "$PWD" = "/"; then exit 1 fi
done echo $PWD/$arg
Modify your bash profile with some handy utilities:
cd ~ vim .profile
Copy the following into .profile:
export PATH=~/bin:$PATH
alias ls='ls -AFG'
prepend() { [ -d "$2" ] && eval $1=\"$2\$\{$1:+':'\$$1\}\" && export $1 ; }
export KDE_COLOR_DEBUG=1 export QTEST_COLORED=1
export OBJ_REPLACEMENT="s#$KDE_SRC#$KDE_BUILD#"
alias make=makeobj
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
# Note: To speed up compiling, change 'make -j2' to 'make -jx', # where x is your number of processors +1 nice make -j3 && make install RETURN=$? cs return ${RETURN}
}
function cmakekdeall {
cs trunk/kdesupport && svn up && cmakekde cs trunk/KDE/kdelibs && svn up && cmakekde cs trunk/KDE/kdepimlibs && svn up && cmakekde cs trunk/KDE/kdebase && svn up && cmakekde cs trunk/KDE/kdepim && svn up && cmakekde cs trunk/KDE/kdegraphics && svn up && cmakekde cs trunk/KDE/kdemultimedia && svn up && cmakekde cs trunk/KDE/kdenetwork && svn up && cmakekde cs trunk/KDE/kdeutils && svn up && cmakekde
}
function cd() {
if test -z "$1"; then builtin cd elif test -z "$2"; then builtin cd "$1" else builtin cd "$1" "$2" fi _f=`findup .my-setup` if test -n "$_f" -a "$_lastf" != "$_f"; then echo "Loading $_f" _lastf="$_f" source "$_f" fi
}
function cb {
local dest
# Make sure build directory exists. mkdir -p "$KDE_BUILD"
# command line argument if test -n "$1"; then cd "$KDE_BUILD/$1" return fi # substitute src dir with build dir dest=`pwd | sed -e s,$KDE_SRC,$KDE_BUILD,` if test ! -d "$dest"; then # build directory does not exist, create mkdir -p "$dest" fi cd "$dest"
}
function cs {
local dest current
# Make sure source directory exists. mkdir -p "$KDE_SRC"
# command line argument if test -n "$1"; then cd "$KDE_SRC/$1" else # substitute build dir with src dir dest=`pwd | sed -e s,$KDE_BUILD,$KDE_SRC,` current=`pwd` if [ "$dest" = "$current" ]; then cd "$KDE_SRC" else cd "$dest" fi fi
}
function _cs_scandir {
local base ext
base=$1 ext=$2 if [ -d $base ]; then for d in `ls $base`; do if [ -d $base/$d ]; then dirs="$dirs $ext$d/" fi done fi
}
function _cs() {
local cur dirs _cs_scandir "$KDE_SRC" _cs_scandir "$KDE_SRC/KDE" "KDE/" COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" COMPREPLY=( $(compgen -W "${dirs}" -- ${cur}) )
}
complete -F _cs cs
svndiff() {
svn diff "$*" | colordiff | less;
}
Close your Terminal and open a new Terminal to have the .profile changes take effect, you should hopefully not see any error messages.
If using svn+ssh for subversion access, copy your key into ~/.ssh and set its permissions to 400.
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:
cd ~ mkdir kde cd kde mkdir kde/build mkdir kde/home mkdir kde/inst mkdir kde/src mkdir kde/src/branches mkdir kde/src/trunk
Now install the script that will set up the KDE environment for trunk development:
vim ~/kde/src/trunk/.my-setup
Copy the following into .my-setup and set BASEDIR as required:
#Set up base directory to your chosen location
export BASEDIR=/Users/your-user/kde
export QTDIR=/opt/local/libexec/qt4-mac export PATH=$QTDIR/bin:$PATH export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH export PKG_CONFIG_PATH=$QTDIR/lib:$PKG_CONFIG_PATH
export KDE_BUILD=$BASEDIR/build export KDEHOME=$BASEDIR/home/.kde4trunk export KDEDIR=$BASEDIR/inst/kde4trunk export KDE_SRC=$BASEDIR/src export KDETMP=/tmp/kde4trunk-$USER export KDEVARTMP=/var/tmp/kde4trunk-$USER mkdir -p $KDETMP mkdir -p $KDEVARTMP export PATH=$KDEDIR/bin:$PATH export LD_LIBRARY_PATH=$KDEDIR/lib:$LD_LIBRARY_PATH prepend PKG_CONFIG_PATH $KDEDIR/lib/pkgconfig export QT_PLUGIN_PATH=$KDEDIR/lib/kde4/plugins export KDEDIRS=$KDEDIR
export PYTHON_SITE_PACKAGES_DIR=$KDEDIR/lib/python2.6/site-packages/PyKDE4
export PATH export LD_LIBRARY_PATH export PKG_CONFIG_PATH export QT_PLUGIN_PATH
prepend CMAKE_PREFIX_PATH $KDEDIR prepend CMAKE_LIBRARY_PATH $KDEDIR/lib prepend CMAKE_INCLUDE_PATH $KDEDIR/include
export CMAKE_PREFIX_PATH export CMAKE_LIBRARY_PATH export CMAKE_INCLUDE_PATH
Finally, change into the trunk directory to activate the environment:
cd ~/kde/src/trunk
You should see the message:
Loading /Users/odysseus/kde/src/trunk/.my-setup
Try typing env to see settings similar to:
BASEDIR=/Users/odysseus/kde
QTDIR=/opt/local/libexec/qt4-mac
QT_PLUGIN_PATH=/Users/odysseus/kde/inst/kde4trunk/lib/kde4/plugins
KDE_BUILD=/Users/odysseus/kde/build
KDE_SRC=/Users/odysseus/kde/src
KDEDIR=/Users/odysseus/kde/inst/kde4trunk
KDEDIRS=/Users/odysseus/kde/inst/kde4trunk
KDEHOME=/Users/odysseus/kde/home/.kde4trunk
KDETMP=/tmp/kde4trunk-odysseus
KDEVARTMP=/var/tmp/kde4trunk-odysseus
LD_LIBRARY_PATH=/Users/odysseus/kde/inst/kde4trunk/lib:/opt/local/libexec/qt4-mac/lib
PATH=/Users/odysseus/kde/inst/kde4trunk/bin:/opt/local/libexec/qt4-mac/bin:/opt/local/bin:/opt/local/sbin:/Users/odysseus/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
PKG_CONFIG_PATH=/opt/local/libexec/qt4-mac/lib
PYTHON_SITE_PACKAGES_DIR=/Users/odysseus/kde/inst/kde4trunk/lib/python2.6/site-packages/PyKDE4