From nobody Mon Feb 9 22:04:31 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1580234145564394.3803302944684; Tue, 28 Jan 2020 09:55:45 -0800 (PST) Received: from localhost ([::1]:34706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iwV5T-0007gi-4A for importer@patchew.org; Tue, 28 Jan 2020 12:55:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57185) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iwV3n-0005kh-Lj for qemu-devel@nongnu.org; Tue, 28 Jan 2020 12:54:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iwV3m-0007LL-7W for qemu-devel@nongnu.org; Tue, 28 Jan 2020 12:53:59 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:42876) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iwV3l-0007Fo-VY for qemu-devel@nongnu.org; Tue, 28 Jan 2020 12:53:58 -0500 Received: by mail-wr1-x444.google.com with SMTP id k11so2413997wrd.9 for ; Tue, 28 Jan 2020 09:53:55 -0800 (PST) Received: from localhost.localdomain (93-36-56-206.ip58.fastwebnet.it. [93.36.56.206]) by smtp.gmail.com with ESMTPSA id o4sm27046968wrx.25.2020.01.28.09.53.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jan 2020 09:53:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v7fP+V9ixvBHX58L9pfbBMpyNUVrGlItPTLd0Obr3k0=; b=BoL1lgahF/lhS3PwpFzVequl9uOTx1rqxrGLix5RU2vYzZfPCHDMjrdT9GC/aD0AP0 LrsnuCPOQQwpd+AcqWFv2emQevs/KOv1HWWatq5cttz3f4CxpWmJ/MsMv+X3uVfNs/Ev wJUhr41qj4Ql8iOKaIVm9bHHu+4t7+2bLG7woITR8e6oa7dI3TlHFJmKZUy674JiW6dz 0Y9BCkdlvz0zRoNfx03WQ3wKycf91iFVJzcav8ZsImFhtRVi6iA6RDxNNJDiGUGyfwyS qgy4bTpFkYKcOg66SG5xSMdUgrKrPJ6u7r2M7GSH4AjpL5cbjDVDLNMkBBpNQSVqtv6T STyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=v7fP+V9ixvBHX58L9pfbBMpyNUVrGlItPTLd0Obr3k0=; b=ubThG8asSLEGRvDhIprGm9IKVh0MQJCKAQmTPutrOUDr5UlJeYWjt9fOe7JuT28roK 0DI0DrChGWjoMcm34hje3zoGF8vzUAj8ynWlr2YD0zzUo5wHOGh2nYoSig4er8YGBqxv fbzm69FgGdbLAjFth5RJMFKq4RQcWpK6+e2DZuJJ/OwmtcU79QdPwb/gtEV/RQAC8JD8 AY4s9+dVJVDxHIQBnbKCIP/Ekcog7DwZP8ARJGUO2JRWTOqIMTiFT6lTclh6mmV49M2T PyqXlcAXlsiBtMXj3Y01aA+Wd+XGWkr3aiGNZAaCu+yyMPo1N4HsXEK2N1ozA+JmtjPU 6O5w== X-Gm-Message-State: APjAAAWprpU+mJzQQ6I3dvy+y6SFMGUJiatVld1ieZHde6ptbDwS1itZ aS2Snh8bvGO2yVM8bMSSoQ+sOxS1 X-Google-Smtp-Source: APXvYqx7+JDUBgRIRAqx9jXuaF/WlEqWtQMCBODqVDGDnWfO8D0uAM7+RAPMheVYfKchdOgtPpctEA== X-Received: by 2002:adf:edd0:: with SMTP id v16mr29337586wro.310.1580234034537; Tue, 28 Jan 2020 09:53:54 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 002/142] optionrom: simplify Makefile Date: Tue, 28 Jan 2020 18:51:22 +0100 Message-Id: <20200128175342.9066-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200128175342.9066-1-pbonzini@redhat.com> References: <20200128175342.9066-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 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: fail (Header signature does not verify) 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 e33a24da0d..51cb6ca9d8 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 2.21.0