xref: /openbmc/qemu/Makefile (revision 76c8b771)
17d13299dSbellardinclude config.mak
2766a487aSbellard
37d13299dSbellardCFLAGS=-Wall -O2 -g
431e31b8aSbellardLDFLAGS=-g
5766a487aSbellardLIBS=
6766a487aSbellardDEFINES=-DHAVE_BYTESWAP_H
77d13299dSbellard
87d13299dSbellardifeq ($(ARCH),i386)
97d13299dSbellardCFLAGS+=-fomit-frame-pointer
10ca735206SbellardOP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
11ca735206Sbellardifeq ($(GCC_MAJOR),3)
12ca735206SbellardOP_CFLAGS+= -falign-functions=0
13ca735206Sbellardelse
14ca735206SbellardOP_CFLAGS+= -malign-functions=0
15ca735206Sbellardendif
1627c75a9aSbellard# WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
1727c75a9aSbellard# that the kernel ELF loader considers as an executable. I think this
1827c75a9aSbellard# is the simplest way to make it self virtualizable!
1927c75a9aSbellardLDFLAGS+=-Wl,-shared
20766a487aSbellardendif
21766a487aSbellard
22766a487aSbellardifeq ($(ARCH),ppc)
23927f621eSbellardOP_CFLAGS=$(CFLAGS)
2427c75a9aSbellardLDFLAGS+=-Wl,-T,ppc.ld
25766a487aSbellardendif
26766a487aSbellard
27fd429f2fSbellardifeq ($(ARCH),s390)
28fd429f2fSbellardOP_CFLAGS=$(CFLAGS)
2927c75a9aSbellardLDFLAGS+=-Wl,-T,s390.ld
30fd429f2fSbellardendif
31fd429f2fSbellard
32ae228531Sbellardifeq ($(ARCH),sparc)
33ae228531SbellardCFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
34ae228531SbellardLDFLAGS+=-m32
35ae228531SbellardOP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
36ae228531Sbellardendif
37ae228531Sbellard
38ae228531Sbellardifeq ($(ARCH),sparc64)
39ae228531SbellardCFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
40ae228531SbellardLDFLAGS+=-m64
41ae228531SbellardOP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
42ae228531Sbellardendif
43ae228531Sbellard
44d6cdca95Sbellardifeq ($(ARCH),alpha)
45a993ba85Sbellard# -msmall-data is not used because we want two-instruction relocations
46a993ba85Sbellard# for the constant constructions
47a993ba85SbellardOP_CFLAGS=-Wall -O2 -g
48d6cdca95Sbellard# Ensure there's only a single GP
49d6cdca95SbellardCFLAGS += -msmall-data -msmall-text
50d6cdca95SbellardLDFLAGS+=-Wl,-T,alpha.ld
51d6cdca95Sbellardendif
52d6cdca95Sbellard
53d6cdca95Sbellardifeq ($(ARCH),ia64)
54d6cdca95SbellardOP_CFLAGS=$(CFLAGS)
55d6cdca95Sbellardendif
56d6cdca95Sbellard
57ca735206Sbellardifeq ($(GCC_MAJOR),3)
58ca735206Sbellard# very important to generate a return at the end of every operation
59ca735206SbellardOP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
60ca735206Sbellardendif
61ca735206Sbellard
62766a487aSbellard#########################################################
63766a487aSbellard
640ecfa993SbellardDEFINES+=-D_GNU_SOURCE
653ef693a0SbellardLIBS+=-lm
667d13299dSbellard
677d13299dSbellard# profiling code
687d13299dSbellardifdef TARGET_GPROF
697d13299dSbellardLDFLAGS+=-p
70dc99065bSbellardmain.o: CFLAGS+=-p
717d13299dSbellardendif
7231e31b8aSbellard
7354936004SbellardOBJS= elfload.o main.o syscall.o mmap.o signal.o vm86.o path.o
743ef693a0SbellardSRCS:= $(OBJS:.o=.c)
753ef693a0SbellardOBJS+= libqemu.a
76612384d7Sbellard
7754936004SbellardLIBOBJS+=thunk.o translate-i386.o op-i386.o exec-i386.o exec.o
780ecfa993Sbellard# NOTE: the disassembler code is only needed for debugging
79a993ba85SbellardLIBOBJS+=disas.o ppc-dis.o i386-dis.o alpha-dis.o dis-buf.o
8031e31b8aSbellard
81d6cdca95Sbellardifeq ($(ARCH),ia64)
82d6cdca95SbellardOBJS += ia64-syscall.o
83d6cdca95Sbellardendif
84d6cdca95Sbellard
853ef693a0Sbellardall: qemu qemu-doc.html
8631e31b8aSbellard
873ef693a0Sbellardqemu: $(OBJS)
8827c75a9aSbellard	$(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
89a993ba85Sbellardifeq ($(ARCH),alpha)
90a993ba85Sbellard# Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
91a993ba85Sbellard# the address space (31 bit so sign extending doesn't matter)
92a993ba85Sbellard	echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
93a993ba85Sbellardendif
9431e31b8aSbellard
9531e31b8aSbellarddepend: $(SRCS)
9631e31b8aSbellard	$(CC) -MM $(CFLAGS) $^ 1>.depend
9731e31b8aSbellard
983ef693a0Sbellard# libqemu
99612384d7Sbellard
1003ef693a0Sbellardlibqemu.a: $(LIBOBJS)
101612384d7Sbellard	rm -f $@
102612384d7Sbellard	$(AR) rcs $@ $(LIBOBJS)
103612384d7Sbellard
104367e86e8Sbellarddyngen: dyngen.c
105367e86e8Sbellard	$(HOST_CC) -O2 -Wall -g $< -o $@
106367e86e8Sbellard
107367e86e8Sbellardtranslate-i386.o: translate-i386.c op-i386.h cpu-i386.h
108367e86e8Sbellard
109367e86e8Sbellardop-i386.h: op-i386.o dyngen
110367e86e8Sbellard	./dyngen -o $@ $<
111367e86e8Sbellard
112367e86e8Sbellardop-i386.o: op-i386.c opreg_template.h ops_template.h
113927f621eSbellard	$(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
114367e86e8Sbellard
11531e31b8aSbellard%.o: %.c
11631e31b8aSbellard	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
11731e31b8aSbellard
11831e31b8aSbellardclean:
1197d13299dSbellard	$(MAKE) -C tests clean
1203ef693a0Sbellard	rm -f *.o  *.a *~ qemu dyngen TAGS
12131e31b8aSbellard
1227d13299dSbellarddistclean: clean
1237d13299dSbellard	rm -f config.mak config.h
1247d13299dSbellard
1253ef693a0Sbellardinstall: qemu
1263ef693a0Sbellard	install -m 755 -s qemu $(prefix)/bin
127612384d7Sbellard
128367e86e8Sbellard# various test targets
1293ef693a0Sbellardtest speed: qemu
130367e86e8Sbellard	make -C tests $@
13131e31b8aSbellard
132367e86e8SbellardTAGS:
133b9adb4a6Sbellard	etags *.[ch] tests/*.[ch]
13431e31b8aSbellard
1353ef693a0Sbellard# documentation
1363ef693a0Sbellardqemu-doc.html: qemu-doc.texi
1373ef693a0Sbellard	texi2html -monolithic -number $<
1383ef693a0Sbellard
139586314f2SbellardFILES= \
140fd429f2fSbellardREADME README.distrib COPYING COPYING.LIB TODO Changelog VERSION \
141fd429f2fSbellarddyngen.c ioctls.h ops_template.h op_string.h  syscall_types.h\
14209bfb054SbellardMakefile     elf.h       thunk.c\
1433ef693a0Sbellardelfload.c   main.c            signal.c        thunk.h\
1443ef693a0Sbellardcpu-i386.h qemu.h op-i386.c opc-i386.h syscall-i386.h  translate-i386.c\
145*76c8b771Sbellardsyscall.c opreg_template.h  syscall_defs.h vm86.c\
146*76c8b771Sbellarddis-asm.h dis-buf.c disas.c disas.h alpha-dis.c ppc-dis.c i386-dis.c\
147*76c8b771Sbellardppc.ld s390.ld exec-i386.h exec-i386.c path.c exec.c mmap.c configure \
14877f8dd5aSbellardtests/Makefile\
149586314f2Sbellardtests/test-i386.c tests/test-i386-shift.h tests/test-i386.h\
150612384d7Sbellardtests/test-i386-muldiv.h tests/test-i386-code16.S\
151612384d7Sbellardtests/hello.c tests/hello tests/sha1.c \
1523ef693a0Sbellardtests/testsig.c tests/testclone.c tests/testthread.c \
153fd429f2fSbellardtests/runcom.c tests/pi_10.com \
1541eb87257Sbellardtests/test_path.c \
1553ef693a0Sbellardqemu-doc.texi qemu-doc.html
156586314f2Sbellard
1573ef693a0SbellardFILE=qemu-$(VERSION)
158586314f2Sbellard
159586314f2Sbellardtar:
160586314f2Sbellard	rm -rf /tmp/$(FILE)
161586314f2Sbellard	mkdir -p /tmp/$(FILE)
162586314f2Sbellard	cp -P $(FILES) /tmp/$(FILE)
163586314f2Sbellard	( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) )
164586314f2Sbellard	rm -rf /tmp/$(FILE)
165586314f2Sbellard
166d691f669Sbellard# generate a binary distribution including the test binary environnment
167d691f669SbellardBINPATH=/usr/local/qemu-i386
168d691f669Sbellard
169d691f669Sbellardtarbin:
1701eb87257Sbellard	tar zcvf /tmp/qemu-$(VERSION)-i386-glibc21.tar.gz \
1711eb87257Sbellard                 $(BINPATH)/etc $(BINPATH)/lib $(BINPATH)/bin $(BINPATH)/usr
1721eb87257Sbellard	tar zcvf /tmp/qemu-$(VERSION)-i386-wine.tar.gz \
1731eb87257Sbellard                 $(BINPATH)/wine
174d691f669Sbellard
17531e31b8aSbellardifneq ($(wildcard .depend),)
17631e31b8aSbellardinclude .depend
17731e31b8aSbellardendif
178