Ympäristön asetukset

Miksi asentaa käyttäjänä eikä root-oikeuksilla?

a single command to compile+link+install (or even a single key in your editor), no su/sudo needed

no risk of root-owned files in the builddir, as can happen when some change forces make install to recompile some files

safer if something goes wrong (for instance, using the wrong prefix would overwrite the system kde3)

make install is faster than "make && sudo make install" since the Makefiles are parsed only once

no link errors during sudo make install due to root's environment missing entries in LD_LIBRARY_PATH. Really, setting up the environment once is hard enough, why do it for two users?

Kehitysasetukset

If you really want to use a separate account for development, see here.

But to save time and avoid many problems, it is strongly recommended to do it all from your usual user.
All you need is an easy way to switch between environments.
You go to ~/kde/src/4, you want to be in the kde4 environment, right?

This way, whenever you enter a directory, it will look up a .my-setup file and source it (it also looks up in parent directories until it finds one, and it doesn't source the same one twice in a row).

Set up all the environment variables that are specific to kde4 (they will be detailed later on in this page) into that ~/kde/src/4/.my-setup file, and do the same for other environments (kde3, and anywhere you need project-specific environment variables...)

Esimerkkipolkuja

Qt

For Qt, by habit from the Qt3 times and to save time by avoiding "make install" after a change, I recommend using one directory for source, builds and install. This is done by configuring Qt with --prefix=$PWD. This isn't mandatory though.

Qt-Path: ~/qt/4/qt-copy

KDE

It was convenient in kde3, it is mandatory in kde4: you need to use out-of-source builds, i.e. separate build and source directories.
It makes it very easy to rebuild from scratch, removing all 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.

Source: ~/kde/src/[version]

Build: ~/kde/build/[version]

Thus source modules for kde4 are checked out in ~/kde/src/4/ and building happens in ~/kde/build/4/.

Ympäristömuuttujat ja muut hyödylliset funktiot

Bash

If you use bash, take a look at this .bashrc. It is an example bash config which sets all KDE4 environment variables and some helper functions. You can also look at these scripts which are based on the above .bashrc.

The steps below describe some of these features as well as giving alternative and additional functions.

Hakemistonavigointi

To easily swap from build and source folder back and forth, you can use cs and cb functions that work like the following:
pwd

~/kde/src/4/kdebase

cb && pwd

~/kde/build/4/kdebase
# note that this folder is created if it does not exist

cs && pwd

~/kde/src/4/kdebase

A number of kde-related scripts will have to be able to do the same. Simply do:
export OBJ_REPLACEMENT='s#/kde/src/#/kde/build/#'
This allows the makeobj script from kdesdk to switch from src to build.
If you also do:
alias make=makeobj
then you can simply type make from the source dir and it will be able to build. This is also very useful in editors - if your vi or emacs uses makeobj as the make command, you can compile with a single key press.

In addition, for fast navigation to other directories, it is very convenient to be able to type "cs 4/kdelibs" in order to go to ~/src/4/kdelibs, from anywhere.
For instance, you could be in ~/kde/src/4/kdebase/workspace/kcontrol and now you decide to look at kdecore... No need to type a long series of "../.." or to restart from the top. You can just type cs 4/kdelibs/kdecore.

This is doable via the two functions cs and cb defined in the .bashrc.

Vaihtoehtoinen tapa

The following code will enable you to use cd similar to cs described above:
export CDPATH=.:~/kde/src
The advantage, when using zsh, is that completion even works. Try cd 4/kdemul and press Tab, it will complete to 4/kdemultimedia, no matter where you currently are. Doesn't work in bash though - but surely you're using zsh by now, aren't you? :)

Siirtyminen takaisin edelliseen hakemistoon

Going back to the previous directory easily can be done with zsh. Set this in .zshrc:
setopt AUTO_PUSHD
alias p=popd
and then you can type "p" to pop back to the directory where you were last,
as many times as needed (type "dirs -v" to see the stack of previous directories).

KDE

Käyttäjä

export KDEHOME=$HOME/.kde4

Muut

export QTEST_COLORED=1
export KDE_COLOR_DEBUG=1

KDE-moduulin kääntäminen

Manuaalisesti

If you use the aforementioned ~/.bashrc it is very convenient to compile a KDE module (it is required to already have aquired the source code, e.g. via SVN. see Using Subversion with KDE):
cs KDE/kdebase
cmakekde