xref: /openbmc/qemu/pc-bios/optionrom/Makefile (revision 2d2e4843)
1include config.mak
2SRC_DIR := $(TOPSRC_DIR)/pc-bios/optionrom
3VPATH = $(SRC_DIR)
4
5all: multiboot.bin multiboot_dma.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin
6# Dummy command so that make thinks it has done something
7	@true
8
9CFLAGS = -O2 -g
10
11quiet-command = $(if $(V),$1,$(if $(2),@printf "  %-7s %s\n" $2 $3 && $1, @$1))
12cc-option = $(if $(shell $(CC) $1 -c -o /dev/null -xc /dev/null >/dev/null 2>&1 && echo OK), $1, $2)
13
14override CFLAGS += -march=i486 -Wall $(EXTRA_CFLAGS) -m16
15
16# If -fcf-protection is enabled in flags or compiler defaults that will
17# conflict with -march=i486
18override CFLAGS += $(call cc-option, -fcf-protection=none)
19
20# Flags for dependency generation
21override CPPFLAGS += -MMD -MP -MT $@ -MF $(@D)/$(*F).d
22
23override CFLAGS += $(filter -W%, $(QEMU_CFLAGS))
24override CFLAGS += $(call cc-option, -fno-pie)
25override CFLAGS += -ffreestanding -I$(TOPSRC_DIR)/include
26override CFLAGS += $(call cc-option, -fno-stack-protector)
27override CFLAGS += $(call cc-option, -Wno-array-bounds)
28
29Wa = -Wa,
30override ASFLAGS += -32
31override CFLAGS += $(call cc-option, $(Wa)-32)
32
33override LDFLAGS = -m $(LD_I386_EMULATION) -T $(SRC_DIR)/flat.lds
34
35pvh.img: pvh.o pvh_main.o
36
37%.o: %.S
38	$(call quiet-command,$(CC) $(CPPFLAGS) -E -o - $< | $(AS) $(ASFLAGS) -o $@,"AS","$@")
39
40%.o: %.c
41	$(call quiet-command,$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@,"CC","$@")
42
43%.img: %.o
44	$(call quiet-command,$(LD) $(LDFLAGS) -s -o $@ $^,"BUILD","$@")
45
46%.raw: %.img
47	$(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@,"BUILD","$@")
48
49%.bin: %.raw
50	$(call quiet-command,$(PYTHON) $(TOPSRC_DIR)/scripts/signrom.py $< $@,"SIGN","$@")
51
52include $(wildcard *.d)
53
54clean:
55	rm -f *.o *.d *.raw *.img *.bin *~
56
57# suppress auto-removal of intermediate files
58.SECONDARY:
59
60.PHONY: all clean
61