Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
[qemu/ar7.git] / pc-bios / optionrom / Makefile
blob8aef1522620e8ac7a95d6003b49e995b6812dd4c
1 all: build-all
2 # Dummy command so that make thinks it has done something
3 @true
5 include ../../config-host.mak
6 include $(SRC_PATH)/rules.mak
8 $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom)
10 .PHONY : all clean build-all
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
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
36 QEMU_INCLUDES += -I$(SRC_PATH)
38 Wa = -Wa,
39 ASFLAGS += -32
40 QEMU_CFLAGS += $(call cc-c-option, $(QEMU_CFLAGS), $(Wa)-32)
42 build-all: multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin
44 # suppress auto-removal of intermediate files
45 .SECONDARY:
48 %.o: %.S
49 $(call quiet-command,$(CPP) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) -c -o - $< | $(AS) $(ASFLAGS) -o $@," AS $(TARGET_DIR)$@")
51 ifdef CONFIG_WIN32
52 LD_EMULATION = i386pe
53 else
54 ifdef CONFIG_BSD
55 LD_EMULATION = elf_i386_fbsd
56 else
57 LD_EMULATION = elf_i386
58 endif
59 endif
61 %.img: %.o
62 $(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -m $(LD_EMULATION) -T $(SRC_PATH)/pc-bios/optionrom/flat.lds -s -o $@ $<," Building $(TARGET_DIR)$@")
64 %.raw: %.img
65 $(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@," Building $(TARGET_DIR)$@")
67 %.bin: %.raw
68 $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/signrom.py $< $@," Signing $(TARGET_DIR)$@")
70 clean:
71 rm -f *.o *.d *.raw *.img *.bin *~