Difference between revisions of "Getting Started/Build/Environment"

Jump to: navigation, search
(Path Configuration)
(Environment Configuration)
Line 86: Line 86:
  
 
== Environment Configuration ==
 
== Environment Configuration ==
 +
The example environment configuration script given below is for building KDE against your system Qt under your normal user account with an out-of-source build and installing into a user directory.  By changing just four variables you can use the script to configure any KDE build environment you want.
  
 +
It is recommended you create a separate script for each build environment you require.  If you have separate source directories for each build then save the script into the root source directory with the name ".build-config" to allow the bash scripts in the next section to automatically load the config and create the required directories.
 +
 +
If you don't wish to use the bash scripts then you must manually create the required directories and manually execute the config script.
  
 
=== Sample .build-config file ===
 
=== Sample .build-config file ===

Revision as of 21:52, 3 March 2011

Contents

Introduction

Configuring your build environment is the single most important step in building KDE. A wrong decision or mistake here could at best mean you have to rebuild everything from scratch again, or at worst break your system KDE rendering your system unusable.

A lot of very important concepts will be discussed and it is important that you understand them before proceeding.

A set of configuration scripts and bash commands are provided as a recommended configuration when building KDE manually. If you use these as provided then your KDE build will be a lot easier and it will be easier for you to find support online. The one disadvantage to these scripts is that they hide important details from you which you may want to learn about, but the two methods are completely interchangeable so once you are comfortable building KDE using the scripts you can learn more by doing everything yourself.

It is recommended that you build KDE using your normal user account. In some circumstances you may want to build using a separate user account, such as if you are a KWin or Plasma developer wishing to test a full KDE session with compositing effects, but for most circumstances a simple way can be found for achieving the same aim while still running using your normal user account (e.g. Nested X using xypher).

Git Configuration

Path Configuration

This section explains the different paths that need to be configured for building KDE. The following section will demonstrate a simple method for setting up the required paths.

Source Path

The $KDE_SRC path environment variable defines where the KDE Build System can find the source files.

TODO: Decide how to do stable and unstable source branches in parallel. While Git supports having these in a single source clone to save disk space, it is sometimes nice to have separate clones to allow simultaneous parallel builds, and it takes less scripting to achieve. It's also conceptually closer to how svn works so seems preferable during the transition.

Build Path

The $KDE_BUILD path environment variable defines where the KDE Build System will create the build files.

The KDE build system requires that your source and build files be in different directories (aka out-of-source builds). This keeps your source directories clean and simplifies management of your different build files. :

  • It makes it very easy to rebuild from scratch, you just delete the build directory to remove all the generated files - even old ones that "make clean" wouldn't remove.
  • It is easier to look at the source files (grep, ls etc.).
  • It allows multiple build trees with different settings, e.g. debug and release.

While for some simple build scenarios you could just create a "build" directory inside your 'source' directory (e.g. "kde/src/kdelibs/build"), this negates many of the advantages when used with a full KDE build. Instead clearly separate paths are recommended.

For example if we were building kdelibs we could have the following folders:

/home/myuser/kde/src/kdelibs
/home/myuser/kde/build/kdelibs

If you plan to build multiple branches of KDE such as stable and unstable in parallel then you will need to add an extra level to the directory:

/home/myuser/kde/src/master/kdelibs
/home/myuser/kde/src/4.6/kdelibs
/home/myuser/kde/build/master/kdelibs
/home/myuser/kde/build/4.6/kdelibs

Install Path

The $KDEDIR path environment variable defines where the KDE Build System will install KDE.

It is strongly recommended for a development build that you do a user based install and not a root install, i.e. install your KDE build into a separate user folder and not into the system /usr folder. This provides a number of advantages:

  • Your root/system installed version of KDE is untouched, meaning your normal desktop and applications remain stable and usable even if your development build breaks
  • You can build and run multiple development versions of KDE at the same time, i.e. a stable branch for bug fixes and an unstable branch for new features
  • You can use a single alias or bash command to compile/link/install without having to do a su/sudo in the middle
  • Doing "make" and "make install" as the same user is a lot quicker as the Makefiles are only parsed once.
  • No root owned files in the build directory
  • No problems caused by root not having a correctly configured KDE build environment

That said, the build instructions provided are completely generic and will work for building a root system install if you configure your environment to do so, i.e. for Linux from Scratch or doing a root install in a virtual machine for testing or packaging purposes.

For the kdelibs example given above we would then have:

/home/myuser/kde/src/master/kdelibs
/home/myuser/kde/src/4.6/kdelibs
/home/myuser/kde/build/master/kdelibs
/home/myuser/kde/build/4.6/kdelibs
/home/myuser/kde/inst/master/kdelibs
/home/myuser/kde/inst/4.6/kdelibs

Home Path

The $KDEHOME path environment variable defines wat directory KDE will treat as your home folder, i.e. for stroing data writing config files to.

For the same reason as the Install Path, it is strongly recommended that you set your KDE Home Path to be different from your normal home folder.

For the kdelibs example given above we would then have:

/home/myuser/kde/src/master/kdelibs
/home/myuser/kde/src/4.6/kdelibs
/home/myuser/kde/build/master/kdelibs
/home/myuser/kde/build/4.6/kdelibs
/home/myuser/kde/inst/master/kdelibs
/home/myuser/kde/inst/4.6/kdelibs
/home/myuser/kde/home/master/kdelibs
/home/myuser/kde/home/4.6/kdelibs

Other Paths

There are a number of other paths that are required, but these can all be automatically derived and created by the config script given below.

Environment Configuration

The example environment configuration script given below is for building KDE against your system Qt under your normal user account with an out-of-source build and installing into a user directory. By changing just four variables you can use the script to configure any KDE build environment you want.

It is recommended you create a separate script for each build environment you require. If you have separate source directories for each build then save the script into the root source directory with the name ".build-config" to allow the bash scripts in the next section to automatically load the config and create the required directories.

If you don't wish to use the bash scripts then you must manually create the required directories and manually execute the config script.

Sample .build-config file

  1. KDE4 Build Environment configuration script
  2. To configure your build environment set LIB_SUFFIX, BASEDIR, BUILDNAME and
  3. QTDIR as appropriate
  4. The default values provided are for a master/trunk/unstable build in your own
  5. user directory using your system Qt
  1. Uncomment if building on a 64 bit system
  2. export LIB_SUFFIX=64
  1. Set where your base KDE development folder is located, usually ~/kde

export BASEDIR=~/kde

  1. Give the build a name, e.g. master, 4.6, debug, etc

export BUILDNAME=master

  1. Set up which Qt to use
  2. Use the system Qt, adjust as required

export QTDIR=/usr

  1. Uncomment to use your own build of qt-kde
  2. export QTDIR=$BASEDIR/src/qt-kde
  1. Set up the KDE paths

export KDE_SRC=$BASEDIR/src export KDE_BUILD=$BASEDIR/build export KDEDIR=$BASEDIR/inst/$BUILDNAME export KDEDIRS=$KDEDIR export KDEHOME=$BASEDIR/home/.$BUILDNAME export KDETMP=/tmp/$BUILDNAME-$USER export KDEVARTMP=/var/tmp/$BUILDNAME-$USER mkdir -p $KDETMP mkdir -p $KDEVARTMP

  1. Add the KDE plugins to the Qt plugins path

export QT_PLUGIN_PATH=$KDEDIR/lib/kde4/plugins

  1. Do we really need these?

export KDE4_DBUS_INTERFACES_DIR=$KDEDIR/share/dbus-1/interfaces export PYTHON_SITE_PACKAGES_DIR=$KDEDIR/lib/python2.6/site-packages/PyKDE4

  1. Export the standard paths to include KDE and Qt in the right order

export PATH=$KDEDIR/bin:$QTDIR/bin:$PATH export LD_LIBRARY_PATH=$KDEDIR/lib:$QTDIR/lib:$LD_LIBRARY_PATH export PKG_CONFIG_PATH=$KDEDIR/lib/pkgconfig:$QTDIR/lib:$PKG_CONFIG_PATH

  1. Export the CMake paths so it searches for KDE in the right places

export CMAKE_PREFIX_PATH=$KDEDIR:$CMAKE_PREFIX_PATH export CMAKE_LIBRARY_PATH=$KDEDIR/lib:$CMAKE_LIBRARY_PATH export CMAKE_INCLUDE_PATH=$KDEDIR/include:$CMAKE_INCLUDE_PATH

  1. Unset XDG to avoid seeing KDE files from /usr

unset XDG_DATA_DIRS unset XDG_CONFIG_DIRS

  1. Uncomment if you are using Icecream for distributed compiling
  2. export PATH=/opt/icecream/bin:$PATH
  1. Report what the environment is set to

echo echo "*** Configured KDE Build Environment " $BUILDNAME " ***" echo echo "QTDIR=" $QTDIR echo "KDEDIR=" $KDEDIR echo "PATH=" $PATH echo

Useful Scripts


KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal