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