redoconf: move -Wl,-rpath flags to shlib.rc and add -Wl,-z,origin.
It was kind of ugly to have this kind of special flag directly in link.od; now we detect whether it's available. This also gives a project the ability to override the flag in some other way if they want. As a result, rc/shlib.rc needs to be included in all.rc.od if you want to create or link against shared libraries. While we're here, also add -Wl,-z,origin on platforms where it works. This is apparently needed for FreeBSD 8.0 at least, and probably other platforms. Reported-by: Wayne Scott <wsc9tt@gmail.com>
This commit is contained in:
parent
1eb7b2879d
commit
88250334da
4 changed files with 24 additions and 6 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
rc_include \
|
rc_include \
|
||||||
rc/CC.required.rc \
|
rc/CC.required.rc \
|
||||||
rc/CXX.rc \
|
rc/CXX.rc \
|
||||||
|
rc/shlib.rc \
|
||||||
rc/libqt4.rc \
|
rc/libqt4.rc \
|
||||||
rc/libgtk2.rc \
|
rc/libgtk2.rc \
|
||||||
rc/Wextra.rc \
|
rc/Wextra.rc \
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
. ./redoconf.rc
|
. ./redoconf.rc
|
||||||
rc_include _all.rc rc/shlib.rc
|
rc_include _all.rc
|
||||||
|
|
||||||
# Tricky quoting: see _compile.od for details.
|
# Tricky quoting: see _compile.od for details.
|
||||||
if [ "$HAVE_SHLIB" = UNIX ]; then
|
if [ "$HAVE_SHLIB" = UNIX ]; then
|
||||||
|
|
@ -40,6 +40,12 @@ elif [ "$HAVE_SHLIB" = MACOS ]; then
|
||||||
\$LIBS
|
\$LIBS
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
|
if [ -z "$HAVE_SHLIB" ]; then
|
||||||
|
echo "link-shlib.od: fatal:" \
|
||||||
|
"must include rc/shlib.rc to use shared libraries." >&2
|
||||||
|
exit 90
|
||||||
|
fi
|
||||||
|
|
||||||
# If no shared library support and we try to build one,
|
# If no shared library support and we try to build one,
|
||||||
# compensate by building a static library instead in the
|
# compensate by building a static library instead in the
|
||||||
# same place.
|
# same place.
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ cat >$3 <<-EOF
|
||||||
IFS="$NL"
|
IFS="$NL"
|
||||||
set -f
|
set -f
|
||||||
\$LINK -o "\$o" \\
|
\$LINK -o "\$o" \\
|
||||||
-Wl,-rpath,'\$ORIGIN' \\
|
|
||||||
\$LDFLAGS \$OPTFLAGS \\
|
\$LDFLAGS \$OPTFLAGS \\
|
||||||
"\$@" \\
|
"\$@" \\
|
||||||
\$LIBS
|
\$LIBS
|
||||||
|
|
|
||||||
|
|
@ -27,17 +27,29 @@ try_macos_style() {
|
||||||
|
|
||||||
if [ -n "$STATIC" ]; then
|
if [ -n "$STATIC" ]; then
|
||||||
echo "--enable-static specified; not building shared libraries." >&2
|
echo "--enable-static specified; not building shared libraries." >&2
|
||||||
rc_replaceln HAVE_SHLIB ""
|
rc_replaceln HAVE_SHLIB "STATIC"
|
||||||
elif [ -n "$NOSHARED" ]; then
|
elif [ -n "$NOSHARED" ]; then
|
||||||
echo "--disable-shared specified; not building shared libraries." >&2
|
echo "--disable-shared specified; not building shared libraries." >&2
|
||||||
rc_replaceln HAVE_SHLIB ""
|
rc_replaceln HAVE_SHLIB "STATIC"
|
||||||
elif try_unix_style; then
|
elif try_unix_style; then
|
||||||
rc_replaceln HAVE_SHLIB UNIX
|
rc_replaceln HAVE_SHLIB UNIX
|
||||||
elif try_macos_style; then
|
elif try_macos_style; then
|
||||||
rc_replaceln HAVE_SHLIB MACOS
|
rc_replaceln HAVE_SHLIB MACOS
|
||||||
else
|
else
|
||||||
echo "Not building shared libraries on this platform." >&2
|
echo "Not building shared libraries on this platform." >&2
|
||||||
rc_undo
|
rc_replaceln HAVE_SHLIB "STATIC"
|
||||||
rc_replaceln HAVE_SHLIB ""
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$HAVE_SHLIB" != "STATIC" ]; then
|
||||||
|
x='-Wl,-z,origin'
|
||||||
|
if (appendln LDFLAGS "$x" && rc_compile cc link); then
|
||||||
|
rc_appendln LDFLAGS "$x"
|
||||||
|
fi
|
||||||
|
|
||||||
|
x='-Wl,-rpath,$ORIGIN'
|
||||||
|
if (appendln LDFLAGS "$x" && rc_compile cc link); then
|
||||||
|
rc_appendln LDFLAGS "$x"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
rc_save
|
rc_save
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue