PowerPC system emulation fixes (Jocelyn Mayer)
[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
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 endif # TARGET_ARCH = ppc
60 endif # !CONFIG_USER_ONLY
61
62 ifdef CONFIG_STATIC
63 LDFLAGS+=-static
64 endif
65
66 ifeq ($(ARCH),i386)
67 CFLAGS+=-fomit-frame-pointer
68 OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
69 ifeq ($(HAVE_GCC3_OPTIONS),yes)
70 OP_CFLAGS+= -falign-functions=0
71 else
72 OP_CFLAGS+= -malign-functions=0
73 endif
74
75 ifdef TARGET_GPROF
76 USE_I386_LD=y
77 endif
78 ifdef CONFIG_STATIC
79 USE_I386_LD=y
80 endif
81 ifdef USE_I386_LD
82 LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
83 else
84 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
85 # that the kernel ELF loader considers as an executable. I think this
86 # is the simplest way to make it self virtualizable!
87 LDFLAGS+=-Wl,-shared
88 endif
89 endif
90
91 ifeq ($(ARCH),amd64)
92 OP_CFLAGS=$(CFLAGS) -falign-functions=0
93 LDFLAGS+=-Wl,-T,$(SRC_PATH)/amd64.ld
94 endif
95
96 ifeq ($(ARCH),ppc)
97 OP_CFLAGS=$(CFLAGS)
98 LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
99 endif
100
101 ifeq ($(ARCH),s390)
102 OP_CFLAGS=$(CFLAGS)
103 LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
104 endif
105
106 ifeq ($(ARCH),sparc)
107 CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
108 LDFLAGS+=-m32
109 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
110 HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
111 # -static is used to avoid g1/g3 usage by the dynamic linker
112 LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
113 endif
114
115 ifeq ($(ARCH),sparc64)
116 CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
117 LDFLAGS+=-m64
118 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
119 endif
120
121 ifeq ($(ARCH),alpha)
122 # -msmall-data is not used because we want two-instruction relocations
123 # for the constant constructions
124 OP_CFLAGS=-Wall -O2 -g
125 # Ensure there's only a single GP
126 CFLAGS += -msmall-data
127 LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
128 endif
129
130 ifeq ($(ARCH),ia64)
131 OP_CFLAGS=$(CFLAGS)
132 endif
133
134 ifeq ($(ARCH),arm)
135 OP_CFLAGS=$(CFLAGS) -mno-sched-prolog
136 LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
137 endif
138
139 ifeq ($(ARCH),m68k)
140 OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
141 LDFLAGS+=-Wl,-T,m68k.ld
142 endif
143
144 ifeq ($(HAVE_GCC3_OPTIONS),yes)
145 # very important to generate a return at the end of every operation
146 OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
147 endif
148
149 #########################################################
150
151 DEFINES+=-D_GNU_SOURCE
152 LIBS+=-lm
153 ifdef CONFIG_WIN32
154 LIBS+=-lwinmm
155 endif
156
157 # profiling code
158 ifdef TARGET_GPROF
159 LDFLAGS+=-p
160 main.o: CFLAGS+=-p
161 endif
162
163 OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o 
164 ifeq ($(TARGET_ARCH), i386)
165 OBJS+= vm86.o
166 endif
167 ifeq ($(TARGET_ARCH), arm)
168 OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
169 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
170  nwfpe/double_cpdo.o nwfpe/extended_cpdo.o
171 endif
172 SRCS:= $(OBJS:.o=.c)
173 OBJS+= libqemu.a
174
175 # cpu emulator library
176 LIBOBJS=exec.o translate-all.o cpu-exec.o\
177         translate.o op.o
178
179 ifeq ($(TARGET_ARCH), i386)
180 LIBOBJS+=helper.o helper2.o
181 ifeq ($(ARCH), i386)
182 LIBOBJS+=translate-copy.o
183 endif
184 endif
185
186 ifeq ($(TARGET_ARCH), ppc)
187 LIBOBJS+= op_helper.o helper.o
188 endif
189
190 # NOTE: the disassembler code is only needed for debugging
191 LIBOBJS+=disas.o 
192 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
193 USE_I386_DIS=y
194 endif
195 ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64)
196 USE_I386_DIS=y
197 endif
198 ifdef USE_I386_DIS
199 LIBOBJS+=i386-dis.o
200 endif
201 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
202 LIBOBJS+=alpha-dis.o
203 endif
204 ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
205 LIBOBJS+=ppc-dis.o
206 endif
207 ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
208 LIBOBJS+=sparc-dis.o
209 endif
210 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
211 LIBOBJS+=arm-dis.o
212 endif
213
214 ifeq ($(ARCH),ia64)
215 OBJS += ia64-syscall.o
216 endif
217
218 all: $(PROGS)
219
220 $(QEMU_USER): $(OBJS)
221         $(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
222 ifeq ($(ARCH),alpha)
223 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
224 # the address space (31 bit so sign extending doesn't matter)
225         echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
226 endif
227
228 # must use static linking to avoid leaving stuff in virtual address space
229 VL_OBJS=vl.o osdep.o block.o monitor.o
230
231 ifeq ($(TARGET_ARCH), i386)
232 # Hardware support
233 VL_OBJS+= ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o
234 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
235 endif
236 ifeq ($(TARGET_ARCH), ppc)
237 # Generic PPC support
238 VL_OBJS+= ppc.o
239 # PREP hardware support
240 VL_OBJS+= ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o
241 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o ppc_prep.o
242 #VL_OBJS+= hw.o of.o setup.o
243 endif
244 ifdef CONFIG_GDBSTUB
245 VL_OBJS+=gdbstub.o 
246 endif
247 ifdef CONFIG_SDL
248 VL_OBJS+=sdl.o
249 ifdef CONFIG_STATIC
250 SDL_LIBS:=$(SDL_STATIC_LIBS)
251 endif
252 endif
253
254 VL_LDFLAGS=
255 # specific flags are needed for non soft mmu emulator
256 ifdef CONFIG_STATIC
257 VL_LDFLAGS+=-static
258 endif
259 ifndef CONFIG_SOFTMMU
260 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld 
261 endif
262 ifndef CONFIG_WIN32
263 VL_LIBS=-lutil
264 endif
265
266 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
267         $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS)
268
269 sdl.o: sdl.c
270         $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
271
272 depend: $(SRCS)
273         $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
274
275 # libqemu 
276
277 libqemu.a: $(LIBOBJS)
278         rm -f $@
279         $(AR) rcs $@ $(LIBOBJS)
280
281 translate.o: translate.c gen-op.h opc.h cpu.h
282
283 translate-all.o: translate-all.c op.h opc.h cpu.h
284
285 op.h: op.o $(DYNGEN)
286         $(DYNGEN) -o $@ $<
287
288 opc.h: op.o $(DYNGEN)
289         $(DYNGEN) -c -o $@ $<
290
291 gen-op.h: op.o $(DYNGEN)
292         $(DYNGEN) -g -o $@ $<
293
294 op.o: op.c
295         $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
296
297 helper.o: helper.c
298         $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
299
300 ifeq ($(TARGET_ARCH), i386)
301 op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h
302 endif
303
304 ifeq ($(TARGET_ARCH), arm)
305 op.o: op.c op_template.h
306 endif
307
308 ifeq ($(TARGET_ARCH), sparc)
309 op.o: op.c op_template.h
310 endif
311
312 ifeq ($(TARGET_ARCH), ppc)
313 op.o: op.c op_template.h op_mem.h
314 op_helper.o: op_helper_mem.h
315 endif
316
317 %.o: %.c
318         $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
319
320 %.o: %.S
321         $(CC) $(DEFINES) -c -o $@ $<
322
323 clean:
324         rm -f *.o  *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o
325
326 install: all 
327 ifneq ($(PROGS),)
328         install -m 755 -s $(PROGS) "$(bindir)"
329 endif
330
331 ifneq ($(wildcard .depend),)
332 include .depend
333 endif