Commit 4fb240a4956fe222e8f65f0d915f8e07a409ee52

Authored by bellard
1 parent 6d5f237a

compile common code once


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3543 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 98 additions and 55 deletions
Makefile
... ... @@ -11,7 +11,9 @@ BASE_LDFLAGS=
11 11 BASE_CFLAGS += $(OS_CFLAGS) $(ARCH_CFLAGS)
12 12 BASE_LDFLAGS += $(OS_LDFLAGS) $(ARCH_LDFLAGS)
13 13  
14   -CPPFLAGS += -I. -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
  14 +CPPFLAGS += -I. -I$(SRC_PATH) -MMD -MP
  15 +CPPFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
  16 +CPPFLAGS += -DQEMU_TOOL
15 17 LIBS=
16 18 ifdef CONFIG_STATIC
17 19 BASE_LDFLAGS += -static
... ... @@ -24,23 +26,100 @@ endif
24 26  
25 27 LIBS+=$(AIOLIBS)
26 28  
27   -all: $(TOOLS) $(DOCS) recurse-all
  29 +all: libqemu_common.a $(TOOLS) $(DOCS) recurse-all
28 30  
29 31 subdir-%: dyngen$(EXESUF)
30 32 $(MAKE) -C $(subst subdir-,,$@) all
31 33  
32 34 recurse-all: $(patsubst %,subdir-%, $(TARGET_DIRS))
33 35  
34   -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
35   - $(CC) -DQEMU_TOOL $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $(LDFLAGS) $(BASE_LDFLAGS) -o $@ $^ -lz $(LIBS)
  36 +######################################################################
  37 +# libqemu_common.a: target indepedent part of system emulation. The
  38 +# long term path is to suppress *all* target specific code in case of
  39 +# system emulation, i.e. a single QEMU executable should support all
  40 +# CPUs and machines.
36 41  
  42 +OBJS+=cutils.o readline.o console.o
  43 +#OBJS+=block.o block-raw.o
  44 +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
  45 +
  46 +ifdef CONFIG_WIN32
  47 +OBJS+=tap-win32.o
  48 +endif
  49 +
  50 +AUDIO_OBJS = audio.o noaudio.o wavaudio.o mixeng.o
  51 +ifdef CONFIG_SDL
  52 +AUDIO_OBJS += sdlaudio.o
  53 +endif
  54 +ifdef CONFIG_OSS
  55 +AUDIO_OBJS += ossaudio.o
  56 +endif
  57 +ifdef CONFIG_COREAUDIO
  58 +AUDIO_OBJS += coreaudio.o
  59 +endif
  60 +ifdef CONFIG_ALSA
  61 +AUDIO_OBJS += alsaaudio.o
  62 +endif
  63 +ifdef CONFIG_DSOUND
  64 +AUDIO_OBJS += dsoundaudio.o
  65 +endif
  66 +ifdef CONFIG_FMOD
  67 +AUDIO_OBJS += fmodaudio.o
  68 +audio/audio.o audio/fmodaudio.o: CPPFLAGS := -I$(CONFIG_FMOD_INC) $(CPPFLAGS)
  69 +endif
  70 +AUDIO_OBJS+= wavcapture.o
  71 +OBJS+=$(addprefix audio/, $(AUDIO_OBJS))
  72 +
  73 +ifdef CONFIG_SDL
  74 +OBJS+=sdl.o x_keymap.o
  75 +endif
  76 +OBJS+=vnc.o d3des.o
  77 +
  78 +ifdef CONFIG_COCOA
  79 +OBJS+=cocoa.o
  80 +endif
  81 +
  82 +ifdef CONFIG_SLIRP
  83 +CPPFLAGS+=-I$(SRC_PATH)/slirp
  84 +SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
  85 +slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
  86 +tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
  87 +OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
  88 +endif
  89 +
  90 +cocoa.o: cocoa.m
  91 + $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
  92 +
  93 +sdl.o: sdl.c keymaps.c sdl_keysym.h
  94 + $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) $(BASE_CFLAGS) -c -o $@ $<
  95 +
  96 +vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h d3des.c d3des.h
  97 + $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
  98 +
  99 +audio/sdlaudio.o: audio/sdlaudio.c
  100 + $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) $(BASE_CFLAGS) -c -o $@ $<
  101 +
  102 +libqemu_common.a: $(OBJS)
  103 + rm -f $@
  104 + $(AR) rcs $@ $(OBJS)
  105 +
  106 +######################################################################
  107 +
  108 +qemu-img$(EXESUF): qemu-img.o block.o block-raw.o libqemu_common.a
  109 + $(CC) $(LDFLAGS) $(BASE_LDFLAGS) -o $@ $^ -lz $(LIBS)
  110 +
  111 +%.o: %.c
  112 + $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
  113 +
  114 +# dyngen host tool
37 115 dyngen$(EXESUF): dyngen.c
38 116 $(HOST_CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -o $@ $^
39 117  
40 118 clean:
41 119 # avoid old build problems by removing potentially incorrect old files
42 120 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
43   - rm -f *.o *.a $(TOOLS) dyngen$(EXESUF) TAGS cscope.* *.pod *~ */*~
  121 + rm -f *.o *.d *.a $(TOOLS) dyngen$(EXESUF) TAGS cscope.* *.pod *~ */*~
  122 + rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d
44 123 $(MAKE) -C tests clean
45 124 for d in $(TARGET_DIRS); do \
46 125 $(MAKE) -C $$d $@ || exit 1 ; \
... ... @@ -180,3 +259,6 @@ tarbin:
180 259 ifneq ($(wildcard .depend),)
181 260 include .depend
182 261 endif
  262 +
  263 +# Include automatically generated dependency files
  264 +-include $(wildcard *.d audio/*.d slirp/*.d)
... ...
Makefile.target
... ... @@ -23,7 +23,7 @@ ifeq ($(TARGET_ARCH), sparc64)
23 23 TARGET_BASE_ARCH:=sparc
24 24 endif
25 25 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
26   -VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio
  26 +VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw
27 27 CPPFLAGS=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH) -MMD -MP
28 28 ifdef CONFIG_DARWIN_USER
29 29 VPATH+=:$(SRC_PATH)/darwin-user
... ... @@ -399,43 +399,25 @@ ifeq ($(ARCH),alpha)
399 399 endif
400 400  
401 401 # must use static linking to avoid leaving stuff in virtual address space
402   -VL_OBJS=vl.o osdep.o readline.o monitor.o pci.o console.o loader.o isa_mmio.o
403   -VL_OBJS+=cutils.o
  402 +VL_OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o
  403 +# XXX: suppress QEMU_TOOL tests
404 404 VL_OBJS+=block.o block-raw.o
405   -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
406 405 VL_OBJS+=irq.o
407   -ifdef CONFIG_WIN32
408   -VL_OBJS+=tap-win32.o
409   -endif
410 406  
411   -SOUND_HW = sb16.o es1370.o
412   -AUDIODRV = audio.o noaudio.o wavaudio.o mixeng.o
413   -ifdef CONFIG_SDL
414   -AUDIODRV += sdlaudio.o
415   -endif
416   -ifdef CONFIG_OSS
417   -AUDIODRV += ossaudio.o
418   -endif
419   -ifdef CONFIG_COREAUDIO
420   -AUDIODRV += coreaudio.o
421   -endif
422 407 ifdef CONFIG_ALSA
423   -AUDIODRV += alsaaudio.o
424 408 LIBS += -lasound
425 409 endif
426 410 ifdef CONFIG_DSOUND
427   -AUDIODRV += dsoundaudio.o
428 411 LIBS += -lole32 -ldxguid
429 412 endif
430 413 ifdef CONFIG_FMOD
431   -AUDIODRV += fmodaudio.o
432   -audio.o fmodaudio.o: CPPFLAGS := -I$(CONFIG_FMOD_INC) $(CPPFLAGS)
433 414 LIBS += $(CONFIG_FMOD_LIB)
434 415 endif
  416 +
  417 +SOUND_HW = sb16.o es1370.o
435 418 ifdef CONFIG_ADLIB
436 419 SOUND_HW += fmopl.o adlib.o
437 420 endif
438   -AUDIODRV+= wavcapture.o
439 421  
440 422 ifdef CONFIG_VNC_TLS
441 423 CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS)
... ... @@ -462,7 +444,7 @@ VL_OBJS += rtl8139.o
462 444  
463 445 ifeq ($(TARGET_BASE_ARCH), i386)
464 446 # Hardware support
465   -VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
  447 +VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o
466 448 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
467 449 VL_OBJS+= cirrus_vga.o apic.o parallel.o acpi.o piix_pci.o
468 450 VL_OBJS+= usb-uhci.o smbus_eeprom.o vmmouse.o vmport.o vmware_vga.o
... ... @@ -471,7 +453,7 @@ endif
471 453 ifeq ($(TARGET_BASE_ARCH), ppc)
472 454 CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
473 455 # shared objects
474   -VL_OBJS+= ppc.o ide.o vga.o $(SOUND_HW) dma.o openpic.o $(AUDIODRV)
  456 +VL_OBJS+= ppc.o ide.o vga.o $(SOUND_HW) dma.o openpic.o
475 457 # PREP target
476 458 VL_OBJS+= pckbd.o ps2.o serial.o i8259.o i8254.o fdc.o m48t59.o mc146818rtc.o
477 459 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
489 471 VL_OBJS+= mips_timer.o mips_int.o dma.o vga.o serial.o i8254.o i8259.o
490 472 VL_OBJS+= jazz_led.o
491 473 VL_OBJS+= ide.o gt64xxx.o pckbd.o ps2.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o
492   -VL_OBJS+= piix_pci.o smbus_eeprom.o parallel.o mixeng.o cirrus_vga.o $(SOUND_HW) $(AUDIODRV)
  474 +VL_OBJS+= piix_pci.o smbus_eeprom.o parallel.o cirrus_vga.o $(SOUND_HW)
493 475 VL_OBJS+= mipsnet.o
494 476 CPPFLAGS += -DHAS_AUDIO
495 477 endif
... ... @@ -518,7 +500,7 @@ VL_OBJS+= arm_gic.o realview.o arm_sysctl.o
518 500 VL_OBJS+= arm-semi.o
519 501 VL_OBJS+= pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o
520 502 VL_OBJS+= pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o max111x.o max7310.o
521   -VL_OBJS+= spitz.o ads7846.o ide.o serial.o nand.o ecc.o $(AUDIODRV) wm8750.o
  503 +VL_OBJS+= spitz.o ads7846.o ide.o serial.o nand.o ecc.o wm8750.o
522 504 VL_OBJS+= omap.o omap_lcdc.o omap1_clk.o omap_mmc.o omap_i2c.o
523 505 VL_OBJS+= palm.o tsc210x.o
524 506 CPPFLAGS += -DHAS_AUDIO
... ... @@ -534,12 +516,7 @@ endif
534 516 ifdef CONFIG_GDBSTUB
535 517 VL_OBJS+=gdbstub.o
536 518 endif
537   -ifdef CONFIG_SDL
538   -VL_OBJS+=sdl.o x_keymap.o
539   -endif
540   -VL_OBJS+=vnc.o d3des.o
541 519 ifdef CONFIG_COCOA
542   -VL_OBJS+=cocoa.o
543 520 COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa -framework IOKit
544 521 ifdef CONFIG_COREAUDIO
545 522 COCOA_LIBS+=-framework CoreAudio
... ... @@ -547,10 +524,6 @@ endif
547 524 endif
548 525 ifdef CONFIG_SLIRP
549 526 CPPFLAGS+=-I$(SRC_PATH)/slirp
550   -SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
551   -slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
552   -tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
553   -VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
554 527 endif
555 528  
556 529 VL_LDFLAGS=$(VL_OS_LDFLAGS)
... ... @@ -589,21 +562,9 @@ ifdef CONFIG_WIN32
589 562 SDL_LIBS := $(filter-out -mwindows, $(SDL_LIBS)) -mconsole
590 563 endif
591 564  
592   -$(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
  565 +$(QEMU_SYSTEM): $(VL_OBJS) ../libqemu_common.a libqemu.a
593 566 $(CC) $(VL_LDFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS)
594 567  
595   -cocoa.o: cocoa.m
596   - $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
597   -
598   -sdl.o: sdl.c keymaps.c sdl_keysym.h
599   - $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) $(BASE_CFLAGS) -c -o $@ $<
600   -
601   -vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h d3des.c d3des.h
602   - $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
603   -
604   -sdlaudio.o: sdlaudio.c
605   - $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) $(BASE_CFLAGS) -c -o $@ $<
606   -
607 568 depend: $(SRCS)
608 569 $(CC) -MM $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $^ 1>.depend
609 570  
... ... @@ -660,7 +621,7 @@ signal.o: signal.c
660 621 $(CC) $(CPPFLAGS) -c -o $@ $<
661 622  
662 623 clean:
663   - rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o
  624 + rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o fpu/*.o
664 625 rm -f *.d */*.d
665 626  
666 627 install: all
... ...