Makefile 5.7 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

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

B
bellard 已提交
13 14
ifeq ($(ARCH),i386)
CFLAGS+=-fomit-frame-pointer
B
bellard 已提交
15 16 17 18 19 20
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 已提交
21 22 23
ifdef TARGET_GPROF
LDFLAGS+=-Wl,-T,i386.ld
else
B
update  
bellard 已提交
24 25 26 27
# 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 已提交
28
endif
B
bellard 已提交
29
endif
B
bellard 已提交
30 31

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

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

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

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

68 69 70 71 72
ifeq ($(ARCH),arm)
OP_CFLAGS=$(CFLAGS) -mno-sched-prolog
LDFLAGS+=-Wl,-T,arm.ld
endif

B
bellard 已提交
73 74 75 76 77
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 已提交
78 79
#########################################################

B
bellard 已提交
80
DEFINES+=-D_GNU_SOURCE
B
bellard 已提交
81
LIBS+=-lm
B
bellard 已提交
82 83 84 85

# profiling code
ifdef TARGET_GPROF
LDFLAGS+=-p
B
bellard 已提交
86
main.o: CFLAGS+=-p
B
bellard 已提交
87
endif
88

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

B
bellard 已提交
96 97 98 99 100 101 102 103 104
# cpu emulator library
LIBOBJS=thunk.o exec.o translate.o cpu-exec.o 

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

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

B
bellard 已提交
124 125 126 127
ifeq ($(ARCH),ia64)
OBJS += ia64-syscall.o
endif

B
bellard 已提交
128
all: qemu qemu-doc.html
129

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

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

B
bellard 已提交
141
# libqemu 
B
bellard 已提交
142

B
bellard 已提交
143
libqemu.a: $(LIBOBJS)
B
bellard 已提交
144 145 146
	rm -f $@
	$(AR) rcs $@ $(LIBOBJS)

B
bellard 已提交
147 148 149
dyngen: dyngen.c
	$(HOST_CC) -O2 -Wall -g $< -o $@

B
bellard 已提交
150 151 152
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 已提交
153

B
bellard 已提交
154
op-$(TARGET_ARCH).h: op-$(TARGET_ARCH).o dyngen
B
bellard 已提交
155 156
	./dyngen -o $@ $<

B
bellard 已提交
157
opc-$(TARGET_ARCH).h: op-$(TARGET_ARCH).o dyngen
B
bellard 已提交
158 159
	./dyngen -c -o $@ $<

B
bellard 已提交
160 161 162 163
gen-op-$(TARGET_ARCH).h: op-$(TARGET_ARCH).o dyngen
	./dyngen -g -o $@ $<

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

B
bellard 已提交
166
helper-$(TARGET_ARCH).o: helper-$(TARGET_ARCH).c
167 168
	$(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<

B
bellard 已提交
169 170 171 172
op-i386.o: op-i386.c opreg_template.h ops_template.h

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

173 174 175 176
%.o: %.c
	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<

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

B
bellard 已提交
180 181 182
distclean: clean
	rm -f config.mak config.h

B
bellard 已提交
183 184
install: qemu
	install -m 755 -s qemu $(prefix)/bin
B
bellard 已提交
185

B
bellard 已提交
186
# various test targets
B
bellard 已提交
187
test speed: qemu
B
bellard 已提交
188
	make -C tests $@
189

B
bellard 已提交
190
TAGS: 
B
bellard 已提交
191
	etags *.[ch] tests/*.[ch]
192

B
bellard 已提交
193 194 195 196
# documentation
qemu-doc.html: qemu-doc.texi
	texi2html -monolithic -number $<

B
bellard 已提交
197
FILES= \
B
update  
bellard 已提交
198
README README.distrib COPYING COPYING.LIB TODO Changelog VERSION \
B
bellard 已提交
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
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 \
ppc.ld alpha.ld s390.ld sparc.ld arm.ld\
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 已提交
214
tests/hello-i386.c tests/hello-i386 \
B
bellard 已提交
215 216
tests/hello-arm.c tests/hello-arm \
tests/sha1.c \
B
bellard 已提交
217
tests/testsig.c tests/testclone.c tests/testthread.c \
B
update  
bellard 已提交
218
tests/runcom.c tests/pi_10.com \
B
update  
bellard 已提交
219
tests/test_path.c \
B
bellard 已提交
220
qemu-doc.texi qemu-doc.html
B
bellard 已提交
221

B
bellard 已提交
222
FILE=qemu-$(VERSION)
B
bellard 已提交
223 224 225 226 227 228 229 230

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)

231 232 233 234
# generate a binary distribution including the test binary environnment 
BINPATH=/usr/local/qemu-i386

tarbin:
B
update  
bellard 已提交
235 236 237 238
	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
239

240 241 242
ifneq ($(wildcard .depend),)
include .depend
endif