aboutsummaryrefslogtreecommitdiff
path: root/pc-bios/optionrom/Makefile
blob: 3e06c11dea1735f321f3385090c7cf6495ddd808 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
include config.mak
SRC_DIR := $(TOPSRC_DIR)/pc-bios/optionrom
VPATH = $(SRC_DIR)

all: multiboot.bin multiboot_dma.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin
# Dummy command so that make thinks it has done something
	@true

CFLAGS = -O2 -g

quiet-command = $(if $(V),$1,$(if $(2),@printf "  %-7s %s\n" $2 $3 && $1, @$1))
cc-option = $(if $(shell $(CC) $1 -c -o /dev/null -xc /dev/null >/dev/null 2>&1 && echo OK), $1, $2)

override CFLAGS += -march=i486 -Wall $(EXTRA_CFLAGS) -m16

# If -fcf-protection is enabled in flags or compiler defaults that will
# conflict with -march=i486
override CFLAGS += $(call cc-option, -fcf-protection=none)

# Flags for dependency generation
override CPPFLAGS += -MMD -MP -MT $@ -MF $(@D)/$(*F).d

override CFLAGS += $(call cc-option, -fno-pie)
override CFLAGS += $(call cc-option, -no-pie)
override CFLAGS += -ffreestanding -I$(TOPSRC_DIR)/include
override CFLAGS += $(call cc-option, -fno-stack-protector)
override CFLAGS += $(call cc-option, -Wno-array-bounds)

override LDFLAGS = -nostdlib -Wl,-T,$(SRC_DIR)/flat.lds

pvh.img: pvh.o pvh_main.o

%.o: %.S
	$(call quiet-command,$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<,"AS","$@")

%.o: %.c
	$(call quiet-command,$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@,"CC","$@")

%.img: %.o
	$(call quiet-command,$(CC) $(CFLAGS) $(LDFLAGS) -s -o $@ $^,"BUILD","$@")

%.raw: %.img
	$(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@,"BUILD","$@")

%.bin: %.raw
	$(call quiet-command,$(PYTHON) $(TOPSRC_DIR)/scripts/signrom.py $< $@,"SIGN","$@")

include $(wildcard *.d)

clean:
	rm -f *.o *.d *.raw *.img *.bin *~

# suppress auto-removal of intermediate files
.SECONDARY:

.PHONY: all clean