--- /dev/null
+--- rpm-4.5/installplatform.orig 2013-07-17 10:01:04.000000000 +0000
++++ rpm-4.5/installplatform 2013-07-17 10:18:26.094178797 +0000
+@@ -35,7 +35,7 @@
+ sparc*) SUBSTS='s_sparc\(64\|v9\)_sparc_ s_sparc64_sparcv9_;s_sparc\([^v]\|$\)_sparcv9\1_ s_sparcv9_sparc64_;s_sparc\([^6]\|$\)_sparc64\1_' ;;
+ powerpc*|ppc*) SUBSTS='s_ppc64_ppc_ s_ppc\([^6ip]\|$\)_ppc64\1_ s_ppc\([^6ip]\|$\)_ppciseries_ s_ppc\([^6ip]\|$\)_ppcpseries_ s_ppc\([^6ip]\|$\)_ppc64iseries_ s_ppc\([^6ip]\|$\)_ppc64pseries_' ;;
+ s390*) SUBSTS='s_s390x_s390_ s_s390\([^x]\|$\)_s390x\1_' ;;
+- x86_64|amd64|ia32e) SUBSTS='s,x86_64,x86_64, s,x86_64,ia32e, s,x86_64,amd64,' ;;
++ x86_64|amd64|ia32e) SUBSTS='s|x86_64|x86_64| s|x86_64|ia32e| s|x86_64|amd64|' ;;
+ *) SUBSTS=y___ ;;
+ esac
+
+@@ -50,7 +50,7 @@
+ [ -d $PPD ] || mkdir $PPD
+
+ RPMRC_OPTFLAGS="`sed -n 's/^optflags: '$ARCH' //p' $RPMRC`"
+- RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e 's, ,\ ,g'`"
++ RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e 's| |\ |g'`"
+ case $RPMRC_OPTFLAGS in
+ *-g*) ;;
+ *) RPMRC_OPTFLAGS="$RPMRC_OPTFLAGS -g" ;;
+@@ -71,45 +71,45 @@
+ esac
+
+ if [ -n "$MULTILIBNO" ]; then
+- MULTILIBSED='-e /^@MULTILIB/d -e s,@MULTILIBNO@,'$MULTILIBNO,
++ MULTILIBSED='-e /^@MULTILIB/d -e s|@MULTILIBNO@|'$MULTILIBNO'|'
+ else
+ MULTILIBSED='-e /^@MULTILIBSTART@/,/^@MULTILIBEND@/d'
+ fi
+
+ case $VENDOR in
+ yellowdog)
+- VENDORSED='-e s,^@yellowdog@,,'
++ VENDORSED='-e s|^@yellowdog@||'
+ ;;
+ tld)
+- VENDORSED='-e s,^@tld@,,'
++ VENDORSED='-e s|^@tld@||'
+ RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e "s/ -g/ /"`"
+ ;;
+ mandrake)
+- VENDORSED='-e s,^@mandrake@,,'
++ VENDORSED='-e s|^@mandrake@||'
+ RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e s/i386/i686/`"
+ ;;
+ conectiva)
+- VENDORSED='-e s,^@conectiva@,,'
++ VENDORSED='-e s|^@conectiva@||'
+ ;;
+ redhat)
+- VENDORSED='-e s,^@redhat@,,'
++ VENDORSED='-e s|^@redhat@||'
+ ;;
+ apple)
+- VENDORSED='-e s,^@apple@,,'
++ VENDORSED='-e s|^@apple@||'
+ ;;
+ crux)
+- VENDORSED='-e s,^@crux@,,'
++ VENDORSED='-e s|^@crux@||'
+ ;;
+ esac
+
+ cat $PLATFORM \
+- | sed -e "s,@RPMRC_OPTFLAGS@,$RPMRC_OPTFLAGS," \
+- -e "s,@RPMRC_ARCH@,$ARCH," \
+- -e "s,@RPMRC_GNU@,$RPMRC_GNU," \
+- -e "s,@LIB@,$LIB," \
+- -e "s,@ARCH_INSTALL_POST@,$ARCH_INSTALL_POST," \
+- -e "s,@DEFAULTDOCDIR@,$DEFAULTDOCDIR," \
+- -e '/\${\w*:-/!s,\${,%{_,' \
++ | sed -e "s|@RPMRC_OPTFLAGS@|$RPMRC_OPTFLAGS|" \
++ -e "s|@RPMRC_ARCH@|$ARCH|" \
++ -e "s|@RPMRC_GNU@|$RPMRC_GNU|" \
++ -e "s|@LIB@|$LIB|" \
++ -e "s|@ARCH_INSTALL_POST@|$ARCH_INSTALL_POST|" \
++ -e "s|@DEFAULTDOCDIR@|$DEFAULTDOCDIR|" \
++ -e '/\${\w*:-/!s|\${|%{_|' \
+ $MULTILIBSED \
+ $VENDORSED \
+ | grep -v '^@' \
+@@ -117,19 +117,20 @@
+
+ done
+
++
+ { cd ${DESTDIR}/${pkglibdir}
+ [ -L noarch-${OS} ] && rm -f noarch-${OS} 2>/dev/null
+ mkdir -p noarch-${OS}
+- sed -e "/^%_arch/s,${arch},noarch," ${arch}-${OS}/macros | grep -v '^%optflags' > noarch-${OS}/macros
++ sed -e "/^%_arch/s|${arch}|noarch|" ${arch}-${OS}/macros | grep -v '^%optflags' > noarch-${OS}/macros
+ # [ -d ${VENDOR} ] || mkdir ${VENDOR}
+ # for i in brp-* find-lang.sh find-provides find-requires perl.prov perl.req
+ # do
+-# sed -e "s,/usr/lib/rpm,/usr/lib/rpm/${VENDOR},g" < $i > ${VENDOR}/$i
++# sed -e "s|/usr/lib/rpm|/usr/lib/rpm/${VENDOR}|g" < $i > ${VENDOR}/$i
+ # chmod +x ${VENDOR}/$i
+ # done
+ ## chmod -x ${VENDOR}/perl.req
+ # echo "macrofiles: /usr/lib/rpm/macros:/usr/lib/rpm/${VENDOR}/macros:/etc/rpm/macros.specspo:/etc/rpm/macros.cdb" > ${VENDOR}/rpmrc
+-# sed -e "s,/usr/lib/rpm,/usr/lib/rpm/${VENDOR},g" < ${arch}-${OS}/macros | grep -v '^%(_arch|optflags)' > ${VENDOR}/macros
++# sed -e "s|/usr/lib/rpm|/usr/lib/rpm/${VENDOR}|g" < ${arch}-${OS}/macros | grep -v '^%(_arch|optflags)' > ${VENDOR}/macros
+ }
+
+ rm $TEMPRC
-optflags: atariclone -O2 -g -fomit-frame-pointer
-optflags: milan -O2 -g -fomit-frame-pointer
-optflags: hades -O2 -g -fomit-frame-pointer
-+optflags: i386 -O2 -pipe -fno-strict-aliasing -fwrapv -march=i386%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_ia32: %{specflags_ia32}}%{?specflags_i386: %{specflags_i386}}}
-+optflags: i486 -O2 -pipe -fno-strict-aliasing -fwrapv -march=i486%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_ia32: %{specflags_ia32}}%{?specflags_i486: %{specflags_i486}}}
-+optflags: i586 -O2 -pipe -fno-strict-aliasing -fwrapv -march=i586%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_ia32: %{specflags_ia32}}%{?specflags_i586: %{specflags_i586}}}
-+optflags: i686 -O2 -pipe -fno-strict-aliasing -fwrapv -march=i686 -mtune=pentium4%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_ia32: %{specflags_ia32}}%{?specflags_i686: %{specflags_i686}}}
-+optflags: pentium3 -O2 -pipe -fno-strict-aliasing -fwrapv -march=pentium3%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_ia32: %{specflags_ia32}}%{?specflags_pentium3: %{specflags_pentium3}}}
-+optflags: pentium4 -O2 -pipe -fno-strict-aliasing -fwrapv -march=pentium4%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_ia32: %{specflags_ia32}}%{?specflags_pentium4: %{specflags_pentium4}}}
-+optflags: athlon -O2 -pipe -fno-strict-aliasing -fwrapv -march=athlon%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_ia32: %{specflags_ia32}}%{?specflags_athlon: %{specflags_athlon}}}
-+optflags: ia64 -O2 -pipe -fno-strict-aliasing -fwrapv%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_ia64: %{specflags_ia64}}}
-+optflags: x86_64 -O2 -pipe -fno-strict-aliasing -fwrapv -march=x86-64%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_x86_64: %{specflags_x86_64}}}
-+optflags: amd64 -O2 -pipe -fno-strict-aliasing -fwrapv -march=k8%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_amd64: %{specflags_amd64}}}
-+optflags: ia32e -O2 -pipe -fno-strict-aliasing -fwrapv -march=nocona%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_ia32e: %{specflags_ia32e}}}
++optflags: i386 -O2 -pipe -fno-strict-aliasing -fwrapv -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fomit-frame-pointer -fasynchronous-unwind-tables -mtune=generic -march=i386%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_ia32: %{specflags_ia32}}%{?specflags_i386: %{specflags_i386}}}
++optflags: i486 -O2 -pipe -fno-strict-aliasing -fwrapv -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fomit-frame-pointer -fasynchronous-unwind-tables -march=i486%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_ia32: %{specflags_ia32}}%{?specflags_i486: %{specflags_i486}}}
++optflags: i586 -O2 -pipe -fno-strict-aliasing -fwrapv -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fomit-frame-pointer -fasynchronous-unwind-tables -mtune=generic -march=i586%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_ia32: %{specflags_ia32}}%{?specflags_i586: %{specflags_i586}}}
++optflags: i686 -O2 -pipe -fno-strict-aliasing -fwrapv -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fomit-frame-pointer -fasynchronous-unwind-tables -march=i686 -mtune=pentium4%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_ia32: %{specflags_ia32}}%{?specflags_i686: %{specflags_i686}}}
++optflags: pentium3 -O2 -pipe -fno-strict-aliasing -fwrapv -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fomit-frame-pointer -march=pentium3%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_ia32: %{specflags_ia32}}%{?specflags_pentium3: %{specflags_pentium3}}}
++optflags: pentium4 -O2 -pipe -fno-strict-aliasing -fwrapv -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fomit-frame-pointer -march=pentium4%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_ia32: %{specflags_ia32}}%{?specflags_pentium4: %{specflags_pentium4}}}
++optflags: athlon -O2 -pipe -fno-strict-aliasing -fwrapv -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fomit-frame-pointer -fasynchronous-unwind-tables -march=athlon%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_ia32: %{specflags_ia32}}%{?specflags_athlon: %{specflags_athlon}}}
++optflags: ia64 -O2 -pipe -fno-strict-aliasing -fwrapv -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_ia64: %{specflags_ia64}}}
++optflags: x86_64 -O2 -pipe -fno-strict-aliasing -fwrapv -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fPIC -march=x86-64%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_x86_64: %{specflags_x86_64}}}
++optflags: amd64 -O2 -pipe -fno-strict-aliasing -fwrapv -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fPIC -march=k8%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_amd64: %{specflags_amd64}}}
++optflags: ia32e -O2 -pipe -fno-strict-aliasing -fwrapv -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fPIC -march=nocona%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_ia32e: %{specflags_ia32e}}}
+
+optflags: alpha -O2 -fno-strict-aliasing -fwrapv -mieee%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_alpha: %{specflags_alpha}}}
+optflags: alphaev5 -O2 -fno-strict-aliasing -fwrapv -mieee -mcpu=ev5%{!?nospecflags:%{?specflags: %{specflags}}%{?specflags_alpha: %{specflags_alpha}}%{?specflags_alphaev5: %{specflags_alphaev5}}}