update
[qemu] / Makefile.target
1 include config.mak
2
3 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH)
4 VPATH=$(SRC_PATH):$(TARGET_PATH)
5 CFLAGS=-Wall -O2 -g
6 LDFLAGS=-g
7 LIBS=
8 DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH)
9 HELPER_CFLAGS=$(CFLAGS)
10 DYNGEN=../dyngen
11 # user emulator name
12 QEMU_USER=qemu-$(TARGET_ARCH)
13 # system emulator name
14 ifdef CONFIG_SOFTMMU
15 QEMU_SYSTEM=qemu
16 else
17 QEMU_SYSTEM=qemu-fast
18 endif
19
20 ifdef CONFIG_USER_ONLY
21 PROGS=$(QEMU_USER)
22 else
23 ifeq ($(TARGET_ARCH), i386)
24
25 ifeq ($(ARCH), i386)
26 PROGS+=$(QEMU_SYSTEM)
27 ifndef CONFIG_SOFTMMU
28 CONFIG_STATIC=y
29 endif
30 endif
31
32 ifeq ($(ARCH), ppc)
33 ifdef CONFIG_SOFTMMU
34 PROGS+=$(QEMU_SYSTEM)
35 endif
36 endif
37
38 endif
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)
49 endif
50 endif # ARCH = i386
51
52 endif # TARGET_ARCH = ppc
53 endif # !CONFIG_USER_ONLY
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
67
68 ifdef TARGET_GPROF
69 USE_I386_LD=y
70 endif
71 ifdef CONFIG_STATIC
72 USE_I386_LD=y
73 endif
74 ifdef USE_I386_LD
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
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
127 ifeq ($(ARCH),m68k)
128 OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
129 LDFLAGS+=-Wl,-T,m68k.ld
130 endif
131
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
156 LIBOBJS=thunk.o exec.o translate-all.o cpu-exec.o gdbstub.o \
157         translate.o op.o
158
159 ifeq ($(TARGET_ARCH), i386)
160 LIBOBJS+=helper.o helper2.o
161 endif
162
163 ifeq ($(TARGET_ARCH), ppc)
164 LIBOBJS+= op_helper.o helper.o
165 endif
166
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
189 all: $(PROGS)
190
191 $(QEMU_USER): $(OBJS)
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
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
204 ifdef CONFIG_SDL
205 VL_OBJS+=sdl.o
206 ifdef CONFIG_STATIC
207 SDL_LIBS:=$(SDL_STATIC_LIBS)
208 endif
209 endif
210
211 VL_LDFLAGS=
212 # specific flags are needed for non soft mmu emulator
213 ifdef CONFIG_STATIC
214 VL_LDFLAGS+=-static
215 endif
216 ifndef CONFIG_SOFTMMU
217 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld 
218 endif
219
220 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
221         $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS)
222
223 sdl.o: sdl.c
224         $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
225
226 depend: $(SRCS)
227         $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
228
229 # libqemu 
230
231 libqemu.a: $(LIBOBJS)
232         rm -f $@
233         $(AR) rcs $@ $(LIBOBJS)
234
235 translate.o: translate.c gen-op.h opc.h cpu.h
236
237 translate-all.o: translate-all.c op.h opc.h cpu.h
238
239 op.h: op.o $(DYNGEN)
240         $(DYNGEN) -o $@ $<
241
242 opc.h: op.o $(DYNGEN)
243         $(DYNGEN) -c -o $@ $<
244
245 gen-op.h: op.o $(DYNGEN)
246         $(DYNGEN) -g -o $@ $<
247
248 op.o: op.c
249         $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
250
251 helper.o: helper.c
252         $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
253
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
261
262 ifeq ($(TARGET_ARCH), sparc)
263 op.o: op.c op_template.h
264 endif
265
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
271 %.o: %.c
272         $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
273
274 clean:
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
279
280 ifneq ($(wildcard .depend),)
281 include .depend
282 endif