diff -up nx-3.5.0/nxcomp/configure~ nx-3.5.0/nxcomp/configure
--- nx-3.5.0/nxcomp/configure~	2011-06-25 14:44:37.184036869 +0300
+++ nx-3.5.0/nxcomp/configure	2011-06-25 14:46:20.588641288 +0300
@@ -1269,8 +1269,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-CXXFLAGS="-O3 -fno-rtti -fno-exceptions"
-CFLAGS="-O3"
+CXXFLAGS="$CXXFLAGS -fno-rtti -fno-exceptions"
 
 
 LIBSTATIC=""
diff -up nx-3.5.0/nxcompext/configure~ nx-3.5.0/nxcompext/configure
--- nx-3.5.0/nxcompext/configure~	2011-06-25 14:44:37.016021263 +0300
+++ nx-3.5.0/nxcompext/configure	2011-06-25 14:46:47.551145591 +0300
@@ -1269,8 +1269,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-CXXFLAGS="-O3"
-CFLAGS="-O3"
 
 
 LIBSTATIC=""
diff -up nx-3.5.0/nxcompshad/configure~ nx-3.5.0/nxcompshad/configure
--- nx-3.5.0/nxcompshad/configure~	2011-06-25 14:44:37.173035846 +0300
+++ nx-3.5.0/nxcompshad/configure	2011-06-25 14:48:14.259199114 +0300
@@ -1269,8 +1269,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-CXXFLAGS="-O3"
-CPPFLAGS="-O3"
 
 
 LIBSTATIC=""
diff -up nx-3.5.0/nxproxy/configure~ nx-3.5.0/nxproxy/configure
--- nx-3.5.0/nxproxy/configure~	2005-11-11 18:27:30.000000000 +0200
+++ nx-3.5.0/nxproxy/configure	2011-06-25 14:48:38.700469269 +0300
@@ -1269,8 +1269,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-CXXFLAGS="-O3"
-CPPFLAGS="-O3"
 
 
 if test -d "../nx-X11/exports/include" ; then
diff -up nx-3.5.0/nxssh/configure~ nx-3.5.0/nxssh/configure
--- nx-3.5.0/nxssh/configure~	2007-10-02 20:02:53.000000000 +0300
+++ nx-3.5.0/nxssh/configure	2011-06-25 14:48:57.942256493 +0300
@@ -4668,7 +4668,6 @@ TEST_SHELL=sh
 
 
 
-CFLAGS="-g -O3"
 
 NXCOMPINC="-I../nxcomp"
 NXCOMPLIBS="-L../nxcomp -lXcomp -lstdc++ -lpng -ljpeg -lz"
diff -up nx-3.5.0/nx-X11/config/cf/host.def~ nx-3.5.0/nx-X11/config/cf/host.def
--- nx-3.5.0/nx-X11/config/cf/host.def~	2011-06-29 01:14:46.974506460 +0300
+++ nx-3.5.0/nx-X11/config/cf/host.def	2011-07-01 00:20:11.261694918 +0300
@@ -497,17 +497,17 @@ XCOMM $XFree86: xc/config/cf/xf86site.de
  * -m486
  *
 #define DefaultGcc2i386Opt	-O2 -fno-strength-reduce
- */
 
 #if defined (LinuxArchitecture)
 #define DefaultGcc2i386Opt      -g -O3
 #endif
+ */
 
 /*
  * Enable all the optimizations on AMD64.
- */
 
 #define DefaultGcc2AMD64Opt	-g -O3 GccAliasingArgs
+ */
 
 /*
  * This allows the GCC warning flags to be set.  The default is shown here.
diff -up nx-3.5.0/nx-X11/config/cf/linux.cf~ nx-3.5.0/nx-X11/config/cf/linux.cf
--- nx-3.5.0/nx-X11/config/cf/linux.cf~	2005-10-21 22:10:27.000000000 +0300
+++ nx-3.5.0/nx-X11/config/cf/linux.cf	2011-06-29 01:09:13.799185571 +0300
@@ -837,7 +837,7 @@ InstallNamedTargetNoClobber(install,file
 #ifdef Arm32Architecture
 # define DefaultCCOptions
 # ifndef OptimizedCDebugFlags
-#  define OptimizedCDebugFlags	-O3
+#  define OptimizedCDebugFlags	$(RPM_CFLAGS)
 # endif
 # define LinuxMachineDefines	-D__arm__ -D__arm32__ -U__arm -Uarm
 # define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME
@@ -845,7 +845,7 @@ InstallNamedTargetNoClobber(install,file
 #endif /* Arm32Achitecture */
 
 #ifdef HPArchitecture
-# define OptimizedCDebugFlags	-O2  GccAliasingArgs
+# define OptimizedCDebugFlags	$(RPM_CFLAGS) GccAliasingArgs
 # define LinuxMachineDefines	-D__hppa__
 # define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME
 # define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
@@ -909,7 +909,7 @@ InstallNamedTargetNoClobber(install,file
 
 #ifdef s390Architecture
 # ifndef OptimizedCDebugFlags
-#  define OptimizedCDebugFlags	-O2 -fomit-frame-pointer GccAliasingArgs
+#  define OptimizedCDebugFlags	$(RPM_CFLAGS) GccAliasingArgs
 # endif
 # define LinuxMachineDefines	-D__s390__
 # define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME
@@ -918,7 +918,7 @@ InstallNamedTargetNoClobber(install,file
 
 #ifdef s390xArchitecture
 /*#define DefaultCCOptions	-fsigned-char */
-#define OptimizedCDebugFlags	-O3 -fomit-frame-pointer
+#define OptimizedCDebugFlags	$(RPM_CFLAGS)
 #define LinuxMachineDefines	-D__s390x__
 #define ServerOSDefines		XFree86ServerOSDefines -DDDXTIME
 #define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines -D_XSERVER64
@@ -926,7 +926,7 @@ InstallNamedTargetNoClobber(install,file
 
 #ifdef SparcArchitecture
 # ifndef OptimizedCDebugFlags
-#  define OptimizedCDebugFlags	-O2  GccAliasingArgs
+#  define OptimizedCDebugFlags	$(RPM_CFLAGS) GccAliasingArgs
 # endif
 # define LinuxMachineDefines	-D__sparc__
 # define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME
@@ -957,7 +957,7 @@ InstallNamedTargetNoClobber(install,file
 #  endif
 # endif
 # ifndef OptimizedCDebugFlags
-#  define OptimizedCDebugFlags	-O2 SuperHArchOptFlags SuperHEndianFlags  GccAliasingArgs
+#  define OptimizedCDebugFlags	$(RPM_CFLAGS) SuperHArchOptFlags SuperHEndianFlags GccAliasingArgs
 # endif
 # define LinuxMachineDefines	-D__sh__
 # define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME
diff -up nx-3.5.0/nx-X11/config/cf/xorg.cf~ nx-3.5.0/nx-X11/config/cf/xorg.cf
--- nx-3.5.0/nx-X11/config/cf/xorg.cf~	2005-10-03 19:08:44.000000000 +0300
+++ nx-3.5.0/nx-X11/config/cf/xorg.cf	2011-06-29 01:10:00.860608947 +0300
@@ -1557,37 +1557,37 @@ XFREE86JAPANESEDOCDIR = $(DOCDIR)/Japane
 
 #if HasGcc2 && defined(i386Architecture)
 # ifndef DefaultGcc2i386Opt
-#  define DefaultGcc2i386Opt -O2 -fno-strength-reduce GccAliasingArgs
+#  define DefaultGcc2i386Opt $(RPM_CFLAGS) -fno-strength-reduce GccAliasingArgs
 # endif
 #endif
 
 #if HasGcc2 && defined(AMD64Architecture)
 # ifndef DefaultGcc2AMD64Opt
-#  define DefaultGcc2AMD64Opt -O2 -fno-strength-reduce GccAliasingArgs
+#  define DefaultGcc2AMD64Opt $(RPM_CFLAGS) -fno-strength-reduce GccAliasingArgs
 # endif
 #endif
 
 #if HasGcc2 && defined(AlphaArchitecture)
 # ifndef DefaultGcc2AxpOpt
-#  define DefaultGcc2AxpOpt -O2 GccAliasingArgs
+#  define DefaultGcc2AxpOpt $(RPM_CFLAGS) GccAliasingArgs
 # endif
 #endif
 
 #if HasGcc2 && defined(Ppc64Architecture)
 # ifndef DefaultGcc2Ppc64Opt
-#  define DefaultGcc2Ppc64Opt -O2 GccAliasingArgs
+#  define DefaultGcc2Ppc64Opt $(RPM_CFLAGS) GccAliasingArgs
 # endif
 #endif
 
 #if HasGcc2 && defined(MipsArchitecture)
 # ifndef DefaultGcc2MipsOpt
-#  define DefaultGcc2MipsOpt -O2 GccAliasingArgs
+#  define DefaultGcc2MipsOpt $(RPM_CFLAGS) GccAliasingArgs
 # endif
 #endif
 
 #if HasGcc2 && defined(PpcArchitecture)
 # ifndef DefaultGcc2PpcOpt
-#  define DefaultGcc2PpcOpt -O2 GccAliasingArgs
+#  define DefaultGcc2PpcOpt $(RPM_CFLAGS) GccAliasingArgs
 # endif
 #endif
 
