Makefile 6.1 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 50
HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
LDFLAGS+=-Wl,-T,sparc.ld
B
bellard 已提交
51 52 53 54 55 56 57 58
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 已提交
59
ifeq ($(ARCH),alpha)
B
bellard 已提交
60 61 62
# -msmall-data is not used because we want two-instruction relocations
# for the constant constructions
OP_CFLAGS=-Wall -O2 -g
B
bellard 已提交
63
# Ensure there's only a single GP
B
bellard 已提交
64
CFLAGS += -msmall-data
B
bellard 已提交
65 66 67 68 69 70 71
LDFLAGS+=-Wl,-T,alpha.ld
endif

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

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

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

B
bellard 已提交
82 83
#########################################################

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

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

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

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

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 已提交
109

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

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

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

B
bellard 已提交
134
qemu: $(OBJS)
B
update  
bellard 已提交
135
	$(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
B
bellard 已提交
136 137 138 139 140
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
141

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

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

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

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

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

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

B
bellard 已提交
161 162 163
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 已提交
164

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

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

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

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

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

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

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

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

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

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

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

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

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

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

B
bellard 已提交
209
FILES= \
B
update  
bellard 已提交
210
README README.distrib COPYING COPYING.LIB TODO Changelog VERSION \
B
bellard 已提交
211 212 213 214
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 \
215
i386.ld ppc.ld alpha.ld s390.ld sparc.ld arm.ld\
B
bellard 已提交
216
vl.c i386-vl.ld vl.h block.c\
B
bellard 已提交
217 218 219 220 221 222 223 224 225 226
thunk.c cpu-exec.c translate.c cpu-all.h thunk.h exec.h\
exec.c cpu-exec.c\
cpu-i386.h op-i386.c helper-i386.c syscall-i386.h translate-i386.c \
exec-i386.h ops_template.h op_string.h opreg_template.h \
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 已提交
227
tests/hello-i386.c tests/hello-i386 \
B
bellard 已提交
228 229
tests/hello-arm.c tests/hello-arm \
tests/sha1.c \
B
bellard 已提交
230
tests/testsig.c tests/testclone.c tests/testthread.c \
B
update  
bellard 已提交
231
tests/runcom.c tests/pi_10.com \
B
update  
bellard 已提交
232
tests/test_path.c \
B
bellard 已提交
233
qemu-doc.texi qemu-doc.html
B
bellard 已提交
234

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

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)

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

tarbin:
B
update  
bellard 已提交
248 249 250 251
	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
252

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