xref: /openbmc/qemu/Makefile (revision 8c9b861e)
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)
316b1534ccSbellardPROGS+=vl
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
143*8c9b861eSbellardvl: vl.o block.o libqemu.a
1440824d6fcSbellard	$(CC) -static -Wl,-T,i386-vl.ld -o $@ $^  $(LIBS)
1450824d6fcSbellard
14631e31b8aSbellarddepend: $(SRCS)
14731e31b8aSbellard	$(CC) -MM $(CFLAGS) $^ 1>.depend
14831e31b8aSbellard
1493ef693a0Sbellard# libqemu
150612384d7Sbellard
1513ef693a0Sbellardlibqemu.a: $(LIBOBJS)
152612384d7Sbellard	rm -f $@
153612384d7Sbellard	$(AR) rcs $@ $(LIBOBJS)
154612384d7Sbellard
155367e86e8Sbellarddyngen: dyngen.c
156367e86e8Sbellard	$(HOST_CC) -O2 -Wall -g $< -o $@
157367e86e8Sbellard
158de83cd02Sbellardtranslate-$(TARGET_ARCH).o: translate-$(TARGET_ARCH).c gen-op-$(TARGET_ARCH).h opc-$(TARGET_ARCH).h cpu-$(TARGET_ARCH).h
159367e86e8Sbellard
160de83cd02Sbellardtranslate.o: translate.c op-$(TARGET_ARCH).h opc-$(TARGET_ARCH).h cpu-$(TARGET_ARCH).h
161de83cd02Sbellard
162de83cd02Sbellardop-$(TARGET_ARCH).h: op-$(TARGET_ARCH).o dyngen
163367e86e8Sbellard	./dyngen -o $@ $<
164367e86e8Sbellard
165de83cd02Sbellardopc-$(TARGET_ARCH).h: op-$(TARGET_ARCH).o dyngen
1662d92f0b8Sbellard	./dyngen -c -o $@ $<
1672d92f0b8Sbellard
168de83cd02Sbellardgen-op-$(TARGET_ARCH).h: op-$(TARGET_ARCH).o dyngen
169de83cd02Sbellard	./dyngen -g -o $@ $<
170de83cd02Sbellard
171de83cd02Sbellardop-$(TARGET_ARCH).o: op-$(TARGET_ARCH).c
172927f621eSbellard	$(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
173367e86e8Sbellard
174de83cd02Sbellardhelper-$(TARGET_ARCH).o: helper-$(TARGET_ARCH).c
1759c5d1246Sbellard	$(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
1769c5d1246Sbellard
177de83cd02Sbellardop-i386.o: op-i386.c opreg_template.h ops_template.h
178de83cd02Sbellard
179de83cd02Sbellardop-arm.o: op-arm.c op-arm-template.h
180de83cd02Sbellard
18131e31b8aSbellard%.o: %.c
18231e31b8aSbellard	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
18331e31b8aSbellard
18431e31b8aSbellardclean:
1857d13299dSbellard	$(MAKE) -C tests clean
1863ef693a0Sbellard	rm -f *.o  *.a *~ qemu dyngen TAGS
18731e31b8aSbellard
1887d13299dSbellarddistclean: clean
1897d13299dSbellard	rm -f config.mak config.h
1907d13299dSbellard
1916b1534ccSbellardinstall: $(PROGS)
192d5a0b50cSbellard	mkdir -p $(prefix)/bin
1936b1534ccSbellard	install -m 755 -s $(PROGS) $(prefix)/bin
194612384d7Sbellard
195367e86e8Sbellard# various test targets
1963ef693a0Sbellardtest speed: qemu
197367e86e8Sbellard	make -C tests $@
19831e31b8aSbellard
199367e86e8SbellardTAGS:
200b9adb4a6Sbellard	etags *.[ch] tests/*.[ch]
20131e31b8aSbellard
2023ef693a0Sbellard# documentation
2033ef693a0Sbellardqemu-doc.html: qemu-doc.texi
2043ef693a0Sbellard	texi2html -monolithic -number $<
2053ef693a0Sbellard
206586314f2SbellardFILES= \
207fd429f2fSbellardREADME README.distrib COPYING COPYING.LIB TODO Changelog VERSION \
208de83cd02Sbellardconfigure \
209de83cd02Sbellarddyngen.c dyngen.h dyngen-exec.h ioctls.h syscall_types.h \
210de83cd02SbellardMakefile elf.h elfload.c main.c signal.c qemu.h \
211de83cd02Sbellardsyscall.c syscall_defs.h vm86.c path.c mmap.c \
2126b1534ccSbellardi386.ld ppc.ld alpha.ld s390.ld sparc.ld arm.ld\
213*8c9b861eSbellardvl.c i386-vl.ld vl.h block.c\
214de83cd02Sbellardthunk.c cpu-exec.c translate.c cpu-all.h thunk.h exec.h\
215de83cd02Sbellardexec.c cpu-exec.c\
216de83cd02Sbellardcpu-i386.h op-i386.c helper-i386.c syscall-i386.h translate-i386.c \
217de83cd02Sbellardexec-i386.h ops_template.h op_string.h opreg_template.h \
218de83cd02Sbellardcpu-arm.h syscall-arm.h exec-arm.h op-arm.c translate-arm.c op-arm-template.h \
219de83cd02Sbellarddis-asm.h disas.c disas.h alpha-dis.c ppc-dis.c i386-dis.c sparc-dis.c \
220de83cd02Sbellardarm-dis.c \
22177f8dd5aSbellardtests/Makefile \
222586314f2Sbellardtests/test-i386.c tests/test-i386-shift.h tests/test-i386.h \
223de83cd02Sbellardtests/test-i386-muldiv.h tests/test-i386-code16.S tests/test-i386-vm86.S \
224322d0c66Sbellardtests/hello-i386.c tests/hello-i386 \
225de83cd02Sbellardtests/hello-arm.c tests/hello-arm \
226de83cd02Sbellardtests/sha1.c \
2273ef693a0Sbellardtests/testsig.c tests/testclone.c tests/testthread.c \
228fd429f2fSbellardtests/runcom.c tests/pi_10.com \
2291eb87257Sbellardtests/test_path.c \
2303ef693a0Sbellardqemu-doc.texi qemu-doc.html
231586314f2Sbellard
2323ef693a0SbellardFILE=qemu-$(VERSION)
233586314f2Sbellard
234586314f2Sbellardtar:
235586314f2Sbellard	rm -rf /tmp/$(FILE)
236586314f2Sbellard	mkdir -p /tmp/$(FILE)
237586314f2Sbellard	cp -P $(FILES) /tmp/$(FILE)
238586314f2Sbellard	( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) )
239586314f2Sbellard	rm -rf /tmp/$(FILE)
240586314f2Sbellard
241d691f669Sbellard# generate a binary distribution including the test binary environnment
242d691f669SbellardBINPATH=/usr/local/qemu-i386
243d691f669Sbellard
244d691f669Sbellardtarbin:
2451eb87257Sbellard	tar zcvf /tmp/qemu-$(VERSION)-i386-glibc21.tar.gz \
2461eb87257Sbellard                 $(BINPATH)/etc $(BINPATH)/lib $(BINPATH)/bin $(BINPATH)/usr
2471eb87257Sbellard	tar zcvf /tmp/qemu-$(VERSION)-i386-wine.tar.gz \
2481eb87257Sbellard                 $(BINPATH)/wine
249d691f669Sbellard
25031e31b8aSbellardifneq ($(wildcard .depend),)
25131e31b8aSbellardinclude .depend
25231e31b8aSbellardendif
253