xref: /openbmc/qemu/pc-bios/optionrom/Makefile (revision 84615a19)
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
11NULL :=
12SPACE := $(NULL) #
13TARGET_PREFIX := $(patsubst %/,%:$(SPACE),$(TARGET_DIR))
14
15quiet-@ = $(if $(V),,@$(if $1,printf "%s\n" "$(TARGET_PREFIX)$1" && ))
16quiet-command = $(call quiet-@,$2 $@)$1
17
18# Flags for dependency generation
19override CPPFLAGS += -MMD -MP -MT $@ -MF $(@D)/$(*F).d
20
21override CFLAGS += -march=i486 -Wall $(EXTRA_CFLAGS) -m16
22override CFLAGS += -ffreestanding -I$(TOPSRC_DIR)/include
23
24cc-test = $(CC) -Werror $1 -c -o /dev/null -xc /dev/null >/dev/null 2>/dev/null
25cc-option = if $(call cc-test, $1); then \
26    echo "$(TARGET_PREFIX)$1 detected" && echo "override CFLAGS += $1" >&3; else \
27    echo "$(TARGET_PREFIX)$1 not detected" $(if $2,&& echo "override CFLAGS += $2" >&3); fi
28
29# If -fcf-protection is enabled in flags or compiler defaults that will
30# conflict with -march=i486
31config-cc.mak: Makefile
32	$(quiet-@)($(call cc-option,-fcf-protection=none); \
33	    $(call cc-option,-fno-pie); \
34	    $(call cc-option,-no-pie); \
35	    $(call cc-option,-fno-stack-protector); \
36	    $(call cc-option,-Wno-array-bounds)) 3> config-cc.mak
37-include config-cc.mak
38
39override LDFLAGS = -nostdlib -Wl,-T,$(SRC_DIR)/flat.lds
40
41pvh.img: pvh.o pvh_main.o
42
43%.o: %.S
44	$(call quiet-command,$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<,Assembling)
45
46%.o: %.c
47	$(call quiet-command,$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@,Compiling)
48
49%.img: %.o
50	$(call quiet-command,$(CC) $(CFLAGS) $(LDFLAGS) -s -o $@ $^,Linking)
51
52%.raw: %.img
53	$(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@,Extracting raw object)
54
55%.bin: %.raw
56	$(call quiet-command,$(PYTHON) $(TOPSRC_DIR)/scripts/signrom.py $< $@,Computing checksum into)
57
58include $(wildcard *.d)
59
60clean:
61	rm -f *.o *.d *.raw *.img *.bin *~
62
63distclean:
64	rm -f config-cc.mak
65
66# suppress auto-removal of intermediate files
67.SECONDARY:
68
69.PHONY: all clean distclean
70