xref: /openbmc/qemu/Makefile (revision 2d92f0b8)
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
16*2d92f0b8Sbellardifdef TARGET_GPROF
17*2d92f0b8SbellardLDFLAGS+=-Wl,-T,i386.ld
18*2d92f0b8Sbellardelse
1927c75a9aSbellard# WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
2027c75a9aSbellard# that the kernel ELF loader considers as an executable. I think this
2127c75a9aSbellard# is the simplest way to make it self virtualizable!
2227c75a9aSbellardLDFLAGS+=-Wl,-shared
23766a487aSbellardendif
24*2d92f0b8Sbellardendif
25766a487aSbellard
26766a487aSbellardifeq ($(ARCH),ppc)
27927f621eSbellardOP_CFLAGS=$(CFLAGS)
2827c75a9aSbellardLDFLAGS+=-Wl,-T,ppc.ld
29766a487aSbellardendif
30766a487aSbellard
31fd429f2fSbellardifeq ($(ARCH),s390)
32fd429f2fSbellardOP_CFLAGS=$(CFLAGS)
3327c75a9aSbellardLDFLAGS+=-Wl,-T,s390.ld
34fd429f2fSbellardendif
35fd429f2fSbellard
36ae228531Sbellardifeq ($(ARCH),sparc)
37ae228531SbellardCFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
38ae228531SbellardLDFLAGS+=-m32
39ae228531SbellardOP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
40ae228531Sbellardendif
41ae228531Sbellard
42ae228531Sbellardifeq ($(ARCH),sparc64)
43ae228531SbellardCFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
44ae228531SbellardLDFLAGS+=-m64
45ae228531SbellardOP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
46ae228531Sbellardendif
47ae228531Sbellard
48d6cdca95Sbellardifeq ($(ARCH),alpha)
49a993ba85Sbellard# -msmall-data is not used because we want two-instruction relocations
50a993ba85Sbellard# for the constant constructions
51a993ba85SbellardOP_CFLAGS=-Wall -O2 -g
52d6cdca95Sbellard# Ensure there's only a single GP
53d6cdca95SbellardCFLAGS += -msmall-data -msmall-text
54d6cdca95SbellardLDFLAGS+=-Wl,-T,alpha.ld
55d6cdca95Sbellardendif
56d6cdca95Sbellard
57d6cdca95Sbellardifeq ($(ARCH),ia64)
58d6cdca95SbellardOP_CFLAGS=$(CFLAGS)
59d6cdca95Sbellardendif
60d6cdca95Sbellard
61ca735206Sbellardifeq ($(GCC_MAJOR),3)
62ca735206Sbellard# very important to generate a return at the end of every operation
63ca735206SbellardOP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
64ca735206Sbellardendif
65ca735206Sbellard
66766a487aSbellard#########################################################
67766a487aSbellard
680ecfa993SbellardDEFINES+=-D_GNU_SOURCE
693ef693a0SbellardLIBS+=-lm
707d13299dSbellard
717d13299dSbellard# profiling code
727d13299dSbellardifdef TARGET_GPROF
737d13299dSbellardLDFLAGS+=-p
74dc99065bSbellardmain.o: CFLAGS+=-p
757d13299dSbellardendif
7631e31b8aSbellard
7754936004SbellardOBJS= elfload.o main.o syscall.o mmap.o signal.o vm86.o path.o
783ef693a0SbellardSRCS:= $(OBJS:.o=.c)
793ef693a0SbellardOBJS+= libqemu.a
80612384d7Sbellard
8154936004SbellardLIBOBJS+=thunk.o translate-i386.o op-i386.o exec-i386.o exec.o
82aa05ae6fSbellard
830ecfa993Sbellard# NOTE: the disassembler code is only needed for debugging
84aa05ae6fSbellardLIBOBJS+=disas.o i386-dis.o dis-buf.o
85aa05ae6fSbellardifeq ($(ARCH),alpha)
86aa05ae6fSbellardLIBOBJS+=alpha-dis.o
87aa05ae6fSbellardendif
88aa05ae6fSbellardifeq ($(ARCH),ppc)
89aa05ae6fSbellardLIBOBJS+=ppc-dis.o
90aa05ae6fSbellardendif
9131e31b8aSbellard
92d6cdca95Sbellardifeq ($(ARCH),ia64)
93d6cdca95SbellardOBJS += ia64-syscall.o
94d6cdca95Sbellardendif
95d6cdca95Sbellard
963ef693a0Sbellardall: qemu qemu-doc.html
9731e31b8aSbellard
983ef693a0Sbellardqemu: $(OBJS)
9927c75a9aSbellard	$(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
100a993ba85Sbellardifeq ($(ARCH),alpha)
101a993ba85Sbellard# Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
102a993ba85Sbellard# the address space (31 bit so sign extending doesn't matter)
103a993ba85Sbellard	echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
104a993ba85Sbellardendif
10531e31b8aSbellard
10631e31b8aSbellarddepend: $(SRCS)
10731e31b8aSbellard	$(CC) -MM $(CFLAGS) $^ 1>.depend
10831e31b8aSbellard
1093ef693a0Sbellard# libqemu
110612384d7Sbellard
1113ef693a0Sbellardlibqemu.a: $(LIBOBJS)
112612384d7Sbellard	rm -f $@
113612384d7Sbellard	$(AR) rcs $@ $(LIBOBJS)
114612384d7Sbellard
115367e86e8Sbellarddyngen: dyngen.c
116367e86e8Sbellard	$(HOST_CC) -O2 -Wall -g $< -o $@
117367e86e8Sbellard
118*2d92f0b8Sbellardtranslate-i386.o: translate-i386.c op-i386.h opc-i386.h cpu-i386.h
119367e86e8Sbellard
120367e86e8Sbellardop-i386.h: op-i386.o dyngen
121367e86e8Sbellard	./dyngen -o $@ $<
122367e86e8Sbellard
123*2d92f0b8Sbellardopc-i386.h: op-i386.o dyngen
124*2d92f0b8Sbellard	./dyngen -c -o $@ $<
125*2d92f0b8Sbellard
126367e86e8Sbellardop-i386.o: op-i386.c opreg_template.h ops_template.h
127927f621eSbellard	$(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
128367e86e8Sbellard
12931e31b8aSbellard%.o: %.c
13031e31b8aSbellard	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
13131e31b8aSbellard
13231e31b8aSbellardclean:
1337d13299dSbellard	$(MAKE) -C tests clean
1343ef693a0Sbellard	rm -f *.o  *.a *~ qemu dyngen TAGS
13531e31b8aSbellard
1367d13299dSbellarddistclean: clean
1377d13299dSbellard	rm -f config.mak config.h
1387d13299dSbellard
1393ef693a0Sbellardinstall: qemu
1403ef693a0Sbellard	install -m 755 -s qemu $(prefix)/bin
141612384d7Sbellard
142367e86e8Sbellard# various test targets
1433ef693a0Sbellardtest speed: qemu
144367e86e8Sbellard	make -C tests $@
14531e31b8aSbellard
146367e86e8SbellardTAGS:
147b9adb4a6Sbellard	etags *.[ch] tests/*.[ch]
14831e31b8aSbellard
1493ef693a0Sbellard# documentation
1503ef693a0Sbellardqemu-doc.html: qemu-doc.texi
1513ef693a0Sbellard	texi2html -monolithic -number $<
1523ef693a0Sbellard
153586314f2SbellardFILES= \
154fd429f2fSbellardREADME README.distrib COPYING COPYING.LIB TODO Changelog VERSION \
155fd429f2fSbellarddyngen.c ioctls.h ops_template.h op_string.h  syscall_types.h\
15609bfb054SbellardMakefile     elf.h       thunk.c\
157aa05ae6fSbellardelfload.c   main.c            signal.c        thunk.h exec.h\
158*2d92f0b8Sbellardcpu-i386.h qemu.h op-i386.c syscall-i386.h  translate-i386.c\
15976c8b771Sbellardsyscall.c opreg_template.h  syscall_defs.h vm86.c\
16076c8b771Sbellarddis-asm.h dis-buf.c disas.c disas.h alpha-dis.c ppc-dis.c i386-dis.c\
16176c8b771Sbellardppc.ld s390.ld exec-i386.h exec-i386.c path.c exec.c mmap.c configure \
16277f8dd5aSbellardtests/Makefile\
163586314f2Sbellardtests/test-i386.c tests/test-i386-shift.h tests/test-i386.h\
164612384d7Sbellardtests/test-i386-muldiv.h tests/test-i386-code16.S\
165612384d7Sbellardtests/hello.c tests/hello tests/sha1.c \
1663ef693a0Sbellardtests/testsig.c tests/testclone.c tests/testthread.c \
167fd429f2fSbellardtests/runcom.c tests/pi_10.com \
1681eb87257Sbellardtests/test_path.c \
1693ef693a0Sbellardqemu-doc.texi qemu-doc.html
170586314f2Sbellard
1713ef693a0SbellardFILE=qemu-$(VERSION)
172586314f2Sbellard
173586314f2Sbellardtar:
174586314f2Sbellard	rm -rf /tmp/$(FILE)
175586314f2Sbellard	mkdir -p /tmp/$(FILE)
176586314f2Sbellard	cp -P $(FILES) /tmp/$(FILE)
177586314f2Sbellard	( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) )
178586314f2Sbellard	rm -rf /tmp/$(FILE)
179586314f2Sbellard
180d691f669Sbellard# generate a binary distribution including the test binary environnment
181d691f669SbellardBINPATH=/usr/local/qemu-i386
182d691f669Sbellard
183d691f669Sbellardtarbin:
1841eb87257Sbellard	tar zcvf /tmp/qemu-$(VERSION)-i386-glibc21.tar.gz \
1851eb87257Sbellard                 $(BINPATH)/etc $(BINPATH)/lib $(BINPATH)/bin $(BINPATH)/usr
1861eb87257Sbellard	tar zcvf /tmp/qemu-$(VERSION)-i386-wine.tar.gz \
1871eb87257Sbellard                 $(BINPATH)/wine
188d691f669Sbellard
18931e31b8aSbellardifneq ($(wildcard .depend),)
19031e31b8aSbellardinclude .depend
19131e31b8aSbellardendif
192