Makefile 6.2 KB
Newer Older
B
bellard 已提交
1
include config.mak
B
bellard 已提交
2

B
bellard 已提交
3
CFLAGS=-Wall -O2 -g
4
LDFLAGS=-g
B
bellard 已提交
5 6
LIBS=
DEFINES=-DHAVE_BYTESWAP_H
7
HELPER_CFLAGS=$(CFLAGS)
8
PROGS=qemu
B
bellard 已提交
9

B
bellard 已提交
10 11 12 13
ifdef CONFIG_STATIC
LDFLAGS+=-static
endif

B
bellard 已提交
14 15
ifeq ($(ARCH),i386)
CFLAGS+=-fomit-frame-pointer
B
bellard 已提交
16
OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
17
ifeq ($(HAVE_GCC3_OPTIONS),yes)
B
bellard 已提交
18 19 20 21
OP_CFLAGS+= -falign-functions=0
else
OP_CFLAGS+= -malign-functions=0
endif
B
bellard 已提交
22 23 24
ifdef TARGET_GPROF
LDFLAGS+=-Wl,-T,i386.ld
else
B
update  
bellard 已提交
25 26 27 28
# WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
# that the kernel ELF loader considers as an executable. I think this
# is the simplest way to make it self virtualizable!
LDFLAGS+=-Wl,-shared
B
bellard 已提交
29
endif
30
ifeq ($(TARGET_ARCH), i386)
31
PROGS+=vl vlmkcow
32
endif
B
bellard 已提交
33
endif
B
bellard 已提交
34 35

ifeq ($(ARCH),ppc)
B
bellard 已提交
36
OP_CFLAGS=$(CFLAGS)
B
update  
bellard 已提交
37
LDFLAGS+=-Wl,-T,ppc.ld
B
bellard 已提交
38 39
endif

B
update  
bellard 已提交
40 41
ifeq ($(ARCH),s390)
OP_CFLAGS=$(CFLAGS)
B
update  
bellard 已提交
42
LDFLAGS+=-Wl,-T,s390.ld
B
update  
bellard 已提交
43 44
endif

B
bellard 已提交
45 46 47 48
ifeq ($(ARCH),sparc)
CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
LDFLAGS+=-m32
OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
49
HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
B
bellard 已提交
50 51
# -static is used to avoid g1/g3 usage by the dynamic linker
LDFLAGS+=-Wl,-T,sparc.ld -static
B
bellard 已提交
52 53 54 55 56 57 58 59
endif

ifeq ($(ARCH),sparc64)
CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
LDFLAGS+=-m64
OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
endif

B
bellard 已提交
60
ifeq ($(ARCH),alpha)
B
bellard 已提交
61 62 63
# -msmall-data is not used because we want two-instruction relocations
# for the constant constructions
OP_CFLAGS=-Wall -O2 -g
B
bellard 已提交
64
# Ensure there's only a single GP
B
bellard 已提交
65
CFLAGS += -msmall-data
B
bellard 已提交
66 67 68 69 70 71 72
LDFLAGS+=-Wl,-T,alpha.ld
endif

ifeq ($(ARCH),ia64)
OP_CFLAGS=$(CFLAGS)
endif

73 74 75 76 77
ifeq ($(ARCH),arm)
OP_CFLAGS=$(CFLAGS) -mno-sched-prolog
LDFLAGS+=-Wl,-T,arm.ld
endif

78
ifeq ($(HAVE_GCC3_OPTIONS),yes)
B
bellard 已提交
79 80 81 82
# very important to generate a return at the end of every operation
OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
endif

B
bellard 已提交
83 84
#########################################################

B
bellard 已提交
85
DEFINES+=-D_GNU_SOURCE
B
bellard 已提交
86
LIBS+=-lm
B
bellard 已提交
87 88 89 90

# profiling code
ifdef TARGET_GPROF
LDFLAGS+=-p
B
bellard 已提交
91
main.o: CFLAGS+=-p
B
bellard 已提交
92
endif
93

B
bellard 已提交
94 95 96 97
OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o
ifeq ($(TARGET_ARCH), i386)
OBJS+= vm86.o
endif
B
bellard 已提交
98 99
SRCS:= $(OBJS:.o=.c)
OBJS+= libqemu.a
B
bellard 已提交
100

B
bellard 已提交
101
# cpu emulator library
B
bellard 已提交
102
LIBOBJS=thunk.o exec.o translate.o cpu-exec.o gdbstub.o
B
bellard 已提交
103 104 105 106 107 108 109

ifeq ($(TARGET_ARCH), i386)
LIBOBJS+=translate-i386.o op-i386.o helper-i386.o
endif
ifeq ($(TARGET_ARCH), arm)
LIBOBJS+=translate-arm.o op-arm.o
endif
B
bellard 已提交
110

B
bellard 已提交
111
# NOTE: the disassembler code is only needed for debugging
B
bellard 已提交
112 113 114 115 116
LIBOBJS+=disas.o 
ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
LIBOBJS+=i386-dis.o
endif
ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
B
bellard 已提交
117 118
LIBOBJS+=alpha-dis.o
endif
B
bellard 已提交
119
ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
B
bellard 已提交
120 121
LIBOBJS+=ppc-dis.o
endif
B
bellard 已提交
122
ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
123 124
LIBOBJS+=sparc-dis.o
endif
B
bellard 已提交
125
ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
126 127
LIBOBJS+=arm-dis.o
endif
128

B
bellard 已提交
129 130 131 132
ifeq ($(ARCH),ia64)
OBJS += ia64-syscall.o
endif

133
all: $(PROGS) qemu-doc.html
134

B
bellard 已提交
135
qemu: $(OBJS)
B
update  
bellard 已提交
136
	$(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
B
bellard 已提交
137 138 139 140 141
ifeq ($(ARCH),alpha)
# Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
# the address space (31 bit so sign extending doesn't matter)
	echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
endif
142

143
# must use static linking to avoid leaving stuff in virtual address space
B
bellard 已提交
144
vl: vl.o block.o libqemu.a
B
update  
bellard 已提交
145
	$(CC) -static -Wl,-T,i386-vl.ld -o $@ $^  $(LIBS)
146 147 148

vlmkcow: vlmkcow.o
	$(CC) -o $@ $^  $(LIBS)
149

150 151 152
depend: $(SRCS)
	$(CC) -MM $(CFLAGS) $^ 1>.depend

B
bellard 已提交
153
# libqemu 
B
bellard 已提交
154

B
bellard 已提交
155
libqemu.a: $(LIBOBJS)
B
bellard 已提交
156 157 158
	rm -f $@
	$(AR) rcs $@ $(LIBOBJS)

B
bellard 已提交
159 160 161
dyngen: dyngen.c
	$(HOST_CC) -O2 -Wall -g $< -o $@

B
bellard 已提交
162 163 164
translate-$(TARGET_ARCH).o: translate-$(TARGET_ARCH).c gen-op-$(TARGET_ARCH).h opc-$(TARGET_ARCH).h cpu-$(TARGET_ARCH).h

translate.o: translate.c op-$(TARGET_ARCH).h opc-$(TARGET_ARCH).h cpu-$(TARGET_ARCH).h
B
bellard 已提交
165

B
bellard 已提交
166
op-$(TARGET_ARCH).h: op-$(TARGET_ARCH).o dyngen
B
bellard 已提交
167 168
	./dyngen -o $@ $<

B
bellard 已提交
169
opc-$(TARGET_ARCH).h: op-$(TARGET_ARCH).o dyngen
B
bellard 已提交
170 171
	./dyngen -c -o $@ $<

B
bellard 已提交
172 173 174 175
gen-op-$(TARGET_ARCH).h: op-$(TARGET_ARCH).o dyngen
	./dyngen -g -o $@ $<

op-$(TARGET_ARCH).o: op-$(TARGET_ARCH).c
B
bellard 已提交
176
	$(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
B
bellard 已提交
177

B
bellard 已提交
178
helper-$(TARGET_ARCH).o: helper-$(TARGET_ARCH).c
179 180
	$(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<

181
op-i386.o: op-i386.c opreg_template.h ops_template.h ops_template_mem.h
B
bellard 已提交
182 183 184

op-arm.o: op-arm.c op-arm-template.h

185 186 187 188
%.o: %.c
	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<

clean:
B
bellard 已提交
189
	$(MAKE) -C tests clean
B
bellard 已提交
190
	rm -f *.o  *.a *~ qemu dyngen TAGS
191

B
bellard 已提交
192 193 194
distclean: clean
	rm -f config.mak config.h

195
install: $(PROGS)
B
update  
bellard 已提交
196
	mkdir -p $(prefix)/bin
197
	install -m 755 -s $(PROGS) $(prefix)/bin
B
bellard 已提交
198

B
bellard 已提交
199
# various test targets
B
bellard 已提交
200
test speed: qemu
B
bellard 已提交
201
	make -C tests $@
202

B
bellard 已提交
203
TAGS: 
B
bellard 已提交
204
	etags *.[ch] tests/*.[ch]
205

B
bellard 已提交
206 207 208 209
# documentation
qemu-doc.html: qemu-doc.texi
	texi2html -monolithic -number $<

B
bellard 已提交
210
FILES= \
B
update  
bellard 已提交
211
README README.distrib COPYING COPYING.LIB TODO Changelog VERSION \
B
bellard 已提交
212 213 214 215
configure \
dyngen.c dyngen.h dyngen-exec.h ioctls.h syscall_types.h \
Makefile elf.h elfload.c main.c signal.c qemu.h \
syscall.c syscall_defs.h vm86.c path.c mmap.c \
216
i386.ld ppc.ld alpha.ld s390.ld sparc.ld arm.ld\
B
update  
bellard 已提交
217
vl.c i386-vl.ld vl.h block.c vlmkcow.c\
B
bellard 已提交
218
thunk.c cpu-exec.c translate.c cpu-all.h thunk.h exec.h\
B
update  
bellard 已提交
219
exec.c cpu-exec.c gdbstub.c\
B
bellard 已提交
220
cpu-i386.h op-i386.c helper-i386.c syscall-i386.h translate-i386.c \
B
update  
bellard 已提交
221
exec-i386.h ops_template.h ops_template_mem.h op_string.h opreg_template.h \
B
bellard 已提交
222 223 224 225 226 227
cpu-arm.h syscall-arm.h exec-arm.h op-arm.c translate-arm.c op-arm-template.h \
dis-asm.h disas.c disas.h alpha-dis.c ppc-dis.c i386-dis.c sparc-dis.c \
arm-dis.c \
tests/Makefile \
tests/test-i386.c tests/test-i386-shift.h tests/test-i386.h \
tests/test-i386-muldiv.h tests/test-i386-code16.S tests/test-i386-vm86.S \
B
update  
bellard 已提交
228
tests/hello-i386.c tests/hello-i386 \
B
bellard 已提交
229 230
tests/hello-arm.c tests/hello-arm \
tests/sha1.c \
B
bellard 已提交
231
tests/testsig.c tests/testclone.c tests/testthread.c \
B
update  
bellard 已提交
232
tests/runcom.c tests/pi_10.com \
B
update  
bellard 已提交
233
tests/test_path.c \
B
bellard 已提交
234
qemu-doc.texi qemu-doc.html
B
bellard 已提交
235

B
bellard 已提交
236
FILE=qemu-$(VERSION)
B
bellard 已提交
237 238 239 240 241 242 243 244

tar:
	rm -rf /tmp/$(FILE)
	mkdir -p /tmp/$(FILE)
	cp -P $(FILES) /tmp/$(FILE)
	( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) )
	rm -rf /tmp/$(FILE)

245 246 247 248
# generate a binary distribution including the test binary environnment 
BINPATH=/usr/local/qemu-i386

tarbin:
B
update  
bellard 已提交
249 250 251 252
	tar zcvf /tmp/qemu-$(VERSION)-i386-glibc21.tar.gz \
                 $(BINPATH)/etc $(BINPATH)/lib $(BINPATH)/bin $(BINPATH)/usr
	tar zcvf /tmp/qemu-$(VERSION)-i386-wine.tar.gz \
                 $(BINPATH)/wine
253

254 255 256
ifneq ($(wildcard .depend),)
include .depend
endif