blob: 8b92f0e5ff37b16581c941885cf3ec972a2328b7 [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
bellard766a4872003-02-18 23:35:48 +000016endif
17
18ifeq ($(ARCH),ppc)
bellard927f6212003-03-02 19:39:42 +000019OP_CFLAGS=$(CFLAGS)
bellard766a4872003-02-18 23:35:48 +000020endif
21
bellardca735202003-03-18 20:41:34 +000022ifeq ($(GCC_MAJOR),3)
23# very important to generate a return at the end of every operation
24OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
25endif
26
bellard766a4872003-02-18 23:35:48 +000027#########################################################
28
bellard0ecfa992003-03-03 14:32:43 +000029DEFINES+=-D_GNU_SOURCE
bellard766a4872003-02-18 23:35:48 +000030LDSCRIPT=$(ARCH).ld
bellard927f6212003-03-02 19:39:42 +000031LIBS+=-ldl -lm
bellard7d132992003-03-06 23:23:54 +000032
33# profiling code
34ifdef TARGET_GPROF
35LDFLAGS+=-p
bellarddc990652003-03-19 00:00:28 +000036main.o: CFLAGS+=-p
bellard7d132992003-03-06 23:23:54 +000037endif
bellard31e31b82003-02-18 22:55:36 +000038
bellard586314f2003-03-03 15:02:29 +000039OBJS= elfload.o main.o thunk.o syscall.o
bellard7d132992003-03-06 23:23:54 +000040OBJS+=translate-i386.o op-i386.o exec-i386.o
bellard0ecfa992003-03-03 14:32:43 +000041# NOTE: the disassembler code is only needed for debugging
42OBJS+=i386-dis.o dis-buf.o
bellard31e31b82003-02-18 22:55:36 +000043SRCS = $(OBJS:.o=.c)
44
45all: gemu
46
47gemu: $(OBJS)
bellard367e86e2003-03-01 17:13:26 +000048 $(CC) -Wl,-T,$(LDSCRIPT) $(LDFLAGS) -o $@ $^ $(LIBS)
bellard31e31b82003-02-18 22:55:36 +000049
50depend: $(SRCS)
51 $(CC) -MM $(CFLAGS) $^ 1>.depend
52
bellard367e86e2003-03-01 17:13:26 +000053# new i386 emulator
54dyngen: dyngen.c
55 $(HOST_CC) -O2 -Wall -g $< -o $@
56
57translate-i386.o: translate-i386.c op-i386.h cpu-i386.h
58
59op-i386.h: op-i386.o dyngen
60 ./dyngen -o $@ $<
61
62op-i386.o: op-i386.c opreg_template.h ops_template.h
bellard927f6212003-03-02 19:39:42 +000063 $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
bellard367e86e2003-03-01 17:13:26 +000064
bellard31e31b82003-02-18 22:55:36 +000065%.o: %.c
66 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
67
68clean:
bellard7d132992003-03-06 23:23:54 +000069 $(MAKE) -C tests clean
bellard586314f2003-03-03 15:02:29 +000070 rm -f *.o *~ gemu dyngen TAGS
bellard31e31b82003-02-18 22:55:36 +000071
bellard7d132992003-03-06 23:23:54 +000072distclean: clean
73 rm -f config.mak config.h
74
bellard367e86e2003-03-01 17:13:26 +000075# various test targets
76test speed: gemu
77 make -C tests $@
bellard31e31b82003-02-18 22:55:36 +000078
bellard367e86e2003-03-01 17:13:26 +000079TAGS:
80 etags *.[ch] i386/*.[ch]
bellard31e31b82003-02-18 22:55:36 +000081
bellard586314f2003-03-03 15:02:29 +000082FILES= \
83COPYING.LIB dyngen.c ioctls.h ops_template.h syscall_types.h\
84Makefile elf.h linux_bin.h segment.h thunk.c\
85TODO elfload.c main.c signal.c thunk.h\
86cpu-i386.h gemu.h op-i386.c syscall-i386.h translate-i386.c\
87dis-asm.h gen-i386.h op-i386.h syscall.c\
88dis-buf.c i386-dis.c opreg_template.h syscall_defs.h\
bellard7d132992003-03-06 23:23:54 +000089i386.ld ppc.ld exec-i386.h exec-i386.c configure VERSION \
bellard77f8dd52003-03-05 22:24:48 +000090tests/Makefile\
bellard586314f2003-03-03 15:02:29 +000091tests/test-i386.c tests/test-i386-shift.h tests/test-i386.h\
bellardd57c4e02003-03-04 01:14:13 +000092tests/test-i386-muldiv.h\
bellard1017ebe2003-03-05 23:26:16 +000093tests/test2.c tests/hello.c tests/sha1.c
bellard586314f2003-03-03 15:02:29 +000094
95FILE=gemu-$(VERSION)
96
97tar:
98 rm -rf /tmp/$(FILE)
99 mkdir -p /tmp/$(FILE)
100 cp -P $(FILES) /tmp/$(FILE)
101 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) )
102 rm -rf /tmp/$(FILE)
103
bellard31e31b82003-02-18 22:55:36 +0000104ifneq ($(wildcard .depend),)
105include .depend
106endif