1# 2# Makefile 3# 4# Leendert van Doorn, leendert@watson.ibm.com 5# Copyright (c) 2005, International Business Machines Corporation. 6# 7# This program is free software; you can redistribute it and/or modify it 8# under the terms and conditions of the GNU General Public License, 9# version 2, as published by the Free Software Foundation. 10# 11# This program is distributed in the hope it will be useful, but WITHOUT 12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14# more details. 15# 16# You should have received a copy of the GNU General Public License along with 17# this program; If not, see <http://www.gnu.org/licenses/>. 18# 19 20XEN_ROOT = $(CURDIR)/../../.. 21include $(XEN_ROOT)/tools/firmware/Rules.mk 22 23ld-option = $(shell if $(LD) -v $(1) >/dev/null 2>&1; then echo y; else echo n; fi) 24 25# SMBIOS spec requires format mm/dd/yyyy 26SMBIOS_REL_DATE ?= $(call date,"+%m/%d/%Y") 27 28CFLAGS += $(CFLAGS_xeninclude) -fno-pic -mregparm=3 29 30# We mustn't use tools-only public interfaces. 31CFLAGS += -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ 32 33OBJS = hvmloader.o mp_tables.o util.o smbios.o 34OBJS += smp.o cacheattr.o xenbus.o vnuma.o 35OBJS += e820.o pci.o pir.o ctype.o 36OBJS += hvm_param.o 37OBJS += ovmf.o seabios.o 38ifeq ($(debug),y) 39OBJS += tests.o 40endif 41 42CIRRUSVGA_DEBUG ?= n 43 44ROMBIOS_DIR := ../rombios 45 46ifeq ($(CONFIG_ROMBIOS),y) 47STDVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.bin 48ifeq ($(CIRRUSVGA_DEBUG),y) 49CIRRUSVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.cirrus.debug.bin 50else 51CIRRUSVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.cirrus.bin 52endif 53endif 54 55ROMS := 56DSDT_FILES := 57 58ifeq ($(CONFIG_ROMBIOS),y) 59OBJS += optionroms.o 32bitbios_support.o rombios.o 60CFLAGS += -DENABLE_ROMBIOS 61ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest 62ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) 63DSDT_FILES += dsdt_anycpu.c dsdt_15cpu.c 64endif 65 66# Suppress the warning about LOAD segments with RWX permissions, as what we 67# build isn't a normal user-mode executable. 68LDFLAGS-$(call ld-option,--warn-rwx-segments) := --no-warn-rwx-segments 69 70.PHONY: all 71all: hvmloader 72 73.PHONY: acpi 74acpi: 75 $(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) DSDT_FILES="$(DSDT_FILES)" 76 77rombios.o: roms.inc 78smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\"" 79 80ACPI_PATH = ../../libacpi 81DSDT_FILES += dsdt_anycpu_qemu_xen.c 82ACPI_OBJS = $(patsubst %.c,%.o,$(DSDT_FILES)) build.o static_tables.o 83$(ACPI_OBJS): CFLAGS += -iquote . -DLIBACPI_STDUTILS=\"$(CURDIR)/util.h\" 84CFLAGS += -I$(ACPI_PATH) 85vpath build.c $(ACPI_PATH) 86vpath static_tables.c $(ACPI_PATH) 87OBJS += $(ACPI_OBJS) 88 89$(DSDT_FILES): acpi 90 91# Add DSDT_FILES as a prerequisite of "build.o" so that make will also 92# generate the "ssdt_*.h" headers needed by "build.o". 93build.o: $(DSDT_FILES) 94 95hvmloader: $(OBJS) hvmloader.lds 96 $(LD) $(LDFLAGS_DIRECT) $(LDFLAGS-y) -N -T hvmloader.lds -o $@ $(OBJS) 97 98roms.inc: $(ROMS) 99 echo "/* Autogenerated file. DO NOT EDIT */" > $@.new 100 101ifneq ($(ROMBIOS_ROM),) 102 echo "#ifdef ROM_INCLUDE_ROMBIOS" >> $@.new 103 $(SHELL) $(XEN_ROOT)/tools/misc/mkhex rombios $(ROMBIOS_ROM) >> $@.new 104 echo "#endif" >> $@.new 105endif 106 107ifneq ($(STDVGA_ROM),) 108 echo "#ifdef ROM_INCLUDE_VGABIOS" >> $@.new 109 $(SHELL) $(XEN_ROOT)/tools/misc/mkhex vgabios_stdvga $(STDVGA_ROM) >> $@.new 110 echo "#endif" >> $@.new 111endif 112ifneq ($(CIRRUSVGA_ROM),) 113 echo "#ifdef ROM_INCLUDE_VGABIOS" >> $@.new 114 $(SHELL) $(XEN_ROOT)/tools/misc/mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> $@.new 115 echo "#endif" >> $@.new 116endif 117 mv -f $@.new $@ 118 119.PHONY: clean 120clean: 121 rm -f roms.inc roms.inc.new acpi.h 122 rm -f hvmloader hvmloader.tmp *.o $(DEPS_RM) 123 $(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) clean 124 125.PHONY: distclean 126distclean: clean 127 128-include $(DEPS_INCLUDE) 129