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 9include ../../config-host.mak 10CFLAGS = -O2 -g 11 12quiet-command = $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1, @$1)) 13cc-option = $(if $(shell $(CC) $1 -c -o /dev/null -xc /dev/null >/dev/null 2>&1 && echo OK), $1, $2) 14 15override CFLAGS += -march=i486 -Wall 16 17# If -fcf-protection is enabled in flags or compiler defaults that will 18# conflict with -march=i486 19override CFLAGS += $(call cc-option, -fcf-protection=none) 20 21# Flags for dependency generation 22override CPPFLAGS += -MMD -MP -MT $@ -MF $(@D)/$(*F).d 23 24override CFLAGS += $(filter -W%, $(QEMU_CFLAGS)) 25override CFLAGS += $(call cc-option, -fno-pie) 26override CFLAGS += -ffreestanding -I$(TOPSRC_DIR)/include 27override CFLAGS += $(call cc-option, -fno-stack-protector) 28override CFLAGS += $(call cc-option, -m16) 29override CFLAGS += $(call cc-option, -Wno-array-bounds) 30 31ifeq ($(filter -m16, $(CFLAGS)),) 32# Attempt to work around compilers that lack -m16 (GCC <= 4.8, clang <= ??) 33# On GCC we add -fno-toplevel-reorder to keep the order of asm blocks with 34# respect to the rest of the code. clang does not have -fno-toplevel-reorder, 35# but it places all asm blocks at the beginning and we're relying on it for 36# the option ROM header. So just force clang not to use the integrated 37# assembler, which doesn't support .code16gcc. 38override CFLAGS += $(call cc-option, -fno-toplevel-reorder) 39override CFLAGS += $(call cc-option, -no-integrated-as) 40override CFLAGS += -m32 -include $(SRC_DIR)/code16gcc.h 41endif 42 43Wa = -Wa, 44override ASFLAGS += -32 45override CFLAGS += $(call cc-option, $(Wa)-32) 46 47LD_I386_EMULATION ?= elf_i386 48override LDFLAGS = -m $(LD_I386_EMULATION) -T $(SRC_DIR)/flat.lds 49 50pvh.img: pvh.o pvh_main.o 51 52%.o: %.S 53 $(call quiet-command,$(CPP) $(CPPFLAGS) -c -o - $< | $(AS) $(ASFLAGS) -o $@,"AS","$@") 54 55%.o: %.c 56 $(call quiet-command,$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@,"CC","$@") 57 58%.img: %.o 59 $(call quiet-command,$(LD) $(LDFLAGS) -s -o $@ $^,"BUILD","$@") 60 61%.raw: %.img 62 $(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@,"BUILD","$@") 63 64%.bin: %.raw 65 $(call quiet-command,$(PYTHON) $(TOPSRC_DIR)/scripts/signrom.py $< $@,"SIGN","$@") 66 67include $(wildcard *.d) 68 69clean: 70 rm -f *.o *.d *.raw *.img *.bin *~ 71 72# suppress auto-removal of intermediate files 73.SECONDARY: 74 75.PHONY: all clean 76