From 4fb240a4956fe222e8f65f0d915f8e07a409ee52 Mon Sep 17 00:00:00 2001 From: bellard Date: Wed, 7 Nov 2007 19:24:02 +0000 Subject: compile common code once git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3543 c046a42c-6fe2-441c-8c8c-71466251a162 --- Makefile | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- Makefile.target | 61 +++++++------------------------------- 2 files changed, 98 insertions(+), 55 deletions(-) diff --git a/Makefile b/Makefile index 0eb39b5c0d..1f77f2c01d 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,9 @@ BASE_LDFLAGS= BASE_CFLAGS += $(OS_CFLAGS) $(ARCH_CFLAGS) BASE_LDFLAGS += $(OS_LDFLAGS) $(ARCH_LDFLAGS) -CPPFLAGS += -I. -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE +CPPFLAGS += -I. -I$(SRC_PATH) -MMD -MP +CPPFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE +CPPFLAGS += -DQEMU_TOOL LIBS= ifdef CONFIG_STATIC BASE_LDFLAGS += -static @@ -24,23 +26,100 @@ endif LIBS+=$(AIOLIBS) -all: $(TOOLS) $(DOCS) recurse-all +all: libqemu_common.a $(TOOLS) $(DOCS) recurse-all subdir-%: dyngen$(EXESUF) $(MAKE) -C $(subst subdir-,,$@) all recurse-all: $(patsubst %,subdir-%, $(TARGET_DIRS)) -qemu-img$(EXESUF): qemu-img.c cutils.c block.c block-raw.c block-cow.c block-qcow.c aes.c block-vmdk.c block-cloop.c block-dmg.c block-bochs.c block-vpc.c block-vvfat.c block-qcow2.c block-parallels.c - $(CC) -DQEMU_TOOL $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $(LDFLAGS) $(BASE_LDFLAGS) -o $@ $^ -lz $(LIBS) +###################################################################### +# libqemu_common.a: target indepedent part of system emulation. The +# long term path is to suppress *all* target specific code in case of +# system emulation, i.e. a single QEMU executable should support all +# CPUs and machines. +OBJS+=cutils.o readline.o console.o +#OBJS+=block.o block-raw.o +OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o block-qcow2.o block-parallels.o + +ifdef CONFIG_WIN32 +OBJS+=tap-win32.o +endif + +AUDIO_OBJS = audio.o noaudio.o wavaudio.o mixeng.o +ifdef CONFIG_SDL +AUDIO_OBJS += sdlaudio.o +endif +ifdef CONFIG_OSS +AUDIO_OBJS += ossaudio.o +endif +ifdef CONFIG_COREAUDIO +AUDIO_OBJS += coreaudio.o +endif +ifdef CONFIG_ALSA +AUDIO_OBJS += alsaaudio.o +endif +ifdef CONFIG_DSOUND +AUDIO_OBJS += dsoundaudio.o +endif +ifdef CONFIG_FMOD +AUDIO_OBJS += fmodaudio.o +audio/audio.o audio/fmodaudio.o: CPPFLAGS := -I$(CONFIG_FMOD_INC) $(CPPFLAGS) +endif +AUDIO_OBJS+= wavcapture.o +OBJS+=$(addprefix audio/, $(AUDIO_OBJS)) + +ifdef CONFIG_SDL +OBJS+=sdl.o x_keymap.o +endif +OBJS+=vnc.o d3des.o + +ifdef CONFIG_COCOA +OBJS+=cocoa.o +endif + +ifdef CONFIG_SLIRP +CPPFLAGS+=-I$(SRC_PATH)/slirp +SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \ +slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \ +tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o +OBJS+=$(addprefix slirp/, $(SLIRP_OBJS)) +endif + +cocoa.o: cocoa.m + $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $< + +sdl.o: sdl.c keymaps.c sdl_keysym.h + $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) $(BASE_CFLAGS) -c -o $@ $< + +vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h d3des.c d3des.h + $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $< + +audio/sdlaudio.o: audio/sdlaudio.c + $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) $(BASE_CFLAGS) -c -o $@ $< + +libqemu_common.a: $(OBJS) + rm -f $@ + $(AR) rcs $@ $(OBJS) + +###################################################################### + +qemu-img$(EXESUF): qemu-img.o block.o block-raw.o libqemu_common.a + $(CC) $(LDFLAGS) $(BASE_LDFLAGS) -o $@ $^ -lz $(LIBS) + +%.o: %.c + $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $< + +# dyngen host tool dyngen$(EXESUF): dyngen.c $(HOST_CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -o $@ $^ clean: # avoid old build problems by removing potentially incorrect old files rm -f config.mak config.h op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h - rm -f *.o *.a $(TOOLS) dyngen$(EXESUF) TAGS cscope.* *.pod *~ */*~ + rm -f *.o *.d *.a $(TOOLS) dyngen$(EXESUF) TAGS cscope.* *.pod *~ */*~ + rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d $(MAKE) -C tests clean for d in $(TARGET_DIRS); do \ $(MAKE) -C $$d $@ || exit 1 ; \ @@ -180,3 +259,6 @@ tarbin: ifneq ($(wildcard .depend),) include .depend endif + +# Include automatically generated dependency files +-include $(wildcard *.d audio/*.d slirp/*.d) diff --git a/Makefile.target b/Makefile.target index 48528413f8..e8ead7df53 100644 --- a/Makefile.target +++ b/Makefile.target @@ -23,7 +23,7 @@ ifeq ($(TARGET_ARCH), sparc64) TARGET_BASE_ARCH:=sparc endif TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH) -VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio +VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw CPPFLAGS=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH) -MMD -MP ifdef CONFIG_DARWIN_USER VPATH+=:$(SRC_PATH)/darwin-user @@ -399,43 +399,25 @@ ifeq ($(ARCH),alpha) endif # must use static linking to avoid leaving stuff in virtual address space -VL_OBJS=vl.o osdep.o readline.o monitor.o pci.o console.o loader.o isa_mmio.o -VL_OBJS+=cutils.o +VL_OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o +# XXX: suppress QEMU_TOOL tests VL_OBJS+=block.o block-raw.o -VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o block-qcow2.o block-parallels.o VL_OBJS+=irq.o -ifdef CONFIG_WIN32 -VL_OBJS+=tap-win32.o -endif -SOUND_HW = sb16.o es1370.o -AUDIODRV = audio.o noaudio.o wavaudio.o mixeng.o -ifdef CONFIG_SDL -AUDIODRV += sdlaudio.o -endif -ifdef CONFIG_OSS -AUDIODRV += ossaudio.o -endif -ifdef CONFIG_COREAUDIO -AUDIODRV += coreaudio.o -endif ifdef CONFIG_ALSA -AUDIODRV += alsaaudio.o LIBS += -lasound endif ifdef CONFIG_DSOUND -AUDIODRV += dsoundaudio.o LIBS += -lole32 -ldxguid endif ifdef CONFIG_FMOD -AUDIODRV += fmodaudio.o -audio.o fmodaudio.o: CPPFLAGS := -I$(CONFIG_FMOD_INC) $(CPPFLAGS) LIBS += $(CONFIG_FMOD_LIB) endif + +SOUND_HW = sb16.o es1370.o ifdef CONFIG_ADLIB SOUND_HW += fmopl.o adlib.o endif -AUDIODRV+= wavcapture.o ifdef CONFIG_VNC_TLS CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS) @@ -462,7 +444,7 @@ VL_OBJS += rtl8139.o ifeq ($(TARGET_BASE_ARCH), i386) # Hardware support -VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV) +VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o VL_OBJS+= cirrus_vga.o apic.o parallel.o acpi.o piix_pci.o VL_OBJS+= usb-uhci.o smbus_eeprom.o vmmouse.o vmport.o vmware_vga.o @@ -471,7 +453,7 @@ endif ifeq ($(TARGET_BASE_ARCH), ppc) CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE # shared objects -VL_OBJS+= ppc.o ide.o vga.o $(SOUND_HW) dma.o openpic.o $(AUDIODRV) +VL_OBJS+= ppc.o ide.o vga.o $(SOUND_HW) dma.o openpic.o # PREP target VL_OBJS+= pckbd.o ps2.o serial.o i8259.o i8254.o fdc.o m48t59.o mc146818rtc.o VL_OBJS+= prep_pci.o ppc_prep.o @@ -489,7 +471,7 @@ VL_OBJS+= mips_r4k.o mips_malta.o mips_pica61.o mips_mipssim.o VL_OBJS+= mips_timer.o mips_int.o dma.o vga.o serial.o i8254.o i8259.o VL_OBJS+= jazz_led.o VL_OBJS+= ide.o gt64xxx.o pckbd.o ps2.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o -VL_OBJS+= piix_pci.o smbus_eeprom.o parallel.o mixeng.o cirrus_vga.o $(SOUND_HW) $(AUDIODRV) +VL_OBJS+= piix_pci.o smbus_eeprom.o parallel.o cirrus_vga.o $(SOUND_HW) VL_OBJS+= mipsnet.o CPPFLAGS += -DHAS_AUDIO endif @@ -518,7 +500,7 @@ VL_OBJS+= arm_gic.o realview.o arm_sysctl.o VL_OBJS+= arm-semi.o VL_OBJS+= pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o VL_OBJS+= pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o max111x.o max7310.o -VL_OBJS+= spitz.o ads7846.o ide.o serial.o nand.o ecc.o $(AUDIODRV) wm8750.o +VL_OBJS+= spitz.o ads7846.o ide.o serial.o nand.o ecc.o wm8750.o VL_OBJS+= omap.o omap_lcdc.o omap1_clk.o omap_mmc.o omap_i2c.o VL_OBJS+= palm.o tsc210x.o CPPFLAGS += -DHAS_AUDIO @@ -534,12 +516,7 @@ endif ifdef CONFIG_GDBSTUB VL_OBJS+=gdbstub.o endif -ifdef CONFIG_SDL -VL_OBJS+=sdl.o x_keymap.o -endif -VL_OBJS+=vnc.o d3des.o ifdef CONFIG_COCOA -VL_OBJS+=cocoa.o COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa -framework IOKit ifdef CONFIG_COREAUDIO COCOA_LIBS+=-framework CoreAudio @@ -547,10 +524,6 @@ endif endif ifdef CONFIG_SLIRP CPPFLAGS+=-I$(SRC_PATH)/slirp -SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \ -slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \ -tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o -VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS)) endif VL_LDFLAGS=$(VL_OS_LDFLAGS) @@ -589,21 +562,9 @@ ifdef CONFIG_WIN32 SDL_LIBS := $(filter-out -mwindows, $(SDL_LIBS)) -mconsole endif -$(QEMU_SYSTEM): $(VL_OBJS) libqemu.a +$(QEMU_SYSTEM): $(VL_OBJS) ../libqemu_common.a libqemu.a $(CC) $(VL_LDFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS) -cocoa.o: cocoa.m - $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $< - -sdl.o: sdl.c keymaps.c sdl_keysym.h - $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) $(BASE_CFLAGS) -c -o $@ $< - -vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h d3des.c d3des.h - $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $< - -sdlaudio.o: sdlaudio.c - $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) $(BASE_CFLAGS) -c -o $@ $< - depend: $(SRCS) $(CC) -MM $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $^ 1>.depend @@ -660,7 +621,7 @@ signal.o: signal.c $(CC) $(CPPFLAGS) -c -o $@ $< clean: - rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o + rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o fpu/*.o rm -f *.d */*.d install: all -- cgit v1.2.3