correct eflags evaluation order for all operations - fixed important CPU state restor...
[qemu] / Makefile
1 include config.mak
2
3 CFLAGS=-Wall -O2 -g
4 LDFLAGS=-g
5 LIBS=
6 DEFINES=-DHAVE_BYTESWAP_H
7 HELPER_CFLAGS=$(CFLAGS)
8 PROGS=qemu
9
10 ifdef CONFIG_STATIC
11 LDFLAGS+=-static
12 endif
13
14 ifeq ($(ARCH),i386)
15 CFLAGS+=-fomit-frame-pointer
16 OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
17 ifeq ($(HAVE_GCC3_OPTIONS),yes)
18 OP_CFLAGS+= -falign-functions=0
19 else
20 OP_CFLAGS+= -malign-functions=0
21 endif
22 ifdef TARGET_GPROF
23 LDFLAGS+=-Wl,-T,i386.ld
24 else
25 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
26 # that the kernel ELF loader considers as an executable. I think this
27 # is the simplest way to make it self virtualizable!
28 LDFLAGS+=-Wl,-shared
29 endif
30 ifeq ($(TARGET_ARCH), i386)
31 PROGS+=vl
32 endif
33 endif
34
35 ifeq ($(ARCH),ppc)
36 OP_CFLAGS=$(CFLAGS)
37 LDFLAGS+=-Wl,-T,ppc.ld
38 endif
39
40 ifeq ($(ARCH),s390)
41 OP_CFLAGS=$(CFLAGS)
42 LDFLAGS+=-Wl,-T,s390.ld
43 endif
44
45 ifeq ($(ARCH),sparc)
46 CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
47 LDFLAGS+=-m32
48 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
49 HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
50 LDFLAGS+=-Wl,-T,sparc.ld
51 endif
52
53 ifeq ($(ARCH),sparc64)
54 CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
55 LDFLAGS+=-m64
56 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
57 endif
58
59 ifeq ($(ARCH),alpha)
60 # -msmall-data is not used because we want two-instruction relocations
61 # for the constant constructions
62 OP_CFLAGS=-Wall -O2 -g
63 # Ensure there's only a single GP
64 CFLAGS += -msmall-data
65 LDFLAGS+=-Wl,-T,alpha.ld
66 endif
67
68 ifeq ($(ARCH),ia64)
69 OP_CFLAGS=$(CFLAGS)
70 endif
71
72 ifeq ($(ARCH),arm)
73 OP_CFLAGS=$(CFLAGS) -mno-sched-prolog
74 LDFLAGS+=-Wl,-T,arm.ld
75 endif
76
77 ifeq ($(HAVE_GCC3_OPTIONS),yes)
78 # very important to generate a return at the end of every operation
79 OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
80 endif
81
82 #########################################################
83
84 DEFINES+=-D_GNU_SOURCE
85 LIBS+=-lm
86
87 # profiling code
88 ifdef TARGET_GPROF
89 LDFLAGS+=-p
90 main.o: CFLAGS+=-p
91 endif
92
93 OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o
94 ifeq ($(TARGET_ARCH), i386)
95 OBJS+= vm86.o
96 endif
97 SRCS:= $(OBJS:.o=.c)
98 OBJS+= libqemu.a
99
100 # cpu emulator library
101 LIBOBJS=thunk.o exec.o translate.o cpu-exec.o gdbstub.o
102
103 ifeq ($(TARGET_ARCH), i386)
104 LIBOBJS+=translate-i386.o op-i386.o helper-i386.o
105 endif
106 ifeq ($(TARGET_ARCH), arm)
107 LIBOBJS+=translate-arm.o op-arm.o
108 endif
109
110 # NOTE: the disassembler code is only needed for debugging
111 LIBOBJS+=disas.o 
112 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
113 LIBOBJS+=i386-dis.o
114 endif
115 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
116 LIBOBJS+=alpha-dis.o
117 endif
118 ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
119 LIBOBJS+=ppc-dis.o
120 endif
121 ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
122 LIBOBJS+=sparc-dis.o
123 endif
124 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
125 LIBOBJS+=arm-dis.o
126 endif
127
128 ifeq ($(ARCH),ia64)
129 OBJS += ia64-syscall.o
130 endif
131
132 all: $(PROGS) qemu-doc.html
133
134 qemu: $(OBJS)
135         $(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
136 ifeq ($(ARCH),alpha)
137 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
138 # the address space (31 bit so sign extending doesn't matter)
139         echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
140 endif
141
142 # must use static linking to avoid leaving stuff in virtual address space
143 vl: vl.o block.o libqemu.a
144         $(CC) -static -Wl,-T,i386-vl.ld -o $@ $^  $(LIBS)
145
146 depend: $(SRCS)
147         $(CC) -MM $(CFLAGS) $^ 1>.depend
148
149 # libqemu 
150
151 libqemu.a: $(LIBOBJS)
152         rm -f $@
153         $(AR) rcs $@ $(LIBOBJS)
154
155 dyngen: dyngen.c
156         $(HOST_CC) -O2 -Wall -g $< -o $@
157
158 translate-$(TARGET_ARCH).o: translate-$(TARGET_ARCH).c gen-op-$(TARGET_ARCH).h opc-$(TARGET_ARCH).h cpu-$(TARGET_ARCH).h
159
160 translate.o: translate.c op-$(TARGET_ARCH).h opc-$(TARGET_ARCH).h cpu-$(TARGET_ARCH).h
161
162 op-$(TARGET_ARCH).h: op-$(TARGET_ARCH).o dyngen
163         ./dyngen -o $@ $<
164
165 opc-$(TARGET_ARCH).h: op-$(TARGET_ARCH).o dyngen
166         ./dyngen -c -o $@ $<
167
168 gen-op-$(TARGET_ARCH).h: op-$(TARGET_ARCH).o dyngen
169         ./dyngen -g -o $@ $<
170
171 op-$(TARGET_ARCH).o: op-$(TARGET_ARCH).c
172         $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
173
174 helper-$(TARGET_ARCH).o: helper-$(TARGET_ARCH).c
175         $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
176
177 op-i386.o: op-i386.c opreg_template.h ops_template.h ops_template_mem.h
178
179 op-arm.o: op-arm.c op-arm-template.h
180
181 %.o: %.c
182         $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
183
184 clean:
185         $(MAKE) -C tests clean
186         rm -f *.o  *.a *~ qemu dyngen TAGS
187
188 distclean: clean
189         rm -f config.mak config.h
190
191 install: $(PROGS)
192         mkdir -p $(prefix)/bin
193         install -m 755 -s $(PROGS) $(prefix)/bin
194
195 # various test targets
196 test speed: qemu
197         make -C tests $@
198
199 TAGS: 
200         etags *.[ch] tests/*.[ch]
201
202 # documentation
203 qemu-doc.html: qemu-doc.texi
204         texi2html -monolithic -number $<
205
206 FILES= \
207 README README.distrib COPYING COPYING.LIB TODO Changelog VERSION \
208 configure \
209 dyngen.c dyngen.h dyngen-exec.h ioctls.h syscall_types.h \
210 Makefile elf.h elfload.c main.c signal.c qemu.h \
211 syscall.c syscall_defs.h vm86.c path.c mmap.c \
212 i386.ld ppc.ld alpha.ld s390.ld sparc.ld arm.ld\
213 vl.c i386-vl.ld vl.h block.c\
214 thunk.c cpu-exec.c translate.c cpu-all.h thunk.h exec.h\
215 exec.c cpu-exec.c\
216 cpu-i386.h op-i386.c helper-i386.c syscall-i386.h translate-i386.c \
217 exec-i386.h ops_template.h op_string.h opreg_template.h \
218 cpu-arm.h syscall-arm.h exec-arm.h op-arm.c translate-arm.c op-arm-template.h \
219 dis-asm.h disas.c disas.h alpha-dis.c ppc-dis.c i386-dis.c sparc-dis.c \
220 arm-dis.c \
221 tests/Makefile \
222 tests/test-i386.c tests/test-i386-shift.h tests/test-i386.h \
223 tests/test-i386-muldiv.h tests/test-i386-code16.S tests/test-i386-vm86.S \
224 tests/hello-i386.c tests/hello-i386 \
225 tests/hello-arm.c tests/hello-arm \
226 tests/sha1.c \
227 tests/testsig.c tests/testclone.c tests/testthread.c \
228 tests/runcom.c tests/pi_10.com \
229 tests/test_path.c \
230 qemu-doc.texi qemu-doc.html
231
232 FILE=qemu-$(VERSION)
233
234 tar:
235         rm -rf /tmp/$(FILE)
236         mkdir -p /tmp/$(FILE)
237         cp -P $(FILES) /tmp/$(FILE)
238         ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) )
239         rm -rf /tmp/$(FILE)
240
241 # generate a binary distribution including the test binary environnment 
242 BINPATH=/usr/local/qemu-i386
243
244 tarbin:
245         tar zcvf /tmp/qemu-$(VERSION)-i386-glibc21.tar.gz \
246                  $(BINPATH)/etc $(BINPATH)/lib $(BINPATH)/bin $(BINPATH)/usr
247         tar zcvf /tmp/qemu-$(VERSION)-i386-wine.tar.gz \
248                  $(BINPATH)/wine
249
250 ifneq ($(wildcard .depend),)
251 include .depend
252 endif