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