diff mbox series

[1/3] package/pkg-generic.mk: fix absolute paths in .pc files for per-package builds

Message ID 20220103230249.310062-2-aduskett@gmail.com
State Rejected, archived
Headers show
Series QT5: Fix per-package builds with non-qt5base packages | expand

Commit Message

Adam Duskett Jan. 3, 2022, 11:02 p.m. UTC
Some packages (notably qmake packages) generate .pc files with absolute paths.
Unfortunately, doing so breaks per-package builds because the paths in the .pc
file point outside the per-package sysroot.

Add the new pre-configure-hook "FIXUP_PC_FILES_ABSOLUTE_PATHS" in
package/pkg-generic.mk which searches for all .pc files in a per-package
staging directory and removes the $(STAGING_DIR)/ prefix in them.
This simple fix allows non-qt5base qt5 packages to build with per-package
enabled.

Based off of Louis-Paul's earlier work found here:
https://lore.kernel.org/buildroot/a339f273-33f3-f232-eac4-6e50427abf6d@cordier.org/

And Yann Morin's feedback found here:
https://patchwork.ozlabs.org/project/buildroot/patch/20200217212350.29750-21-anaumann@ultratronik.de/

Signed-off-by: Adam Duskett <aduskett@gmail.com>
---
 package/pkg-generic.mk | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 5626af1d87..94104cbfa9 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -103,6 +103,17 @@  define fixup-libtool-files
 endef
 endif
 
+# When per-package is enabled, packages may generate .pc files with absolute
+# paths for the prefix field. Remove the absolute paths from the generated .pc
+# files to keep per-package isolation with the build sysroot.
+ifeq ($(BR2_PER_PACKAGE_DIRECTORIES),y)
+define FIXUP_PC_FILES_ABSOLUTE_PATHS
+	$(Q)find $(STAGING_DIR)/ -name "*.pc" | xargs --no-run-if-empty \
+		$(SED) "s:$(STAGING_DIR)::g"
+endef
+$(2)_PRE_CONFIGURE_HOOKS += FIXUP_PC_ABSOLUTE_PATHS
+endif
+
 # Make sure python _sysconfigdata*.py files only reference the current
 # per-package directory.
 #