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