Fold set_pkgconfig_paths into setup_build_environment.

Both of these set environment variables that allow libraries etc. to
be located. It's quite plausible that some implementations of the
check_installed function might depend on values of CFLAGS, LDFLAGS and
so on to check if a library is installed. Therefore, just set all these
variables in a single common function only invoked just before build, or
before performing an 'installed' check.
This commit is contained in:
Simon Howard 2016-02-23 22:30:34 -05:00
parent 280ef8dd89
commit 33306ccdb4

View file

@ -55,23 +55,6 @@ dependencies() {
DEPENDENCIES+="$*" DEPENDENCIES+="$*"
} }
# set_pkgconfig_paths sets the values of the PKG_CONFIG_PATH and
# PKG_CONFIG_LIBDIR environment variables. This is deliberately only done
# when needed, as otherwise the value could affect child builds when
# recursing to build dependent packages.
set_pkgconfig_paths() {
PKG_CONFIG_PATH="$PACKAGE_INSTALL_DIR/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
export PKG_CONFIG_PATH
# When cross-compiling, reconfigure pkg-config to not look for .pc
# files in the standard system directories; only in our own build
# directory. It may be that a library is installed on the system
# but that is useless if it is for the wrong architecture.
if $IS_CROSS_COMPILE && [ "$PACKAGE_TYPE" = "target" ]; then
export PKG_CONFIG_LIBDIR=
fi
}
# Given a package name, find the pkgdef file associated with it, source # Given a package name, find the pkgdef file associated with it, source
# the contents of the file and set various variables. # the contents of the file and set various variables.
configure_for_package() { configure_for_package() {
@ -107,15 +90,9 @@ configure_for_package() {
esac esac
} }
cmd_installed() { # setup_build_environment sets environment variables for build. This is
set_pkgconfig_paths # deliberately only done when needed, as otherwise the value could affect
check_installed # child builds when recursing to build dependent packages.
}
cmd_fetch() {
do_fetch
}
setup_build_environment() { setup_build_environment() {
CPPFLAGS="-I$PACKAGE_INSTALL_DIR/include" CPPFLAGS="-I$PACKAGE_INSTALL_DIR/include"
LDFLAGS="-L$PACKAGE_INSTALL_DIR/lib ${LDFLAGS:-}" LDFLAGS="-L$PACKAGE_INSTALL_DIR/lib ${LDFLAGS:-}"
@ -126,6 +103,18 @@ setup_build_environment() {
ACLOCAL_PATH="$INSTALL_DIR/share/aclocal:${ACLOCAL_PATH:-}" ACLOCAL_PATH="$INSTALL_DIR/share/aclocal:${ACLOCAL_PATH:-}"
ACLOCAL_PATH="$NATIVE_INSTALL_DIR/share/aclocal:$ACLOCAL_PATH" ACLOCAL_PATH="$NATIVE_INSTALL_DIR/share/aclocal:$ACLOCAL_PATH"
export ACLOCAL_PATH export ACLOCAL_PATH
# We need to find where to look for pkg-config .pc files:
PKG_CONFIG_PATH="$PACKAGE_INSTALL_DIR/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
export PKG_CONFIG_PATH
# When cross-compiling, reconfigure pkg-config to not look for .pc
# files in the standard system directories; only in our own build
# directory. It may be that a library is installed on the system
# but that is useless if it is for the wrong architecture.
if $IS_CROSS_COMPILE && [ "$PACKAGE_TYPE" = "target" ]; then
export PKG_CONFIG_LIBDIR=
fi
} }
install_dependencies() { install_dependencies() {
@ -134,6 +123,15 @@ install_dependencies() {
done done
} }
cmd_installed() {
setup_build_environment
check_installed
}
cmd_fetch() {
do_fetch
}
# Function invoked before a package is built to set up the build environment, # Function invoked before a package is built to set up the build environment,
# if necessary. Can be overridden by pkgdef files. # if necessary. Can be overridden by pkgdef files.
prebuild_setup() { prebuild_setup() {
@ -141,7 +139,6 @@ prebuild_setup() {
} }
cmd_build() { cmd_build() {
set_pkgconfig_paths
install_dependencies install_dependencies
chocpkg fetch "$PACKAGE_NAME" chocpkg fetch "$PACKAGE_NAME"