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
23
24LOADADDR = 0x100000
25
26# SMBIOS spec requires format mm/dd/yyyy
27SMBIOS_REL_DATE ?= $(shell date +%m/%d/%Y)
28
29CFLAGS += $(CFLAGS_xeninclude)
30
31# We mustn't use tools-only public interfaces.
32CFLAGS += -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__
33
34OBJS  = hvmloader.o mp_tables.o util.o smbios.o
35OBJS += smp.o cacheattr.o xenbus.o vnuma.o
36OBJS += e820.o pci.o pir.o ctype.o
37OBJS += hvm_param.o
38OBJS += ovmf.o seabios.o
39ifeq ($(debug),y)
40OBJS += tests.o
41endif
42
43CIRRUSVGA_DEBUG ?= n
44
45ROMBIOS_DIR := ../rombios
46
47ifeq ($(CONFIG_ROMBIOS),y)
48STDVGA_ROM    := ../vgabios/VGABIOS-lgpl-latest.bin
49ifeq ($(CIRRUSVGA_DEBUG),y)
50CIRRUSVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.cirrus.debug.bin
51else
52CIRRUSVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.cirrus.bin
53endif
54ETHERBOOT_ROMS := $(addprefix ../etherboot/ipxe/src/bin/, $(addsuffix .rom, $(ETHERBOOT_NICS)))
55endif
56
57ROMS :=
58
59ifeq ($(CONFIG_ROMBIOS),y)
60OBJS += optionroms.o 32bitbios_support.o rombios.o
61CFLAGS += -DENABLE_ROMBIOS
62ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest
63ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) $(ETHERBOOT_ROMS)
64endif
65
66.PHONY: all
67all: acpi subdirs-all
68	$(MAKE) hvmloader
69
70.PHONY: acpi
71acpi:
72	$(MAKE) -C $(ACPI_PATH)  ACPI_BUILD_DIR=$(CURDIR) DSDT_FILES="$(DSDT_FILES)"
73
74rombios.o: roms.inc
75smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
76
77ACPI_PATH = ../../libacpi
78DSDT_FILES = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
79ACPI_OBJS = $(patsubst %.c,%.o,$(DSDT_FILES)) build.o static_tables.o
80$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/util.h\"
81CFLAGS += -I$(ACPI_PATH)
82vpath build.c $(ACPI_PATH)
83vpath static_tables.c $(ACPI_PATH)
84OBJS += $(ACPI_OBJS)
85
86hvmloader: $(OBJS)
87	$(LD) $(LDFLAGS_DIRECT) -N -Ttext $(LOADADDR) -o $@ $^
88
89roms.inc: $(ROMS)
90	echo "/* Autogenerated file. DO NOT EDIT */" > $@.new
91
92ifneq ($(ROMBIOS_ROM),)
93	echo "#ifdef ROM_INCLUDE_ROMBIOS" >> $@.new
94	sh ../../misc/mkhex rombios $(ROMBIOS_ROM) >> $@.new
95	echo "#endif" >> $@.new
96endif
97
98ifneq ($(STDVGA_ROM),)
99	echo "#ifdef ROM_INCLUDE_VGABIOS" >> $@.new
100	sh ../../misc/mkhex vgabios_stdvga $(STDVGA_ROM) >> $@.new
101	echo "#endif" >> $@.new
102endif
103ifneq ($(CIRRUSVGA_ROM),)
104	echo "#ifdef ROM_INCLUDE_VGABIOS" >> $@.new
105	sh ../../misc/mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> $@.new
106	echo "#endif" >> $@.new
107endif
108ifneq ($(ETHERBOOT_ROMS),)
109	echo "#ifdef ROM_INCLUDE_ETHERBOOT" >> $@.new
110	sh ../../misc/mkhex etherboot $(ETHERBOOT_ROMS) >> $@.new
111	echo "#endif" >> $@.new
112endif
113
114	mv $@.new $@
115
116.PHONY: clean
117clean: subdirs-clean
118	rm -f roms.inc roms.inc.new acpi.h
119	rm -f hvmloader hvmloader.tmp *.o $(DEPS_RM)
120	$(MAKE) -C $(ACPI_PATH)  ACPI_BUILD_DIR=$(CURDIR) clean
121
122.PHONY: distclean
123distclean: clean
124
125-include $(DEPS_INCLUDE)
126