]>
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 FB |
13 | HELPER_CFLAGS=$(CFLAGS) |
14 | DYNGEN=../dyngen | |
1e43adfc FB |
15 | # user emulator name |
16 | QEMU_USER=qemu-$(TARGET_ARCH) | |
17 | # system emulator name | |
18 | ifdef CONFIG_SOFTMMU | |
1e43adfc | 19 | QEMU_SYSTEM=qemu |
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 | |
149 | ||
150 | # profiling code | |
151 | ifdef TARGET_GPROF | |
152 | LDFLAGS+=-p | |
153 | main.o: CFLAGS+=-p | |
154 | endif | |
155 | ||
3035f7ff | 156 | OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o |
626df76a FB |
157 | ifeq ($(TARGET_ARCH), i386) |
158 | OBJS+= vm86.o | |
159 | endif | |
f72b519c FB |
160 | ifeq ($(TARGET_ARCH), arm) |
161 | OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \ | |
162 | nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \ | |
163 | nwfpe/double_cpdo.o nwfpe/extended_cpdo.o | |
164 | endif | |
626df76a FB |
165 | SRCS:= $(OBJS:.o=.c) |
166 | OBJS+= libqemu.a | |
167 | ||
168 | # cpu emulator library | |
858693c6 | 169 | LIBOBJS=exec.o translate-all.o cpu-exec.o\ |
1e43adfc | 170 | translate.o op.o |
626df76a FB |
171 | |
172 | ifeq ($(TARGET_ARCH), i386) | |
1e43adfc | 173 | LIBOBJS+=helper.o helper2.o |
f72b519c FB |
174 | ifeq ($(ARCH), i386) |
175 | LIBOBJS+=translate-copy.o | |
176 | endif | |
626df76a FB |
177 | endif |
178 | ||
67867308 | 179 | ifeq ($(TARGET_ARCH), ppc) |
728c9fd5 | 180 | LIBOBJS+= op_helper.o helper.o |
67867308 FB |
181 | endif |
182 | ||
626df76a FB |
183 | # NOTE: the disassembler code is only needed for debugging |
184 | LIBOBJS+=disas.o | |
185 | ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386) | |
bc51c5c9 FB |
186 | USE_I386_DIS=y |
187 | endif | |
188 | ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64) | |
189 | USE_I386_DIS=y | |
190 | endif | |
191 | ifdef USE_I386_DIS | |
626df76a FB |
192 | LIBOBJS+=i386-dis.o |
193 | endif | |
194 | ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha) | |
195 | LIBOBJS+=alpha-dis.o | |
196 | endif | |
197 | ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc) | |
198 | LIBOBJS+=ppc-dis.o | |
199 | endif | |
200 | ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc) | |
201 | LIBOBJS+=sparc-dis.o | |
202 | endif | |
203 | ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm) | |
204 | LIBOBJS+=arm-dis.o | |
205 | endif | |
206 | ||
207 | ifeq ($(ARCH),ia64) | |
208 | OBJS += ia64-syscall.o | |
209 | endif | |
210 | ||
1e43adfc | 211 | all: $(PROGS) |
626df76a | 212 | |
1e43adfc | 213 | $(QEMU_USER): $(OBJS) |
626df76a FB |
214 | $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) |
215 | ifeq ($(ARCH),alpha) | |
216 | # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of | |
217 | # the address space (31 bit so sign extending doesn't matter) | |
218 | echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc | |
219 | endif | |
220 | ||
221 | # must use static linking to avoid leaving stuff in virtual address space | |
858693c6 | 222 | VL_OBJS=vl.o osdep.o block.o monitor.o gdbstub.o \ |
9dc39cba | 223 | ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o \ |
80cabfad | 224 | fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o |
728c9fd5 FB |
225 | ifeq ($(TARGET_ARCH), ppc) |
226 | VL_OBJS+= hw.o | |
227 | endif | |
626df76a FB |
228 | ifdef CONFIG_SDL |
229 | VL_OBJS+=sdl.o | |
de5eaa64 FB |
230 | ifdef CONFIG_STATIC |
231 | SDL_LIBS:=$(SDL_STATIC_LIBS) | |
232 | endif | |
626df76a FB |
233 | endif |
234 | ||
c321f673 FB |
235 | VL_LDFLAGS= |
236 | # specific flags are needed for non soft mmu emulator | |
c321f673 FB |
237 | ifdef CONFIG_STATIC |
238 | VL_LDFLAGS+=-static | |
239 | endif | |
de5eaa64 FB |
240 | ifndef CONFIG_SOFTMMU |
241 | VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld | |
242 | endif | |
c321f673 | 243 | |
1e43adfc | 244 | $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a |
9dc39cba | 245 | $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) -lutil |
626df76a FB |
246 | |
247 | sdl.o: sdl.c | |
248 | $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $< | |
249 | ||
250 | depend: $(SRCS) | |
16e9b7de | 251 | $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend |
626df76a FB |
252 | |
253 | # libqemu | |
254 | ||
255 | libqemu.a: $(LIBOBJS) | |
256 | rm -f $@ | |
257 | $(AR) rcs $@ $(LIBOBJS) | |
258 | ||
1e43adfc | 259 | translate.o: translate.c gen-op.h opc.h cpu.h |
626df76a | 260 | |
1e43adfc | 261 | translate-all.o: translate-all.c op.h opc.h cpu.h |
626df76a | 262 | |
1e43adfc | 263 | op.h: op.o $(DYNGEN) |
626df76a FB |
264 | $(DYNGEN) -o $@ $< |
265 | ||
1e43adfc | 266 | opc.h: op.o $(DYNGEN) |
626df76a FB |
267 | $(DYNGEN) -c -o $@ $< |
268 | ||
1e43adfc | 269 | gen-op.h: op.o $(DYNGEN) |
626df76a FB |
270 | $(DYNGEN) -g -o $@ $< |
271 | ||
1e43adfc | 272 | op.o: op.c |
626df76a FB |
273 | $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $< |
274 | ||
1e43adfc | 275 | helper.o: helper.c |
626df76a FB |
276 | $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $< |
277 | ||
1e43adfc FB |
278 | ifeq ($(TARGET_ARCH), i386) |
279 | op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h | |
280 | endif | |
281 | ||
282 | ifeq ($(TARGET_ARCH), arm) | |
283 | op.o: op.c op_template.h | |
284 | endif | |
626df76a | 285 | |
1e43adfc FB |
286 | ifeq ($(TARGET_ARCH), sparc) |
287 | op.o: op.c op_template.h | |
288 | endif | |
626df76a | 289 | |
728c9fd5 FB |
290 | ifeq ($(TARGET_ARCH), ppc) |
291 | op.o: op.c op_template.h op_mem.h | |
292 | op_helper.o: op_helper_mem.h | |
293 | endif | |
294 | ||
626df76a FB |
295 | %.o: %.c |
296 | $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $< | |
297 | ||
f72b519c FB |
298 | %.o: %.S |
299 | $(CC) $(DEFINES) -c -o $@ $< | |
300 | ||
626df76a | 301 | clean: |
f72b519c | 302 | rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o |
1e43adfc FB |
303 | |
304 | install: all | |
9b14bb04 | 305 | ifneq ($(PROGS),) |
1e43adfc | 306 | install -m 755 -s $(PROGS) $(prefix)/bin |
9b14bb04 | 307 | endif |
626df76a FB |
308 | |
309 | ifneq ($(wildcard .depend),) | |
310 | include .depend | |
311 | endif |