aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Sokolov <sokolov@google.com>2020-11-26 00:39:09 +0000
committerUlrich Müller <ulm@gentoo.org>2021-01-03 15:17:41 +0100
commit9612233e20944cb719690da2cc79586a538afd15 (patch)
treef7e0349441bb1115fca2d6f0a9dbc861a66937ab
parentebuild-writing/functions/src_test: IUSE=test is not required. (diff)
downloaddevmanual-9612233e20944cb719690da2cc79586a538afd15.tar.gz
devmanual-9612233e20944cb719690da2cc79586a538afd15.tar.bz2
devmanual-9612233e20944cb719690da2cc79586a538afd15.zip
src_compile/building: Change example with bug 685160 #c9 in mind
Closes: https://github.com/gentoo/devmanual/pull/181 Signed-off-by: Alexey Sokolov <sokolov@google.com> [Delete build.sh example because it is not used afterwards. The note refers to sed usage in the codesample so keep it below.] Signed-off-by: Ulrich Müller <ulm@gentoo.org>
-rw-r--r--ebuild-writing/functions/src_compile/building/text.xml25
1 files changed, 17 insertions, 8 deletions
diff --git a/ebuild-writing/functions/src_compile/building/text.xml b/ebuild-writing/functions/src_compile/building/text.xml
index 4245c5f..696dacf 100644
--- a/ebuild-writing/functions/src_compile/building/text.xml
+++ b/ebuild-writing/functions/src_compile/building/text.xml
@@ -47,27 +47,36 @@ It is <e>not</e> correct to use the <c>${CC}</c> variable for this purpose.
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.
+example, with <c>sed</c> or via a patch) to use <c>${CFLAGS}</c> or
+<c>${LDFLAGS}</c> correctly.
</p>
<codesample lang="ebuild">
inherit flag-o-matic toolchain-funcs
+src_prepare() {
+ default
+
+ # We have a weird Makefile to work with which ignores our
+ # compiler preferences. yay!
+ # Note the single quotes.
+ sed -i -e 's:cc -O2:$(CC) $(CFLAGS) $(LDFLAGS):' Makefile \
+ || die "sed fix failed. Uh-oh..."
+}
+
src_compile() {
# -Os not happy
replace-flags -Os -O2
- # 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 \
- || die "sed fix failed. Uh-oh..."
- ./build.sh || die "Build failed!"
+ emake CC="$(tc-getCC)" CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}"
}
</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.
+Try to not substitute the value with <c>sed</c> directly, but instead make the
+build script use the variables. The variables may contain characters such as a
+slash, a comma, or a colon, which are often used with <c>sed</c>, and this
+would break its syntax.
</note>
<p>