[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 131/132] meson: convert pc-bios/optionrom
From: |
Paolo Bonzini |
Subject: |
[PATCH 131/132] meson: convert pc-bios/optionrom |
Date: |
Thu, 19 Dec 2019 13:23:51 +0100 |
From: Marc-André Lureau <address@hidden>
Signed-off-by: Marc-André Lureau <address@hidden>
---
Makefile | 12 -------
configure | 20 +----------
pc-bios/meson.build | 4 +++
pc-bios/optionrom/Makefile | 77 -------------------------------------------
pc-bios/optionrom/meson.build | 72 ++++++++++++++++++++++++++++++++++++++++
scripts/signrom.py | 2 ++
6 files changed, 79 insertions(+), 108 deletions(-)
delete mode 100644 pc-bios/optionrom/Makefile
create mode 100644 pc-bios/optionrom/meson.build
diff --git a/Makefile b/Makefile
index 0493a3b..1bc219a 100644
--- a/Makefile
+++ b/Makefile
@@ -158,18 +158,6 @@ subdir-dtc: dtc/all
subdir-capstone: capstone/all
subdir-slirp: slirp/all
-ROM_DIRS = $(addprefix pc-bios/, $(ROMS))
-ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS)))
-# Only keep -O and -g cflags
-.PHONY: $(ROM_DIRS_RULES)
-$(ROM_DIRS_RULES):
- $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)"
TARGET_DIR="$(dir $@)" CFLAGS="$(filter -O% -g%,$(CFLAGS))" $(notdir $@),)
-
-.PHONY: recurse-all recurse-clean recurse-install
-recurse-all: $(ROM_DIRS)
-recurse-clean: $(addsuffix /clean, $(ROM_DIRS))
-recurse-install:
-
######################################################################
COMMON_LDADDS = libqemuutil.a
diff --git a/configure b/configure
index a1b71b9..9d4974e 100755
--- a/configure
+++ b/configure
@@ -6156,23 +6156,6 @@ if test "$guest_agent_msi" = "yes"; then
esac
fi
-# Mac OS X ships with a broken assembler
-roms=
-if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
- test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
- test "$softmmu" = yes ; then
- # Different host OS linkers have different ideas about the name of the ELF
- # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
- # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
- for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
- if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
- ld_i386_emulation="$emu"
- roms="optionrom"
- break
- fi
- done
-fi
-
# Probe for the need for relocating the user-only binary.
if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ];
then
textseg_addr=
@@ -7302,7 +7285,6 @@ else
fi
QEMU_INCLUDES="-iquote ${source_path}/tcg $QEMU_INCLUDES"
-echo "ROMS=$roms" >> $config_host_mak
echo "MAKE=$make" >> $config_host_mak
echo "INSTALL=$install" >> $config_host_mak
echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
@@ -7824,7 +7806,7 @@ DIRS="$DIRS roms/seabios roms/vgabios"
LINKS="Makefile"
LINKS="$LINKS tests/tcg/lm32/Makefile po/Makefile"
LINKS="$LINKS tests/tcg/Makefile.target tests/fp/Makefile"
-LINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
+LINKS="$LINKS pc-bios/keymaps"
LINKS="$LINKS pc-bios/s390-ccw/Makefile"
LINKS="$LINKS roms/seabios/Makefile roms/vgabios/Makefile"
LINKS="$LINKS pc-bios/qemu-icon.bmp"
diff --git a/pc-bios/meson.build b/pc-bios/meson.build
index 1697c55..ff1eebf 100644
--- a/pc-bios/meson.build
+++ b/pc-bios/meson.build
@@ -100,6 +100,10 @@ if dtc.found()
alias_target('update-dtb', t)
endif
+if host_machine.cpu_family() in ['x86', 'x86_64']
+ subdir('optionrom')
+endif
+
cc = meson.get_compiler('c')
if host_machine.cpu_family() == 's390x' and cc.has_argument('-march=z900')
subdir('s390-ccw')
diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile
deleted file mode 100644
index 51cb6ca..0000000
--- a/pc-bios/optionrom/Makefile
+++ /dev/null
@@ -1,77 +0,0 @@
-CURRENT_MAKEFILE := $(realpath $(word $(words
$(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
-SRC_DIR := $(dir $(CURRENT_MAKEFILE))
-TOPSRC_DIR := $(SRC_DIR)/../..
-VPATH = $(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
-
-include ../../config-host.mak
-
-quiet-command = $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1, @$1))
-cc-option = $(if $(shell $(CC) $1 -S -o /dev/null -xc /dev/null >/dev/null
2>&1 && echo OK), $1, $2)
-
-# Compiling with no optimization creates ROMs that are too large
-ifeq ($(lastword $(filter -O%, -O0 $(CFLAGS))),-O0)
-override CFLAGS += -O2
-endif
-override CFLAGS += -march=i486
-
-# Flags for dependency generation
-override CPPFLAGS += -MMD -MP -MT $@ -MF $(@D)/$(*F).d
-
-override CFLAGS += $(filter -W%, $(QEMU_CFLAGS))
-override CFLAGS += $(CFLAGS_NOPIE) -ffreestanding -I$(TOPSRC_DIR)/include
-override CFLAGS += $(call cc-option, -fno-stack-protector)
-override CFLAGS += $(call cc-option, -m16)
-
-ifeq ($(filter -m16, $(CFLAGS)),)
-# Attempt to work around compilers that lack -m16 (GCC <= 4.8, clang <= ??)
-# 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-reorder,
-# 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.
-override CFLAGS += $(call cc-option, -fno-toplevel-reorder)
-override CFLAGS += $(call cc-option, -no-integrated-as)
-override CFLAGS += -m32 -include $(SRC_DIR)/code16gcc.h
-endif
-
-Wa = -Wa,
-override ASFLAGS += -32
-override CFLAGS += $(call cc-option, $(Wa)-32)
-
-
-LD_I386_EMULATION ?= elf_i386
-override LDFLAGS = -m $(LD_I386_EMULATION) -T $(SRC_DIR)/flat.lds
-override LDFLAGS += $(LDFLAGS_NOPIE)
-
-all: multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin
-
-pvh.img: pvh.o pvh_main.o
-
-%.o: %.S
- $(call quiet-command,$(CPP) $(CPPFLAGS) -c -o - $< | $(AS) $(ASFLAGS)
-o $@,"AS","$@")
-
-%.o: %.c
- $(call quiet-command,$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@,"CC","$@")
-
-%.img: %.o
- $(call quiet-command,$(LD) $(LDFLAGS) -s -o $@ $^,"BUILD","$@")
-
-%.raw: %.img
- $(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@,"BUILD","$@")
-
-%.bin: %.raw
- $(call quiet-command,$(PYTHON) $(TOPSRC_DIR)/scripts/signrom.py $<
$@,"SIGN","$@")
-
-include $(wildcard *.d)
-
-clean:
- rm -f *.o *.d *.raw *.img *.bin *~
-
-# suppress auto-removal of intermediate files
-.SECONDARY:
-
-.PHONY: all clean
diff --git a/pc-bios/optionrom/meson.build b/pc-bios/optionrom/meson.build
new file mode 100644
index 0000000..5761736
--- /dev/null
+++ b/pc-bios/optionrom/meson.build
@@ -0,0 +1,72 @@
+cc = meson.get_compiler('c')
+objcopy = find_program('objcopy')
+signrom = find_program(meson.current_source_dir() / '../../scripts/signrom.py')
+
+emu = ''
+foreach e: ['elf_i386', 'elf_i386_fbsd', 'elf_i386_obsd', 'i386pe']
+ if cc.has_multi_link_arguments('-m32', '-Wl,-m' + e)
+ emu = e
+ break
+ endif
+endforeach
+
+if emu == ''
+ message('No suitable compiler/linker found to build optionrom')
+else
+ link_args = ['-nostdlib', '-m32', '-Wl,-m' + e]
+ link_args += cc.get_supported_link_arguments('-Wl,--build-id=none')
+ if cc.has_multi_link_arguments('-fno-pie', '-no-pie')
+ link_args += ['-no-pie']
+ endif
+
+ link_args += '-Wl,-T' + meson.current_source_dir() / 'flat.lds'
+
+ c_args = ['-ffreestanding', '-march=i486']
+ c_args += cc.get_supported_arguments('-fno-pie', '-fno-stack-protector',
'-m32')
+
+ # Compiling with no optimization creates ROMs that are too large
+ code16_c_args = ['-O2']
+ if cc.has_argument('-m16')
+ code16_c_args += '-m16'
+ else
+ # Attempt to work around compilers that lack -m16 (GCC <= 4.8, clang <= ??)
+ # 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-reorder,
+ # 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.
+ code16_c_args += cc.get_supported_arguments('-fno-toplevel-reorder',
'-no-integrated-as')
+ code16_c_args += ['-m32', '-include', meson.current_source_dir() /
'code16gcc.h']
+ endif
+
+ foreach target, opt: {
+ 'multiboot': {'src': ['multiboot.S'], 'cargs': ['-m32', '-g0']},
+ 'linuxboot_dma': {'src': ['linuxboot_dma.c'], 'cargs': code16_c_args},
+ 'linuxboot': {'src': ['linuxboot.S']},
+ 'kvmvapic': {'src': ['kvmvapic.S']},
+ 'pvh': {'src': ['pvh.S', 'pvh_main.c']},
+ }
+ img = executable(
+ target + '.img',
+ opt['src'],
+ c_args: [c_args, opt.get('cargs', [])],
+ include_directories: include_directories('../../include'),
+ link_args: link_args,
+ )
+
+ raw = custom_target(
+ target + '.raw',
+ output: target + '.raw',
+ input: img,
+ command: [objcopy, '-O', 'binary', '-j', '.text', '@INPUT@', '@OUTPUT@'],
+ )
+
+ bin = custom_target(
+ target + '.bin',
+ output: target + '.bin',
+ input: raw,
+ command: [signrom, '@INPUT@', '@OUTPUT@'],
+ build_by_default: true,
+ )
+ endforeach
+endif
diff --git a/scripts/signrom.py b/scripts/signrom.py
index 313ee28..ba9ac03 100644
--- a/scripts/signrom.py
+++ b/scripts/signrom.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
from __future__ import print_function
#
# Option ROM signing utility
--
1.8.3.1
- [PATCH 118/132] meson: build texi doc, (continued)
- [PATCH 118/132] meson: build texi doc, Paolo Bonzini, 2019/12/19
- [PATCH 124/132] meson: install icons, Paolo Bonzini, 2019/12/19
- [PATCH 123/132] meson: install edk2 json descriptors, Paolo Bonzini, 2019/12/19
- [PATCH 125/132] meson: install desktop file, Paolo Bonzini, 2019/12/19
- [PATCH 126/132] meson: install keymaps, Paolo Bonzini, 2019/12/19
- [PATCH 127/132] meson: convert po/, Paolo Bonzini, 2019/12/19
- [PATCH 128/132] meson: replace pc-bios/keymaps/Makefile, Paolo Bonzini, 2019/12/19
- [PATCH 129/132] meson: replace mostly useless pc-bios/Makefile, Paolo Bonzini, 2019/12/19
- [PATCH 130/132] meson: convert pc-bios/s390-ccw, Paolo Bonzini, 2019/12/19
- [PATCH 132/132] rules.mak: drop unneeded macros, Paolo Bonzini, 2019/12/19
- [PATCH 131/132] meson: convert pc-bios/optionrom,
Paolo Bonzini <=