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