]>
Commit | Line | Data |
---|---|---|
626df76a FB |
1 | include config.mak |
2 | ||
1e43adfc FB |
3 | TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH) |
4 | VPATH=$(SRC_PATH):$(TARGET_PATH) | |
626df76a FB |
5 | CFLAGS=-Wall -O2 -g |
6 | LDFLAGS=-g | |
7 | LIBS= | |
1e43adfc | 8 | DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH) |
626df76a FB |
9 | HELPER_CFLAGS=$(CFLAGS) |
10 | DYNGEN=../dyngen | |
1e43adfc FB |
11 | # user emulator name |
12 | QEMU_USER=qemu-$(TARGET_ARCH) | |
13 | # system emulator name | |
14 | ifdef CONFIG_SOFTMMU | |
1e43adfc | 15 | QEMU_SYSTEM=qemu |
0db63474 FB |
16 | else |
17 | QEMU_SYSTEM=qemu-fast | |
1e43adfc FB |
18 | endif |
19 | ||
16e9b7de | 20 | ifdef CONFIG_USER_ONLY |
1e43adfc | 21 | PROGS=$(QEMU_USER) |
16e9b7de FB |
22 | else |
23 | ifeq ($(ARCH),i386) | |
24 | ifeq ($(TARGET_ARCH), i386) | |
25 | PROGS+=$(QEMU_SYSTEM) | |
26 | endif | |
27 | endif | |
626df76a FB |
28 | endif |
29 | ||
30 | ifdef CONFIG_STATIC | |
31 | LDFLAGS+=-static | |
32 | endif | |
33 | ||
34 | ifeq ($(ARCH),i386) | |
35 | CFLAGS+=-fomit-frame-pointer | |
36 | OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2 | |
37 | ifeq ($(HAVE_GCC3_OPTIONS),yes) | |
38 | OP_CFLAGS+= -falign-functions=0 | |
39 | else | |
40 | OP_CFLAGS+= -malign-functions=0 | |
41 | endif | |
42 | ifdef TARGET_GPROF | |
43 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld | |
44 | else | |
45 | # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object | |
46 | # that the kernel ELF loader considers as an executable. I think this | |
47 | # is the simplest way to make it self virtualizable! | |
48 | LDFLAGS+=-Wl,-shared | |
49 | endif | |
626df76a FB |
50 | endif |
51 | ||
52 | ifeq ($(ARCH),ppc) | |
53 | OP_CFLAGS=$(CFLAGS) | |
54 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld | |
55 | endif | |
56 | ||
57 | ifeq ($(ARCH),s390) | |
58 | OP_CFLAGS=$(CFLAGS) | |
59 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld | |
60 | endif | |
61 | ||
62 | ifeq ($(ARCH),sparc) | |
63 | CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6 | |
64 | LDFLAGS+=-m32 | |
65 | OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0 | |
66 | HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat | |
67 | # -static is used to avoid g1/g3 usage by the dynamic linker | |
68 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static | |
69 | endif | |
70 | ||
71 | ifeq ($(ARCH),sparc64) | |
72 | CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6 | |
73 | LDFLAGS+=-m64 | |
74 | OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0 | |
75 | endif | |
76 | ||
77 | ifeq ($(ARCH),alpha) | |
78 | # -msmall-data is not used because we want two-instruction relocations | |
79 | # for the constant constructions | |
80 | OP_CFLAGS=-Wall -O2 -g | |
81 | # Ensure there's only a single GP | |
82 | CFLAGS += -msmall-data | |
83 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld | |
84 | endif | |
85 | ||
86 | ifeq ($(ARCH),ia64) | |
87 | OP_CFLAGS=$(CFLAGS) | |
88 | endif | |
89 | ||
90 | ifeq ($(ARCH),arm) | |
91 | OP_CFLAGS=$(CFLAGS) -mno-sched-prolog | |
92 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld | |
93 | endif | |
94 | ||
38e584a0 FB |
95 | ifeq ($(ARCH),m68k) |
96 | OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer | |
97 | LDFLAGS+=-Wl,-T,m68k.ld | |
98 | endif | |
99 | ||
626df76a FB |
100 | ifeq ($(HAVE_GCC3_OPTIONS),yes) |
101 | # very important to generate a return at the end of every operation | |
102 | OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls | |
103 | endif | |
104 | ||
105 | ######################################################### | |
106 | ||
107 | DEFINES+=-D_GNU_SOURCE | |
108 | LIBS+=-lm | |
109 | ||
110 | # profiling code | |
111 | ifdef TARGET_GPROF | |
112 | LDFLAGS+=-p | |
113 | main.o: CFLAGS+=-p | |
114 | endif | |
115 | ||
116 | OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o | |
117 | ifeq ($(TARGET_ARCH), i386) | |
118 | OBJS+= vm86.o | |
119 | endif | |
120 | SRCS:= $(OBJS:.o=.c) | |
121 | OBJS+= libqemu.a | |
122 | ||
123 | # cpu emulator library | |
1e43adfc FB |
124 | LIBOBJS=thunk.o exec.o translate-all.o cpu-exec.o gdbstub.o \ |
125 | translate.o op.o | |
626df76a FB |
126 | |
127 | ifeq ($(TARGET_ARCH), i386) | |
1e43adfc | 128 | LIBOBJS+=helper.o helper2.o |
626df76a FB |
129 | endif |
130 | ||
131 | # NOTE: the disassembler code is only needed for debugging | |
132 | LIBOBJS+=disas.o | |
133 | ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386) | |
134 | LIBOBJS+=i386-dis.o | |
135 | endif | |
136 | ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha) | |
137 | LIBOBJS+=alpha-dis.o | |
138 | endif | |
139 | ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc) | |
140 | LIBOBJS+=ppc-dis.o | |
141 | endif | |
142 | ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc) | |
143 | LIBOBJS+=sparc-dis.o | |
144 | endif | |
145 | ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm) | |
146 | LIBOBJS+=arm-dis.o | |
147 | endif | |
148 | ||
149 | ifeq ($(ARCH),ia64) | |
150 | OBJS += ia64-syscall.o | |
151 | endif | |
152 | ||
1e43adfc | 153 | all: $(PROGS) |
626df76a | 154 | |
1e43adfc | 155 | $(QEMU_USER): $(OBJS) |
626df76a FB |
156 | $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) |
157 | ifeq ($(ARCH),alpha) | |
158 | # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of | |
159 | # the address space (31 bit so sign extending doesn't matter) | |
160 | echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc | |
161 | endif | |
162 | ||
163 | # must use static linking to avoid leaving stuff in virtual address space | |
164 | VL_OBJS=vl.o block.o vga.o | |
165 | ifdef CONFIG_SDL | |
166 | VL_OBJS+=sdl.o | |
b7dda06a | 167 | SDL_LIBS+=-L/usr/X11R6/lib -lX11 -lXext -lXv -ldl -lm |
626df76a FB |
168 | endif |
169 | ||
1e43adfc | 170 | $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a |
626df76a FB |
171 | $(CC) -static -Wl,-T,$(SRC_PATH)/i386-vl.ld -o $@ $^ $(LIBS) $(SDL_LIBS) |
172 | ||
173 | sdl.o: sdl.c | |
174 | $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $< | |
175 | ||
176 | depend: $(SRCS) | |
16e9b7de | 177 | $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend |
626df76a FB |
178 | |
179 | # libqemu | |
180 | ||
181 | libqemu.a: $(LIBOBJS) | |
182 | rm -f $@ | |
183 | $(AR) rcs $@ $(LIBOBJS) | |
184 | ||
1e43adfc | 185 | translate.o: translate.c gen-op.h opc.h cpu.h |
626df76a | 186 | |
1e43adfc | 187 | translate-all.o: translate-all.c op.h opc.h cpu.h |
626df76a | 188 | |
1e43adfc | 189 | op.h: op.o $(DYNGEN) |
626df76a FB |
190 | $(DYNGEN) -o $@ $< |
191 | ||
1e43adfc | 192 | opc.h: op.o $(DYNGEN) |
626df76a FB |
193 | $(DYNGEN) -c -o $@ $< |
194 | ||
1e43adfc | 195 | gen-op.h: op.o $(DYNGEN) |
626df76a FB |
196 | $(DYNGEN) -g -o $@ $< |
197 | ||
1e43adfc | 198 | op.o: op.c |
626df76a FB |
199 | $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $< |
200 | ||
1e43adfc | 201 | helper.o: helper.c |
626df76a FB |
202 | $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $< |
203 | ||
1e43adfc FB |
204 | ifeq ($(TARGET_ARCH), i386) |
205 | op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h | |
206 | endif | |
207 | ||
208 | ifeq ($(TARGET_ARCH), arm) | |
209 | op.o: op.c op_template.h | |
210 | endif | |
626df76a | 211 | |
1e43adfc FB |
212 | ifeq ($(TARGET_ARCH), sparc) |
213 | op.o: op.c op_template.h | |
214 | endif | |
626df76a FB |
215 | |
216 | %.o: %.c | |
217 | $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $< | |
218 | ||
219 | clean: | |
1e43adfc FB |
220 | rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h |
221 | ||
222 | install: all | |
223 | install -m 755 -s $(PROGS) $(prefix)/bin | |
626df76a FB |
224 | |
225 | ifneq ($(wildcard .depend),) | |
226 | include .depend | |
227 | endif |