From nobody Fri Oct 24 09:53:14 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519423260995353.9643635645406; Fri, 23 Feb 2018 14:01:00 -0800 (PST) Received: from localhost ([::1]:47299 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epLOj-0002Zm-L2 for importer@patchew.org; Fri, 23 Feb 2018 17:00:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epLN5-0001Zy-AG for qemu-devel@nongnu.org; Fri, 23 Feb 2018 16:59:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1epLN2-0007YC-6M for qemu-devel@nongnu.org; Fri, 23 Feb 2018 16:59:15 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47796 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1epLN2-0007Wv-1Y for qemu-devel@nongnu.org; Fri, 23 Feb 2018 16:59:12 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DDEFE40FB646; Fri, 23 Feb 2018 21:59:05 +0000 (UTC) Received: from weilaptop.redhat.com (ovpn-125-241.rdu2.redhat.com [10.10.125.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83363213AEED; Fri, 23 Feb 2018 21:59:03 +0000 (UTC) From: Wei Huang To: qemu-devel@nongnu.org Date: Fri, 23 Feb 2018 15:58:55 -0600 Message-Id: <20180223215858.16987-2-wei@redhat.com> In-Reply-To: <20180223215858.16987-1-wei@redhat.com> References: <20180223215858.16987-1-wei@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Fri, 23 Feb 2018 21:59:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Fri, 23 Feb 2018 21:59:05 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'wei@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH V5 1/4] rules: Move cross compilation auto detection functions to rules.mak X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, drjones@redhat.com, dgilbert@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch moves the auto detection functions for cross compilation from roms/Makefile to rules.mak. So the functions can be shared among Makefiles in QEMU. Signed-off-by: Wei Huang Reviewed-by: Andrew Jones --- roms/Makefile | 24 +++++++----------------- rules.mak | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/roms/Makefile b/roms/Makefile index b5e5a69e91..e972c65333 100644 --- a/roms/Makefile +++ b/roms/Makefile @@ -21,23 +21,6 @@ pxe-rom-virtio efi-rom-virtio : DID :=3D 1000 pxe-rom-vmxnet3 efi-rom-vmxnet3 : VID :=3D 15ad pxe-rom-vmxnet3 efi-rom-vmxnet3 : DID :=3D 07b0 =20 -# -# cross compiler auto detection -# -path :=3D $(subst :, ,$(PATH)) -system :=3D $(shell uname -s | tr "A-Z" "a-z") - -# first find cross binutils in path -find-cross-ld =3D $(firstword $(wildcard $(patsubst %,%/$(1)-*$(system)*-l= d,$(path)))) -# then check we have cross gcc too -find-cross-gcc =3D $(firstword $(wildcard $(patsubst %ld,%gcc,$(call find-= cross-ld,$(1))))) -# finally strip off path + toolname so we get the prefix -find-cross-prefix =3D $(subst gcc,,$(notdir $(call find-cross-gcc,$(1)))) - -powerpc64_cross_prefix :=3D $(call find-cross-prefix,powerpc64) -powerpc_cross_prefix :=3D $(call find-cross-prefix,powerpc) -x86_64_cross_prefix :=3D $(call find-cross-prefix,x86_64) - # tag our seabios builds SEABIOS_EXTRAVERSION=3D"-prebuilt.qemu-project.org" =20 @@ -66,6 +49,13 @@ default: @echo " skiboot -- update skiboot.lid" @echo " u-boot.e500 -- update u-boot.e500" =20 +SRC_PATH=3D.. +include $(SRC_PATH)/rules.mak + +powerpc64_cross_prefix :=3D $(call find-cross-prefix,powerpc64) +powerpc_cross_prefix :=3D $(call find-cross-prefix,powerpc) +x86_64_cross_prefix :=3D $(call find-cross-prefix,x86_64) + bios: build-seabios-config-seabios-128k build-seabios-config-seabios-256k cp seabios/builds/seabios-128k/bios.bin ../pc-bios/bios.bin cp seabios/builds/seabios-256k/bios.bin ../pc-bios/bios-256k.bin diff --git a/rules.mak b/rules.mak index 6e943335f3..ef8adee3f8 100644 --- a/rules.mak +++ b/rules.mak @@ -62,6 +62,21 @@ expand-objs =3D $(strip $(sort $(filter %.o,$1)) \ $(foreach o,$(filter %.mo,$1),$($o-objs)) \ $(filter-out %.o %.mo,$1)) =20 +# Cross compilation auto detection. Use find-cross-prefix to detect the +# target archtecture's prefix, and then append it to the build tool or pass +# it to CROSS_COMPILE directly. Here is one example: +# x86_64_cross_prefix :=3D $(call find-cross-prefix,x86_64) +# $(x86_64_cross_prefix)gcc -c test.c -o test.o +# make -C testdir CROSS_COMPILE=3D$(x86_64_cross_prefix) +cross-search-path :=3D $(subst :, ,$(PATH)) +cross-host-system :=3D $(shell uname -s | tr "A-Z" "a-z") + +find-cross-ld =3D $(firstword $(wildcard $(patsubst \ + %,%/$(1)-*$(cross-host-system)*-ld,$(cross-search-path= )))) +find-cross-gcc =3D $(firstword $(wildcard \ + $(patsubst %ld,%gcc,$(call find-cross-ld,$(1))))) +find-cross-prefix =3D $(subst gcc,,$(notdir $(call find-cross-gcc,$(1)))) + %.o: %.c $(call quiet-command,$(CC) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \ $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) \ --=20 2.14.3