2015-12-19 23:20:27 +01:00
|
|
|
if [[ -z "$QMAKE" ]]; then
|
|
|
|
|
2016-01-23 22:55:21 +01:00
|
|
|
_qtLinkDependencyDir() {
|
2015-12-19 23:20:27 +01:00
|
|
|
@lndir@/bin/lndir -silent "$1/$2" "$qtOut/$2"
|
|
|
|
if [[ -n "$NIX_QT_SUBMODULE" ]]; then
|
|
|
|
find "$1/$2" -printf "$2/%P\n" >> "$out/nix-support/qt-inputs"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-01-23 22:55:21 +01:00
|
|
|
_qtLinkModule() {
|
|
|
|
if [ -d "$1/mkspecs" ]; then
|
2015-12-19 23:20:27 +01:00
|
|
|
# $1 is a Qt module
|
2016-01-23 22:55:21 +01:00
|
|
|
_qtLinkDependencyDir "$1" mkspecs
|
2015-12-19 23:20:27 +01:00
|
|
|
|
|
|
|
for dir in bin include lib share; do
|
2016-01-23 22:55:21 +01:00
|
|
|
if [ -d "$1/$dir" ]; then
|
|
|
|
_qtLinkDependencyDir "$1" "$dir"
|
2015-12-19 23:20:27 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-01-23 22:55:21 +01:00
|
|
|
_qtRmModules() {
|
2015-12-19 23:20:27 +01:00
|
|
|
cat "$out/nix-support/qt-inputs" | while read file; do
|
|
|
|
if [[ -h "$out/$file" ]]; then
|
|
|
|
rm "$out/$file"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
cat "$out/nix-support/qt-inputs" | while read file; do
|
|
|
|
if [[ -d "$out/$file" ]]; then
|
|
|
|
rmdir --ignore-fail-on-non-empty -p "$out/$file"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
rm "$out/nix-support/qt-inputs"
|
|
|
|
}
|
|
|
|
|
2016-01-23 22:55:21 +01:00
|
|
|
addToSearchPathOnceWithCustomDelimiter() {
|
|
|
|
local delim="$1"
|
|
|
|
local search="$2"
|
|
|
|
local target="$3"
|
|
|
|
local dirs
|
|
|
|
local exported
|
|
|
|
IFS="$delim" read -a dirs <<< "${!search}"
|
|
|
|
for dir in ${dirs[@]}; do
|
|
|
|
if [ "z$dir" == "z$target" ]; then exported=1; fi
|
|
|
|
done
|
|
|
|
if [ -z $exported ]; then
|
|
|
|
eval "export ${search}=\"${!search}${!search:+$delim}$target\""
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
addToSearchPathOnce() {
|
|
|
|
addToSearchPathOnceWithCustomDelimiter ':' "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
propagateOnce() {
|
|
|
|
addToSearchPathOnceWithCustomDelimiter ' ' "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
_qtPropagateRuntimeDependencies() {
|
|
|
|
for dir in "lib/qt5/plugins" "lib/qt5/qml" "lib/qt5/imports"; do
|
|
|
|
if [ -d "$1/$dir" ]; then
|
|
|
|
propagateOnce propagatedBuildInputs "$1"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
addToSearchPathOnce QT_PLUGIN_PATH "$1/lib/qt5/plugins"
|
|
|
|
addToSearchPathOnce QML_IMPORT_PATH "$1/lib/qt5/imports"
|
|
|
|
addToSearchPathOnce QML2_IMPORT_PATH "$1/lib/qt5/qml"
|
|
|
|
}
|
|
|
|
|
|
|
|
_qtRmQmake() {
|
2015-12-19 23:20:27 +01:00
|
|
|
rm "$qtOut/bin/qmake" "$qtOut/bin/qt.conf"
|
|
|
|
}
|
|
|
|
|
2016-01-23 22:55:21 +01:00
|
|
|
_qtSetQmakePath() {
|
2015-12-19 23:20:27 +01:00
|
|
|
export PATH="$qtOut/bin${PATH:+:}$PATH"
|
|
|
|
}
|
|
|
|
|
2016-01-23 22:55:21 +01:00
|
|
|
_qtMultioutModuleDevs() {
|
|
|
|
# We cannot simply set these paths in configureFlags because libQtCore retains
|
|
|
|
# references to the paths it was built with.
|
|
|
|
moveToOutput "bin" "${!outputDev}"
|
|
|
|
moveToOutput "include" "${!outputDev}"
|
|
|
|
|
|
|
|
# The destination directory must exist or moveToOutput will do nothing
|
|
|
|
mkdir -p "${!outputDev}/share"
|
|
|
|
moveToOutput "share/doc" "${!outputDev}"
|
|
|
|
}
|
|
|
|
|
|
|
|
_qtMultioutDevs() {
|
|
|
|
# This is necessary whether the package is a Qt module or not
|
|
|
|
moveToOutput "mkspecs" "${!outputDev}"
|
|
|
|
}
|
|
|
|
|
2015-12-19 23:20:27 +01:00
|
|
|
qtOut=""
|
|
|
|
if [[ -z "$NIX_QT_SUBMODULE" ]]; then
|
|
|
|
qtOut=`mktemp -d`
|
|
|
|
else
|
|
|
|
qtOut=$out
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p "$qtOut/bin" "$qtOut/mkspecs" "$qtOut/include" "$qtOut/nix-support" "$qtOut/lib" "$qtOut/share"
|
|
|
|
|
2016-01-23 22:55:21 +01:00
|
|
|
cp "@dev@/bin/qmake" "$qtOut/bin"
|
2015-12-19 23:20:27 +01:00
|
|
|
cat >"$qtOut/bin/qt.conf" <<EOF
|
|
|
|
[Paths]
|
|
|
|
Prefix = $qtOut
|
|
|
|
Plugins = lib/qt5/plugins
|
|
|
|
Imports = lib/qt5/imports
|
|
|
|
Qml2Imports = lib/qt5/qml
|
|
|
|
Documentation = share/doc/qt5
|
|
|
|
EOF
|
|
|
|
|
|
|
|
export QMAKE="$qtOut/bin/qmake"
|
|
|
|
|
2016-01-23 22:55:21 +01:00
|
|
|
envHooks+=(_qtLinkModule _qtPropagateRuntimeDependencies)
|
|
|
|
# Set PATH to find qmake first in a preConfigure hook
|
|
|
|
# It must run after all the envHooks!
|
|
|
|
preConfigureHooks+=(_qtSetQmakePath)
|
2015-12-19 23:20:27 +01:00
|
|
|
|
2016-01-23 22:55:21 +01:00
|
|
|
preFixupHooks+=(_qtMultioutDevs)
|
2015-12-19 23:20:27 +01:00
|
|
|
if [[ -n "$NIX_QT_SUBMODULE" ]]; then
|
2016-01-23 22:55:21 +01:00
|
|
|
postInstallHooks+=(_qtRmQmake _qtRmModules)
|
|
|
|
preFixupHooks+=(_qtMultioutModuleDevs)
|
2015-12-19 23:20:27 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "$NIX_QT_PIC" ]]; then
|
2016-01-23 22:55:21 +01:00
|
|
|
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE${NIX_CFLAGS_COMPILE:+ }-fPIC"
|
2015-12-19 23:20:27 +01:00
|
|
|
export NIX_QT_PIC=1
|
|
|
|
fi
|