aboutsummaryrefslogtreecommitdiffstats
path: root/tools/firmware/vmxassist/Makefile
blob: 70f7a0e0a3ab00a93c70309745771c914d3e8237 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#
# Makefile
#
# Leendert van Doorn, leendert@watson.ibm.com
# Copyright (c) 2005, International Business Machines Corporation.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms and conditions of the GNU General Public License,
# version 2, as published by the Free Software Foundation.
#
# This program is distributed in the hope it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place - Suite 330, Boston, MA 02111-1307 USA.
#

# External CFLAGS can do more harm than good.
CFLAGS :=

override XEN_TARGET_ARCH = x86_32
XEN_ROOT = ../../..
include $(XEN_ROOT)/Config.mk

# The emulator code lives in ROM space
TEXTADDR=0x000D0000

DEFINES=-DDEBUG -DTEXTADDR=$(TEXTADDR)
XENINC=-I$(XEN_ROOT)/tools/libxc

# Disable PIE/SSP if GCC supports them. They can break us.
CFLAGS  += $(call cc-option,$(CC),-nopie,)
CFLAGS  += $(call cc-option,$(CC),-fno-stack-protector,)
CFLAGS  += $(call cc-option,$(CC),-fno-stack-protector-all,)

CPP      = cpp -P
OBJCOPY  = objcopy -p -O binary -R .note -R .comment -R .bss -S --gap-fill=0
CFLAGS  += $(DEFINES) -I. $(XENINC) -fno-builtin -O2 -msoft-float

OBJECTS = head.o trap.o vm86.o setup.o util.o

.PHONY: all
all: vmxassist.bin

vmxassist.bin: vmxassist.ld $(OBJECTS)
	$(CPP) $(DEFINES) vmxassist.ld > vmxassist.tmp
	$(LD) -o vmxassist $(LDFLAGS_DIRECT) -nostdlib --fatal-warnings -N -T vmxassist.tmp $(OBJECTS)
	nm -n vmxassist > vmxassist.sym
	$(OBJCOPY) vmxassist vmxassist.tmp
	dd if=vmxassist.tmp of=vmxassist.bin ibs=512 conv=sync
	rm -f vmxassist.tmp

head.o: machine.h vm86.h head.S
	$(CC) $(CFLAGS) -D__ASSEMBLY__ $(DEFINES) -c head.S

trap.o: machine.h vm86.h offsets.h trap.S
	$(CC) $(CFLAGS) -D__ASSEMBLY__ $(DEFINES) -c trap.S

vm86.o: machine.h vm86.h vm86.c
	$(CC) $(CFLAGS) -c vm86.c

setup.o: machine.h vm86.h setup.c
	$(CC) $(CFLAGS) -c setup.c

util.o: machine.h vm86.h util.c
	$(CC) $(CFLAGS) -c util.c

offsets.h: gen
	./gen > offsets.h

gen:	vm86.h gen.c
	$(HOSTCC) $(HOSTCFLAGS) -I. $(XENINC) -o gen gen.c

.PHONY: clean
clean:
	rm -f vmxassist vmxassist.tmp vmxassist.bin vmxassist.run vmxassist.sym head.s
	rm -f $(OBJECTS)
	rm -f gen gen.o offsets.h