From patchwork Thu Nov 13 23:03:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Naour X-Patchwork-Id: 410640 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ozlabs.org (Postfix) with ESMTP id B34391400E2 for ; Fri, 14 Nov 2014 10:03:48 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 42B2FA3686; Thu, 13 Nov 2014 23:03:46 +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 g6DsSd0kzB5X; Thu, 13 Nov 2014 23:03:44 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 06569A3673; Thu, 13 Nov 2014 23:03:42 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 0E4661CEDA9 for ; Thu, 13 Nov 2014 23:03:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 07EEF33CAD for ; Thu, 13 Nov 2014 23:03:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id c7vJ34EwiDQX for ; Thu, 13 Nov 2014 23:03:34 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from smtp5-g21.free.fr (smtp5-g21.free.fr [212.27.42.5]) by silver.osuosl.org (Postfix) with ESMTPS id 6568A32E2D for ; Thu, 13 Nov 2014 23:03:34 +0000 (UTC) Received: from localhost.localdomain (unknown [81.57.22.125]) by smtp5-g21.free.fr (Postfix) with ESMTP id C6E87D48028; Fri, 14 Nov 2014 00:03:23 +0100 (CET) From: Romain Naour To: buildroot@buildroot.org Date: Fri, 14 Nov 2014 00:03:25 +0100 Message-Id: <1415919806-13005-3-git-send-email-romain.naour@openwide.fr> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1415919806-13005-1-git-send-email-romain.naour@openwide.fr> References: <1415919806-13005-1-git-send-email-romain.naour@openwide.fr> Cc: thomas.petazzoni@free-electrons.com, yann.morin.1998@free.fr Subject: [Buildroot] [PATCH v3 2/3] toolchain-helpers: factorise the arch sysroot symlink creation 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" The part of copy_toolchain_sysroot function that create the symlink in the staging directory will be used in two different place in the following patch. So factorize this part in a new function called toolchain_create_arch_sysroot_symlink. Signed-off-by: Romain Naour --- v3: no change v2: new patch --- toolchain/helpers.mk | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk index 3121da4..7d7af5f 100644 --- a/toolchain/helpers.mk +++ b/toolchain/helpers.mk @@ -83,6 +83,20 @@ copy_toolchain_lib_root = \ \ echo -n +# Calculate the symlink's depth by counting the number of slashs. +# Then create the symlink to arch sysroot. +# $1: arch specific subdirectory in the sysroot +toolchain_create_arch_sysroot_symlink = \ + ARCH_SUBDIR="$(strip $1)"; \ + mkdir -p `dirname $(STAGING_DIR)/$${ARCH_SUBDIR}` ; \ + relpath="./" ; \ + nbslashs=`echo -n $${ARCH_SUBDIR} | sed 's%[^/]%%g' | wc -c` ; \ + for slash in `seq 1 $${nbslashs}` ; do \ + relpath=$${relpath}"../" ; \ + done ; \ + ln -s $${relpath} $(STAGING_DIR)/$${ARCH_SUBDIR} ; \ + echo "Symlinking $(STAGING_DIR)/$${ARCH_SUBDIR} -> $${relpath}" + # # Copy the full external toolchain sysroot directory to the staging # dir. The operation of this function is rendered a little bit @@ -148,14 +162,7 @@ copy_toolchain_sysroot = \ if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \ cp -a $${SYSROOT_DIR}/usr/include $(STAGING_DIR)/usr ; \ fi ; \ - mkdir -p `dirname $(STAGING_DIR)/$${ARCH_SUBDIR}` ; \ - relpath="./" ; \ - nbslashs=`echo -n $${ARCH_SUBDIR} | sed 's%[^/]%%g' | wc -c` ; \ - for slash in `seq 1 $${nbslashs}` ; do \ - relpath=$${relpath}"../" ; \ - done ; \ - ln -s $${relpath} $(STAGING_DIR)/$${ARCH_SUBDIR} ; \ - echo "Symlinking $(STAGING_DIR)/$${ARCH_SUBDIR} -> $${relpath}" ; \ + $(call toolchain_create_arch_sysroot_symlink,$${ARCH_SUBDIR}) ; \ fi ; \ if test -n "$${SUPPORT_LIB_DIR}" ; then \ cp -a $${SUPPORT_LIB_DIR}/* $(STAGING_DIR)/lib/ ; \