SH usermode fault handling.
[qemu/mini2440.git] / Makefile.target
blob1626833bc03b5a030bf421e977738c70a3bd6eff
1 include config.mak
3 TARGET_BASE_ARCH:=$(TARGET_ARCH)
4 ifeq ($(TARGET_ARCH), x86_64)
5 TARGET_BASE_ARCH:=i386
6 endif
7 ifeq ($(TARGET_ARCH), ppc64)
8 TARGET_BASE_ARCH:=ppc
9 endif
10 ifeq ($(TARGET_ARCH), sparc64)
11 TARGET_BASE_ARCH:=sparc
12 endif
13 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
14 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio
15 DEFINES=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH)
16 ifdef CONFIG_USER_ONLY
17 VPATH+=:$(SRC_PATH)/linux-user
18 DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
19 endif
20 CFLAGS=-Wall -O2 -g -fno-strict-aliasing
21 #CFLAGS+=-Werror
22 LDFLAGS=-g
23 LIBS=
24 HELPER_CFLAGS=$(CFLAGS)
25 DYNGEN=../dyngen$(EXESUF)
26 # user emulator name
27 TARGET_ARCH2=$(TARGET_ARCH)
28 ifeq ($(TARGET_ARCH),arm)
29   ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
30     TARGET_ARCH2=armeb
31   endif
32 endif
33 ifeq ($(TARGET_ARCH),mips)
34   ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
35     TARGET_ARCH2=mipsel
36   endif
37 endif
38 QEMU_USER=qemu-$(TARGET_ARCH2)
39 # system emulator name
40 ifdef CONFIG_SOFTMMU
41 ifeq ($(TARGET_ARCH), i386)
42 QEMU_SYSTEM=qemu$(EXESUF)
43 else
44 QEMU_SYSTEM=qemu-system-$(TARGET_ARCH2)$(EXESUF)
45 endif
46 else
47 QEMU_SYSTEM=qemu-fast
48 endif
50 ifdef CONFIG_USER_ONLY
51 PROGS=$(QEMU_USER)
52 else
53 PROGS+=$(QEMU_SYSTEM)
54 ifndef CONFIG_SOFTMMU
55 CONFIG_STATIC=y
56 endif
57 endif # !CONFIG_USER_ONLY
59 ifdef CONFIG_STATIC
60 LDFLAGS+=-static
61 endif
63 ifeq ($(ARCH),i386)
64 CFLAGS+=-fomit-frame-pointer
65 OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
66 ifeq ($(HAVE_GCC3_OPTIONS),yes)
67 OP_CFLAGS+= -falign-functions=0 -fno-gcse
68 else
69 OP_CFLAGS+= -malign-functions=0
70 endif
72 ifdef TARGET_GPROF
73 USE_I386_LD=y
74 endif
75 ifdef CONFIG_STATIC
76 USE_I386_LD=y
77 endif
78 ifdef USE_I386_LD
79 LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
80 else
81 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
82 # that the kernel ELF loader considers as an executable. I think this
83 # is the simplest way to make it self virtualizable!
84 LDFLAGS+=-Wl,-shared
85 endif
86 endif
88 ifeq ($(ARCH),x86_64)
89 OP_CFLAGS=$(CFLAGS) -falign-functions=0
90 LDFLAGS+=-Wl,-T,$(SRC_PATH)/x86_64.ld
91 endif
93 ifeq ($(ARCH),ppc)
94 CFLAGS+= -D__powerpc__
95 OP_CFLAGS=$(CFLAGS)
96 LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
97 endif
99 ifeq ($(ARCH),s390)
100 OP_CFLAGS=$(CFLAGS)
101 LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
102 endif
104 ifeq ($(ARCH),sparc)
105 ifeq ($(CONFIG_SOLARIS),yes)
106 CFLAGS+=-mcpu=ultrasparc -m32 -ffixed-g2 -ffixed-g3
107 LDFLAGS+=-m32
108 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -fno-omit-frame-pointer -ffixed-i0
109 else
110 CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
111 LDFLAGS+=-m32
112 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
113 HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
114 # -static is used to avoid g1/g3 usage by the dynamic linker
115 LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
116 endif
117 endif
119 ifeq ($(ARCH),sparc64)
120 CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
121 LDFLAGS+=-m64
122 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
123 endif
125 ifeq ($(ARCH),alpha)
126 # -msmall-data is not used because we want two-instruction relocations
127 # for the constant constructions
128 OP_CFLAGS=-Wall -O2 -g
129 # Ensure there's only a single GP
130 CFLAGS += -msmall-data
131 LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
132 endif
134 ifeq ($(ARCH),ia64)
135 CFLAGS += -mno-sdata
136 OP_CFLAGS=$(CFLAGS)
137 LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
138 endif
140 ifeq ($(ARCH),arm)
141 OP_CFLAGS=$(CFLAGS) -mno-sched-prolog -fno-omit-frame-pointer
142 LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
143 endif
145 ifeq ($(ARCH),m68k)
146 OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
147 LDFLAGS+=-Wl,-T,m68k.ld
148 endif
150 ifeq ($(HAVE_GCC3_OPTIONS),yes)
151 # very important to generate a return at the end of every operation
152 OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
153 endif
155 ifeq ($(CONFIG_DARWIN),yes)
156 OP_CFLAGS+= -mdynamic-no-pic
157 LIBS+=-lmx
158 endif
160 #########################################################
162 DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
163 LIBS+=-lm
164 ifndef CONFIG_USER_ONLY
165 LIBS+=-lz
166 endif
167 ifdef CONFIG_WIN32
168 LIBS+=-lwinmm -lws2_32 -liphlpapi
169 endif
170 ifdef CONFIG_SOLARIS
171 LIBS+=-lsocket -lnsl -lresolv
172 endif
174 # profiling code
175 ifdef TARGET_GPROF
176 LDFLAGS+=-p
177 main.o: CFLAGS+=-p
178 endif
180 OBJS= main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o \
181       elfload.o linuxload.o
182 ifdef TARGET_HAS_BFLT
183 OBJS+= flatload.o
184 endif
186 ifeq ($(TARGET_ARCH), i386)
187 OBJS+= vm86.o
188 endif
189 ifeq ($(TARGET_ARCH), arm)
190 OBJS+=nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
191 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
192  nwfpe/double_cpdo.o nwfpe/extended_cpdo.o arm-semi.o
193 endif
194 SRCS:= $(OBJS:.o=.c)
195 OBJS+= libqemu.a
197 # cpu emulator library
198 LIBOBJS=exec.o kqemu.o translate-op.o translate-all.o cpu-exec.o\
199         translate.o op.o 
200 ifdef CONFIG_SOFTFLOAT
201 LIBOBJS+=fpu/softfloat.o
202 else
203 LIBOBJS+=fpu/softfloat-native.o
204 endif
205 DEFINES+=-I$(SRC_PATH)/fpu
207 ifeq ($(TARGET_ARCH), i386)
208 LIBOBJS+=helper.o helper2.o
209 ifeq ($(ARCH), i386)
210 LIBOBJS+=translate-copy.o
211 endif
212 endif
214 ifeq ($(TARGET_ARCH), x86_64)
215 LIBOBJS+=helper.o helper2.o
216 endif
218 ifeq ($(TARGET_BASE_ARCH), ppc)
219 LIBOBJS+= op_helper.o helper.o
220 endif
222 ifeq ($(TARGET_ARCH), mips)
223 LIBOBJS+= op_helper.o helper.o
224 endif
226 ifeq ($(TARGET_BASE_ARCH), sparc)
227 LIBOBJS+= op_helper.o helper.o
228 endif
230 ifeq ($(TARGET_BASE_ARCH), arm)
231 LIBOBJS+= op_helper.o helper.o
232 endif
234 ifeq ($(TARGET_BASE_ARCH), sh4)
235 LIBOBJS+= op_helper.o helper.o
236 endif
238 # NOTE: the disassembler code is only needed for debugging
239 LIBOBJS+=disas.o 
240 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
241 USE_I386_DIS=y
242 endif
243 ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
244 USE_I386_DIS=y
245 endif
246 ifdef USE_I386_DIS
247 LIBOBJS+=i386-dis.o
248 endif
249 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
250 LIBOBJS+=alpha-dis.o
251 endif
252 ifeq ($(findstring ppc, $(TARGET_BASE_ARCH) $(ARCH)),ppc)
253 LIBOBJS+=ppc-dis.o
254 endif
255 ifeq ($(findstring mips, $(TARGET_ARCH) $(ARCH)),mips)
256 LIBOBJS+=mips-dis.o
257 endif
258 ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc)
259 LIBOBJS+=sparc-dis.o
260 endif
261 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
262 LIBOBJS+=arm-dis.o
263 endif
264 ifeq ($(findstring m68k, $(TARGET_ARCH) $(ARCH)),m68k)
265 LIBOBJS+=m68k-dis.o
266 endif
267 ifeq ($(findstring sh4, $(TARGET_ARCH) $(ARCH)),sh4)
268 LIBOBJS+=sh4-dis.o
269 endif
271 ifdef CONFIG_GDBSTUB
272 OBJS+=gdbstub.o
273 endif
275 all: $(PROGS)
277 $(QEMU_USER): $(OBJS)
278         $(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
279 ifeq ($(ARCH),alpha)
280 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
281 # the address space (31 bit so sign extending doesn't matter)
282         echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
283 endif
285 # must use static linking to avoid leaving stuff in virtual address space
286 VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o loader.o
287 VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o
288 ifdef CONFIG_WIN32
289 VL_OBJS+=tap-win32.o
290 endif
292 SOUND_HW = sb16.o es1370.o
293 AUDIODRV = audio.o noaudio.o wavaudio.o
294 ifdef CONFIG_SDL
295 AUDIODRV += sdlaudio.o
296 endif
297 ifdef CONFIG_OSS
298 AUDIODRV += ossaudio.o
299 endif
300 ifdef CONFIG_COREAUDIO
301 AUDIODRV += coreaudio.o
302 endif
303 ifdef CONFIG_ALSA
304 AUDIODRV += alsaaudio.o
305 LIBS += -lasound
306 endif
307 ifdef CONFIG_DSOUND
308 AUDIODRV += dsoundaudio.o
309 LIBS += -lole32 -ldxguid
310 endif
311 ifdef CONFIG_FMOD
312 AUDIODRV += fmodaudio.o
313 audio.o fmodaudio.o: DEFINES := -I$(CONFIG_FMOD_INC) $(DEFINES)
314 LIBS += $(CONFIG_FMOD_LIB)
315 endif
316 ifdef CONFIG_ADLIB
317 SOUND_HW += fmopl.o adlib.o
318 endif
320 # SCSI layer
321 VL_OBJS+= scsi-disk.o cdrom.o lsi53c895a.o
323 # USB layer
324 VL_OBJS+= usb.o usb-hub.o usb-linux.o usb-hid.o usb-ohci.o usb-msd.o
326 # PCI network cards
327 VL_OBJS+= ne2000.o rtl8139.o
329 ifeq ($(TARGET_BASE_ARCH), i386)
330 # Hardware support
331 VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
332 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
333 VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o acpi.o piix_pci.o
334 VL_OBJS+= usb-uhci.o
335 DEFINES += -DHAS_AUDIO
336 endif
337 ifeq ($(TARGET_BASE_ARCH), ppc)
338 VL_OBJS+= ppc.o ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
339 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
340 VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o heathrow_pic.o mixeng.o
341 VL_OBJS+= grackle_pci.o prep_pci.o unin_pci.o
342 DEFINES += -DHAS_AUDIO
343 endif
344 ifeq ($(TARGET_ARCH), mips)
345 VL_OBJS+= mips_r4k.o dma.o vga.o serial.o i8254.o i8259.o
346 #VL_OBJS+= #ide.o pckbd.o fdc.o m48t59.o
347 endif
348 ifeq ($(TARGET_BASE_ARCH), sparc)
349 ifeq ($(TARGET_ARCH), sparc64)
350 VL_OBJS+= sun4u.o ide.o pckbd.o ps2.o vga.o apb_pci.o
351 VL_OBJS+= fdc.o mc146818rtc.o serial.o m48t59.o
352 VL_OBJS+= cirrus_vga.o parallel.o
353 else
354 VL_OBJS+= sun4m.o tcx.o lance.o iommu.o m48t59.o slavio_intctl.o
355 VL_OBJS+= slavio_timer.o slavio_serial.o slavio_misc.o fdc.o esp.o
356 endif
357 endif
358 ifeq ($(TARGET_BASE_ARCH), arm)
359 VL_OBJS+= integratorcp.o versatilepb.o ps2.o smc91c111.o arm_pic.o arm_timer.o
360 VL_OBJS+= arm_boot.o pl011.o pl050.o pl080.o pl110.o pl190.o
361 VL_OBJS+= versatile_pci.o
362 endif
363 ifeq ($(TARGET_BASE_ARCH), sh4)
364 VL_OBJS+= shix.o sh7750.o sh7750_regnames.o tc58128.o
365 endif
366 ifdef CONFIG_GDBSTUB
367 VL_OBJS+=gdbstub.o 
368 endif
369 ifdef CONFIG_SDL
370 VL_OBJS+=sdl.o
371 endif
372 VL_OBJS+=vnc.o
373 ifdef CONFIG_COCOA
374 VL_OBJS+=cocoa.o
375 COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa -framework IOKit
376 ifdef CONFIG_COREAUDIO
377 COCOA_LIBS+=-framework CoreAudio
378 endif
379 endif
380 ifdef CONFIG_SLIRP
381 DEFINES+=-I$(SRC_PATH)/slirp
382 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
383 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
384 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
385 VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
386 endif
388 VL_LDFLAGS=
389 # specific flags are needed for non soft mmu emulator
390 ifdef CONFIG_STATIC
391 VL_LDFLAGS+=-static
392 endif
393 ifndef CONFIG_SOFTMMU
394 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld 
395 endif
396 ifndef CONFIG_DARWIN
397 ifndef CONFIG_WIN32
398 ifndef CONFIG_SOLARIS
399 VL_LIBS=-lutil
400 endif
401 endif
402 endif
403 ifdef TARGET_GPROF
404 vl.o: CFLAGS+=-p
405 VL_LDFLAGS+=-p
406 endif
408 ifeq ($(ARCH),ia64)
409 VL_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
410 endif
412 ifdef CONFIG_WIN32
413 SDL_LIBS := $(filter-out -mwindows, $(SDL_LIBS)) -mconsole
414 endif
416 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
417         $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS)
419 cocoa.o: cocoa.m
420         $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
422 sdl.o: sdl.c keymaps.c sdl_keysym.h
423         $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
425 vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h
426         $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
428 sdlaudio.o: sdlaudio.c
429         $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
431 depend: $(SRCS)
432         $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
434 vldepend: $(VL_OBJS:.o=.c)
435         $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
437 # libqemu 
439 libqemu.a: $(LIBOBJS)
440         rm -f $@
441         $(AR) rcs $@ $(LIBOBJS)
443 translate.o: translate.c gen-op.h opc.h cpu.h
445 translate-all.o: translate-all.c opc.h cpu.h
447 translate-op.o: translate-all.c op.h opc.h cpu.h
449 op.h: op.o $(DYNGEN)
450         $(DYNGEN) -o $@ $<
452 opc.h: op.o $(DYNGEN)
453         $(DYNGEN) -c -o $@ $<
455 gen-op.h: op.o $(DYNGEN)
456         $(DYNGEN) -g -o $@ $<
458 op.o: op.c
459         $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
461 helper.o: helper.c
462         $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
464 ifeq ($(TARGET_BASE_ARCH), i386)
465 op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h ops_sse.h
466 endif
468 ifeq ($(TARGET_ARCH), arm)
469 op.o: op.c op_template.h
470 pl110.o: pl110_template.h
471 endif
473 ifeq ($(TARGET_BASE_ARCH), sparc)
474 op.o: op.c op_template.h op_mem.h fop_template.h fbranch_template.h
475 magic_load.o: elf_op.h
476 endif
478 ifeq ($(TARGET_BASE_ARCH), ppc)
479 op.o: op.c op_template.h op_mem.h
480 op_helper.o: op_helper_mem.h
481 translate.o: translate.c translate_init.c
482 endif
484 ifeq ($(TARGET_ARCH), mips)
485 op.o: op.c op_template.c op_mem.c
486 op_helper.o: op_helper_mem.c
487 endif
489 loader.o: loader.c elf_ops.h
491 acpi.o: acpi.c acpi-dsdt.hex
493 ifdef BUILD_ACPI_TABLES
494 $(SRC_PATH)/hw/acpi-dsdt.hex: acpi-dsdt.dsl
495         iasl -tc -p $@ $<
496 endif
498 ifeq ($(TARGET_ARCH), sh4)
499 op.o: op.c op_mem.c cpu.h
500 op_helper.o: op_helper.c exec.h cpu.h
501 helper.o: helper.c exec.h cpu.h
502 sh7750.o: sh7750.c sh7750_regs.h sh7750_regnames.h cpu.h
503 shix.o: shix.c sh7750_regs.h sh7750_regnames.h
504 sh7750_regnames.o: sh7750_regnames.c sh7750_regnames.h sh7750_regs.h
505 tc58128.o: tc58128.c
506 endif
508 $(OBJS) $(LIBOBJS) $(VL_OBJS): config.h ../config-host.h
510 %.o: %.c
511         $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
513 %.o: %.S
514         $(CC) $(DEFINES) -c -o $@ $<
516 clean:
517         rm -f *.o  *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o
519 install: all 
520 ifneq ($(PROGS),)
521         $(INSTALL) -m 755 -s $(PROGS) "$(DESTDIR)$(bindir)"
522 endif
524 ifneq ($(wildcard .depend),)
525 include .depend
526 endif
528 ifeq (1, 0)
529 audio.o sdlaudio.o dsoundaudio.o ossaudio.o wavaudio.o noaudio.o \
530 fmodaudio.o alsaaudio.o mixeng.o sb16.o es1370.o gus.o adlib.o: \
531 CFLAGS := $(CFLAGS) -Wall -Werror -W -Wsign-compare
532 endif