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

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

ifeq ($(ARCH),ppc)
B
bellard 已提交
23
OP_CFLAGS=$(CFLAGS)
B
update  
bellard 已提交
24
LDFLAGS+=-Wl,-T,ppc.ld
B
bellard 已提交
25 26
endif

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

B
bellard 已提交
32 33 34 35 36
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 已提交
37 38
#########################################################

B
bellard 已提交
39
DEFINES+=-D_GNU_SOURCE
B
bellard 已提交
40
LIBS+=-lm
B
bellard 已提交
41 42 43 44

# profiling code
ifdef TARGET_GPROF
LDFLAGS+=-p
B
bellard 已提交
45
main.o: CFLAGS+=-p
B
bellard 已提交
46
endif
47

B
update  
bellard 已提交
48
OBJS= elfload.o main.o syscall.o signal.o path.o
B
bellard 已提交
49 50
SRCS:= $(OBJS:.o=.c)
OBJS+= libqemu.a
B
bellard 已提交
51

B
bellard 已提交
52
LIBOBJS+=thunk.o translate-i386.o op-i386.o exec-i386.o
B
bellard 已提交
53
# NOTE: the disassembler code is only needed for debugging
B
bellard 已提交
54
LIBOBJS+=disas.o ppc-dis.o i386-dis.o dis-buf.o
55

B
bellard 已提交
56
all: qemu qemu-doc.html
57

B
bellard 已提交
58
qemu: $(OBJS)
B
update  
bellard 已提交
59
	$(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
60 61 62 63

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

B
bellard 已提交
64
# libqemu 
B
bellard 已提交
65

B
bellard 已提交
66
libqemu.a: $(LIBOBJS)
B
bellard 已提交
67 68 69
	rm -f $@
	$(AR) rcs $@ $(LIBOBJS)

B
bellard 已提交
70 71 72 73 74 75 76 77 78
dyngen: dyngen.c
	$(HOST_CC) -O2 -Wall -g $< -o $@

translate-i386.o: translate-i386.c op-i386.h cpu-i386.h

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

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

81 82 83 84
%.o: %.c
	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<

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

B
bellard 已提交
88 89 90
distclean: clean
	rm -f config.mak config.h

B
bellard 已提交
91 92
install: qemu
	install -m 755 -s qemu $(prefix)/bin
B
bellard 已提交
93

B
bellard 已提交
94
# various test targets
B
bellard 已提交
95
test speed: qemu
B
bellard 已提交
96
	make -C tests $@
97

B
bellard 已提交
98
TAGS: 
B
bellard 已提交
99
	etags *.[ch] tests/*.[ch]
100

B
bellard 已提交
101 102 103 104
# documentation
qemu-doc.html: qemu-doc.texi
	texi2html -monolithic -number $<

B
bellard 已提交
105
FILES= \
B
update  
bellard 已提交
106 107
README README.distrib COPYING COPYING.LIB TODO Changelog VERSION \
dyngen.c ioctls.h ops_template.h op_string.h  syscall_types.h\
B
bellard 已提交
108
Makefile     elf.h       thunk.c\
B
bellard 已提交
109
elfload.c   main.c            signal.c        thunk.h\
B
update  
bellard 已提交
110
cpu-i386.h qemu.h op-i386.c opc-i386.h syscall-i386.h  translate-i386.c\
B
update  
bellard 已提交
111
dis-asm.h    gen-i386.h  syscall.c\
B
bellard 已提交
112
dis-buf.c disas.c disas.h ppc-dis.c i386-dis.c  opreg_template.h  syscall_defs.h\
B
update  
bellard 已提交
113
ppc.ld s390.ld exec-i386.h exec-i386.c path.c configure \
B
bellard 已提交
114
tests/Makefile\
B
bellard 已提交
115
tests/test-i386.c tests/test-i386-shift.h tests/test-i386.h\
B
bellard 已提交
116 117
tests/test-i386-muldiv.h tests/test-i386-code16.S\
tests/hello.c tests/hello tests/sha1.c \
B
bellard 已提交
118
tests/testsig.c tests/testclone.c tests/testthread.c \
B
update  
bellard 已提交
119
tests/runcom.c tests/pi_10.com \
B
update  
bellard 已提交
120
tests/test_path.c \
B
bellard 已提交
121
qemu-doc.texi qemu-doc.html
B
bellard 已提交
122

B
bellard 已提交
123
FILE=qemu-$(VERSION)
B
bellard 已提交
124 125 126 127 128 129 130 131

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)

132 133 134 135
# generate a binary distribution including the test binary environnment 
BINPATH=/usr/local/qemu-i386

tarbin:
B
update  
bellard 已提交
136 137 138 139
	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
140

141 142 143
ifneq ($(wildcard .depend),)
include .depend
endif