]>
Commit | Line | Data |
---|---|---|
626df76a FB |
1 | include config.mak |
2 | ||
1e43adfc | 3 | TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH) |
80cabfad | 4 | VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw |
3035f7ff FB |
5 | DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH) |
6 | ifdef CONFIG_USER_ONLY | |
7 | VPATH+=:$(SRC_PATH)/linux-user | |
8 | DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH) | |
9 | endif | |
ab2572d7 | 10 | CFLAGS=-Wall -O2 -g -fno-strict-aliasing |
626df76a FB |
11 | LDFLAGS=-g |
12 | LIBS= | |
626df76a | 13 | HELPER_CFLAGS=$(CFLAGS) |
67b915a5 | 14 | DYNGEN=../dyngen$(EXESUF) |
1e43adfc FB |
15 | # user emulator name |
16 | QEMU_USER=qemu-$(TARGET_ARCH) | |
17 | # system emulator name | |
18 | ifdef CONFIG_SOFTMMU | |
a541f297 | 19 | ifeq ($(TARGET_ARCH), i386) |
67b915a5 | 20 | QEMU_SYSTEM=qemu$(EXESUF) |
0db63474 | 21 | else |
a541f297 FB |
22 | QEMU_SYSTEM=qemu-system-$(TARGET_ARCH)$(EXESUF) |
23 | endif | |
24 | else | |
0db63474 | 25 | QEMU_SYSTEM=qemu-fast |
1e43adfc FB |
26 | endif |
27 | ||
16e9b7de | 28 | ifdef CONFIG_USER_ONLY |
1e43adfc | 29 | PROGS=$(QEMU_USER) |
16e9b7de | 30 | else |
16e9b7de | 31 | ifeq ($(TARGET_ARCH), i386) |
c321f673 FB |
32 | |
33 | ifeq ($(ARCH), i386) | |
34 | PROGS+=$(QEMU_SYSTEM) | |
de5eaa64 FB |
35 | ifndef CONFIG_SOFTMMU |
36 | CONFIG_STATIC=y | |
37 | endif | |
38ca2abc FB |
38 | else |
39 | # the system emulator using soft mmu is portable | |
c321f673 | 40 | ifdef CONFIG_SOFTMMU |
16e9b7de FB |
41 | PROGS+=$(QEMU_SYSTEM) |
42 | endif | |
38ca2abc | 43 | endif # ARCH != i386 |
c321f673 | 44 | |
38ca2abc | 45 | endif # TARGET_ARCH = i386 |
728c9fd5 FB |
46 | |
47 | ifeq ($(TARGET_ARCH), ppc) | |
48 | ||
49 | ifeq ($(ARCH), ppc) | |
50 | PROGS+=$(QEMU_SYSTEM) | |
51 | endif | |
52 | ||
53 | ifeq ($(ARCH), i386) | |
54 | ifdef CONFIG_SOFTMMU | |
55 | PROGS+=$(QEMU_SYSTEM) | |
626df76a | 56 | endif |
728c9fd5 FB |
57 | endif # ARCH = i386 |
58 | ||
75dfaa1e FB |
59 | ifeq ($(ARCH), amd64) |
60 | ifdef CONFIG_SOFTMMU | |
61 | PROGS+=$(QEMU_SYSTEM) | |
62 | endif | |
63 | endif # ARCH = amd64 | |
64 | ||
728c9fd5 FB |
65 | endif # TARGET_ARCH = ppc |
66 | endif # !CONFIG_USER_ONLY | |
626df76a FB |
67 | |
68 | ifdef CONFIG_STATIC | |
69 | LDFLAGS+=-static | |
70 | endif | |
71 | ||
72 | ifeq ($(ARCH),i386) | |
73 | CFLAGS+=-fomit-frame-pointer | |
74 | OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2 | |
75 | ifeq ($(HAVE_GCC3_OPTIONS),yes) | |
76 | OP_CFLAGS+= -falign-functions=0 | |
77 | else | |
78 | OP_CFLAGS+= -malign-functions=0 | |
79 | endif | |
3a4739d6 | 80 | |
626df76a | 81 | ifdef TARGET_GPROF |
3a4739d6 FB |
82 | USE_I386_LD=y |
83 | endif | |
84 | ifdef CONFIG_STATIC | |
85 | USE_I386_LD=y | |
86 | endif | |
87 | ifdef USE_I386_LD | |
626df76a FB |
88 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld |
89 | else | |
90 | # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object | |
91 | # that the kernel ELF loader considers as an executable. I think this | |
92 | # is the simplest way to make it self virtualizable! | |
93 | LDFLAGS+=-Wl,-shared | |
94 | endif | |
626df76a FB |
95 | endif |
96 | ||
bc51c5c9 FB |
97 | ifeq ($(ARCH),amd64) |
98 | OP_CFLAGS=$(CFLAGS) -falign-functions=0 | |
99 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/amd64.ld | |
100 | endif | |
101 | ||
626df76a | 102 | ifeq ($(ARCH),ppc) |
83fb7adf | 103 | CFLAGS+= -D__powerpc__ |
626df76a FB |
104 | OP_CFLAGS=$(CFLAGS) |
105 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld | |
106 | endif | |
107 | ||
108 | ifeq ($(ARCH),s390) | |
109 | OP_CFLAGS=$(CFLAGS) | |
110 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld | |
111 | endif | |
112 | ||
113 | ifeq ($(ARCH),sparc) | |
114 | CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6 | |
115 | LDFLAGS+=-m32 | |
116 | OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0 | |
117 | HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat | |
118 | # -static is used to avoid g1/g3 usage by the dynamic linker | |
119 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static | |
120 | endif | |
121 | ||
122 | ifeq ($(ARCH),sparc64) | |
123 | CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6 | |
124 | LDFLAGS+=-m64 | |
125 | OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0 | |
126 | endif | |
127 | ||
128 | ifeq ($(ARCH),alpha) | |
129 | # -msmall-data is not used because we want two-instruction relocations | |
130 | # for the constant constructions | |
131 | OP_CFLAGS=-Wall -O2 -g | |
132 | # Ensure there's only a single GP | |
133 | CFLAGS += -msmall-data | |
134 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld | |
135 | endif | |
136 | ||
137 | ifeq ($(ARCH),ia64) | |
138 | OP_CFLAGS=$(CFLAGS) | |
139 | endif | |
140 | ||
141 | ifeq ($(ARCH),arm) | |
142 | OP_CFLAGS=$(CFLAGS) -mno-sched-prolog | |
143 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld | |
144 | endif | |
145 | ||
38e584a0 FB |
146 | ifeq ($(ARCH),m68k) |
147 | OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer | |
148 | LDFLAGS+=-Wl,-T,m68k.ld | |
149 | endif | |
150 | ||
626df76a FB |
151 | ifeq ($(HAVE_GCC3_OPTIONS),yes) |
152 | # very important to generate a return at the end of every operation | |
153 | OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls | |
154 | endif | |
155 | ||
83fb7adf FB |
156 | ifeq ($(CONFIG_DARWIN),yes) |
157 | OP_CFLAGS+= -mdynamic-no-pic | |
158 | endif | |
159 | ||
626df76a FB |
160 | ######################################################### |
161 | ||
162 | DEFINES+=-D_GNU_SOURCE | |
163 | LIBS+=-lm | |
b932caba FB |
164 | ifndef CONFIG_USER_ONLY |
165 | LIBS+=-lz | |
166 | endif | |
67b915a5 | 167 | ifdef CONFIG_WIN32 |
3db38e87 | 168 | LIBS+=-lwinmm -lws2_32 -liphlpapi |
67b915a5 | 169 | endif |
626df76a FB |
170 | |
171 | # profiling code | |
172 | ifdef TARGET_GPROF | |
173 | LDFLAGS+=-p | |
174 | main.o: CFLAGS+=-p | |
175 | endif | |
176 | ||
3035f7ff | 177 | OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o |
626df76a FB |
178 | ifeq ($(TARGET_ARCH), i386) |
179 | OBJS+= vm86.o | |
180 | endif | |
f72b519c FB |
181 | ifeq ($(TARGET_ARCH), arm) |
182 | OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \ | |
183 | nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \ | |
184 | nwfpe/double_cpdo.o nwfpe/extended_cpdo.o | |
185 | endif | |
626df76a FB |
186 | SRCS:= $(OBJS:.o=.c) |
187 | OBJS+= libqemu.a | |
188 | ||
189 | # cpu emulator library | |
858693c6 | 190 | LIBOBJS=exec.o translate-all.o cpu-exec.o\ |
1e43adfc | 191 | translate.o op.o |
626df76a FB |
192 | |
193 | ifeq ($(TARGET_ARCH), i386) | |
1e43adfc | 194 | LIBOBJS+=helper.o helper2.o |
f72b519c FB |
195 | ifeq ($(ARCH), i386) |
196 | LIBOBJS+=translate-copy.o | |
197 | endif | |
626df76a FB |
198 | endif |
199 | ||
67867308 | 200 | ifeq ($(TARGET_ARCH), ppc) |
728c9fd5 | 201 | LIBOBJS+= op_helper.o helper.o |
67867308 FB |
202 | endif |
203 | ||
626df76a FB |
204 | # NOTE: the disassembler code is only needed for debugging |
205 | LIBOBJS+=disas.o | |
206 | ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386) | |
bc51c5c9 FB |
207 | USE_I386_DIS=y |
208 | endif | |
209 | ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64) | |
210 | USE_I386_DIS=y | |
211 | endif | |
212 | ifdef USE_I386_DIS | |
626df76a FB |
213 | LIBOBJS+=i386-dis.o |
214 | endif | |
215 | ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha) | |
216 | LIBOBJS+=alpha-dis.o | |
217 | endif | |
218 | ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc) | |
219 | LIBOBJS+=ppc-dis.o | |
220 | endif | |
221 | ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc) | |
222 | LIBOBJS+=sparc-dis.o | |
223 | endif | |
224 | ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm) | |
225 | LIBOBJS+=arm-dis.o | |
226 | endif | |
227 | ||
228 | ifeq ($(ARCH),ia64) | |
229 | OBJS += ia64-syscall.o | |
230 | endif | |
231 | ||
1e43adfc | 232 | all: $(PROGS) |
626df76a | 233 | |
1e43adfc | 234 | $(QEMU_USER): $(OBJS) |
626df76a FB |
235 | $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) |
236 | ifeq ($(ARCH),alpha) | |
237 | # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of | |
238 | # the address space (31 bit so sign extending doesn't matter) | |
239 | echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc | |
240 | endif | |
241 | ||
242 | # must use static linking to avoid leaving stuff in virtual address space | |
b932caba FB |
243 | VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o |
244 | VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o | |
a541f297 FB |
245 | |
246 | ifeq ($(TARGET_ARCH), i386) | |
247 | # Hardware support | |
248 | VL_OBJS+= ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o | |
d6bfa22f FB |
249 | VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o |
250 | VL_OBJS+= cirrus_vga.o | |
67b915a5 | 251 | endif |
728c9fd5 | 252 | ifeq ($(TARGET_ARCH), ppc) |
95ea3fa1 | 253 | VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o |
64201201 | 254 | VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o |
95ea3fa1 | 255 | VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o |
a541f297 FB |
256 | endif |
257 | ifdef CONFIG_GDBSTUB | |
258 | VL_OBJS+=gdbstub.o | |
728c9fd5 | 259 | endif |
626df76a FB |
260 | ifdef CONFIG_SDL |
261 | VL_OBJS+=sdl.o | |
de5eaa64 | 262 | endif |
7c1f25b4 FB |
263 | ifdef CONFIG_SLIRP |
264 | DEFINES+=-I$(SRC_PATH)/slirp | |
265 | SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \ | |
266 | slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \ | |
267 | tcp_subr.o tcp_timer.o udp.o bootp.o debug.o | |
268 | VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS)) | |
626df76a FB |
269 | endif |
270 | ||
c321f673 FB |
271 | VL_LDFLAGS= |
272 | # specific flags are needed for non soft mmu emulator | |
c321f673 FB |
273 | ifdef CONFIG_STATIC |
274 | VL_LDFLAGS+=-static | |
275 | endif | |
de5eaa64 FB |
276 | ifndef CONFIG_SOFTMMU |
277 | VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld | |
278 | endif | |
83fb7adf | 279 | ifndef CONFIG_DARWIN |
11d9f695 FB |
280 | ifndef CONFIG_WIN32 |
281 | VL_LIBS=-lutil | |
282 | endif | |
83fb7adf | 283 | endif |
c321f673 | 284 | |
1e43adfc | 285 | $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a |
11d9f695 | 286 | $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS) |
626df76a FB |
287 | |
288 | sdl.o: sdl.c | |
289 | $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $< | |
290 | ||
291 | depend: $(SRCS) | |
16e9b7de | 292 | $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend |
626df76a FB |
293 | |
294 | # libqemu | |
295 | ||
296 | libqemu.a: $(LIBOBJS) | |
297 | rm -f $@ | |
298 | $(AR) rcs $@ $(LIBOBJS) | |
299 | ||
1e43adfc | 300 | translate.o: translate.c gen-op.h opc.h cpu.h |
626df76a | 301 | |
1e43adfc | 302 | translate-all.o: translate-all.c op.h opc.h cpu.h |
626df76a | 303 | |
1e43adfc | 304 | op.h: op.o $(DYNGEN) |
626df76a FB |
305 | $(DYNGEN) -o $@ $< |
306 | ||
1e43adfc | 307 | opc.h: op.o $(DYNGEN) |
626df76a FB |
308 | $(DYNGEN) -c -o $@ $< |
309 | ||
1e43adfc | 310 | gen-op.h: op.o $(DYNGEN) |
626df76a FB |
311 | $(DYNGEN) -g -o $@ $< |
312 | ||
1e43adfc | 313 | op.o: op.c |
626df76a FB |
314 | $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $< |
315 | ||
1e43adfc | 316 | helper.o: helper.c |
626df76a FB |
317 | $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $< |
318 | ||
1e43adfc FB |
319 | ifeq ($(TARGET_ARCH), i386) |
320 | op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h | |
321 | endif | |
322 | ||
323 | ifeq ($(TARGET_ARCH), arm) | |
324 | op.o: op.c op_template.h | |
325 | endif | |
626df76a | 326 | |
1e43adfc FB |
327 | ifeq ($(TARGET_ARCH), sparc) |
328 | op.o: op.c op_template.h | |
329 | endif | |
626df76a | 330 | |
728c9fd5 FB |
331 | ifeq ($(TARGET_ARCH), ppc) |
332 | op.o: op.c op_template.h op_mem.h | |
333 | op_helper.o: op_helper_mem.h | |
334 | endif | |
335 | ||
626df76a FB |
336 | %.o: %.c |
337 | $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $< | |
338 | ||
f72b519c FB |
339 | %.o: %.S |
340 | $(CC) $(DEFINES) -c -o $@ $< | |
341 | ||
626df76a | 342 | clean: |
7c1f25b4 | 343 | rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o |
1e43adfc FB |
344 | |
345 | install: all | |
9b14bb04 | 346 | ifneq ($(PROGS),) |
11d9f695 | 347 | install -m 755 -s $(PROGS) "$(bindir)" |
9b14bb04 | 348 | endif |
626df76a FB |
349 | |
350 | ifneq ($(wildcard .depend),) | |
351 | include .depend | |
352 | endif |