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 ?= $(shell date +%m/%d/%Y)
27
28CFLAGS += $(CFLAGS_xeninclude) -fno-pic
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 :=
56
57ifeq ($(CONFIG_ROMBIOS),y)
58OBJS += optionroms.o 32bitbios_support.o rombios.o
59CFLAGS += -DENABLE_ROMBIOS
60ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest
61ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM)
62endif
63
64# Suppress the warning about LOAD segments with RWX permissions, as what we
65# build isn't a normal user-mode executable.
66LDFLAGS-$(call ld-option,--warn-rwx-segments) := --no-warn-rwx-segments
67
68.PHONY: all
69all: hvmloader
70
71.PHONY: acpi
72acpi:
73	$(MAKE) -C $(ACPI_PATH)  ACPI_BUILD_DIR=$(CURDIR) DSDT_FILES="$(DSDT_FILES)"
74
75rombios.o: roms.inc
76smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
77
78ACPI_PATH = ../../libacpi
79DSDT_FILES = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
80ACPI_OBJS = $(patsubst %.c,%.o,$(DSDT_FILES)) build.o static_tables.o
81$(ACPI_OBJS): CFLAGS += -iquote . -DLIBACPI_STDUTILS=\"$(CURDIR)/util.h\"
82CFLAGS += -I$(ACPI_PATH)
83vpath build.c $(ACPI_PATH)
84vpath static_tables.c $(ACPI_PATH)
85OBJS += $(ACPI_OBJS)
86
87$(DSDT_FILES): acpi
88
89# Add DSDT_FILES as a prerequisite of "build.o" so that make will also
90# generate the "ssdt_*.h" headers needed by "build.o".
91build.o: $(DSDT_FILES)
92
93hvmloader: $(OBJS) hvmloader.lds
94	$(LD) $(LDFLAGS_DIRECT) $(LDFLAGS-y) -N -T hvmloader.lds -o $@ $(OBJS)
95
96roms.inc: $(ROMS)
97	echo "/* Autogenerated file. DO NOT EDIT */" > $@.new
98
99ifneq ($(ROMBIOS_ROM),)
100	echo "#ifdef ROM_INCLUDE_ROMBIOS" >> $@.new
101	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex rombios $(ROMBIOS_ROM) >> $@.new
102	echo "#endif" >> $@.new
103endif
104
105ifneq ($(STDVGA_ROM),)
106	echo "#ifdef ROM_INCLUDE_VGABIOS" >> $@.new
107	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex vgabios_stdvga $(STDVGA_ROM) >> $@.new
108	echo "#endif" >> $@.new
109endif
110ifneq ($(CIRRUSVGA_ROM),)
111	echo "#ifdef ROM_INCLUDE_VGABIOS" >> $@.new
112	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> $@.new
113	echo "#endif" >> $@.new
114endif
115	mv -f $@.new $@
116
117.PHONY: clean
118clean:
119	rm -f roms.inc roms.inc.new acpi.h
120	rm -f hvmloader hvmloader.tmp *.o $(DEPS_RM)
121	$(MAKE) -C $(ACPI_PATH)  ACPI_BUILD_DIR=$(CURDIR) clean
122
123.PHONY: distclean
124distclean: clean
125
126-include $(DEPS_INCLUDE)
127