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