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