From patchwork Tue Jan 31 16:03:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas De Schampheleire X-Patchwork-Id: 722041 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vCWKZ3ftrz9sCG for ; Wed, 1 Feb 2017 03:04:18 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dGHKOGR/"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id A5EFB8B78A; Tue, 31 Jan 2017 16:04:16 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ozoAt52l47fx; Tue, 31 Jan 2017 16:04:14 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id B90CC8B738; Tue, 31 Jan 2017 16:04:10 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id A23DD1C072D for ; Tue, 31 Jan 2017 16:04:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 9C6D78AD4A for ; Tue, 31 Jan 2017 16:04:02 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jc4FdVTMC8Ud for ; Tue, 31 Jan 2017 16:04:02 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by hemlock.osuosl.org (Postfix) with ESMTPS id 054648AD44 for ; Tue, 31 Jan 2017 16:04:02 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id c85so84756929wmi.1 for ; Tue, 31 Jan 2017 08:04:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U9hCzAJvrc6Dp5sYuZYyBcRa7wAl0Hsf6/MmdXZpk6U=; b=dGHKOGR/M2iaQT5l6l4g932mMmW9yKy0pk1KwCCnLB0V8yz6Bz12h9SQseD6eDzm2V DshVPTmHrUAqxTFCCtop5fg4sjV2weprcEDdVxbhVqCCvUqXG7//CIEUb5qSIM9qc0Ip BrrZiG1+rwA+LDEazgBu8CnKuZW5BEP0wx8NrmGp8OuMU7aKYIvV1zJEneHOAuddgUxl 04eG2R3ZQO1NUvizPYNCv1qgAPCtLOM6dBThxKAPEwhRajxi/z81baxSXbAZv5MocdVX lejmB4Dr/cl3xHmM0phG+a042XUUm9BVRAbw0q6KQLscxDmvRXURVMBMMpBK6uV8WYEO oTag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U9hCzAJvrc6Dp5sYuZYyBcRa7wAl0Hsf6/MmdXZpk6U=; b=adiT5whxWbb1DtsvsmNy07mRHjACPgzHi9FDXjCDP5PiGNG8tc5dSQ4wryNvF/debS wQtkIXyaZUZ/f74ltlFOI85ZVNtN12VKAR24yeeUfOFSWDrVV1HLykX1J9nFaxsGxlJg CVeQxK0J21rqU0XbRrCc32OD+T2HtSyHon3eNBBrvPZX3FfwJHE842d4cptnl/hxzGZC r+BNs+i5Zh+7irA2v1MyUZmV0MVahCCYgHogCHzrsCaX+/6NimOcxGp3wzIuw7pZuSac NAHWCloQ3GooF4aIO621cashb0HuDJU5jH7m/XmhxHM93ZKy3PdBA+6WaS6r19hRj7fJ t8cg== X-Gm-Message-State: AIkVDXIC5T93RzcrxPiqa0r3ILZxuD7J5OM/LifzQACxQcRn7dNwrwaXHQtXO2vC3w1shw== X-Received: by 10.28.66.221 with SMTP id k90mr11566926wmi.90.1485878640224; Tue, 31 Jan 2017 08:04:00 -0800 (PST) Received: from argentina.be.alcatel-lucent.com ([195.207.101.112]) by smtp.gmail.com with ESMTPSA id w126sm28764704wmw.0.2017.01.31.08.03.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 Jan 2017 08:03:59 -0800 (PST) From: Thomas De Schampheleire To: buildroot@buildroot.org Date: Tue, 31 Jan 2017 17:03:41 +0100 Message-Id: <20170131160343.27144-5-patrickdepinguin@gmail.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170131160343.27144-1-patrickdepinguin@gmail.com> References: <20170131160343.27144-1-patrickdepinguin@gmail.com> Cc: Thomas Petazzoni , Thomas De Schampheleire Subject: [Buildroot] [PATCH 4/6] toolchain helpers: introduce function relpath_prefix X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Thomas De Schampheleire The helper function copy_toolchain_sysroot has some logic to transform a path into a number of '../' components based on the depth of that path. As this same logic will be needed in another place in a subsequent patch, extract it into a separate helper relpath_prefix. Signed-off-by: Thomas De Schampheleire --- toolchain/helpers.mk | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk index 6720629..ba14b38 100644 --- a/toolchain/helpers.mk +++ b/toolchain/helpers.mk @@ -121,11 +121,7 @@ copy_toolchain_sysroot = \ 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 ; \ @@ -424,3 +420,22 @@ check_toolchain_ssp = \ 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