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