Makefile 3.25 KB
Newer Older
bellard's avatar
bellard committed
1
include config.mak
bellard's avatar
bellard committed
2

bellard's avatar
bellard committed
3
CFLAGS=-Wall -O2 -g
4
LDFLAGS=-g
bellard's avatar
bellard committed
5
6
LIBS=
DEFINES=-DHAVE_BYTESWAP_H
bellard's avatar
bellard committed
7
8
9

ifeq ($(ARCH),i386)
CFLAGS+=-fomit-frame-pointer
bellard's avatar
bellard committed
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
bellard's avatar
update    
bellard committed
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
bellard's avatar
bellard committed
20
21
22
endif

ifeq ($(ARCH),ppc)
bellard's avatar
bellard committed
23
OP_CFLAGS=$(CFLAGS)
bellard's avatar
update    
bellard committed
24
LDFLAGS+=-Wl,-T,ppc.ld
bellard's avatar
bellard committed
25
26
endif

bellard's avatar
update    
bellard committed
27
28
ifeq ($(ARCH),s390)
OP_CFLAGS=$(CFLAGS)
bellard's avatar
update    
bellard committed
29
LDFLAGS+=-Wl,-T,s390.ld
bellard's avatar
update    
bellard committed
30
31
endif

bellard's avatar
bellard committed
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

bellard's avatar
bellard committed
37
38
#########################################################

bellard's avatar
bellard committed
39
DEFINES+=-D_GNU_SOURCE
bellard's avatar
bellard committed
40
LIBS+=-lm
bellard's avatar
bellard committed
41
42
43
44

# profiling code
ifdef TARGET_GPROF
LDFLAGS+=-p
bellard's avatar
bellard committed
45
main.o: CFLAGS+=-p
bellard's avatar
bellard committed
46
endif
47

bellard's avatar
bellard committed
48
49
50
OBJS= elfload.o main.o syscall.o signal.o
SRCS:= $(OBJS:.o=.c)
OBJS+= libqemu.a
bellard's avatar
bellard committed
51

bellard's avatar
bellard committed
52
LIBOBJS+=thunk.o translate-i386.o op-i386.o exec-i386.o
bellard's avatar
bellard committed
53
# NOTE: the disassembler code is only needed for debugging
bellard's avatar
bellard committed
54
LIBOBJS+=i386-dis.o dis-buf.o
55

bellard's avatar
bellard committed
56
all: qemu qemu-doc.html
57

bellard's avatar
bellard committed
58
qemu: $(OBJS)
bellard's avatar
update    
bellard committed
59
	$(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
60
61
62
63

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

bellard's avatar
bellard committed
64
# libqemu 
bellard's avatar
bellard committed
65

bellard's avatar
bellard committed
66
libqemu.a: $(LIBOBJS)
bellard's avatar
bellard committed
67
68
69
	rm -f $@
	$(AR) rcs $@ $(LIBOBJS)

bellard's avatar
bellard committed
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
bellard's avatar
bellard committed
79
	$(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
bellard's avatar
bellard committed
80

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

clean:
bellard's avatar
bellard committed
85
	$(MAKE) -C tests clean
bellard's avatar
bellard committed
86
	rm -f *.o  *.a *~ qemu dyngen TAGS
87

bellard's avatar
bellard committed
88
89
90
distclean: clean
	rm -f config.mak config.h

bellard's avatar
bellard committed
91
92
install: qemu
	install -m 755 -s qemu $(prefix)/bin
bellard's avatar
bellard committed
93

bellard's avatar
bellard committed
94
# various test targets
bellard's avatar
bellard committed
95
test speed: qemu
bellard's avatar
bellard committed
96
	make -C tests $@
97

bellard's avatar
bellard committed
98
99
TAGS: 
	etags *.[ch] i386/*.[ch]
100

bellard's avatar
bellard committed
101
102
103
104
# documentation
qemu-doc.html: qemu-doc.texi
	texi2html -monolithic -number $<

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

bellard's avatar
bellard committed
122
FILE=qemu-$(VERSION)
bellard's avatar
bellard committed
123
124
125
126
127
128
129
130

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)

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

tarbin:
	tar zcvf /tmp/qemu-i386-glibc21.tar.gz \
                 $(BINPATH)/etc $(BINPATH)/lib $(BINPATH)/bin
	tar zcvf /tmp/qemu-i386-wine.tar.gz \
                 $(BINPATH)/X11R6 $(BINPATH)/wine

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