virtual console support - slirp for win32 support
[qemu] / Makefile.target
1 include config.mak
2
3 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH)
4 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw
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
10 CFLAGS=-Wall -O2 -g -fno-strict-aliasing
11 LDFLAGS=-g
12 LIBS=
13 HELPER_CFLAGS=$(CFLAGS)
14 DYNGEN=../dyngen$(EXESUF)
15 # user emulator name
16 QEMU_USER=qemu-$(TARGET_ARCH)
17 # system emulator name
18 ifdef CONFIG_SOFTMMU
19 ifeq ($(TARGET_ARCH), i386)
20 QEMU_SYSTEM=qemu$(EXESUF)
21 else
22 QEMU_SYSTEM=qemu-system-$(TARGET_ARCH)$(EXESUF)
23 endif
24 else
25 QEMU_SYSTEM=qemu-fast
26 endif
27
28 ifdef CONFIG_USER_ONLY
29 PROGS=$(QEMU_USER)
30 else
31 ifeq ($(TARGET_ARCH), i386)
32
33 ifeq ($(ARCH), i386)
34 PROGS+=$(QEMU_SYSTEM)
35 ifndef CONFIG_SOFTMMU
36 CONFIG_STATIC=y
37 endif
38 else
39 # the system emulator using soft mmu is portable
40 ifdef CONFIG_SOFTMMU
41 PROGS+=$(QEMU_SYSTEM)
42 endif
43 endif # ARCH != i386
44
45 endif # TARGET_ARCH = i386
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)
56 endif
57 endif # ARCH = i386
58
59 ifeq ($(ARCH), amd64)
60 ifdef CONFIG_SOFTMMU
61 PROGS+=$(QEMU_SYSTEM)
62 endif
63 endif # ARCH = amd64
64
65 endif # TARGET_ARCH = ppc
66 endif # !CONFIG_USER_ONLY
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
80
81 ifdef TARGET_GPROF
82 USE_I386_LD=y
83 endif
84 ifdef CONFIG_STATIC
85 USE_I386_LD=y
86 endif
87 ifdef USE_I386_LD
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
95 endif
96
97 ifeq ($(ARCH),amd64)
98 OP_CFLAGS=$(CFLAGS) -falign-functions=0
99 LDFLAGS+=-Wl,-T,$(SRC_PATH)/amd64.ld
100 endif
101
102 ifeq ($(ARCH),ppc)
103 CFLAGS+= -D__powerpc__
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
146 ifeq ($(ARCH),m68k)
147 OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
148 LDFLAGS+=-Wl,-T,m68k.ld
149 endif
150
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
156 ifeq ($(CONFIG_DARWIN),yes)
157 OP_CFLAGS+= -mdynamic-no-pic
158 endif
159
160 #########################################################
161
162 DEFINES+=-D_GNU_SOURCE
163 LIBS+=-lm
164 ifdef CONFIG_WIN32
165 LIBS+=-lwinmm -lws2_32 -liphlpapi
166 endif
167
168 # profiling code
169 ifdef TARGET_GPROF
170 LDFLAGS+=-p
171 main.o: CFLAGS+=-p
172 endif
173
174 OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o 
175 ifeq ($(TARGET_ARCH), i386)
176 OBJS+= vm86.o
177 endif
178 ifeq ($(TARGET_ARCH), arm)
179 OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
180 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
181  nwfpe/double_cpdo.o nwfpe/extended_cpdo.o
182 endif
183 SRCS:= $(OBJS:.o=.c)
184 OBJS+= libqemu.a
185
186 # cpu emulator library
187 LIBOBJS=exec.o translate-all.o cpu-exec.o\
188         translate.o op.o
189
190 ifeq ($(TARGET_ARCH), i386)
191 LIBOBJS+=helper.o helper2.o
192 ifeq ($(ARCH), i386)
193 LIBOBJS+=translate-copy.o
194 endif
195 endif
196
197 ifeq ($(TARGET_ARCH), ppc)
198 LIBOBJS+= op_helper.o helper.o
199 endif
200
201 # NOTE: the disassembler code is only needed for debugging
202 LIBOBJS+=disas.o 
203 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
204 USE_I386_DIS=y
205 endif
206 ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64)
207 USE_I386_DIS=y
208 endif
209 ifdef USE_I386_DIS
210 LIBOBJS+=i386-dis.o
211 endif
212 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
213 LIBOBJS+=alpha-dis.o
214 endif
215 ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
216 LIBOBJS+=ppc-dis.o
217 endif
218 ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
219 LIBOBJS+=sparc-dis.o
220 endif
221 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
222 LIBOBJS+=arm-dis.o
223 endif
224
225 ifeq ($(ARCH),ia64)
226 OBJS += ia64-syscall.o
227 endif
228
229 all: $(PROGS)
230
231 $(QEMU_USER): $(OBJS)
232         $(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
233 ifeq ($(ARCH),alpha)
234 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
235 # the address space (31 bit so sign extending doesn't matter)
236         echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
237 endif
238
239 # must use static linking to avoid leaving stuff in virtual address space
240 VL_OBJS=vl.o osdep.o block.o monitor.o pci.o console.o
241
242 ifeq ($(TARGET_ARCH), i386)
243 # Hardware support
244 VL_OBJS+= ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o
245 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o 
246 VL_OBJS+= cirrus_vga.o
247 endif
248 ifeq ($(TARGET_ARCH), ppc)
249 VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o
250 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
251 VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o
252 endif
253 ifdef CONFIG_GDBSTUB
254 VL_OBJS+=gdbstub.o 
255 endif
256 ifdef CONFIG_SDL
257 VL_OBJS+=sdl.o
258 endif
259 ifdef CONFIG_SLIRP
260 DEFINES+=-I$(SRC_PATH)/slirp
261 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
262 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
263 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o
264 VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
265 endif
266
267 VL_LDFLAGS=
268 # specific flags are needed for non soft mmu emulator
269 ifdef CONFIG_STATIC
270 VL_LDFLAGS+=-static
271 endif
272 ifndef CONFIG_SOFTMMU
273 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld 
274 endif
275 ifndef CONFIG_DARWIN
276 ifndef CONFIG_WIN32
277 VL_LIBS=-lutil
278 endif
279 endif
280
281 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
282         $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS)
283
284 sdl.o: sdl.c
285         $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
286
287 depend: $(SRCS)
288         $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
289
290 # libqemu 
291
292 libqemu.a: $(LIBOBJS)
293         rm -f $@
294         $(AR) rcs $@ $(LIBOBJS)
295
296 translate.o: translate.c gen-op.h opc.h cpu.h
297
298 translate-all.o: translate-all.c op.h opc.h cpu.h
299
300 op.h: op.o $(DYNGEN)
301         $(DYNGEN) -o $@ $<
302
303 opc.h: op.o $(DYNGEN)
304         $(DYNGEN) -c -o $@ $<
305
306 gen-op.h: op.o $(DYNGEN)
307         $(DYNGEN) -g -o $@ $<
308
309 op.o: op.c
310         $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
311
312 helper.o: helper.c
313         $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
314
315 ifeq ($(TARGET_ARCH), i386)
316 op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h
317 endif
318
319 ifeq ($(TARGET_ARCH), arm)
320 op.o: op.c op_template.h
321 endif
322
323 ifeq ($(TARGET_ARCH), sparc)
324 op.o: op.c op_template.h
325 endif
326
327 ifeq ($(TARGET_ARCH), ppc)
328 op.o: op.c op_template.h op_mem.h
329 op_helper.o: op_helper_mem.h
330 endif
331
332 %.o: %.c
333         $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
334
335 %.o: %.S
336         $(CC) $(DEFINES) -c -o $@ $<
337
338 clean:
339         rm -f *.o  *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o
340
341 install: all 
342 ifneq ($(PROGS),)
343         install -m 755 -s $(PROGS) "$(bindir)"
344 endif
345
346 ifneq ($(wildcard .depend),)
347 include .depend
348 endif