Patchwork [30/81] Rename CPPFLAGS to QEMU_CFLAGS

login
register
mail settings
Submitter Juan Quintela
Date Aug. 3, 2009, 12:46 p.m.
Message ID <c5ab872f6166e0535a30d04558d80f06b1971a52.1249301360.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/30532/
State Superseded
Headers show

Comments

Juan Quintela - Aug. 3, 2009, 12:46 p.m.
Now we have to variables: QEMU_CFLAGS: flags without which we can't compile
CFLAGS: "-g -O2"

We can now run:

make CFLAGS="-fbar" foo.o
make CFLAGS="" foo.o
make CFLAGS="-O3" foo.o

And it all should work.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 Makefile                   |   18 ++++++------
 Makefile.hw                |    6 ++--
 Makefile.target            |   64 ++++++++++++++++++++++----------------------
 configure                  |   57 ++++++++++++++++++++------------------
 pc-bios/optionrom/Makefile |    6 ++--
 rules.mak                  |    6 ++--
 6 files changed, 80 insertions(+), 77 deletions(-)

Patch

diff --git a/Makefile b/Makefile
index 0ea8b46..37eba6b 100644
--- a/Makefile
+++ b/Makefile
@@ -16,9 +16,9 @@  endif

 VPATH=$(SRC_PATH):$(SRC_PATH)/hw

-CPPFLAGS += -I. -I$(SRC_PATH) -MMD -MP -MT $@
-CPPFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
-CPPFLAGS += -U_FORTIFY_SOURCE
+QEMU_CFLAGS += -I. -I$(SRC_PATH) -MMD -MP -MT $@
+QEMU_CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
+QEMU_CFLAGS += -U_FORTIFY_SOURCE
 LIBS+=-lz

 ifdef BUILD_DOCS
@@ -105,7 +105,7 @@  ifdef CONFIG_COREAUDIO
 AUDIO_PT = y
 endif
 ifdef CONFIG_FMOD
-audio/audio.o audio/fmodaudio.o: CPPFLAGS := $(FMOD_CFLAGS) $(CPPFLAGS)
+audio/audio.o audio/fmodaudio.o: QEMU_CFLAGS := $(FMOD_CFLAGS) $(QEMU_CFLAGS)
 endif
 ifdef CONFIG_ESD
 AUDIO_PT = y
@@ -142,7 +142,7 @@  obj-$(CONFIG_COCOA) += cocoa.o
 obj-$(CONFIG_IOTHREAD) += qemu-thread.o

 ifdef CONFIG_SLIRP
-CPPFLAGS+=-I$(SRC_PATH)/slirp
+QEMU_CFLAGS+=-I$(SRC_PATH)/slirp
 endif

 slirp-obj-y = cksum.o if.o ip_icmp.o ip_input.o ip_output.o
@@ -156,7 +156,7 @@  LIBS+=$(VDE_LIBS)
 obj-$(CONFIG_XEN) += xen_backend.o xen_devconfig.o
 obj-$(CONFIG_XEN) += xen_console.o xenfb.o xen_disk.o xen_nic.o

-CPPFLAGS+=$(CURL_CFLAGS)
+QEMU_CFLAGS+=$(CURL_CFLAGS)
 LIBS+=$(CURL_LIBS)

 cocoa.o: cocoa.m
@@ -167,7 +167,7 @@  sdl_zoom.o: sdl_zoom.c sdl_zoom.h sdl_zoom_template.h

 sdl.o: sdl.c keymaps.h sdl_keysym.h sdl_zoom.h

-sdl.o audio/sdlaudio.o sdl_zoom.o baum.o: CFLAGS += $(SDL_CFLAGS)
+sdl.o audio/sdlaudio.o sdl_zoom.o baum.o: QEMU_CFLAGS += $(SDL_CFLAGS)

 acl.o: acl.h acl.c

@@ -175,7 +175,7 @@  vnc.h: vnc-tls.h vnc-auth-vencrypt.h vnc-auth-sasl.h keymaps.h

 vnc.o: vnc.c vnc.h vnc_keysym.h vnchextile.h d3des.c d3des.h acl.h

-vnc.o: CFLAGS += $(VNC_TLS_CFLAGS)
+vnc.o: QEMU_CFLAGS += $(VNC_TLS_CFLAGS)

 vnc-tls.o: vnc-tls.c vnc.h

@@ -185,7 +185,7 @@  vnc-auth-sasl.o: vnc-auth-sasl.c vnc.h

 curses.o: curses.c keymaps.h curses_keys.h

-bt-host.o: CFLAGS += $(BLUEZ_CFLAGS)
+bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS)

 libqemu_common.a: $(obj-y)

diff --git a/Makefile.hw b/Makefile.hw
index 131ae51..052eb1a 100644
--- a/Makefile.hw
+++ b/Makefile.hw
@@ -8,9 +8,9 @@  include $(SRC_PATH)/rules.mak

 VPATH=$(SRC_PATH):$(SRC_PATH)/hw

-CPPFLAGS += -I. -I.. -I$(SRC_PATH) -MMD -MP -MT $@
-CPPFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
-CPPFLAGS+=-I$(SRC_PATH)/fpu
+QEMU_CFLAGS += -I. -I.. -I$(SRC_PATH) -MMD -MP -MT $@
+QEMU_CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
+QEMU_CFLAGS+=-I$(SRC_PATH)/fpu

 obj-y =
 obj-y += virtio.o virtio-pci.o
diff --git a/Makefile.target b/Makefile.target
index 0bc46e0..fcf6eeb 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -3,7 +3,7 @@  include $(SRC_PATH)/rules.mak

 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw
-CPPFLAGS=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH) -MMD -MT $@ -MP -DNEED_CPU_H
+QEMU_CFLAGS=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH) -MMD -MT $@ -MP -DNEED_CPU_H

 ifdef CONFIG_USER_ONLY
 # user emulator name
@@ -26,7 +26,7 @@  HELPER_CFLAGS+=-fomit-frame-pointer
 endif

 ifeq ($(subst ppc64,ppc,$(ARCH))$(TARGET_BASE_ARCH),ppcppc)
-translate.o: CFLAGS := $(CFLAGS) $(call cc-option, $(CFLAGS), -fno-unit-at-a-time,)
+translate.o: QEMU_CFLAGS := $(QEMU_CFLAGS) $(call cc-option, $(QEMU_CFLAGS), -fno-unit-at-a-time,)
 endif

 ifeq ($(ARCH),sparc)
@@ -37,26 +37,26 @@  endif

 ifeq ($(ARCH),alpha)
 # Ensure there's only a single GP
-CFLAGS+=-msmall-data
+QEMU_CFLAGS+=-msmall-data
 endif

 ifeq ($(ARCH),ia64)
-CFLAGS+=-mno-sdata
+QEMU_CFLAGS+=-mno-sdata
 endif

-CPPFLAGS+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
-CPPFLAGS+=-U_FORTIFY_SOURCE
+QEMU_CFLAGS+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
+QEMU_CFLAGS+=-U_FORTIFY_SOURCE
 LIBS+=-lm
 ifdef CONFIG_SOLARIS
 ifdef CONFIG_NEEDS_LIBSUNMATH
 LIBS+=-lsunmath
 LDFLAGS+=-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib
-CFLAGS+=-I/opt/SUNWspro/prod/include/cc
+QEMU_CFLAGS+=-I/opt/SUNWspro/prod/include/cc
 endif
 endif

-kvm.o: CFLAGS+=$(KVM_CFLAGS)
-kvm-all.o: CFLAGS+=$(KVM_CFLAGS)
+kvm.o: QEMU_CFLAGS+=$(KVM_CFLAGS)
+kvm-all.o: QEMU_CFLAGS+=$(KVM_CFLAGS)

 all: $(PROGS)
 # Dummy command so that make thinks it has done something
@@ -68,16 +68,16 @@  libobj-y = exec.o translate-all.o cpu-exec.o translate.o host-utils.o
 libobj-$(CONFIG_KQEMU) += kqemu.o
 # TCG code generator
 libobj-y += tcg/tcg.o tcg/tcg-runtime.o
-CPPFLAGS+=-I$(SRC_PATH)/tcg -I$(SRC_PATH)/tcg/$(ARCH)
+QEMU_CFLAGS+=-I$(SRC_PATH)/tcg -I$(SRC_PATH)/tcg/$(ARCH)
 ifeq ($(ARCH),sparc64)
-CPPFLAGS+=-I$(SRC_PATH)/tcg/sparc
+QEMU_CFLAGS+=-I$(SRC_PATH)/tcg/sparc
 endif
 ifdef CONFIG_SOFTFLOAT
 libobj-y += fpu/softfloat.o
 else
 libobj-y += fpu/softfloat-native.o
 endif
-CPPFLAGS+=-I$(SRC_PATH)/fpu
+QEMU_CFLAGS+=-I$(SRC_PATH)/fpu
 libobj-y += op_helper.o helper.o

 ifeq ($(TARGET_BASE_ARCH), arm)
@@ -151,9 +151,9 @@  tcg/tcg.o: cpu.h

 # HELPER_CFLAGS is used for all the code compiled with static register
 # variables
-op_helper.o: CFLAGS += $(HELPER_CFLAGS)
+op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)

-cpu-exec.o: CFLAGS += $(HELPER_CFLAGS)
+cpu-exec.o: QEMU_CFLAGS += $(HELPER_CFLAGS)

 #########################################################
 # Linux user emulator target
@@ -161,12 +161,12 @@  cpu-exec.o: CFLAGS += $(HELPER_CFLAGS)
 ifdef CONFIG_LINUX_USER

 VPATH+=:$(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
-CPPFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
+QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)

 # profiling code
 ifdef TARGET_GPROF
 LDFLAGS+=-p
-CFLAGS+=-p
+QEMU_CFLAGS+=-p
 endif

 obj-y = main.o syscall.o strace.o mmap.o signal.o path.o thunk.o \
@@ -192,7 +192,7 @@  obj-m68k-y += m68k-sim.o m68k-semi.o

 # Note: this is a workaround. The real fix is to avoid compiling
 # cpu_signal_handler() in cpu-exec.c.
-signal.o: CFLAGS += $(HELPER_CFLAGS)
+signal.o: QEMU_CFLAGS += $(HELPER_CFLAGS)

 ARLIBS=../libqemu_user.a libqemu.a
 endif #CONFIG_LINUX_USER
@@ -203,7 +203,7 @@  endif #CONFIG_LINUX_USER
 ifdef CONFIG_DARWIN_USER

 VPATH+=:$(SRC_PATH)/darwin-user
-CPPFLAGS+=-I$(SRC_PATH)/darwin-user -I$(SRC_PATH)/darwin-user/$(TARGET_ARCH)
+QEMU_CFLAGS+=-I$(SRC_PATH)/darwin-user -I$(SRC_PATH)/darwin-user/$(TARGET_ARCH)

 # Leave some space for the regular program loading zone
 LDFLAGS+=-Wl,-segaddr,__STD_PROG_ZONE,0x1000 -image_base 0x0e000000
@@ -215,7 +215,7 @@  obj-y = main.o commpage.o machload.o mmap.o signal.o syscall.o thunk.o \

 # Note: this is a workaround. The real fix is to avoid compiling
 # cpu_signal_handler() in cpu-exec.c.
-signal.o: CFLAGS += $(HELPER_CFLAGS)
+signal.o: QEMU_CFLAGS += $(HELPER_CFLAGS)

 ARLIBS=libqemu.a

@@ -227,7 +227,7 @@  endif #CONFIG_DARWIN_USER
 ifdef CONFIG_BSD_USER

 VPATH+=:$(SRC_PATH)/bsd-user
-CPPFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ARCH)
+QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ARCH)

 obj-y = main.o bsdload.o elfload.o mmap.o path.o signal.o strace.o syscall.o \
         gdbstub.o gdbstub-xml.o ioport-user.o
@@ -235,7 +235,7 @@  obj-y += uaccess.o

 # Note: this is a workaround. The real fix is to avoid compiling
 # cpu_signal_handler() in cpu-exec.c.
-signal.o: CFLAGS += $(HELPER_CFLAGS)
+signal.o: QEMU_CFLAGS += $(HELPER_CFLAGS)

 ARLIBS=libqemu.a ../libqemu_user.a

@@ -281,16 +281,16 @@  sound-obj-$(CONFIG_GUS) += gus.o gusemu_hal.o gusemu_mixer.o
 sound-obj-$(CONFIG_CS4231A) += cs4231a.o

 ifdef CONFIG_ADLIB
-adlib.o fmopl.o: CFLAGS := ${CFLAGS} -DBUILD_Y8950=0
+adlib.o fmopl.o: QEMU_CFLAGS := ${QEMU_CFLAGS} -DBUILD_Y8950=0
 endif

 ifdef CONFIG_VNC_TLS
-CPPFLAGS += $(VNC_TLS_CFLAGS)
+QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
 LIBS += $(VNC_TLS_LIBS)
 endif

 ifdef CONFIG_VNC_SASL
-CPPFLAGS += $(VNC_SASL_CFLAGS)
+QEMU_CFLAGS += $(VNC_SASL_CFLAGS)
 LIBS += $(VNC_SASL_LIBS)
 endif

@@ -325,7 +325,7 @@  obj-i386-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o
 obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o

 ifeq ($(TARGET_BASE_ARCH), i386)
-CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
+QEMU_CFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
 endif

 # shared objects
@@ -347,7 +347,7 @@  obj-ppc-y += ppce500_pci.o ppce500_mpc8544ds.o
 obj-ppc-$(CONFIG_KVM) += kvm_ppc.o

 ifeq ($(TARGET_BASE_ARCH), ppc)
-CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
+QEMU_CFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
 endif

 obj-ppc-$(CONFIG_FDT) += device_tree.o
@@ -363,7 +363,7 @@  obj-mips-y += pflash_cfi01.o
 obj-mips-y += vmware_vga.o

 ifeq ($(TARGET_BASE_ARCH), mips)
-CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
+QEMU_CFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
 endif

 obj-microblaze-y = petalogix_s3adsp1800_mmu.o
@@ -424,7 +424,7 @@  obj-arm-y += syborg_serial.o syborg_timer.o syborg_pointer.o syborg_rtc.o
 obj-arm-y += syborg_virtio.o

 ifeq ($(TARGET_BASE_ARCH), arm)
-CPPFLAGS += -DHAS_AUDIO
+QEMU_CFLAGS += -DHAS_AUDIO
 endif

 obj-sh4-y = shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o
@@ -441,7 +441,7 @@  COCOA_LIBS+=-framework CoreAudio
 endif
 endif
 ifdef CONFIG_SLIRP
-CPPFLAGS+=-I$(SRC_PATH)/slirp
+QEMU_CFLAGS+=-I$(SRC_PATH)/slirp
 endif

 # specific flags are needed for non soft mmu emulator
@@ -455,7 +455,7 @@  endif
 endif
 endif
 ifdef TARGET_GPROF
-vl.o: CFLAGS+=-p
+vl.o: QEMU_CFLAGS+=-p
 LDFLAGS+=-p
 endif

@@ -470,10 +470,10 @@  endif
 # profiling code
 ifdef TARGET_GPROF
 LDFLAGS+=-p
-main.o: CFLAGS+=-p
+main.o: QEMU_CFLAGS+=-p
 endif

-vl.o: CFLAGS+=$(SDL_CFLAGS)
+vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS)

 vl.o: qemu-options.h

diff --git a/configure b/configure
index bc60dc1..3093de4 100755
--- a/configure
+++ b/configure
@@ -18,13 +18,13 @@  TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}"
 trap "rm -f $TMPC $TMPO $TMPE ; exit" 0 2 3 15

 compile_object() {
-  $cc $CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
+  $cc $QEMU_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
 }

 compile_prog() {
   local_cflags="$1"
   local_ldflags="$2"
-  $cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null
+  $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null
 }

 # default parameters
@@ -55,7 +55,7 @@  for opt do
   ;;
   --cpu=*) cpu="$optarg"
   ;;
-  --extra-cflags=*) CFLAGS="$optarg $CFLAGS"
+  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
   ;;
   --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
   ;;
@@ -224,7 +224,7 @@  fi
 case $targetos in
 CYGWIN*)
   mingw32="yes"
-  CFLAGS="-mno-cygwin $CFLAGS"
+  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
   audio_possible_drivers="sdl"
 ;;
 MINGW32*)
@@ -277,10 +277,10 @@  Darwin)
     [ "$is_x86_64" = "1" ] && cpu=x86_64
   fi
   if [ "$cpu" = "x86_64" ] ; then
-    CFLAGS="-arch x86_64 $CFLAGS"
+    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
     LDFLAGS="-arch x86_64 $LDFLAGS"
   else
-    CFLAGS="-mdynamic-no-pic $CFLAGS"
+    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
   fi
   darwin_user="yes"
   cocoa="yes"
@@ -320,7 +320,7 @@  SunOS)
     audio_drv_list="oss"
   fi
   audio_possible_drivers="oss sdl"
-  CFLAGS="-std=gnu99 $CFLAGS"
+  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
   LIBS="-lsocket -lnsl -lresolv $LIBS"
 ;;
 AIX)
@@ -354,7 +354,7 @@  if test "$mingw32" = "yes" ; then
     kqemu="yes"
   fi
   EXESUF=".exe"
-  CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $CFLAGS"
+  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
   LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
 fi

@@ -515,44 +515,44 @@  done

 #
 # If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
-# CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
+# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
 #
 host_guest_base="no"
 case "$cpu" in
     sparc) case $sparc_cpu in
            v7|v8)
-             CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $CFLAGS"
+             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
            ;;
            v8plus|v8plusa)
-             CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $CFLAGS"
+             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
            ;;
            *) # sparc_cpu not defined in the command line
-             CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $CFLAGS"
+             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
            esac
            LDFLAGS="-m32 $LDFLAGS"
-           CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $CFLAGS"
+           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
            if test "$solaris" = "no" ; then
-             CFLAGS="-ffixed-g1 -ffixed-g6 $CFLAGS"
+             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
            fi
            ;;
     sparc64)
-           CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $CFLAGS"
+           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
            LDFLAGS="-m64 $LDFLAGS"
-           CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $CFLAGS"
+           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
            if test "$solaris" != "no" ; then
-             CFLAGS="-ffixed-g1 $CFLAGS"
+             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
            fi
            ;;
     s390)
-           CFLAGS="-march=z900 $CFLAGS"
+           QEMU_CFLAGS="-march=z900 $QEMU_CFLAGS"
            ;;
     i386)
-           CFLAGS="-m32 $CFLAGS"
+           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
            LDFLAGS="-m32 $LDFLAGS"
            host_guest_base="yes"
            ;;
     x86_64)
-           CFLAGS="-m64 $CFLAGS"
+           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
            LDFLAGS="-m64 $LDFLAGS"
            host_guest_base="yes"
            ;;
@@ -588,7 +588,7 @@  echo "  --source-path=PATH       path of source code [$source_path]"
 echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
 echo "  --cc=CC                  use C compiler CC [$cc]"
 echo "  --host-cc=CC             use C compiler CC [$host_cc] for dyngen etc."
-echo "  --extra-cflags=CFLAGS    append extra C compiler flags CFLAGS"
+echo "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
 echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
 echo "  --make=MAKE              use specified make [$make]"
 echo "  --install=INSTALL        use specified install [$install]"
@@ -1131,7 +1131,7 @@  EOF
     kvm="no";
     if [ -x "`which awk 2>/dev/null`" ] && \
        [ -x "`which grep 2>/dev/null`" ]; then
-      kvmerr=`LANG=C $cc $CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
+      kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
 	| grep "error: " \
 	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
       if test "$kvmerr" != "" ; then
@@ -1382,11 +1382,12 @@  fi
 # After here, no more $cc or $ld runs

 # default flags for all hosts
-CFLAGS="-g -fno-strict-aliasing $CFLAGS"
+QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
+CFLAGS="-g $CFLAGS"
 if test "$debug" = "no" ; then
   CFLAGS="-O2 $CFLAGS"
 fi
-CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls $CFLAGS"
+QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
 LDFLAGS="-g $LDFLAGS"

 # Consult white-list to determine whether to enable werror
@@ -1402,7 +1403,7 @@  if test -z "$werror" ; then
 fi

 if test "$werror" = "yes" ; then
-    CFLAGS="-Werror $CFLAGS"
+    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
 fi

 if test "$solaris" = "no" ; then
@@ -1440,6 +1441,7 @@  echo "Source path       $source_path"
 echo "C compiler        $cc"
 echo "Host C compiler   $host_cc"
 echo "CFLAGS            $CFLAGS"
+echo "QEMU_CFLAGS       $QEMU_CFLAGS"
 echo "LDFLAGS           $LDFLAGS"
 echo "make              $make"
 echo "install           $install"
@@ -1740,12 +1742,13 @@  echo "HOST_CC=$host_cc" >> $config_host_mak
 if test "$sparse" = "yes" ; then
   echo "CC      := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
   echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
-  echo "CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
+  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
 fi
 echo "AR=$ar" >> $config_host_mak
 echo "OBJCOPY=$objcopy" >> $config_host_mak
 echo "LD=$ld" >> $config_host_mak
 echo "CFLAGS=$CFLAGS" >> $config_host_mak
+echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
 echo "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
 echo "ARLIBS_END=$arlibs_end" >> $config_host_mak
@@ -2114,5 +2117,5 @@  for hwlib in 32 64; do
   rm -f $d/Makefile
   ln -s $source_path/Makefile.hw $d/Makefile
   echo "HWLIB=libqemuhw$hwlib.a" > $d/config.mak
-  echo "CPPFLAGS=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak
+  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak
 done
diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile
index 7ddc242..f6a596f 100644
--- a/pc-bios/optionrom/Makefile
+++ b/pc-bios/optionrom/Makefile
@@ -7,9 +7,9 @@  include $(SRC_PATH)/rules.mak

 VPATH=$(SRC_PATH)/pc-bios/optionrom

-CPPFLAGS = -Wall -Wstrict-prototypes -Werror -fomit-frame-pointer -fno-builtin
-CPPFLAGS += -I$(SRC_PATH)
-CPPFLAGS += $(call cc-option, $(CFLAGS), -fno-stack-protector,"")
+CFLAGS = -Wall -Wstrict-prototypes -Werror -fomit-frame-pointer -fno-builtin
+CFLAGS += -I$(SRC_PATH)
+CFLAGS += $(call cc-option, $(CFLAGS), -fno-stack-protector,"")

 build-all: multiboot.bin

diff --git a/rules.mak b/rules.mak
index f9d0ca0..c0315ac 100644
--- a/rules.mak
+++ b/rules.mak
@@ -1,12 +1,12 @@ 

 %.o: %.c
-	$(call quiet-command,$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
+	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")

 %.o: %.S
-	$(call quiet-command,$(CC) $(CPPFLAGS) -c -o $@ $<,"  AS    $(TARGET_DIR)$@")
+	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CLAGS) -c -o $@ $<,"  AS    $(TARGET_DIR)$@")

 %.o: %.m
-	$(call quiet-command,$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
+	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")

 LINK = $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $(1) $(ARLIBS_BEGIN) $(ARLIBS) $(ARLIBS_END) $(LIBS),"  LINK  $(TARGET_DIR)$@")