]>
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 | |
626df76a FB |
10 | CFLAGS=-Wall -O2 -g |
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 | ||
59 | endif # TARGET_ARCH = ppc | |
60 | endif # !CONFIG_USER_ONLY | |
626df76a FB |
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 | |
3a4739d6 | 74 | |
626df76a | 75 | ifdef TARGET_GPROF |
3a4739d6 FB |
76 | USE_I386_LD=y |
77 | endif | |
78 | ifdef CONFIG_STATIC | |
79 | USE_I386_LD=y | |
80 | endif | |
81 | ifdef USE_I386_LD | |
626df76a FB |
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 | |
626df76a FB |
89 | endif |
90 | ||
bc51c5c9 FB |
91 | ifeq ($(ARCH),amd64) |
92 | OP_CFLAGS=$(CFLAGS) -falign-functions=0 | |
93 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/amd64.ld | |
94 | endif | |
95 | ||
626df76a FB |
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 | ||
38e584a0 FB |
139 | ifeq ($(ARCH),m68k) |
140 | OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer | |
141 | LDFLAGS+=-Wl,-T,m68k.ld | |
142 | endif | |
143 | ||
626df76a FB |
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 | |
67b915a5 FB |
153 | ifdef CONFIG_WIN32 |
154 | LIBS+=-lwinmm | |
155 | endif | |
626df76a FB |
156 | |
157 | # profiling code | |
158 | ifdef TARGET_GPROF | |
159 | LDFLAGS+=-p | |
160 | main.o: CFLAGS+=-p | |
161 | endif | |
162 | ||
3035f7ff | 163 | OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o |
626df76a FB |
164 | ifeq ($(TARGET_ARCH), i386) |
165 | OBJS+= vm86.o | |
166 | endif | |
f72b519c FB |
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 | |
626df76a FB |
172 | SRCS:= $(OBJS:.o=.c) |
173 | OBJS+= libqemu.a | |
174 | ||
175 | # cpu emulator library | |
858693c6 | 176 | LIBOBJS=exec.o translate-all.o cpu-exec.o\ |
1e43adfc | 177 | translate.o op.o |
626df76a FB |
178 | |
179 | ifeq ($(TARGET_ARCH), i386) | |
1e43adfc | 180 | LIBOBJS+=helper.o helper2.o |
f72b519c FB |
181 | ifeq ($(ARCH), i386) |
182 | LIBOBJS+=translate-copy.o | |
183 | endif | |
626df76a FB |
184 | endif |
185 | ||
67867308 | 186 | ifeq ($(TARGET_ARCH), ppc) |
728c9fd5 | 187 | LIBOBJS+= op_helper.o helper.o |
67867308 FB |
188 | endif |
189 | ||
626df76a FB |
190 | # NOTE: the disassembler code is only needed for debugging |
191 | LIBOBJS+=disas.o | |
192 | ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386) | |
bc51c5c9 FB |
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 | |
626df76a FB |
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 | ||
1e43adfc | 218 | all: $(PROGS) |
626df76a | 219 | |
1e43adfc | 220 | $(QEMU_USER): $(OBJS) |
626df76a FB |
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 | |
a541f297 FB |
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 | |
67b915a5 | 235 | endif |
728c9fd5 | 236 | ifeq ($(TARGET_ARCH), ppc) |
a541f297 FB |
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 | |
728c9fd5 | 246 | endif |
626df76a FB |
247 | ifdef CONFIG_SDL |
248 | VL_OBJS+=sdl.o | |
de5eaa64 | 249 | endif |
7c1f25b4 FB |
250 | ifdef CONFIG_SLIRP |
251 | DEFINES+=-I$(SRC_PATH)/slirp | |
252 | SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \ | |
253 | slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \ | |
254 | tcp_subr.o tcp_timer.o udp.o bootp.o debug.o | |
255 | VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS)) | |
626df76a FB |
256 | endif |
257 | ||
c321f673 FB |
258 | VL_LDFLAGS= |
259 | # specific flags are needed for non soft mmu emulator | |
c321f673 FB |
260 | ifdef CONFIG_STATIC |
261 | VL_LDFLAGS+=-static | |
262 | endif | |
de5eaa64 FB |
263 | ifndef CONFIG_SOFTMMU |
264 | VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld | |
265 | endif | |
11d9f695 FB |
266 | ifndef CONFIG_WIN32 |
267 | VL_LIBS=-lutil | |
268 | endif | |
c321f673 | 269 | |
1e43adfc | 270 | $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a |
11d9f695 | 271 | $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS) |
626df76a FB |
272 | |
273 | sdl.o: sdl.c | |
274 | $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $< | |
275 | ||
276 | depend: $(SRCS) | |
16e9b7de | 277 | $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend |
626df76a FB |
278 | |
279 | # libqemu | |
280 | ||
281 | libqemu.a: $(LIBOBJS) | |
282 | rm -f $@ | |
283 | $(AR) rcs $@ $(LIBOBJS) | |
284 | ||
1e43adfc | 285 | translate.o: translate.c gen-op.h opc.h cpu.h |
626df76a | 286 | |
1e43adfc | 287 | translate-all.o: translate-all.c op.h opc.h cpu.h |
626df76a | 288 | |
1e43adfc | 289 | op.h: op.o $(DYNGEN) |
626df76a FB |
290 | $(DYNGEN) -o $@ $< |
291 | ||
1e43adfc | 292 | opc.h: op.o $(DYNGEN) |
626df76a FB |
293 | $(DYNGEN) -c -o $@ $< |
294 | ||
1e43adfc | 295 | gen-op.h: op.o $(DYNGEN) |
626df76a FB |
296 | $(DYNGEN) -g -o $@ $< |
297 | ||
1e43adfc | 298 | op.o: op.c |
626df76a FB |
299 | $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $< |
300 | ||
1e43adfc | 301 | helper.o: helper.c |
626df76a FB |
302 | $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $< |
303 | ||
1e43adfc FB |
304 | ifeq ($(TARGET_ARCH), i386) |
305 | op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h | |
306 | endif | |
307 | ||
308 | ifeq ($(TARGET_ARCH), arm) | |
309 | op.o: op.c op_template.h | |
310 | endif | |
626df76a | 311 | |
1e43adfc FB |
312 | ifeq ($(TARGET_ARCH), sparc) |
313 | op.o: op.c op_template.h | |
314 | endif | |
626df76a | 315 | |
728c9fd5 FB |
316 | ifeq ($(TARGET_ARCH), ppc) |
317 | op.o: op.c op_template.h op_mem.h | |
318 | op_helper.o: op_helper_mem.h | |
319 | endif | |
320 | ||
626df76a FB |
321 | %.o: %.c |
322 | $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $< | |
323 | ||
f72b519c FB |
324 | %.o: %.S |
325 | $(CC) $(DEFINES) -c -o $@ $< | |
326 | ||
626df76a | 327 | clean: |
7c1f25b4 | 328 | rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o |
1e43adfc FB |
329 | |
330 | install: all | |
9b14bb04 | 331 | ifneq ($(PROGS),) |
11d9f695 | 332 | install -m 755 -s $(PROGS) "$(bindir)" |
9b14bb04 | 333 | endif |
626df76a FB |
334 | |
335 | ifneq ($(wildcard .depend),) | |
336 | include .depend | |
337 | endif |