From patchwork Wed Feb 28 18:02:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 10249179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B4D5B60594 for ; Wed, 28 Feb 2018 18:03:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AEAD4205AD for ; Wed, 28 Feb 2018 18:03:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A30C328DB1; Wed, 28 Feb 2018 18:03:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 60D7C28DAA for ; Wed, 28 Feb 2018 18:03:33 +0000 (UTC) Received: from localhost ([::1]:45925 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er64i-0002fQ-8i for patchwork-qemu-devel@patchwork.kernel.org; Wed, 28 Feb 2018 13:03:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er63k-0001s2-Jd for qemu-devel@nongnu.org; Wed, 28 Feb 2018 13:02:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1er63j-00026M-3v for qemu-devel@nongnu.org; Wed, 28 Feb 2018 13:02:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38472) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1er63i-000260-RE for qemu-devel@nongnu.org; Wed, 28 Feb 2018 13:02:31 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF9B17FEB5; Wed, 28 Feb 2018 18:02:29 +0000 (UTC) Received: from weilaptop.redhat.com (ovpn-120-96.rdu2.redhat.com [10.10.120.96]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C4B25D6A3; Wed, 28 Feb 2018 18:02:25 +0000 (UTC) From: Wei Huang To: qemu-devel@nongnu.org Date: Wed, 28 Feb 2018 12:02:12 -0600 Message-Id: <20180228180215.25470-2-wei@redhat.com> In-Reply-To: <20180228180215.25470-1-wei@redhat.com> References: <20180228180215.25470-1-wei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 28 Feb 2018 18:02:29 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH V7 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 := 1000 pxe-rom-vmxnet3 efi-rom-vmxnet3 : VID := 15ad pxe-rom-vmxnet3 efi-rom-vmxnet3 : DID := 07b0 -# -# cross compiler auto detection -# -path := $(subst :, ,$(PATH)) -system := $(shell uname -s | tr "A-Z" "a-z") - -# first find cross binutils in path -find-cross-ld = $(firstword $(wildcard $(patsubst %,%/$(1)-*$(system)*-ld,$(path)))) -# then check we have cross gcc too -find-cross-gcc = $(firstword $(wildcard $(patsubst %ld,%gcc,$(call find-cross-ld,$(1))))) -# finally strip off path + toolname so we get the prefix -find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1)))) - -powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64) -powerpc_cross_prefix := $(call find-cross-prefix,powerpc) -x86_64_cross_prefix := $(call find-cross-prefix,x86_64) - # tag our seabios builds SEABIOS_EXTRAVERSION="-prebuilt.qemu-project.org" @@ -66,6 +49,13 @@ default: @echo " skiboot -- update skiboot.lid" @echo " u-boot.e500 -- update u-boot.e500" +SRC_PATH=.. +include $(SRC_PATH)/rules.mak + +powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64) +powerpc_cross_prefix := $(call find-cross-prefix,powerpc) +x86_64_cross_prefix := $(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 = $(strip $(sort $(filter %.o,$1)) \ $(foreach o,$(filter %.mo,$1),$($o-objs)) \ $(filter-out %.o %.mo,$1)) +# 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 := $(call find-cross-prefix,x86_64) +# $(x86_64_cross_prefix)gcc -c test.c -o test.o +# make -C testdir CROSS_COMPILE=$(x86_64_cross_prefix) +cross-search-path := $(subst :, ,$(PATH)) +cross-host-system := $(shell uname -s | tr "A-Z" "a-z") + +find-cross-ld = $(firstword $(wildcard $(patsubst \ + %,%/$(1)-*$(cross-host-system)*-ld,$(cross-search-path)))) +find-cross-gcc = $(firstword $(wildcard \ + $(patsubst %ld,%gcc,$(call find-cross-ld,$(1))))) +find-cross-prefix = $(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) \