| 1 | include config.mak |
| 2 | SRC_DIR := $(TOPSRC_DIR)/pc-bios/optionrom |
| 3 | VPATH = $(SRC_DIR) |
| 4 | |
| 5 | all: multiboot_dma.bin linuxboot_dma.bin kvmvapic.bin pvh.bin |
| 6 | # Dummy command so that make thinks it has done something |
| 7 | @true |
| 8 | |
| 9 | CFLAGS = -O2 -g |
| 10 | |
| 11 | NULL := |
| 12 | SPACE := $(NULL) # |
| 13 | TARGET_PREFIX := $(patsubst %/,%:$(SPACE),$(TARGET_DIR)) |
| 14 | |
| 15 | quiet-@ = $(if $(V),,@$(if $1,printf "%s\n" "$(TARGET_PREFIX)$1" && )) |
| 16 | quiet-command = $(call quiet-@,$2 $@)$1 |
| 17 | |
| 18 | # Flags for dependency generation |
| 19 | override CPPFLAGS += -MMD -MP -MT $@ -MF $(@D)/$(*F).d |
| 20 | |
| 21 | override CFLAGS += -march=i486 -Wall $(EXTRA_CFLAGS) -m16 |
| 22 | override CFLAGS += -ffreestanding -I$(TOPSRC_DIR)/include |
| 23 | |
| 24 | cc-test = $(CC) -Werror $1 -c -o /dev/null -xc /dev/null >/dev/null 2>/dev/null |
| 25 | cc-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 |
| 31 | config-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 | |
| 39 | override LDFLAGS = -nostdlib -Wl,--build-id=none,-T,$(SRC_DIR)/flat.lds,-m,elf_i386 |
| 40 | |
| 41 | pvh.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 | |
| 58 | include $(wildcard *.d) |
| 59 | |
| 60 | clean: |
| 61 | rm -f *.o *.d *.raw *.img *.bin *~ |
| 62 | |
| 63 | distclean: |
| 64 | rm -f config-cc.mak |
| 65 | |
| 66 | # suppress auto-removal of intermediate files |
| 67 | .SECONDARY: |
| 68 | |
| 69 | .PHONY: all clean distclean |