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