]> git.proxmox.com Git - mirror_qemu.git/blob - pc-bios/optionrom/Makefile
9bdc49798c60bf3c77b5d796a6133903b61bf7cd
[mirror_qemu.git] / pc-bios / optionrom / Makefile
1 all: build-all
2 # Dummy command so that make thinks it has done something
3 @true
4
5 include ../../config-host.mak
6 include $(SRC_PATH)/rules.mak
7
8 $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom)
9
10 .PHONY : all clean build-all
11
12 # Compiling with no optimization creates ROMs that are too large
13 ifeq ($(filter -O%, $(CFLAGS)),)
14 override CFLAGS += -O2
15 endif
16 ifeq ($(filter -O%, $(CFLAGS)),-O0)
17 override CFLAGS += -O2
18 endif
19
20 # Drop -fstack-protector and the like
21 QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) $(CFLAGS_NOPIE) -ffreestanding
22 QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector)
23 QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -m16)
24 ifeq ($(filter -m16, $(QEMU_CFLAGS)),)
25 # Attempt to work around compilers that lack -m16 (GCC <= 4.8, clang <= ??)
26 # On GCC we add -fno-toplevel-reorder to keep the order of asm blocks with
27 # respect to the rest of the code. clang does not have -fno-toplevel-reorder,
28 # but it places all asm blocks at the beginning and we're relying on it for
29 # the option ROM header. So just force clang not to use the integrated
30 # assembler, which doesn't support .code16gcc.
31 QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-toplevel-reorder)
32 QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -no-integrated-as)
33 QEMU_CFLAGS += -m32 -include $(SRC_PATH)/pc-bios/optionrom/code16gcc.h
34 endif
35
36 QEMU_INCLUDES += -I$(SRC_PATH)
37
38 Wa = -Wa,
39 ASFLAGS += -32
40 QEMU_CFLAGS += $(call cc-c-option, $(QEMU_CFLAGS), $(Wa)-32)
41
42 build-all: multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin
43
44 # suppress auto-removal of intermediate files
45 .SECONDARY:
46
47
48 %.o: %.S
49 $(call quiet-command,$(CPP) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) -c -o - $< | $(AS) $(ASFLAGS) -o $@," AS $(TARGET_DIR)$@")
50
51 %.img: %.o
52 $(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -m $(LD_I386_EMULATION) -T $(SRC_PATH)/pc-bios/optionrom/flat.lds -s -o $@ $<," Building $(TARGET_DIR)$@")
53
54 %.raw: %.img
55 $(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@," Building $(TARGET_DIR)$@")
56
57 %.bin: %.raw
58 $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/signrom.py $< $@," Signing $(TARGET_DIR)$@")
59
60 clean:
61 rm -f *.o *.d *.raw *.img *.bin *~