1ecmCMakeFlags() {
2 appendToVar cmakeFlags "-DECM_DIR=@out@/share/ECM/cmake"
3}
4
5preConfigureHooks+=(ecmCMakeFlags)
6
7ecmEnvHook() {
8 addToSearchPath XDG_DATA_DIRS "$1/share"
9 addToSearchPath XDG_CONFIG_DIRS "$1/etc/xdg"
10}
11addEnvHooks "$targetOffset" ecmEnvHook
12
13ecmPostHook() {
14 # Because we need to use absolute paths here, we must set *all* the paths.
15 appendToVar cmakeFlags "-DKDE_INSTALL_EXECROOTDIR=${!outputBin}"
16 appendToVar cmakeFlags "-DKDE_INSTALL_BINDIR=${!outputBin}/bin"
17 appendToVar cmakeFlags "-DKDE_INSTALL_SBINDIR=${!outputBin}/sbin"
18 appendToVar cmakeFlags "-DKDE_INSTALL_LIBDIR=${!outputLib}/lib"
19 appendToVar cmakeFlags "-DKDE_INSTALL_LIBEXECDIR=${!outputLib}/libexec"
20 appendToVar cmakeFlags "-DKDE_INSTALL_CMAKEPACKAGEDIR=${!outputDev}/lib/cmake"
21 appendToVar cmakeFlags "-DKDE_INSTALL_INCLUDEDIR=${!outputInclude}/include"
22 appendToVar cmakeFlags "-DKDE_INSTALL_LOCALSTATEDIR=/var"
23 appendToVar cmakeFlags "-DKDE_INSTALL_DATAROOTDIR=${!outputBin}/share"
24 appendToVar cmakeFlags "-DKDE_INSTALL_DATADIR=${!outputBin}/share"
25 appendToVar cmakeFlags "-DKDE_INSTALL_DOCBUNDLEDIR=${!outputBin}/share/doc/HTML"
26 appendToVar cmakeFlags "-DKDE_INSTALL_KCFGDIR=${!outputBin}/share/config.kcfg"
27 appendToVar cmakeFlags "-DKDE_INSTALL_KCONFUPDATEDIR=${!outputBin}/share/kconf_update"
28 appendToVar cmakeFlags "-DKDE_INSTALL_KSERVICES5DIR=${!outputBin}/share/kservices5"
29 appendToVar cmakeFlags "-DKDE_INSTALL_KSERVICETYPES5DIR=${!outputBin}/share/kservicetypes5"
30 appendToVar cmakeFlags "-DKDE_INSTALL_KXMLGUI5DIR=${!outputBin}/share/kxmlgui5"
31 appendToVar cmakeFlags "-DKDE_INSTALL_KNOTIFY5RCDIR=${!outputBin}/share/knotifications5"
32 appendToVar cmakeFlags "-DKDE_INSTALL_ICONDIR=${!outputBin}/share/icons"
33 appendToVar cmakeFlags "-DKDE_INSTALL_LOCALEDIR=${!outputLib}/share/locale"
34 appendToVar cmakeFlags "-DKDE_INSTALL_SOUNDDIR=${!outputBin}/share/sounds"
35 appendToVar cmakeFlags "-DKDE_INSTALL_TEMPLATEDIR=${!outputBin}/share/templates"
36 appendToVar cmakeFlags "-DKDE_INSTALL_WALLPAPERDIR=${!outputBin}/share/wallpapers"
37 appendToVar cmakeFlags "-DKDE_INSTALL_APPDIR=${!outputBin}/share/applications"
38 appendToVar cmakeFlags "-DKDE_INSTALL_DESKTOPDIR=${!outputBin}/share/desktop-directories"
39 appendToVar cmakeFlags "-DKDE_INSTALL_MIMEDIR=${!outputBin}/share/mime/packages"
40 appendToVar cmakeFlags "-DKDE_INSTALL_METAINFODIR=${!outputBin}/share/appdata"
41 appendToVar cmakeFlags "-DKDE_INSTALL_MANDIR=${!outputBin}/share/man"
42 appendToVar cmakeFlags "-DKDE_INSTALL_INFODIR=${!outputBin}/share/info"
43 appendToVar cmakeFlags "-DKDE_INSTALL_DBUSDIR=${!outputBin}/share/dbus-1"
44 appendToVar cmakeFlags "-DKDE_INSTALL_DBUSINTERFACEDIR=${!outputBin}/share/dbus-1/interfaces"
45 appendToVar cmakeFlags "-DKDE_INSTALL_DBUSSERVICEDIR=${!outputBin}/share/dbus-1/services"
46 appendToVar cmakeFlags "-DKDE_INSTALL_DBUSSYSTEMSERVICEDIR=${!outputBin}/share/dbus-1/system-services"
47 appendToVar cmakeFlags "-DKDE_INSTALL_SYSCONFDIR=${!outputBin}/etc"
48 appendToVar cmakeFlags "-DKDE_INSTALL_CONFDIR=${!outputBin}/etc/xdg"
49 appendToVar cmakeFlags "-DKDE_INSTALL_AUTOSTARTDIR=${!outputBin}/etc/xdg/autostart"
50
51 if [ "$(uname)" = "Darwin" ]; then
52 appendToVar cmakeFlags "-DKDE_INSTALL_BUNDLEDIR=${!outputBin}/Applications/KDE"
53 fi
54
55 if [ -n "${qtPluginPrefix-}" ]; then
56 appendToVar cmakeFlags "-DKDE_INSTALL_QTPLUGINDIR=${!outputBin}/$qtPluginPrefix"
57 appendToVar cmakeFlags "-DKDE_INSTALL_PLUGINDIR=${!outputBin}/$qtPluginPrefix"
58 fi
59
60 if [ -n "${qtQmlPrefix-}" ]; then
61 appendToVar cmakeFlags "-DKDE_INSTALL_QMLDIR=${!outputBin}/$qtQmlPrefix"
62 fi
63}
64postHooks+=(ecmPostHook)
65
66xdgDataSubdirs=( \
67 "config.kcfg" "kconf_update" "kservices5" "kservicetypes5" \
68 "kxmlgui5" "knotifications5" "icons" "locale" "sounds" "templates" \
69 "wallpapers" "applications" "desktop-directories" "mime" "appdata" "dbus-1" \
70)
71
72# ecmHostPathsSeen is an associative array of the paths that have already been
73# seen by ecmHostPathHook.
74declare -gA ecmHostPathsSeen
75
76ecmHostPathIsNotSeen() {
77 if [[ -n "${ecmHostPathsSeen["$1"]:-}" ]]; then
78 # The path has been seen before.
79 return 1
80 else
81 # The path has not been seen before.
82 # Now it is seen, so record it.
83 ecmHostPathsSeen["$1"]=1
84 return 0
85 fi
86}
87
88ecmHostPathHook() {
89 ecmHostPathIsNotSeen "$1" || return 0
90
91 local xdgConfigDir="$1/etc/xdg"
92 if [ -d "$xdgConfigDir" ]
93 then
94 qtWrapperArgs+=(--prefix XDG_CONFIG_DIRS : "$xdgConfigDir")
95 fi
96
97 for xdgDataSubdir in "${xdgDataSubdirs[@]}"
98 do
99 if [ -d "$1/share/$xdgDataSubdir" ]
100 then
101 qtWrapperArgs+=(--prefix XDG_DATA_DIRS : "$1/share")
102 break
103 fi
104 done
105
106 local manDir="$1/man"
107 if [ -d "$manDir" ]
108 then
109 qtWrapperArgs+=(--prefix MANPATH : "$manDir")
110 fi
111
112 local infoDir="$1/info"
113 if [ -d "$infoDir" ]
114 then
115 qtWrapperArgs+=(--prefix INFOPATH : "$infoDir")
116 fi
117
118 if [ -d "$1/dbus-1" ]
119 then
120 appendToVar propagatedUserEnvPkgs "$1"
121 fi
122}
123addEnvHooks "$targetOffset" ecmHostPathHook