vm exploit testcases
[ioq3vmtest:ioq3vmtest.git] / Makefile
1 VM=none
2 CC=gcc
3 ARCH=$(shell uname -m | sed -e s/i.86/i386/)
4 ifeq ($(ARCH),x86_64)
5   VM=vm_x86_64
6 else
7 ifeq ($(ARCH),i386)
8   VM=vm_x86
9   CC+=-m32
10 else
11 ifeq ($(ARCH),ppc)
12   VM=vm_powerpc
13   CC+=-m32
14 else
15 ifeq ($(ARCH),ppc64)
16   VM=vm_powerpc
17   CC+=-m64
18 else
19 $(error arch $(ARCH) is currently not supported)
20 endif
21 endif
22 endif
23 endif
24 CFLAGS=-g3 -Wall -O0 -fno-strict-aliasing
25 CPPFLAGS=-DVM_X86_64_STANDALONE -DHAVE_VM_COMPILED -I../code/qcommon/ -DDEBUG_VM
26 Q3LCC=../build/release-linux-$(ARCH)/tools/q3lcc
27 Q3ASM=../build/release-linux-$(ARCH)/tools/q3asm
28 DO_Q3LCC=$(Q3LCC) -Wf-target=bytecode -Wf-g -o $@ -S -DQ3_VM $< || (/bin/rm -f $@; false)
29 DO_CC=$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
30 DO_Q3ASM=$(Q3ASM) -v -o $@ $< syscalls.ASM
31 OBJ=vm_interpreted.o dummy.o main.o vm.o standalone.o vmstats.o
32 V=0
33
34 ifeq ($(VM),vm_x86)
35 #XXX
36 OBJ += ../build/release-linux-i386/ded/ftola.o
37 else
38 ifeq ($(VM),vm_x86_64)
39 OBJ += vm_x86_64_assembler.o
40 else
41 ifeq ($(VM),vm_powerpc)
42 OBJ += vm_powerpc_asm.o
43 endif
44 endif
45 endif
46
47 all: t1.qvm t2.qvm t3.qvm t4.qvm t5.qvm t6.qvm strcpy.qvm main jmp.qvm segfault.qvm
48
49 syscalls.ASM:
50
51 t2.c: tests.c
52 %.c: syscalls.h
53 %.asm: %.c
54         $(DO_Q3LCC)
55
56 %.qvm: %.asm
57         $(DO_Q3ASM)
58
59 %.qvm: %.tasm
60         $(DO_Q3ASM)
61
62 main.o: ../code/qcommon/$(VM).c
63         $(DO_CC) -I. -DDEBUG_VM
64
65 standalone.o: tests.c
66 standalone.o: standalone.c
67         $(DO_CC) -I. -DDEBUG_VM
68
69 vm.o: ../code/qcommon/vm.c
70         $(DO_CC)
71
72 vm_x86_64_assembler.o: ../code/qcommon/vm_x86_64_assembler.c
73         $(DO_CC)
74
75 vm_powerpc_asm.o: ../code/qcommon/vm_powerpc_asm.c
76         $(DO_CC)
77
78 vm_interpreted.o: ../code/qcommon/vm_interpreted.c
79         $(DO_CC)
80
81 dummy.o: dummy.c
82         $(DO_CC)
83
84 main: $(OBJ)
85         $(CC) -g -o $@ $(OBJ)
86
87 %.s: main
88 %.s: %.qvm
89         ./main $< $@
90
91 %.obj: %.s
92         as -o $@ $<
93
94 %.disasm: %.obj
95         objdump -d $<
96
97 %.raw: %.obj
98         objcopy -O binary -j .text $< $@
99
100 c: t1.s
101
102 cs: main t2.qvm
103         ./main t2.qvm
104
105 asm: t1.obj
106
107 disasm: t1.disasm
108
109 raw: t1.raw
110
111 clean:
112         rm -f *.o *.asm *.qvm *.map *.obj *.s *.disasm *.qdasm *.raw
113
114 .SUFFIXES: .asm
115 .PRECIOUS: %.asm