Makefile 4.8 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)
B
bellard 已提交
8 9 10

ifeq ($(ARCH),i386)
CFLAGS+=-fomit-frame-pointer
B
bellard 已提交
11 12 13 14 15 16
OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
ifeq ($(GCC_MAJOR),3)
OP_CFLAGS+= -falign-functions=0
else
OP_CFLAGS+= -malign-functions=0
endif
B
bellard 已提交
17 18 19
ifdef TARGET_GPROF
LDFLAGS+=-Wl,-T,i386.ld
else
B
update  
bellard 已提交
20 21 22 23
# 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 已提交
24
endif
B
bellard 已提交
25
endif
B
bellard 已提交
26 27

ifeq ($(ARCH),ppc)
B
bellard 已提交
28
OP_CFLAGS=$(CFLAGS)
B
update  
bellard 已提交
29
LDFLAGS+=-Wl,-T,ppc.ld
B
bellard 已提交
30 31
endif

B
update  
bellard 已提交
32 33
ifeq ($(ARCH),s390)
OP_CFLAGS=$(CFLAGS)
B
update  
bellard 已提交
34
LDFLAGS+=-Wl,-T,s390.ld
B
update  
bellard 已提交
35 36
endif

B
bellard 已提交
37 38 39 40
ifeq ($(ARCH),sparc)
CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
LDFLAGS+=-m32
OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
41 42
HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
LDFLAGS+=-Wl,-T,sparc.ld
B
bellard 已提交
43 44 45 46 47 48 49 50
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 已提交
51
ifeq ($(ARCH),alpha)
B
bellard 已提交
52 53 54
# -msmall-data is not used because we want two-instruction relocations
# for the constant constructions
OP_CFLAGS=-Wall -O2 -g
B
bellard 已提交
55
# Ensure there's only a single GP
B
bellard 已提交
56
CFLAGS += -msmall-data
B
bellard 已提交
57 58 59 60 61 62 63
LDFLAGS+=-Wl,-T,alpha.ld
endif

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

64 65 66 67 68
ifeq ($(ARCH),arm)
OP_CFLAGS=$(CFLAGS) -mno-sched-prolog
LDFLAGS+=-Wl,-T,arm.ld
endif

B
bellard 已提交
69 70 71 72 73
ifeq ($(GCC_MAJOR),3)
# very important to generate a return at the end of every operation
OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
endif

B
bellard 已提交
74 75
#########################################################

B
bellard 已提交
76
DEFINES+=-D_GNU_SOURCE
B
bellard 已提交
77
LIBS+=-lm
B
bellard 已提交
78 79 80 81

# profiling code
ifdef TARGET_GPROF
LDFLAGS+=-p
B
bellard 已提交
82
main.o: CFLAGS+=-p
B
bellard 已提交
83
endif
84

B
bellard 已提交
85
OBJS= elfload.o main.o syscall.o mmap.o signal.o vm86.o path.o
B
bellard 已提交
86 87
SRCS:= $(OBJS:.o=.c)
OBJS+= libqemu.a
B
bellard 已提交
88

B
bellard 已提交
89
LIBOBJS+=thunk.o translate-i386.o op-i386.o helper-i386.o exec-i386.o exec.o
B
bellard 已提交
90

B
bellard 已提交
91
# NOTE: the disassembler code is only needed for debugging
92
LIBOBJS+=disas.o i386-dis.o
B
bellard 已提交
93 94 95 96 97 98
ifeq ($(ARCH),alpha)
LIBOBJS+=alpha-dis.o
endif
ifeq ($(ARCH),ppc)
LIBOBJS+=ppc-dis.o
endif
99 100 101 102 103 104
ifeq ($(ARCH),sparc)
LIBOBJS+=sparc-dis.o
endif
ifeq ($(ARCH),arm)
LIBOBJS+=arm-dis.o
endif
105

B
bellard 已提交
106 107 108 109
ifeq ($(ARCH),ia64)
OBJS += ia64-syscall.o
endif

B
bellard 已提交
110
all: qemu qemu-doc.html
111

B
bellard 已提交
112
qemu: $(OBJS)
B
update  
bellard 已提交
113
	$(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
B
bellard 已提交
114 115 116 117 118
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
119 120 121 122

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

B
bellard 已提交
123
# libqemu 
B
bellard 已提交
124

B
bellard 已提交
125
libqemu.a: $(LIBOBJS)
B
bellard 已提交
126 127 128
	rm -f $@
	$(AR) rcs $@ $(LIBOBJS)

B
bellard 已提交
129 130 131
dyngen: dyngen.c
	$(HOST_CC) -O2 -Wall -g $< -o $@

B
bellard 已提交
132
translate-i386.o: translate-i386.c op-i386.h opc-i386.h cpu-i386.h
B
bellard 已提交
133 134 135 136

op-i386.h: op-i386.o dyngen
	./dyngen -o $@ $<

B
bellard 已提交
137 138 139
opc-i386.h: op-i386.o dyngen
	./dyngen -c -o $@ $<

B
bellard 已提交
140
op-i386.o: op-i386.c opreg_template.h ops_template.h
B
bellard 已提交
141
	$(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
B
bellard 已提交
142

143 144 145
helper-i386.o: helper-i386.c
	$(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<

146 147 148 149
%.o: %.c
	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<

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

B
bellard 已提交
153 154 155
distclean: clean
	rm -f config.mak config.h

B
bellard 已提交
156 157
install: qemu
	install -m 755 -s qemu $(prefix)/bin
B
bellard 已提交
158

B
bellard 已提交
159
# various test targets
B
bellard 已提交
160
test speed: qemu
B
bellard 已提交
161
	make -C tests $@
162

B
bellard 已提交
163
TAGS: 
B
bellard 已提交
164
	etags *.[ch] tests/*.[ch]
165

B
bellard 已提交
166 167 168 169
# documentation
qemu-doc.html: qemu-doc.texi
	texi2html -monolithic -number $<

B
bellard 已提交
170
FILES= \
B
update  
bellard 已提交
171
README README.distrib COPYING COPYING.LIB TODO Changelog VERSION \
172
dyngen.c dyngen.h ioctls.h ops_template.h op_string.h  syscall_types.h\
B
bellard 已提交
173
Makefile     elf.h       thunk.c\
B
bellard 已提交
174
elfload.c   main.c            signal.c        thunk.h exec.h\
B
bellard 已提交
175
cpu-i386.h qemu.h op-i386.c helper-i386.c syscall-i386.h  translate-i386.c\
B
bellard 已提交
176
syscall.c opreg_template.h  syscall_defs.h vm86.c\
177 178
dis-asm.h disas.c disas.h alpha-dis.c ppc-dis.c i386-dis.c sparc-dis.c arm-dis.c\
ppc.ld alpha.ld s390.ld sparc.ld arm.ld exec-i386.h exec-i386.c path.c exec.c mmap.c configure \
B
bellard 已提交
179
tests/Makefile\
B
bellard 已提交
180
tests/test-i386.c tests/test-i386-shift.h tests/test-i386.h\
B
bellard 已提交
181 182
tests/test-i386-muldiv.h tests/test-i386-code16.S\
tests/hello.c tests/hello tests/sha1.c \
B
bellard 已提交
183
tests/testsig.c tests/testclone.c tests/testthread.c \
B
update  
bellard 已提交
184
tests/runcom.c tests/pi_10.com \
B
update  
bellard 已提交
185
tests/test_path.c \
B
bellard 已提交
186
qemu-doc.texi qemu-doc.html
B
bellard 已提交
187

B
bellard 已提交
188
FILE=qemu-$(VERSION)
B
bellard 已提交
189 190 191 192 193 194 195 196

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)

197 198 199 200
# generate a binary distribution including the test binary environnment 
BINPATH=/usr/local/qemu-i386

tarbin:
B
update  
bellard 已提交
201 202 203 204
	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
205

206 207 208
ifneq ($(wildcard .depend),)
include .depend
endif