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