xref: /qemu/pc-bios/optionrom/Makefile (revision 0f900bae)
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 += $(call cc-option, -fno-pie)
24override CFLAGS += $(call cc-option, -no-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
29override LDFLAGS = -nostdlib -Wl,-T,$(SRC_DIR)/flat.lds
30
31pvh.img: pvh.o pvh_main.o
32
33%.o: %.S
34	$(call quiet-command,$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<,"AS","$@")
35
36%.o: %.c
37	$(call quiet-command,$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@,"CC","$@")
38
39%.img: %.o
40	$(call quiet-command,$(CC) $(CFLAGS) $(LDFLAGS) -s -o $@ $^,"BUILD","$@")
41
42%.raw: %.img
43	$(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@,"BUILD","$@")
44
45%.bin: %.raw
46	$(call quiet-command,$(PYTHON) $(TOPSRC_DIR)/scripts/signrom.py $< $@,"SIGN","$@")
47
48include $(wildcard *.d)
49
50clean:
51	rm -f *.o *.d *.raw *.img *.bin *~
52
53# suppress auto-removal of intermediate files
54.SECONDARY:
55
56.PHONY: all clean
57