cp -a $${SYSROOT_DIR}/usr/include $(STAGING_DIR)/usr ; \
fi ; \
mkdir -p `dirname $(STAGING_DIR)/$${ARCH_SUBDIR}` ; \
- relpath="./" ; \
- nbslashs=`printf $${ARCH_SUBDIR} | sed 's%[^/]%%g' | wc -c` ; \
- for slash in `seq 1 $${nbslashs}` ; do \
- relpath=$${relpath}"../" ; \
- done ; \
+ relpath="$(call relpath_prefix,$${ARCH_SUBDIR})./" ; \
ln -s $${relpath} $(STAGING_DIR)/$${ARCH_SUBDIR} ; \
echo "Symlinking $(STAGING_DIR)/$${ARCH_SUBDIR} -> $${relpath}" ; \
fi ; \
gen_gdbinit_file = \
mkdir -p $(STAGING_DIR)/usr/share/buildroot/ ; \
echo "set sysroot $(STAGING_DIR)" > $(STAGING_DIR)/usr/share/buildroot/gdbinit
+
+# Given a path, determine the relative prefix (../) needed to return to the
+# root level. Note that the last component is treated as a file component; use a
+# trailing slash to force treating it as a directory. Examples:
+# relpath_prefix(lib32) = ""
+# relpath_prefix(lib32/octeon2) = "../"
+# relpath_prefix(lib32/octeon2/) = "../../"
+#
+# $1: input path
+define relpath_prefix
+$$( \
+ prefix="" ; \
+ nbslashs=`printf $1 | sed 's%[^/]%%g' | wc -c` ; \
+ for slash in `seq 1 $${nbslashs}` ; do \
+ prefix=$${prefix}"../" ; \
+ done ; \
+ printf "$$prefix" ; \
+)
+endef