Thank you Fabian, Michał. Added note on Makefile and mentioned other
tools as well. Updated patch is in attachment.

--
Peter.
>From 9d24f4bab09be481e70ab04c85f20a246162dc0a Mon Sep 17 00:00:00 2001
From: Peter Volkov <p...@gentoo.org>
Date: Tue, 28 Jun 2011 10:05:17 +0400
Subject: [PATCH] Use | as a separator for sed'ing CFLAGS

/, : is a bad idea per thread on gentoo-dev:

http://archives.gentoo.org/gentoo-dev/msg_654cd9daf2548a524c8a09a82b80916f.xml
---
 .../functions/src_compile/building/text.xml        |   31 +++++++++++++++----
 1 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/ebuild-writing/functions/src_compile/building/text.xml b/ebuild-writing/functions/src_compile/building/text.xml
index 700f0f1..1bc3ec2 100644
--- a/ebuild-writing/functions/src_compile/building/text.xml
+++ b/ebuild-writing/functions/src_compile/building/text.xml
@@ -43,10 +43,24 @@ It is <e>not</e> correct to use the <c>${CC}</c> variable for this purpose.
 </note>
 
 <p>
-Sometimes a package will not use the user's <c>${CFLAGS}</c> or <c>${LDFLAGS}</c>.
-This must be worked around, as sometimes these variables are used for specifying
-critical ABI options. In these cases, the build scripts should be modified (for
-example, with <c>sed</c>) to use <c>${CFLAGS}</c> or <c>${LDFLAGS}</c> correctly.
+Sometimes a package will not use the user's <c>${CFLAGS}</c> or
+<c>${LDFLAGS}</c>. This must be worked around, as sometimes these variables are
+used for specifying critical ABI options. In some cases it's enough to pass
+correct parameters for the <c>emake</c> (check Makefile to see if this is
+possible):
+</p>
+
+<codesample lang="ebuild">
+EAPI="4"
+
+src_compile() {
+	emake CC="$(tc-getCC)" CFLAGS="${CFLAGS}"
+}
+</codesample>
+
+<p>
+In other cases, the build scripts should be modified (for example, with
+<c>sed</c>) to use <c>${CFLAGS}</c> or <c>${LDFLAGS}</c> correctly.
 </p>
 
 <codesample lang="ebuild">
@@ -58,15 +72,18 @@ src_compile() {
 
     # We have a weird build.sh to work with which ignores our
     # compiler preferences. yay!
-    sed -i -e "s:cc -O2:$(tc-getCC) ${CFLAGS} ${LDFLAGS}:" build.sh \
+    sed -i -e "s|cc -O2|$(tc-getCC) ${CFLAGS} ${LDFLAGS}|" build.sh \
         || die "sed fix failed. Uh-oh..."
     ./build.sh || die "Build failed!"
 }
 </codesample>
 
 <note>
-When using <c>sed</c> with <c>CFLAGS</c> or <c>LDFLAGS</c>, it is not safe to use
-a comma or a slash as a delimiter. The recommended character is a colon.
+When using <c>sed</c> with <c>CFLAGS</c> or <c>LDFLAGS</c>, it is not safe to
+use a comma, a colon or a slash as a delimiter. <c>gcc</c>, <c>ld</c>,
+<c>ar</c>, etc... options may contain this characters so <c>sed</c> will fail
+after bash expansion. The recommended character is a vertical bar: '|' (the
+pipe).
 </note>
 
 <p>
-- 
1.7.3.4

Reply via email to