···1+# Fix libtool libraries generated by qmake.
2+# qmake started inserting filenames of shared objects instead of the appropriate
3+# linker flags. fixQmakeLibtool searches for broken libtool libraries and
4+# replaces the filenames with the linker flags that should have been there.
5+fixQmakeLibtool() {
6+ if [ -d "$1" ]; then
7+ find "$1" -name '*.la' | while read la; do
8+ set +e
9+ framework_libs=$(grep '^dependency_libs' "$la" | grep -Eo -- '-framework +\w+' | tr '\n' ' ')
10+ set -e
11+ sed -i "$la" \
12+ -e '/^dependency_libs/ s,\(/[^ ]\+\)/lib\([^/ ]\+\)\.so,-L\1 -l\2,g' \
13+ -e '/^dependency_libs/ s,-framework \+\w\+,,g'
14+ if [ ! -z "$framework_libs" ]; then
15+ if grep '^inherited_linker_flags=' $la >/dev/null; then
16+ sed -i "$la" -e "s/^\(inherited_linker_flags='[^']*\)/\1 $framework_libs/"
17+ else
18+ echo "inherited_linker_flags='$framework_libs'" >>"$la"
19+ fi
20+ fi
21+ done
22+ fi
23+}
24+25+fixupOutputHooks+=('fixQmakeLibtool $prefix')
···1+updateToolPath() {
2+ local tool="$1"
3+ local target="$2"
4+ local original="${!outputBin}/$tool"
5+ local actual="${!outputDev}/$tool"
6+ if grep -q "$original" "$target"; then
7+ echo "updateToolPath: Updating \`$original' in \`$target\'..."
8+ sed -i "$target" -e "s|$original|$actual|"
9+ fi
10+}
11+12+moveQtDevTools() {
13+ if [ -n "$devTools" ]; then
14+ for tool in $devTools; do
15+ moveToOutput "$tool" "${!outputDev}"
16+ done
17+18+ if [ -d "${!outputDev}/mkspecs" ]; then
19+ find "${!outputDev}/mkspecs" -name '*.pr?' | while read pr_; do
20+ for tool in $devTools; do
21+ updateToolPath "$tool" "$pr_"
22+ done
23+ done
24+ fi
25+26+ if [ -d "${!outputDev}/lib/cmake" ]; then
27+ find "${!outputDev}/lib/cmake" -name '*.cmake' | while read cmake; do
28+ for tool in $devTools; do
29+ updateToolPath "$tool" "$cmake"
30+ done
31+ done
32+ fi
33+ fi
34+}
···7 exit 1
8 fi
9else # Only set up Qt once.
10-__nix_qtbase="@dev@"
1112-qtPluginPrefix=@qtPluginPrefix@
13-qtQmlPrefix=@qtQmlPrefix@
1415-# Disable debug symbols if qtbase was built without debugging.
16-# This stops -dev paths from leaking into other outputs.
17-if [ -z "@debug@" ]; then
18- NIX_CFLAGS_COMPILE="${NIX_CFLAGS_COMPILE-}${NIX_CFLAGS_COMPILE:+ }-DQT_NO_DEBUG"
19-fi
2021-# Integration with CMake:
22-# Set the CMake build type corresponding to how qtbase was built.
23-if [ -n "@debug@" ]; then
24- cmakeBuildType="Debug"
25-else
26- cmakeBuildType="Release"
27-fi
2829-qtPreHook() {
30- # Check that wrapQtAppsHook is used, or it is explicitly disabled.
31- if [[ -z "$__nix_wrapQtAppsHook" && -z "$dontWrapQtApps" ]]; then
32- echo >&2 "Error: wrapQtAppsHook is not used, and dontWrapQtApps is not set."
33- exit 1
034 fi
35-}
36-prePhases+=" qtPreHook"
03738-addQtModulePrefix () {
39- addToSearchPath QT_ADDITIONAL_PACKAGES_PREFIX_PATH $1
40-}
41-addEnvHooks "$hostOffset" addQtModulePrefix
000000000000000000000000000000000000000000000000000004243fi
···7 exit 1
8 fi
9else # Only set up Qt once.
10+ __nix_qtbase="@dev@"
1112+ qtPluginPrefix=@qtPluginPrefix@
13+ qtQmlPrefix=@qtQmlPrefix@
1415+ . @fix_qt_builtin_paths@
16+ . @fix_qt_module_paths@
0001718+ # Disable debug symbols if qtbase was built without debugging.
19+ # This stops -dev paths from leaking into other outputs.
20+ if [ -z "@debug@" ]; then
21+ NIX_CFLAGS_COMPILE="${NIX_CFLAGS_COMPILE-}${NIX_CFLAGS_COMPILE:+ }-DQT_NO_DEBUG"
22+ fi
002324+ # Integration with CMake:
25+ # Set the CMake build type corresponding to how qtbase was built.
26+ if [ -n "@debug@" ]; then
27+ cmakeBuildType="Debug"
28+ else
29+ cmakeBuildType="Release"
30 fi
31+32+ # Build tools are often confused if QMAKE is unset.
33+ export QMAKE=@dev@/bin/qmake
3435+ export QMAKEPATH=
36+37+ export QMAKEMODULES=
38+39+ declare -Ag qmakePathSeen=()
40+ qmakePathHook() {
41+ # Skip this path if we have seen it before.
42+ # MUST use 'if' because 'qmakePathSeen[$]' may be unset.
43+ if [ -n "${qmakePathSeen[$1]-}" ]; then return; fi
44+ qmakePathSeen[$1]=1
45+ if [ -d "$1/mkspecs" ]; then
46+ QMAKEMODULES="${QMAKEMODULES}${QMAKEMODULES:+:}/mkspecs"
47+ QMAKEPATH="${QMAKEPATH}${QMAKEPATH:+:}$1"
48+ fi
49+ }
50+ envBuildHostHooks+=(qmakePathHook)
51+52+ postPatchMkspecs() {
53+ # Prevent this hook from running multiple times
54+ dontPatchMkspecs=1
55+56+ local bin="${!outputBin}"
57+ local dev="${!outputDev}"
58+ local doc="${!outputDoc}"
59+ local lib="${!outputLib}"
60+61+ moveToOutput "mkspecs" "$dev"
62+63+ if [ -d "$dev/mkspecs/modules" ]; then
64+ fixQtModulePaths "$dev/mkspecs/modules"
65+ fi
66+67+ if [ -d "$dev/mkspecs" ]; then
68+ fixQtBuiltinPaths "$dev/mkspecs" '*.pr?'
69+ fi
70+71+ if [ -d "$lib" ]; then
72+ fixQtBuiltinPaths "$lib" '*.pr?'
73+ fi
74+ }
75+ if [ -z "${dontPatchMkspecs-}" ]; then
76+ postPhases="${postPhases-}${postPhases:+ }postPatchMkspecs"
77+ fi
78+79+ qtPreHook() {
80+ # Check that wrapQtAppsHook is used, or it is explicitly disabled.
81+ if [[ -z "$__nix_wrapQtAppsHook" && -z "$dontWrapQtApps" ]]; then
82+ echo >&2 "Error: wrapQtAppsHook is not used, and dontWrapQtApps is not set."
83+ exit 1
84+ fi
85+ }
86+ prePhases+=" qtPreHook"
87+88+ addQtModulePrefix() {
89+ addToSearchPath QT_ADDITIONAL_PACKAGES_PREFIX_PATH $1
90+ }
91+ addEnvHooks "$hostOffset" addQtModulePrefix
9293fi
···18 perl
19 cmake
20 ninja
021 ];
22 propagatedBuildInputs = args.qtInputs ++ (args.propagatedBuildInputs or [ ]);
000002324 outputs = args.outputs or [ "out" "dev" ];
25···32 moveToOutput "$dir" "$dev"
33 done
34 fi
035 ${args.postInstall or ""}
36 '';
0000000000000000000000000000000000003738 meta = with lib; {
39 homepage = "https://www.qt.io/";
···18 perl
19 cmake
20 ninja
21+ self.qmake
22 ];
23 propagatedBuildInputs = args.qtInputs ++ (args.propagatedBuildInputs or [ ]);
24+25+ preHook = ''
26+ . ${./hooks/move-qt-dev-tools.sh}
27+ . ${./hooks/fix-qt-builtin-paths.sh}
28+ '';
2930 outputs = args.outputs or [ "out" "dev" ];
31···38 moveToOutput "$dir" "$dev"
39 done
40 fi
41+ fixQtBuiltinPaths $out/lib "*.pr?"
42 ${args.postInstall or ""}
43 '';
44+45+ preConfigure = args.preConfigure or "" + ''
46+ fixQtBuiltinPaths . '*.pr?'
47+ '' + lib.optionalString (builtins.compareVersions "5.15.0" version <= 0)
48+ # Note: We use ${version%%-*} to remove any tag from the end of the version
49+ # string. Version tags are added by Nixpkgs maintainers and not reflected in
50+ # the source version.
51+ ''
52+ if [[ -z "$dontCheckQtModuleVersion" ]] \
53+ && grep -q '^MODULE_VERSION' .qmake.conf 2>/dev/null \
54+ && ! grep -q -F "''${version%%-*}" .qmake.conf 2>/dev/null
55+ then
56+ echo >&2 "error: could not find version ''${version%%-*} in .qmake.conf"
57+ echo >&2 "hint: check .qmake.conf and update the package version in Nixpkgs"
58+ exit 1
59+ fi
60+61+ if [[ -z "$dontSyncQt" && -f sync.profile ]]; then
62+ # FIXME: this probably breaks crosscompiling as it's not from nativeBuildInputs
63+ # I don't know how to get /libexec from nativeBuildInputs to work, it's not under /bin
64+ ${self.qtbase.dev.nativeDrv or self.qtbase.dev}/libexec/syncqt.pl -version "''${version%%-*}"
65+ fi
66+ '';
67+68+ postFixup = ''
69+ if [ -d "''${!outputDev}/lib/pkgconfig" ]; then
70+ find "''${!outputDev}/lib/pkgconfig" -name '*.pc' | while read pc; do
71+ sed -i "$pc" \
72+ -e "/^prefix=/ c prefix=''${!outputLib}" \
73+ -e "/^exec_prefix=/ c exec_prefix=''${!outputBin}" \
74+ -e "/^includedir=/ c includedir=''${!outputDev}/include"
75+ done
76+ fi
77+78+ moveQtDevTools
79+ '' + args.postFixup or "";
8081 meta = with lib; {
82 homepage = "https://www.qt.io/";