blob: 9008dc95b6fe673638ffcd952cd8f77907629bcf [file] [log] [blame]
bellard7d132992003-03-06 23:23:54 +00001include config.mak
bellard766a4872003-02-18 23:35:48 +00002
bellard7d132992003-03-06 23:23:54 +00003CFLAGS=-Wall -O2 -g
bellard31e31b82003-02-18 22:55:36 +00004LDFLAGS=-g
bellard766a4872003-02-18 23:35:48 +00005LIBS=
bellard766a4872003-02-18 23:35:48 +00006DEFINES=-DHAVE_BYTESWAP_H
bellard7d132992003-03-06 23:23:54 +00007
8ifeq ($(ARCH),i386)
9CFLAGS+=-fomit-frame-pointer
bellardca735202003-03-18 20:41:34 +000010OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
11ifeq ($(GCC_MAJOR),3)
12OP_CFLAGS+= -falign-functions=0
13else
14OP_CFLAGS+= -malign-functions=0
15endif
bellard27c75a92003-04-07 21:35:21 +000016# WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
17# that the kernel ELF loader considers as an executable. I think this
18# is the simplest way to make it self virtualizable!
19LDFLAGS+=-Wl,-shared
bellard766a4872003-02-18 23:35:48 +000020endif
21
22ifeq ($(ARCH),ppc)
bellard927f6212003-03-02 19:39:42 +000023OP_CFLAGS=$(CFLAGS)
bellard27c75a92003-04-07 21:35:21 +000024LDFLAGS+=-Wl,-T,ppc.ld
bellard766a4872003-02-18 23:35:48 +000025endif
26
bellardfd429f22003-03-30 20:59:46 +000027ifeq ($(ARCH),s390)
28OP_CFLAGS=$(CFLAGS)
bellard27c75a92003-04-07 21:35:21 +000029LDFLAGS+=-Wl,-T,s390.ld
bellardfd429f22003-03-30 20:59:46 +000030endif
31
bellardca735202003-03-18 20:41:34 +000032ifeq ($(GCC_MAJOR),3)
33# very important to generate a return at the end of every operation
34OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
35endif
36
bellard766a4872003-02-18 23:35:48 +000037#########################################################
38
bellard0ecfa992003-03-03 14:32:43 +000039DEFINES+=-D_GNU_SOURCE
bellard3ef693a2003-03-23 20:17:16 +000040LIBS+=-lm
bellard7d132992003-03-06 23:23:54 +000041
42# profiling code
43ifdef TARGET_GPROF
44LDFLAGS+=-p
bellarddc990652003-03-19 00:00:28 +000045main.o: CFLAGS+=-p
bellard7d132992003-03-06 23:23:54 +000046endif
bellard31e31b82003-02-18 22:55:36 +000047
bellard1eb87252003-04-11 01:12:28 +000048OBJS= elfload.o main.o syscall.o signal.o path.o
bellard3ef693a2003-03-23 20:17:16 +000049SRCS:= $(OBJS:.o=.c)
50OBJS+= libqemu.a
bellard612384d2003-03-22 17:31:19 +000051
bellard3ef693a2003-03-23 20:17:16 +000052LIBOBJS+=thunk.o translate-i386.o op-i386.o exec-i386.o
bellard0ecfa992003-03-03 14:32:43 +000053# NOTE: the disassembler code is only needed for debugging
bellardb9adb4a2003-04-29 20:41:16 +000054LIBOBJS+=disas.o ppc-dis.o i386-dis.o dis-buf.o
bellard31e31b82003-02-18 22:55:36 +000055
bellard3ef693a2003-03-23 20:17:16 +000056all: qemu qemu-doc.html
bellard31e31b82003-02-18 22:55:36 +000057
bellard3ef693a2003-03-23 20:17:16 +000058qemu: $(OBJS)
bellard27c75a92003-04-07 21:35:21 +000059 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
bellard31e31b82003-02-18 22:55:36 +000060
61depend: $(SRCS)
62 $(CC) -MM $(CFLAGS) $^ 1>.depend
63
bellard3ef693a2003-03-23 20:17:16 +000064# libqemu
bellard612384d2003-03-22 17:31:19 +000065
bellard3ef693a2003-03-23 20:17:16 +000066libqemu.a: $(LIBOBJS)
bellard612384d2003-03-22 17:31:19 +000067 rm -f $@
68 $(AR) rcs $@ $(LIBOBJS)
69
bellard367e86e2003-03-01 17:13:26 +000070dyngen: dyngen.c
71 $(HOST_CC) -O2 -Wall -g $< -o $@
72
73translate-i386.o: translate-i386.c op-i386.h cpu-i386.h
74
75op-i386.h: op-i386.o dyngen
76 ./dyngen -o $@ $<
77
78op-i386.o: op-i386.c opreg_template.h ops_template.h
bellard927f6212003-03-02 19:39:42 +000079 $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
bellard367e86e2003-03-01 17:13:26 +000080
bellard31e31b82003-02-18 22:55:36 +000081%.o: %.c
82 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
83
84clean:
bellard7d132992003-03-06 23:23:54 +000085 $(MAKE) -C tests clean
bellard3ef693a2003-03-23 20:17:16 +000086 rm -f *.o *.a *~ qemu dyngen TAGS
bellard31e31b82003-02-18 22:55:36 +000087
bellard7d132992003-03-06 23:23:54 +000088distclean: clean
89 rm -f config.mak config.h
90
bellard3ef693a2003-03-23 20:17:16 +000091install: qemu
92 install -m 755 -s qemu $(prefix)/bin
bellard612384d2003-03-22 17:31:19 +000093
bellard367e86e2003-03-01 17:13:26 +000094# various test targets
bellard3ef693a2003-03-23 20:17:16 +000095test speed: qemu
bellard367e86e2003-03-01 17:13:26 +000096 make -C tests $@
bellard31e31b82003-02-18 22:55:36 +000097
bellard367e86e2003-03-01 17:13:26 +000098TAGS:
bellardb9adb4a2003-04-29 20:41:16 +000099 etags *.[ch] tests/*.[ch]
bellard31e31b82003-02-18 22:55:36 +0000100
bellard3ef693a2003-03-23 20:17:16 +0000101# documentation
102qemu-doc.html: qemu-doc.texi
103 texi2html -monolithic -number $<
104
bellard586314f2003-03-03 15:02:29 +0000105FILES= \
bellardfd429f22003-03-30 20:59:46 +0000106README README.distrib COPYING COPYING.LIB TODO Changelog VERSION \
107dyngen.c ioctls.h ops_template.h op_string.h syscall_types.h\
bellard09bfb052003-04-10 00:03:40 +0000108Makefile elf.h thunk.c\
bellard3ef693a2003-03-23 20:17:16 +0000109elfload.c main.c signal.c thunk.h\
bellardfd429f22003-03-30 20:59:46 +0000110cpu-i386.h qemu.h op-i386.c opc-i386.h syscall-i386.h translate-i386.c\
bellard27c75a92003-04-07 21:35:21 +0000111dis-asm.h gen-i386.h syscall.c\
bellardb9adb4a2003-04-29 20:41:16 +0000112dis-buf.c disas.c disas.h ppc-dis.c i386-dis.c opreg_template.h syscall_defs.h\
bellard1eb87252003-04-11 01:12:28 +0000113ppc.ld s390.ld exec-i386.h exec-i386.c path.c configure \
bellard77f8dd52003-03-05 22:24:48 +0000114tests/Makefile\
bellard586314f2003-03-03 15:02:29 +0000115tests/test-i386.c tests/test-i386-shift.h tests/test-i386.h\
bellard612384d2003-03-22 17:31:19 +0000116tests/test-i386-muldiv.h tests/test-i386-code16.S\
117tests/hello.c tests/hello tests/sha1.c \
bellard3ef693a2003-03-23 20:17:16 +0000118tests/testsig.c tests/testclone.c tests/testthread.c \
bellardfd429f22003-03-30 20:59:46 +0000119tests/runcom.c tests/pi_10.com \
bellard1eb87252003-04-11 01:12:28 +0000120tests/test_path.c \
bellard3ef693a2003-03-23 20:17:16 +0000121qemu-doc.texi qemu-doc.html
bellard586314f2003-03-03 15:02:29 +0000122
bellard3ef693a2003-03-23 20:17:16 +0000123FILE=qemu-$(VERSION)
bellard586314f2003-03-03 15:02:29 +0000124
125tar:
126 rm -rf /tmp/$(FILE)
127 mkdir -p /tmp/$(FILE)
128 cp -P $(FILES) /tmp/$(FILE)
129 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) )
130 rm -rf /tmp/$(FILE)
131
bellardd691f662003-03-24 21:58:34 +0000132# generate a binary distribution including the test binary environnment
133BINPATH=/usr/local/qemu-i386
134
135tarbin:
bellard1eb87252003-04-11 01:12:28 +0000136 tar zcvf /tmp/qemu-$(VERSION)-i386-glibc21.tar.gz \
137 $(BINPATH)/etc $(BINPATH)/lib $(BINPATH)/bin $(BINPATH)/usr
138 tar zcvf /tmp/qemu-$(VERSION)-i386-wine.tar.gz \
139 $(BINPATH)/wine
bellardd691f662003-03-24 21:58:34 +0000140
bellard31e31b82003-02-18 22:55:36 +0000141ifneq ($(wildcard .depend),)
142include .depend
143endif