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