###
## A script to setup some needed variables and functions for KDE 4 development.
## This should normally go in the ~/.bashrc file of your kde-devel user, so
## that it is executed when a session for that user is started.
##
## Example:
## su - kde-devel
## kwrite ~/.bashrc
## (then paste this file)
## exit
## su - kde-devel
##
## If you don't use a separate user, the first section with the
## environment variables should go into a separate file of course.
#export KDE_LANG=vi.UTF-8
export KDE_COLOR_DEBUG=1
export QTEST_COLORED=1
#export QT_FLUSH_PAINT=1
#export PHONON_XINE_VERBOSITY=99
#export PHONON_DEBUG=1
if test `uname -m` != "i686"; then
MYP=$HOME/e1/path/64;
else MYP=$HOME/e1/path/32;
fi
export MYP
# KDE
export KDEDIR=$MYP/KDE4
export KDEHOME=$HOME/e1/kde4-home
export KDETMP=/tmp/$USER-KDE4
export KDEVARTMP=/var/tmp/$USER-KDE4
mkdir -p $KDETMP $KDEVARTMP
export KDEDIRS=$KDEDIR
export PKG_CONFIG_PATH=$KDEDIR/lib/pkgconfig:$PKG_CONFIG_PATH
# Qt
export QTDIR=$KDEDIR/qt-copy
export QT_PLUGIN_PATH=$KDEDIR/lib/kde4/plugins:$QT_PLUGIN_PATH
export PKG_CONFIG_PATH=$QTDIR/lib/pkgconfig:$PKG_CONFIG_PATH
#export QMAKESPEC=$QTDIR/mkspecs/linux-g++-64
# DBus
export DBUSDIR=/usr
export LD_LIBRARY_PATH=$KDEDIR/lib:$QTDIR/lib:$LD_LIBRARY_PATH
# Other
# you might want to remove $PATH from the end of this line and add any
# essential items from your path - to make sure the your kde3 path isn't
# in here
alias make_path="python -c \"import sys; print ':'.join((sys.stdin.read().split()))\""
export PATH=/bin:/sbin:/usr/games:$HOME/bin:$(\ls -d $MYP/*/bin | python -c "import sys; print ':'.join((sys.stdin.read().split()))" ):$QTDIR/bin:/usr/bin:/usr/local/bin
export YACC='byacc -d'
# XDG
unset XDG_DATA_DIRS # to avoid seeing kde3 files from /usr
unset XDG_CONFIG_DIRS
# Poppler-Qt4
#export LD_LIBRARY_PATH=$KDEDIR/libpoppler/lib:$LD_LIBRARY_PATH
#export PKG_CONFIG_PATH=$KDEDIR/libpoppler/lib/pkgconfig:$PKG_CONFIG_PATH
#Sip and PyQt4
export PYTHONPATH=$KDEDIR/PyQt4/lib:$KDEDIR:$PYTHONPATH
export PATH=$KDEDIR/PyQt4/bin:$PATH
# build and src folders
# you might want to change these!
export KDE_BUILD=$HOME/KDE4-build/
export KDE_SRC=$HOME/e1/KDE4-trunk/
# Unleash the Daemons
#if test "`pidof kded4`" == ""; then
# kdeinit4
#fi
#for d in ksysguardd knotify4; do
# if test "`pidof $d`" == ""; then
# $d &
# fi
#done
function dox {
if test -n "$1"; then
srcFolder=$1;
else
srcFolder=kdelibs;
fi;
cd /Books/KDE4-api/
nice -20 $KDE_SRC/KDE/kdelibs/doc/api/doxygen.sh --doxdatadir=$KDE_SRC/KDE/kdelibs/doc/common --installdir=/Books/KDE4-api/ $KDE_SRC/KDE/$srcFolder
} # installdir doesn't count, change to /Books/KDE4-api first
# Make
# Tell many scripts how to switch from source dir to build dir:
export OBJ_REPLACEMENT="s#$KDE_SRC#$KDE_BUILD#"
# 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=$KDE_SRC/KDE/kdesdk/scripts/makeobj
##
# IMPORTANT! Uncomment the following lines if DBus does not work. DBus is not
# working if, when you run `dbus-uuidgen --ensure && qdbus`, you get an error.
#
# alias dbusstart="eval `PATH=$DBUSDIR/bin \
# $DBUSDIR/bin/dbus-launch --auto-syntax`"
##
# 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
#
alias make="makeobj -s -j2"
alias mmi="nice makeobj -s -j2 && make install && make test"
KDE_CMAKE_OPTS=" -DCMAKE_INSTALL_PREFIX=$KDEDIR"
#KDE_CMAKE_OPTS+=" -DDATA_INSTALL_DIR=$KDEDIR/share/apps"
KDE_CMAKE_OPTS+=" -DCMAKE_BUILD_TYPE=debug"
#KDE_CMAKE_OPTS+=" -DKDE4_BUILD_TESTS=ON"
KDE_CMAKE_OPTS+=" -DCMAKE_SKIP_RPATH=ON"
#KDE_CMAKE_OPTS+=" -DQMAKE_MOC=$QTDIR/bin/moc -DQT_MOC_EXECUTABLE=$QTDIR/bin/moc -DQMAKE_UIC=$QTDIR/bin/uic -DQT_UIC_EXECUTABLE=$QTDIR/bin/uic"
function cmakekde-no-pause {
if test -n "$1"; then
srcFolder=$1
else
srcFolder=`pwd | sed -e s,$KDE_BUILD,$KDE_SRC,`
fi
if [ "$srcFolder" = `pwd` ]; then
cb
fi
CMAKE_KDE_MOREOPTS="$@"
cmake $srcFolder -G"Unix Makefiles" $KDE_CMAKE_OPTS $CMAKE_KDE_MOREOPTS && mmi;
}
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...
if [ "$srcFolder" = `pwd` ]; 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_KDE_MOREOPTS="$@"
cmake $srcFolder -G"Unix Makefiles" $KDE_CMAKE_OPTS $CMAKE_KDE_MOREOPTS && echo "know what to do?" && cat && mmi;
}
##
# for the lazy ones, add/comment other directories
function cmakekdeall {
cs kdesupport && svn up && cmakekde-no-pause
cs KDE/kdelibs && svn up && cmakekde-no-pause
cs KDE/kdepimlibs && svn up && cmakekde-no-pause
cs KDE/kdebase && svn up && cmakekde-no-pause
cs KDE/kdeartwork && svn up && cmakekde-no-pause
cs KDE/kdepim && svn up && cmakekde-no-pause
cs KDE/kdegraphics && svn up && cmakekde-no-pause
cs KDE/kdemultimedia && svn up && cmakekde-no-pause
cs KDE/kdenetwork && svn up && cmakekde-no-pause
cs KDE/kdeutils && svn up && cmakekde-no-pause
}
##
# A function to easily change to the build directory.
# Usage: cb KDE/kdebase
# will change to $KDE_BUILD/KDE/kdebase
# Usage: cb
# will simply go to the build folder if you are currently in a src folder
# Example:
# $ pwd
# /home/user/src/KDE/kdebase
# $ cb && pwd
# /home/user/build/KDE/kdebase
#
function cb {
# 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
}
##
# Change to the source directory. Same as cb, except this
# switches to $KDE_SRC instead of $KDE_BUILD.
# Usage: cs KDE/kdebase
# will change to $KDE_SRC/KDE/kdebase
# Usage: cs
# will simply go to the source folder if you are currently in a build folder
# Example:
# $ pwd
# /home/user/build/KDE/kdebase
# $ cs && pwd
# /home/user/src/KDE/kdebase
#
function cs {
# 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,`
if [ $dest = `pwd` ]; then
cd $KDE_SRC
else
cd $dest
fi
fi
}
##
# Add autocompletion to cs function
#
function _cs_scandir
{
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}) )
}
# Remove comment on next line to enable cs autocompletion
complete -F _cs cs
# function start3 {
# mkdir -p /tmp/$USER-kde
# export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games
# export LD_LIBRARY_PATH=
# export KDETMP=/tmp/$USER-kde
# export KDEVARTMP=/var/tmp/$USER-kde
# export KDEHOME=$HOME/.kde
# export KDEDIR=/usr
# export KDEDIRS=$KDEDIR
# export DISPLAY=:0
# eval "$@"
# kde4env #Reset environment variables again
# }