xref: /openbmc/qemu/Makefile (revision 33e3963e)
17d13299dSbellardinclude config.mak
2766a487aSbellard
37d13299dSbellardCFLAGS=-Wall -O2 -g
431e31b8aSbellardLDFLAGS=-g
5766a487aSbellardLIBS=
6766a487aSbellardDEFINES=-DHAVE_BYTESWAP_H
79c5d1246SbellardHELPER_CFLAGS=$(CFLAGS)
86b1534ccSbellardPROGS=qemu
97d13299dSbellard
1043ce4dfeSbellardifdef CONFIG_STATIC
1143ce4dfeSbellardLDFLAGS+=-static
1243ce4dfeSbellardendif
1343ce4dfeSbellard
147d13299dSbellardifeq ($(ARCH),i386)
157d13299dSbellardCFLAGS+=-fomit-frame-pointer
16ca735206SbellardOP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
176b1534ccSbellardifeq ($(HAVE_GCC3_OPTIONS),yes)
18ca735206SbellardOP_CFLAGS+= -falign-functions=0
19ca735206Sbellardelse
20ca735206SbellardOP_CFLAGS+= -malign-functions=0
21ca735206Sbellardendif
222d92f0b8Sbellardifdef TARGET_GPROF
232d92f0b8SbellardLDFLAGS+=-Wl,-T,i386.ld
242d92f0b8Sbellardelse
2527c75a9aSbellard# WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
2627c75a9aSbellard# that the kernel ELF loader considers as an executable. I think this
2727c75a9aSbellard# is the simplest way to make it self virtualizable!
2827c75a9aSbellardLDFLAGS+=-Wl,-shared
29766a487aSbellardendif
306b1534ccSbellardifeq ($(TARGET_ARCH), i386)
31*33e3963eSbellardPROGS+=vl vlmkcow
326b1534ccSbellardendif
332d92f0b8Sbellardendif
34766a487aSbellard
35766a487aSbellardifeq ($(ARCH),ppc)
36927f621eSbellardOP_CFLAGS=$(CFLAGS)
3727c75a9aSbellardLDFLAGS+=-Wl,-T,ppc.ld
38766a487aSbellardendif
39766a487aSbellard
40fd429f2fSbellardifeq ($(ARCH),s390)
41fd429f2fSbellardOP_CFLAGS=$(CFLAGS)
4227c75a9aSbellardLDFLAGS+=-Wl,-T,s390.ld
43fd429f2fSbellardendif
44fd429f2fSbellard
45ae228531Sbellardifeq ($(ARCH),sparc)
46ae228531SbellardCFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
47ae228531SbellardLDFLAGS+=-m32
48ae228531SbellardOP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
499c5d1246SbellardHELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
509c5d1246SbellardLDFLAGS+=-Wl,-T,sparc.ld
51ae228531Sbellardendif
52ae228531Sbellard
53ae228531Sbellardifeq ($(ARCH),sparc64)
54ae228531SbellardCFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
55ae228531SbellardLDFLAGS+=-m64
56ae228531SbellardOP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
57ae228531Sbellardendif
58ae228531Sbellard
59d6cdca95Sbellardifeq ($(ARCH),alpha)
60a993ba85Sbellard# -msmall-data is not used because we want two-instruction relocations
61a993ba85Sbellard# for the constant constructions
62a993ba85SbellardOP_CFLAGS=-Wall -O2 -g
63d6cdca95Sbellard# Ensure there's only a single GP
6482d19dafSbellardCFLAGS += -msmall-data
65d6cdca95SbellardLDFLAGS+=-Wl,-T,alpha.ld
66d6cdca95Sbellardendif
67d6cdca95Sbellard
68d6cdca95Sbellardifeq ($(ARCH),ia64)
69d6cdca95SbellardOP_CFLAGS=$(CFLAGS)
70d6cdca95Sbellardendif
71d6cdca95Sbellard
729c5d1246Sbellardifeq ($(ARCH),arm)
739c5d1246SbellardOP_CFLAGS=$(CFLAGS) -mno-sched-prolog
749c5d1246SbellardLDFLAGS+=-Wl,-T,arm.ld
759c5d1246Sbellardendif
769c5d1246Sbellard
776b1534ccSbellardifeq ($(HAVE_GCC3_OPTIONS),yes)
78ca735206Sbellard# very important to generate a return at the end of every operation
79ca735206SbellardOP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
80ca735206Sbellardendif
81ca735206Sbellard
82766a487aSbellard#########################################################
83766a487aSbellard
840ecfa993SbellardDEFINES+=-D_GNU_SOURCE
853ef693a0SbellardLIBS+=-lm
867d13299dSbellard
877d13299dSbellard# profiling code
887d13299dSbellardifdef TARGET_GPROF
897d13299dSbellardLDFLAGS+=-p
90dc99065bSbellardmain.o: CFLAGS+=-p
917d13299dSbellardendif
9231e31b8aSbellard
93de83cd02SbellardOBJS= elfload.o main.o syscall.o mmap.o signal.o path.o
94de83cd02Sbellardifeq ($(TARGET_ARCH), i386)
95de83cd02SbellardOBJS+= vm86.o
96de83cd02Sbellardendif
973ef693a0SbellardSRCS:= $(OBJS:.o=.c)
983ef693a0SbellardOBJS+= libqemu.a
99612384d7Sbellard
100de83cd02Sbellard# cpu emulator library
101b4608c04SbellardLIBOBJS=thunk.o exec.o translate.o cpu-exec.o gdbstub.o
102de83cd02Sbellard
103de83cd02Sbellardifeq ($(TARGET_ARCH), i386)
104de83cd02SbellardLIBOBJS+=translate-i386.o op-i386.o helper-i386.o
105de83cd02Sbellardendif
106de83cd02Sbellardifeq ($(TARGET_ARCH), arm)
107de83cd02SbellardLIBOBJS+=translate-arm.o op-arm.o
108de83cd02Sbellardendif
109aa05ae6fSbellard
1100ecfa993Sbellard# NOTE: the disassembler code is only needed for debugging
111de83cd02SbellardLIBOBJS+=disas.o
112de83cd02Sbellardifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
113de83cd02SbellardLIBOBJS+=i386-dis.o
114de83cd02Sbellardendif
115de83cd02Sbellardifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
116aa05ae6fSbellardLIBOBJS+=alpha-dis.o
117aa05ae6fSbellardendif
118de83cd02Sbellardifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
119aa05ae6fSbellardLIBOBJS+=ppc-dis.o
120aa05ae6fSbellardendif
121de83cd02Sbellardifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
1229c5d1246SbellardLIBOBJS+=sparc-dis.o
1239c5d1246Sbellardendif
124de83cd02Sbellardifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
1259c5d1246SbellardLIBOBJS+=arm-dis.o
1269c5d1246Sbellardendif
12731e31b8aSbellard
128d6cdca95Sbellardifeq ($(ARCH),ia64)
129d6cdca95SbellardOBJS += ia64-syscall.o
130d6cdca95Sbellardendif
131d6cdca95Sbellard
1326b1534ccSbellardall: $(PROGS) qemu-doc.html
13331e31b8aSbellard
1343ef693a0Sbellardqemu: $(OBJS)
13527c75a9aSbellard	$(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
136a993ba85Sbellardifeq ($(ARCH),alpha)
137a993ba85Sbellard# Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
138a993ba85Sbellard# the address space (31 bit so sign extending doesn't matter)
139a993ba85Sbellard	echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
140a993ba85Sbellardendif
14131e31b8aSbellard
1420824d6fcSbellard# must use static linking to avoid leaving stuff in virtual address space
1438c9b861eSbellardvl: vl.o block.o libqemu.a
144*33e3963eSbellard	$(CC) -pg -static -Wl,-T,i386-vl.ld -o $@ $^  $(LIBS)
145*33e3963eSbellard
146*33e3963eSbellardvlmkcow: vlmkcow.o
147*33e3963eSbellard	$(CC) -o $@ $^  $(LIBS)
1480824d6fcSbellard
14931e31b8aSbellarddepend: $(SRCS)
15031e31b8aSbellard	$(CC) -MM $(CFLAGS) $^ 1>.depend
15131e31b8aSbellard
1523ef693a0Sbellard# libqemu
153612384d7Sbellard
1543ef693a0Sbellardlibqemu.a: $(LIBOBJS)
155612384d7Sbellard	rm -f $@
156612384d7Sbellard	$(AR) rcs $@ $(LIBOBJS)
157612384d7Sbellard
158367e86e8Sbellarddyngen: dyngen.c
159367e86e8Sbellard	$(HOST_CC) -O2 -Wall -g $< -o $@
160367e86e8Sbellard
161de83cd02Sbellardtranslate-$(TARGET_ARCH).o: translate-$(TARGET_ARCH).c gen-op-$(TARGET_ARCH).h opc-$(TARGET_ARCH).h cpu-$(TARGET_ARCH).h
162367e86e8Sbellard
163de83cd02Sbellardtranslate.o: translate.c op-$(TARGET_ARCH).h opc-$(TARGET_ARCH).h cpu-$(TARGET_ARCH).h
164de83cd02Sbellard
165de83cd02Sbellardop-$(TARGET_ARCH).h: op-$(TARGET_ARCH).o dyngen
166367e86e8Sbellard	./dyngen -o $@ $<
167367e86e8Sbellard
168de83cd02Sbellardopc-$(TARGET_ARCH).h: op-$(TARGET_ARCH).o dyngen
1692d92f0b8Sbellard	./dyngen -c -o $@ $<
1702d92f0b8Sbellard
171de83cd02Sbellardgen-op-$(TARGET_ARCH).h: op-$(TARGET_ARCH).o dyngen
172de83cd02Sbellard	./dyngen -g -o $@ $<
173de83cd02Sbellard
174de83cd02Sbellardop-$(TARGET_ARCH).o: op-$(TARGET_ARCH).c
175927f621eSbellard	$(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
176367e86e8Sbellard
177de83cd02Sbellardhelper-$(TARGET_ARCH).o: helper-$(TARGET_ARCH).c
1789c5d1246Sbellard	$(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
1799c5d1246Sbellard
180e477b8b8Sbellardop-i386.o: op-i386.c opreg_template.h ops_template.h ops_template_mem.h
181de83cd02Sbellard
182de83cd02Sbellardop-arm.o: op-arm.c op-arm-template.h
183de83cd02Sbellard
18431e31b8aSbellard%.o: %.c
18531e31b8aSbellard	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
18631e31b8aSbellard
18731e31b8aSbellardclean:
1887d13299dSbellard	$(MAKE) -C tests clean
1893ef693a0Sbellard	rm -f *.o  *.a *~ qemu dyngen TAGS
19031e31b8aSbellard
1917d13299dSbellarddistclean: clean
1927d13299dSbellard	rm -f config.mak config.h
1937d13299dSbellard
1946b1534ccSbellardinstall: $(PROGS)
195d5a0b50cSbellard	mkdir -p $(prefix)/bin
1966b1534ccSbellard	install -m 755 -s $(PROGS) $(prefix)/bin
197612384d7Sbellard
198367e86e8Sbellard# various test targets
1993ef693a0Sbellardtest speed: qemu
200367e86e8Sbellard	make -C tests $@
20131e31b8aSbellard
202367e86e8SbellardTAGS:
203b9adb4a6Sbellard	etags *.[ch] tests/*.[ch]
20431e31b8aSbellard
2053ef693a0Sbellard# documentation
2063ef693a0Sbellardqemu-doc.html: qemu-doc.texi
2073ef693a0Sbellard	texi2html -monolithic -number $<
2083ef693a0Sbellard
209586314f2SbellardFILES= \
210fd429f2fSbellardREADME README.distrib COPYING COPYING.LIB TODO Changelog VERSION \
211de83cd02Sbellardconfigure \
212de83cd02Sbellarddyngen.c dyngen.h dyngen-exec.h ioctls.h syscall_types.h \
213de83cd02SbellardMakefile elf.h elfload.c main.c signal.c qemu.h \
214de83cd02Sbellardsyscall.c syscall_defs.h vm86.c path.c mmap.c \
2156b1534ccSbellardi386.ld ppc.ld alpha.ld s390.ld sparc.ld arm.ld\
2168c9b861eSbellardvl.c i386-vl.ld vl.h block.c\
217de83cd02Sbellardthunk.c cpu-exec.c translate.c cpu-all.h thunk.h exec.h\
218de83cd02Sbellardexec.c cpu-exec.c\
219de83cd02Sbellardcpu-i386.h op-i386.c helper-i386.c syscall-i386.h translate-i386.c \
220de83cd02Sbellardexec-i386.h ops_template.h op_string.h opreg_template.h \
221de83cd02Sbellardcpu-arm.h syscall-arm.h exec-arm.h op-arm.c translate-arm.c op-arm-template.h \
222de83cd02Sbellarddis-asm.h disas.c disas.h alpha-dis.c ppc-dis.c i386-dis.c sparc-dis.c \
223de83cd02Sbellardarm-dis.c \
22477f8dd5aSbellardtests/Makefile \
225586314f2Sbellardtests/test-i386.c tests/test-i386-shift.h tests/test-i386.h \
226de83cd02Sbellardtests/test-i386-muldiv.h tests/test-i386-code16.S tests/test-i386-vm86.S \
227322d0c66Sbellardtests/hello-i386.c tests/hello-i386 \
228de83cd02Sbellardtests/hello-arm.c tests/hello-arm \
229de83cd02Sbellardtests/sha1.c \
2303ef693a0Sbellardtests/testsig.c tests/testclone.c tests/testthread.c \
231fd429f2fSbellardtests/runcom.c tests/pi_10.com \
2321eb87257Sbellardtests/test_path.c \
2333ef693a0Sbellardqemu-doc.texi qemu-doc.html
234586314f2Sbellard
2353ef693a0SbellardFILE=qemu-$(VERSION)
236586314f2Sbellard
237586314f2Sbellardtar:
238586314f2Sbellard	rm -rf /tmp/$(FILE)
239586314f2Sbellard	mkdir -p /tmp/$(FILE)
240586314f2Sbellard	cp -P $(FILES) /tmp/$(FILE)
241586314f2Sbellard	( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) )
242586314f2Sbellard	rm -rf /tmp/$(FILE)
243586314f2Sbellard
244d691f669Sbellard# generate a binary distribution including the test binary environnment
245d691f669SbellardBINPATH=/usr/local/qemu-i386
246d691f669Sbellard
247d691f669Sbellardtarbin:
2481eb87257Sbellard	tar zcvf /tmp/qemu-$(VERSION)-i386-glibc21.tar.gz \
2491eb87257Sbellard                 $(BINPATH)/etc $(BINPATH)/lib $(BINPATH)/bin $(BINPATH)/usr
2501eb87257Sbellard	tar zcvf /tmp/qemu-$(VERSION)-i386-wine.tar.gz \
2511eb87257Sbellard                 $(BINPATH)/wine
252d691f669Sbellard
25331e31b8aSbellardifneq ($(wildcard .depend),)
25431e31b8aSbellardinclude .depend
25531e31b8aSbellardendif
256