From nobody Tue Dec 16 08:39:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1597079431; cv=none; d=zohomail.com; s=zohoarc; b=Nz6i0+fbnXz6bIp+rwDUdGUYPksjYqPmCw7hdnan7kmMEbxHk5ouCYPbQdjaGFYLtkyCYUxUnXBysaGIbt4LjHMnE5IRieQ418FcJjC9cLekHQQTcHU+kXL4AxipL+rFYaQDNPCt20vAFu9G2vpJ0AfKWQf/2p2snWFpzNKRHZo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597079431; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7YfJeKoZjmp5EjXaiy91R897KhxVAZLBJndd9VXwKjc=; b=Xykv6Xy0r0Gr31rKLF1IImPpX8xx6xzhP53ldvK0KROKprcocYjxodDlvcJvVFIw6TfzybZ1slFHLOLZq2L1Y9BLmbitibekIsnx7d/IGyHfgbUFMtGNaht+2N7e6KJF6kVQu5aXJK1j3OVI4IVn84ONhmHeew/mntpyZvQxCnE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1597079431075842.7622927888704; Mon, 10 Aug 2020 10:10:31 -0700 (PDT) Received: from localhost ([::1]:60996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5BJd-0006z6-MF for importer@patchew.org; Mon, 10 Aug 2020 13:10:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45008) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5BIc-0005GX-4I for qemu-devel@nongnu.org; Mon, 10 Aug 2020 13:09:26 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:51842 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k5BIa-0002hK-4F for qemu-devel@nongnu.org; Mon, 10 Aug 2020 13:09:25 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-430-48BC0E8RPiKsIaVhCcdCKw-1; Mon, 10 Aug 2020 13:09:19 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 685E0100CCC0 for ; Mon, 10 Aug 2020 17:09:18 +0000 (UTC) Received: from 640k.localdomain.com (unknown [10.36.110.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id A002387D64; Mon, 10 Aug 2020 17:09:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597079363; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7YfJeKoZjmp5EjXaiy91R897KhxVAZLBJndd9VXwKjc=; b=OXtvcmOsDsFn6CLcqy/t3Bp/tJjoaOirOw/L8ZAC6DsQMzLvlganF7HhjMFWvwduhxx98i 0TLPSbmml+4H38yhZx0vbQucCPNg8OG2+nGJOeEUk7Tfje4ExmuQYYlyBz25EsFd157t97 z7u5G8vyAvFG6e6fwxHXFQo7Aoep/ME= X-MC-Unique: 48BC0E8RPiKsIaVhCcdCKw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 002/147] optionrom: simplify Makefile Date: Mon, 10 Aug 2020 19:06:40 +0200 Message-Id: <1597079345-42801-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1597079345-42801-1-git-send-email-pbonzini@redhat.com> References: <1597079345-42801-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/10 11:00:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Marc-Andr=C3=A9 Lureau Make it independent from the rules.mak, and clean up to use pattern rules. Signed-off-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini --- pc-bios/optionrom/Makefile | 67 ++++++++++++++++++++++++++++--------------= ---- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile index e33a24d..51cb6ca 100644 --- a/pc-bios/optionrom/Makefile +++ b/pc-bios/optionrom/Makefile @@ -1,13 +1,16 @@ -all: build-all +CURRENT_MAKEFILE :=3D $(realpath $(word $(words $(MAKEFILE_LIST)),$(MAKEFI= LE_LIST))) +SRC_DIR :=3D $(dir $(CURRENT_MAKEFILE)) +TOPSRC_DIR :=3D $(SRC_DIR)/../.. +VPATH =3D $(SRC_DIR) + +all: multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin # Dummy command so that make thinks it has done something @true =20 include ../../config-host.mak -include $(SRC_PATH)/rules.mak - -$(call set-vpath, $(SRC_PATH)/pc-bios/optionrom) =20 -.PHONY : all clean build-all +quiet-command =3D $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1= , @$1)) +cc-option =3D $(if $(shell $(CC) $1 -S -o /dev/null -xc /dev/null >/dev/nu= ll 2>&1 && echo OK), $1, $2) =20 # Compiling with no optimization creates ROMs that are too large ifeq ($(lastword $(filter -O%, -O0 $(CFLAGS))),-O0) @@ -15,48 +18,60 @@ override CFLAGS +=3D -O2 endif override CFLAGS +=3D -march=3Di486 =20 -# Drop -fstack-protector and the like -QEMU_CFLAGS :=3D $(filter -W%, $(QEMU_CFLAGS)) $(CFLAGS_NOPIE) -ffreestand= ing -QEMU_CFLAGS +=3D $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector) -QEMU_CFLAGS +=3D $(call cc-option, $(QEMU_CFLAGS), -m16) -ifeq ($(filter -m16, $(QEMU_CFLAGS)),) +# Flags for dependency generation +override CPPFLAGS +=3D -MMD -MP -MT $@ -MF $(@D)/$(*F).d + +override CFLAGS +=3D $(filter -W%, $(QEMU_CFLAGS)) +override CFLAGS +=3D $(CFLAGS_NOPIE) -ffreestanding -I$(TOPSRC_DIR)/include +override CFLAGS +=3D $(call cc-option, -fno-stack-protector) +override CFLAGS +=3D $(call cc-option, -m16) + +ifeq ($(filter -m16, $(CFLAGS)),) # Attempt to work around compilers that lack -m16 (GCC <=3D 4.8, clang <= =3D ??) # On GCC we add -fno-toplevel-reorder to keep the order of asm blocks with # respect to the rest of the code. clang does not have -fno-toplevel-reor= der, # but it places all asm blocks at the beginning and we're relying on it for # the option ROM header. So just force clang not to use the integrated # assembler, which doesn't support .code16gcc. -QEMU_CFLAGS +=3D $(call cc-option, $(QEMU_CFLAGS), -fno-toplevel-reorder) -QEMU_CFLAGS +=3D $(call cc-option, $(QEMU_CFLAGS), -no-integrated-as) -QEMU_CFLAGS +=3D -m32 -include $(SRC_PATH)/pc-bios/optionrom/code16gcc.h +override CFLAGS +=3D $(call cc-option, -fno-toplevel-reorder) +override CFLAGS +=3D $(call cc-option, -no-integrated-as) +override CFLAGS +=3D -m32 -include $(SRC_DIR)/code16gcc.h endif =20 -QEMU_INCLUDES +=3D -I$(SRC_PATH) - Wa =3D -Wa, -ASFLAGS +=3D -32 -QEMU_CFLAGS +=3D $(call cc-c-option, $(QEMU_CFLAGS), $(Wa)-32) +override ASFLAGS +=3D -32 +override CFLAGS +=3D $(call cc-option, $(Wa)-32) =20 -build-all: multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.= bin =20 -# suppress auto-removal of intermediate files -.SECONDARY: +LD_I386_EMULATION ?=3D elf_i386 +override LDFLAGS =3D -m $(LD_I386_EMULATION) -T $(SRC_DIR)/flat.lds +override LDFLAGS +=3D $(LDFLAGS_NOPIE) =20 +all: multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin + +pvh.img: pvh.o pvh_main.o =20 %.o: %.S - $(call quiet-command,$(CPP) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) -c -o - $< |= $(AS) $(ASFLAGS) -o $@,"AS","$(TARGET_DIR)$@") + $(call quiet-command,$(CPP) $(CPPFLAGS) -c -o - $< | $(AS) $(ASFLAGS) -o = $@,"AS","$@") =20 -pvh.img: pvh.o pvh_main.o - $(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -m $(LD_I386_EMULATION) -T $(= SRC_PATH)/pc-bios/optionrom/flat.lds -s -o $@ $^,"BUILD","$(TARGET_DIR)$@") +%.o: %.c + $(call quiet-command,$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@,"CC","$@") =20 %.img: %.o - $(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -m $(LD_I386_EMULATION) -T $(= SRC_PATH)/pc-bios/optionrom/flat.lds -s -o $@ $<,"BUILD","$(TARGET_DIR)$@") + $(call quiet-command,$(LD) $(LDFLAGS) -s -o $@ $^,"BUILD","$@") =20 %.raw: %.img - $(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@,"BUILD","$(TARGE= T_DIR)$@") + $(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@,"BUILD","$@") =20 %.bin: %.raw - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/signrom.py $< $@,"SIGN= ","$(TARGET_DIR)$@") + $(call quiet-command,$(PYTHON) $(TOPSRC_DIR)/scripts/signrom.py $< $@,"SI= GN","$@") + +include $(wildcard *.d) =20 clean: rm -f *.o *.d *.raw *.img *.bin *~ + +# suppress auto-removal of intermediate files +.SECONDARY: + +.PHONY: all clean --=20 1.8.3.1