xbps-src: added XBPS_LDFLAGS into the configuration file.

This is to specify common LDFLAGS settings for all packages, by default
it's set to '-Wl,--as-needed' to avoid linking extra libraries into
the binaries. This helped to find such cases.
This commit is contained in:
Juan RP 2010-10-29 10:23:25 +02:00
parent 6387ead759
commit 71e5c38598
5 changed files with 29 additions and 5 deletions

View File

@ -19,6 +19,15 @@ XBPS_MASTERDIR=$XBPS_DISTRIBUTIONDIR/masterdir
XBPS_CFLAGS="-O2 -pipe"
XBPS_CXXFLAGS="$XBPS_CFLAGS"
#
# Linker flags passed to the compiler. By default we use --as-needed to
# avoid linking extra libraries into binaries. See the following link
# for info:
#
# http://www.gentoo.org/proj/en/qa/asneeded.xml
#
XBPS_LDFLAGS="-Wl,--as-needed"
#
# Number of jobs when running make(1)-alike commands.
#

View File

@ -30,6 +30,7 @@
build_src_phase()
{
local pkg="$pkgname-$version" pkgparam="$1" f lver
local mkldflags
[ -z $pkgparam ] && [ -z $pkgname -o -z $version ] && return 1
@ -57,7 +58,7 @@ build_src_phase()
make_cmd="python"
make_build_args="setup.py build"
else
[ -z "$make_cmd" ] && make_cmd=/usr/bin/make
[ -z "$make_cmd" ] && make_cmd=make
[ -n "$XBPS_MAKEJOBS" -a -z "$disable_parallel_build" ] && \
makejobs="-j$XBPS_MAKEJOBS"
fi
@ -77,6 +78,7 @@ build_src_phase()
msg_normal "Package '$pkgname ($lver)': running build phase."
if [ "$build_style" = "custom-install" ]; then
[ -n "$XBPS_LDFLAGS" ] && export LDFLAGS="$XBPS_LDFLAGS"
run_func do_build 2>${wrksrc}/.xbps_do_build.log
if [ $? -ne 0 -a $? -ne 255 ]; then
msg_error "Package '$pkgname': do_build phase failed!"
@ -85,7 +87,12 @@ build_src_phase()
#
# Build package via make.
#
${make_cmd} ${makejobs} ${make_build_args} \
if [ "$build_style" = "gnu_makefile" ]; then
if [ -n "$XBPS_LDFLAGS" ]; then
mkldfags="$LDFLAGS $XBPS_LDFLAGS"
fi
fi
env LDFLAGS="$mkldflags" ${make_cmd} ${makejobs} ${make_build_args} \
${make_build_target} ||
msg_error "Package '$pkgname': build phase failed!"
fi

View File

@ -61,6 +61,7 @@ XBPS_DISTRIBUTIONDIR=/xbps
XBPS_MASTERDIR=/
XBPS_CFLAGS="$XBPS_CFLAGS"
XBPS_CXXFLAGS="$XBPS_CFLAGS"
XBPS_LDFLAGS="$XBPS_LDFLAGS"
XBPS_FETCH_CMD="xbps-uhelper.static fetch"
XBPS_COMPRESS_CMD="$XBPS_COMPRESS_CMD"
_EOF

View File

@ -30,6 +30,7 @@
configure_src_phase()
{
local f lver error=0
local conf_ldflags
[ -z $pkgname ] && return 1
@ -84,12 +85,17 @@ configure_src_phase()
cd $build_wrksrc || return 1
fi
if [ -n "$XBPS_LDFLAGS" ]; then
conf_ldflags="$XBPS_LDFLAGS"
fi
case "$build_style" in
gnu_configure|gnu-configure)
#
# Packages using GNU autoconf
#
${configure_script} --prefix=/usr --sysconfdir=/etc \
env LDFLAGS="$LDFLAGS $conf_ldflags" \
${configure_script} --prefix=/usr --sysconfdir=/etc \
--infodir=/usr/share/info --mandir=/usr/share/man \
${configure_args} || error=$?
;;
@ -97,7 +103,8 @@ configure_src_phase()
#
# Packages using custom configure scripts.
#
${configure_script} ${configure_args} || error=$?
env LDFLAGS="$LDFLAGS $conf_ldflags" ${configure_script} \
${configure_args} || error=$?
;;
perl-module|perl_module)
#

View File

@ -265,9 +265,9 @@ set_tmpl_common_vars()
export CFLAGS="$XBPS_CFLAGS"
export CXXFLAGS="$XBPS_CXXFLAGS"
export CPPFLAGS="-I$XBPS_MASTERDIR/usr/include"
if [ -z "$in_chroot" ]; then
export CPPFLAGS="-I$XBPS_MASTERDIR/usr/include"
if [ -d /usr/lib/libfakeroot ]; then
LDLIBPATH="/usr/lib/libfakeroot:$XBPS_MASTERDIR/usr/lib"
else