]>
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 | ||
75dfaa1e FB |
59 | ifeq ($(ARCH), amd64) |
60 | ifdef CONFIG_SOFTMMU | |
61 | PROGS+=$(QEMU_SYSTEM) | |
62 | endif | |
63 | endif # ARCH = amd64 | |
64 | ||
728c9fd5 FB |
65 | endif # TARGET_ARCH = ppc |
66 | endif # !CONFIG_USER_ONLY | |
626df76a FB |
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 | |
3a4739d6 | 80 | |
626df76a | 81 | ifdef TARGET_GPROF |
3a4739d6 FB |
82 | USE_I386_LD=y |
83 | endif | |
84 | ifdef CONFIG_STATIC | |
85 | USE_I386_LD=y | |
86 | endif | |
87 | ifdef USE_I386_LD | |
626df76a FB |
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 | |
626df76a FB |
95 | endif |
96 | ||
bc51c5c9 FB |
97 | ifeq ($(ARCH),amd64) |
98 | OP_CFLAGS=$(CFLAGS) -falign-functions=0 | |
99 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/amd64.ld | |
100 | endif | |
101 | ||
626df76a FB |
102 | ifeq ($(ARCH),ppc) |
103 | OP_CFLAGS=$(CFLAGS) | |
104 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld | |
105 | endif | |
106 | ||
107 | ifeq ($(ARCH),s390) | |
108 | OP_CFLAGS=$(CFLAGS) | |
109 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld | |
110 | endif | |
111 | ||
112 | ifeq ($(ARCH),sparc) | |
113 | CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6 | |
114 | LDFLAGS+=-m32 | |
115 | OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0 | |
116 | HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat | |
117 | # -static is used to avoid g1/g3 usage by the dynamic linker | |
118 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static | |
119 | endif | |
120 | ||
121 | ifeq ($(ARCH),sparc64) | |
122 | CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6 | |
123 | LDFLAGS+=-m64 | |
124 | OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0 | |
125 | endif | |
126 | ||
127 | ifeq ($(ARCH),alpha) | |
128 | # -msmall-data is not used because we want two-instruction relocations | |
129 | # for the constant constructions | |
130 | OP_CFLAGS=-Wall -O2 -g | |
131 | # Ensure there's only a single GP | |
132 | CFLAGS += -msmall-data | |
133 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld | |
134 | endif | |
135 | ||
136 | ifeq ($(ARCH),ia64) | |
137 | OP_CFLAGS=$(CFLAGS) | |
138 | endif | |
139 | ||
140 | ifeq ($(ARCH),arm) | |
141 | OP_CFLAGS=$(CFLAGS) -mno-sched-prolog | |
142 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld | |
143 | endif | |
144 | ||
38e584a0 FB |
145 | ifeq ($(ARCH),m68k) |
146 | OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer | |
147 | LDFLAGS+=-Wl,-T,m68k.ld | |
148 | endif | |
149 | ||
626df76a FB |
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 | |
154 | ||
155 | ######################################################### | |
156 | ||
157 | DEFINES+=-D_GNU_SOURCE | |
158 | LIBS+=-lm | |
67b915a5 FB |
159 | ifdef CONFIG_WIN32 |
160 | LIBS+=-lwinmm | |
161 | endif | |
626df76a FB |
162 | |
163 | # profiling code | |
164 | ifdef TARGET_GPROF | |
165 | LDFLAGS+=-p | |
166 | main.o: CFLAGS+=-p | |
167 | endif | |
168 | ||
3035f7ff | 169 | OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o |
626df76a FB |
170 | ifeq ($(TARGET_ARCH), i386) |
171 | OBJS+= vm86.o | |
172 | endif | |
f72b519c FB |
173 | ifeq ($(TARGET_ARCH), arm) |
174 | OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \ | |
175 | nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \ | |
176 | nwfpe/double_cpdo.o nwfpe/extended_cpdo.o | |
177 | endif | |
626df76a FB |
178 | SRCS:= $(OBJS:.o=.c) |
179 | OBJS+= libqemu.a | |
180 | ||
181 | # cpu emulator library | |
858693c6 | 182 | LIBOBJS=exec.o translate-all.o cpu-exec.o\ |
1e43adfc | 183 | translate.o op.o |
626df76a FB |
184 | |
185 | ifeq ($(TARGET_ARCH), i386) | |
1e43adfc | 186 | LIBOBJS+=helper.o helper2.o |
f72b519c FB |
187 | ifeq ($(ARCH), i386) |
188 | LIBOBJS+=translate-copy.o | |
189 | endif | |
626df76a FB |
190 | endif |
191 | ||
67867308 | 192 | ifeq ($(TARGET_ARCH), ppc) |
728c9fd5 | 193 | LIBOBJS+= op_helper.o helper.o |
67867308 FB |
194 | endif |
195 | ||
626df76a FB |
196 | # NOTE: the disassembler code is only needed for debugging |
197 | LIBOBJS+=disas.o | |
198 | ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386) | |
bc51c5c9 FB |
199 | USE_I386_DIS=y |
200 | endif | |
201 | ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64) | |
202 | USE_I386_DIS=y | |
203 | endif | |
204 | ifdef USE_I386_DIS | |
626df76a FB |
205 | LIBOBJS+=i386-dis.o |
206 | endif | |
207 | ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha) | |
208 | LIBOBJS+=alpha-dis.o | |
209 | endif | |
210 | ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc) | |
211 | LIBOBJS+=ppc-dis.o | |
212 | endif | |
213 | ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc) | |
214 | LIBOBJS+=sparc-dis.o | |
215 | endif | |
216 | ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm) | |
217 | LIBOBJS+=arm-dis.o | |
218 | endif | |
219 | ||
220 | ifeq ($(ARCH),ia64) | |
221 | OBJS += ia64-syscall.o | |
222 | endif | |
223 | ||
1e43adfc | 224 | all: $(PROGS) |
626df76a | 225 | |
1e43adfc | 226 | $(QEMU_USER): $(OBJS) |
626df76a FB |
227 | $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) |
228 | ifeq ($(ARCH),alpha) | |
229 | # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of | |
230 | # the address space (31 bit so sign extending doesn't matter) | |
231 | echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc | |
232 | endif | |
233 | ||
234 | # must use static linking to avoid leaving stuff in virtual address space | |
69135b5c | 235 | VL_OBJS=vl.o osdep.o block.o monitor.o pci.o |
a541f297 FB |
236 | |
237 | ifeq ($(TARGET_ARCH), i386) | |
238 | # Hardware support | |
239 | VL_OBJS+= ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o | |
240 | VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o | |
67b915a5 | 241 | endif |
728c9fd5 | 242 | ifeq ($(TARGET_ARCH), ppc) |
a541f297 FB |
243 | # Generic PPC support |
244 | VL_OBJS+= ppc.o | |
245 | # PREP hardware support | |
246 | VL_OBJS+= ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o | |
247 | VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o ppc_prep.o | |
248 | #VL_OBJS+= hw.o of.o setup.o | |
249 | endif | |
250 | ifdef CONFIG_GDBSTUB | |
251 | VL_OBJS+=gdbstub.o | |
728c9fd5 | 252 | endif |
626df76a FB |
253 | ifdef CONFIG_SDL |
254 | VL_OBJS+=sdl.o | |
de5eaa64 | 255 | endif |
7c1f25b4 FB |
256 | ifdef CONFIG_SLIRP |
257 | DEFINES+=-I$(SRC_PATH)/slirp | |
258 | SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \ | |
259 | slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \ | |
260 | tcp_subr.o tcp_timer.o udp.o bootp.o debug.o | |
261 | VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS)) | |
626df76a FB |
262 | endif |
263 | ||
c321f673 FB |
264 | VL_LDFLAGS= |
265 | # specific flags are needed for non soft mmu emulator | |
c321f673 FB |
266 | ifdef CONFIG_STATIC |
267 | VL_LDFLAGS+=-static | |
268 | endif | |
de5eaa64 FB |
269 | ifndef CONFIG_SOFTMMU |
270 | VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld | |
271 | endif | |
11d9f695 FB |
272 | ifndef CONFIG_WIN32 |
273 | VL_LIBS=-lutil | |
274 | endif | |
c321f673 | 275 | |
1e43adfc | 276 | $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a |
11d9f695 | 277 | $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS) |
626df76a FB |
278 | |
279 | sdl.o: sdl.c | |
280 | $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $< | |
281 | ||
282 | depend: $(SRCS) | |
16e9b7de | 283 | $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend |
626df76a FB |
284 | |
285 | # libqemu | |
286 | ||
287 | libqemu.a: $(LIBOBJS) | |
288 | rm -f $@ | |
289 | $(AR) rcs $@ $(LIBOBJS) | |
290 | ||
1e43adfc | 291 | translate.o: translate.c gen-op.h opc.h cpu.h |
626df76a | 292 | |
1e43adfc | 293 | translate-all.o: translate-all.c op.h opc.h cpu.h |
626df76a | 294 | |
1e43adfc | 295 | op.h: op.o $(DYNGEN) |
626df76a FB |
296 | $(DYNGEN) -o $@ $< |
297 | ||
1e43adfc | 298 | opc.h: op.o $(DYNGEN) |
626df76a FB |
299 | $(DYNGEN) -c -o $@ $< |
300 | ||
1e43adfc | 301 | gen-op.h: op.o $(DYNGEN) |
626df76a FB |
302 | $(DYNGEN) -g -o $@ $< |
303 | ||
1e43adfc | 304 | op.o: op.c |
626df76a FB |
305 | $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $< |
306 | ||
1e43adfc | 307 | helper.o: helper.c |
626df76a FB |
308 | $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $< |
309 | ||
1e43adfc FB |
310 | ifeq ($(TARGET_ARCH), i386) |
311 | op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h | |
312 | endif | |
313 | ||
314 | ifeq ($(TARGET_ARCH), arm) | |
315 | op.o: op.c op_template.h | |
316 | endif | |
626df76a | 317 | |
1e43adfc FB |
318 | ifeq ($(TARGET_ARCH), sparc) |
319 | op.o: op.c op_template.h | |
320 | endif | |
626df76a | 321 | |
728c9fd5 FB |
322 | ifeq ($(TARGET_ARCH), ppc) |
323 | op.o: op.c op_template.h op_mem.h | |
324 | op_helper.o: op_helper_mem.h | |
325 | endif | |
326 | ||
626df76a FB |
327 | %.o: %.c |
328 | $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $< | |
329 | ||
f72b519c FB |
330 | %.o: %.S |
331 | $(CC) $(DEFINES) -c -o $@ $< | |
332 | ||
626df76a | 333 | clean: |
7c1f25b4 | 334 | rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o |
1e43adfc FB |
335 | |
336 | install: all | |
9b14bb04 | 337 | ifneq ($(PROGS),) |
11d9f695 | 338 | install -m 755 -s $(PROGS) "$(bindir)" |
9b14bb04 | 339 | endif |
626df76a FB |
340 | |
341 | ifneq ($(wildcard .depend),) | |
342 | include .depend | |
343 | endif |