package/pkg-generic: ensure absolute paths in config-script fixups
authorYann E. MORIN <yann.morin.1998@free.fr>
Wed, 28 Nov 2018 20:44:04 +0000 (21:44 +0100)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Thu, 29 Nov 2018 22:00:26 +0000 (23:00 +0100)
In case a config script is called from a relative path, the $(dirname
$0) would return a relative path too.

Those paths are usually parts of includes or libraries search
directories, and the packagfes buildsystems may chdir() anywhere, and
thus the relative path will no longer be valid. For example:

  $ ./host/powerpc-buildroot-linux-uclibc/sysroot/usr/bin/net-snmp-config --cflags
  [...] -I./host/powerpc-buildroot-linux-uclibc/sysroot/usr/bin/../../.././bin/../powerpc-buildroot-linux-uclibc/sysroot/usr/include/libnl3 [...]

Canonicalise the path to be sure we use absolute paths.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/pkg-generic.mk

index 887dc838a4a0dd74d7d7c8820f00b3fd17af05ec..649a7ad187e2c7d376fceae65627792113685df4 100644 (file)
@@ -280,8 +280,8 @@ $(BUILD_DIR)/%/.stamp_staging_installed:
                                -e "s,^\(exec_\)\?prefix=.*,\1prefix=@STAGING_DIR@/usr,g" \
                                -e "s,-I/usr/,-I@STAGING_DIR@/usr/,g" \
                                -e "s,-L/usr/,-L@STAGING_DIR@/usr/,g" \
-                               -e 's,@STAGING_DIR@,$$(dirname $$0)/../..,g' \
-                               -e 's,@HOST_DIR@,$$(dirname $$0)/../../../..,g' \
+                               -e 's,@STAGING_DIR@,$$(dirname $$(realpath -e $$0))/../..,g' \
+                               -e 's,@HOST_DIR@,$$(dirname $$(realpath -e $$0))/../../../..,g' \
                                -e "s,@BASE_DIR@,$(BASE_DIR),g" \
                                $(addprefix $(STAGING_DIR)/usr/bin/,$($(PKG)_CONFIG_SCRIPTS)) ;\
        fi