-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
121 lines (96 loc) · 2.07 KB
/
Makefile
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
VM=none
CC=gcc
ARCH=$(shell uname -m | sed -e s/i.86/i386/)
ifeq ($(ARCH),x86_64)
VM=vm_x86
else
ifeq ($(ARCH),i386)
VM=vm_x86
CC+=-m32
else
ifeq ($(ARCH),ppc)
VM=vm_powerpc
CC+=-m32
else
ifeq ($(ARCH),ppc64)
VM=vm_powerpc
CC+=-m64
else
ifeq ($(ARCH),armv7l)
VM=vm_armv7l
else
$(error arch $(ARCH) is currently not supported)
endif
endif
endif
endif
endif
CFLAGS=-g3 -Wall -O0 -fno-strict-aliasing
CPPFLAGS=-DVM_X86_64_STANDALONE -DHAVE_VM_COMPILED -I../code/qcommon/ -DDEBUG_VM
Q3LCC=../build/release-linux-$(ARCH)/tools/q3lcc
Q3ASM=../build/release-linux-$(ARCH)/tools/q3asm
DO_Q3LCC=$(Q3LCC) -Wf-target=bytecode -Wf-g -o $@ -S -DQ3_VM $< || (/bin/rm -f $@; false)
DO_CC=$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
DO_Q3ASM=$(Q3ASM) -v -o $@ $< syscalls.ASM
OBJ=vm_interpreted.o dummy.o main.o vm.o standalone.o vmstats.o
V=0
ifeq ($(VM),vm_x86)
#XXX
ifeq ($(ARCH),i386)
OBJ += ../build/release-linux-x86/ded/ftola.o
else
ifeq ($(ARCH),x86_64)
OBJ += ../build/release-linux-x86_64/ded/ftola.o
endif
endif
else
ifeq ($(VM),vm_powerpc)
OBJ += vm_powerpc_asm.o
endif
endif
all: t1.qvm comparenative.qvm t2.qvm t3.qvm t4.qvm t5.qvm t6.qvm strcpy.qvm main jmp.qvm segfault.qvm
syscalls.ASM:
comparenative.c: tests.c
%.c: syscalls.h
%.asm: %.c
$(DO_Q3LCC)
%.qvm: %.asm
$(DO_Q3ASM)
%.qvm: %.tasm
$(DO_Q3ASM)
main.o: ../code/qcommon/$(VM).c
$(DO_CC) -I. -DDEBUG_VM
standalone.o: tests.c
standalone.o: standalone.c
$(DO_CC) -I. -DDEBUG_VM
vm.o: ../code/qcommon/vm.c
$(DO_CC)
vm_x86_64_assembler.o: ../code/qcommon/vm_x86_64_assembler.c
$(DO_CC)
vm_powerpc_asm.o: ../code/qcommon/vm_powerpc_asm.c
$(DO_CC)
vm_interpreted.o: ../code/qcommon/vm_interpreted.c
$(DO_CC)
dummy.o: dummy.c
$(DO_CC)
main: $(OBJ)
$(CC) -g -o $@ $(OBJ) -lm -static
%.s: main
%.s: %.qvm
./main $< $@
%.obj: %.s
as -o $@ $<
%.disasm: %.obj
objdump -d $<
%.raw: %.obj
objcopy -O binary -j .text $< $@
c: t1.s
cs: main comparenative.qvm
./main comparenative.qvm
asm: t1.obj
disasm: t1.disasm
raw: t1.raw
clean:
rm -f *.o *.asm *.qvm *.map *.obj *.disasm *.qdasm *.raw
.SUFFIXES: .asm
.PRECIOUS: %.asm