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