Warning, file /sdk/kdesrc-build/sample-kde-env-master.sh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #!/bin/sh
0002 #
0003 # This sets the various environment variables needed to start Plasma (or other KDE
0004 # software built by kdesrc-build), or to run programs/build programs/etc. in the
0005 # same environment, ideally without clashing with system-built KDE or Qt.
0006 #
0007 # This should not produce any output in order to make it usable by
0008 # non-interactive scripts.
0009 #
0010 # See also the sample xsession setup script, which requires this file.
0011 #
0012 # Use by copying this script to $XDG_CONFIG_HOME/kde-env-master.sh (this will
0013 # be done for you by kdesrc-build and/or kdesrc-build-setup, later). 99% of the
0014 # time this means ~/.config/kde-env-master.sh
0015 #
0016 # NOTHING IN THIS FILE IS MODIFIABLE, OTHERWISE WARNINGS WILL BE GENERATED
0017 # (instead make your changes in your ~/.bashrc, ~/.bash_profile, or whatever else
0018 # you are using)
0019 
0020 # === Load user environment settings (i.e. not set through kdesrc-buildrc)
0021 XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
0022 export XDG_CONFIG_HOME
0023 
0024 # === Modifiable variables. Should be set automatically by kdesrc-build based
0025 # on kdesrc-buildrc settings. Nothing below this line is user-modifiable!
0026 
0027 # The KDESRC_BUILD_TESTING stuff is to allow the script to     # kdesrc-build: filter
0028 # be executable by testsuite. It is filtered from destination. # kdesrc-build: filter
0029 if ! test -n "$KDESRC_BUILD_TESTING"; then                     # kdesrc-build: filter
0030 # Where KDE libraries and applications are installed to.
0031 kde_prefix="<% kdedir %>"  # E.g. "$HOME/kf5"
0032 
0033 # Where Qt is installed to. If using the system Qt, leave blank and this script
0034 # will try to auto-detect.
0035 qt_prefix="<% qtdir %>"    # E.g. "$HOME/qt5" or "/usr" on many systems.
0036 else                                                           # kdesrc-build: filter
0037 kde_prefix="$HOME/kf5"                                         # kdesrc-build: filter
0038 qt_prefix="$HOME/qt5"                                          # kdesrc-build: filter
0039 fi                                                             # kdesrc-build: filter
0040 
0041 # === End of modifiable variables.
0042 
0043 # Default qmake executable if we don't find a better one
0044 qmake=${qt_prefix}/bin/qmake
0045 
0046 # Find system Qt5
0047 if test -z "$qt_prefix"; then
0048     # Find right qmake, look for specific executables first
0049     for qmake_candidate in qmake-qt5 qmake5; do
0050         if ${qmake_candidate} --version >/dev/null 2>&1; then
0051             qmake="$qmake_candidate"
0052             break;
0053         fi
0054     done
0055 
0056     qt_prefix=$(${qmake} -query QT_INSTALL_PREFIX 2>/dev/null)
0057 
0058     test -z "$qt_prefix" && qt_prefix="/usr" # Emergency fallback?
0059 fi
0060 
0061 # Add path elements to a colon-separated environment variable,
0062 # taking care not to add extra unneeded colons.
0063 # Should be sh-compatible.
0064 # Can't use function keyword in Busybox-sh
0065 path_add()
0066 {
0067     eval curVal=\$'{'$1'-}'
0068 
0069     if test -n "$curVal"; then
0070         eval "$1"="$2:'$curVal'";
0071     else
0072         eval "$1"="'$2'"
0073     fi
0074 }
0075 
0076 # Now add the necessary directories, starting with Qt (although we don't add Qt
0077 # if it's system Qt to avoid moving /usr up in the PATH.
0078 if test "x$qt_prefix" != "x/usr"; then
0079     path_add "PATH"               "$(${qmake} -query QT_INSTALL_BINS 2>/dev/null)";
0080     path_add "PKG_CONFIG_PATH"    "$(${qmake} -query QT_INSTALL_LIBS 2>/dev/null)/pkgconfig";
0081 fi
0082 
0083 # There doesn't seem to be a great way to get this from CMake easily but we can
0084 # reason that if there's a /usr/lib64 (and it's not just a compat symlink),
0085 # there will likely end up being a $kde_prefix/lib64 once kdesrc-build gets
0086 # done installing it
0087 libname=lib
0088 if test -d /usr/lib/x86_64-linux-gnu; then
0089         libname=lib/x86_64-linux-gnu
0090 elif test -d /usr/lib64 -a '!' -L /usr/lib64; then
0091         libname=lib64
0092 fi
0093 
0094 # Now add KDE-specific paths.
0095 path_add "PATH"               "$kde_prefix/bin";
0096 # For some reason I've seen both of lib and lib64 used.  I think due
0097 # to qmake vs. cmake modules
0098 if test $libname = lib64; then
0099         path_add "PKG_CONFIG_PATH"    "$kde_prefix/lib64/pkgconfig";
0100 fi
0101 path_add "PKG_CONFIG_PATH"    "$kde_prefix/lib/pkgconfig";
0102 path_add "MANPATH"            "$kde_prefix/share/man";
0103 path_add "CMAKE_PREFIX_PATH"  "$kde_prefix";
0104 path_add "QML2_IMPORT_PATH"   "$kde_prefix/$libname/qml";
0105 path_add "QT_PLUGIN_PATH"     "$kde_prefix/$libname/qt5/plugins" # phonon likes this one
0106 path_add "QT_PLUGIN_PATH"     "$kde_prefix/$libname/plugins"     # others like this more
0107 
0108 # For Python bindings support.
0109 path_add "PYTHONPATH"         "$kde_prefix/$libname/site-packages";
0110 
0111 # https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
0112 path_add "XDG_DATA_DIRS"      "$kde_prefix/share:/usr/share";
0113 path_add "XDG_CONFIG_DIRS"    "$kde_prefix/etc/xdg:/etc/xdg";
0114 
0115 # Finally, export the variables.
0116 export CMAKE_PREFIX_PATH
0117 export PATH
0118 export PKG_CONFIG_PATH
0119 export PYTHONPATH
0120 export QML2_IMPORT_PATH
0121 export QT_PLUGIN_PATH
0122 export XDG_DATA_DIRS
0123 export XDG_CONFIG_DIRS
0124 export MANPATH