summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2018-09-03 10:40:49 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2018-09-06 08:47:38 +0200
commit4c6e7fa28b66dee069d10b514d5e1317173da250 (patch)
tree9a8a85efbcfe36fe8842f5e0ad3e819b73ae3b61 /scripts
parenta7d93ba352b42652f275a946bc4473f2f47bf908 (diff)
downloadptxdist-4c6e7fa28b66dee069d10b514d5e1317173da250.tar.gz
ptxdist-4c6e7fa28b66dee069d10b514d5e1317173da250.tar.xz
pkg-config: cleanup and improve path and dependency handling
- move all search path magic into the wrapper script - use the wrapper script for host packages as well - enforce the dependencies for host packages - make it possible to overwrite the script in the BSP - track host and target dependencies separately Needed e.g. by barebox to build host tools Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/ptxd_make_00-init.sh46
-rw-r--r--scripts/lib/ptxd_make_world_common.sh21
-rw-r--r--scripts/lib/ptxd_make_world_install.sh13
-rwxr-xr-xscripts/pkg-config-wrapper55
4 files changed, 57 insertions, 78 deletions
diff --git a/scripts/lib/ptxd_make_00-init.sh b/scripts/lib/ptxd_make_00-init.sh
index 4103d4f39..7e561a4e6 100644
--- a/scripts/lib/ptxd_make_00-init.sh
+++ b/scripts/lib/ptxd_make_00-init.sh
@@ -191,7 +191,6 @@ export -f ptxd_get_lib_dir
# out:
# PTXDIST_CROSS_CPPFLAGS CPPFLAGS for cross-compiled packages
# PTXDIST_CROSS_LDFLAGS LDFLAGS for cross-compiled packages
-# PTXDIST_CROSS_ENV_PKG_CONFIG PKG_CONFIG_* environemnt for cross pkg-config
#
ptxd_init_cross_env() {
@@ -219,32 +218,6 @@ ptxd_init_cross_env() {
export \
PTXDIST_CROSS_CPPFLAGS="${cppflags[*]}" \
PTXDIST_CROSS_LDFLAGS="${ldflags[*]}"
-
-
-
- ######## PKG_CONFIG_LIBDIR, PKG_CONFIG_PATH ########
-
- #
- # PKG_CONFIG_LIBDIR contains the default pkg-config search
- # directories. Set it to the components of
- # PTXDIST_PATH_SYSROOT_PREFIX.
- #
-
- # add <DIR>/lib/pkgconfig and <DIR>/share/pkgconfig
- local -a pkg_libdir pkg_lib_system_path pkg_system_incpath
- pkg_libdir=( "${prefix[@]/%//${lib_dir}/pkgconfig}" "${prefix[@]/%//share/pkgconfig}" )
- pkg_system_libpath=( "${pkg_libdir[@]/%//../../lib}" "${pkg_libdir[@]/%//../lib}" "/usr/lib" "/lib" )
- pkg_system_incpath=( "${pkg_libdir[@]/%//../../include}" "${pkg_libdir[@]/%//../include}" "/usr/include" "/include" )
-
- IFS=":"
- local pc_path="PKG_CONFIG_PATH=''"
- local pc_libdir="PKG_CONFIG_LIBDIR='${pkg_libdir[*]}'"
- local pc_sys_lib_path="PKG_CONFIG_SYSTEM_LIBRARY_PATH='${pkg_system_libpath[*]}'"
- local pc_syc_inc_path="PKG_CONFIG_SYSTEM_INCLUDE_PATH='${pkg_system_incpath[*]}'"
- IFS="${orig_IFS}"
- local pc="PKG_CONFIG='$(ptxd_get_ptxconf PTXCONF_SYSROOT_CROSS)/bin/$(ptxd_get_ptxconf PTXCONF_COMPILER_PREFIX)pkg-config'"
- PTXDIST_CROSS_ENV_PKG_CONFIG="${pc_path} ${pc_libdir} ${pc_sys_lib_path} ${pc_syc_inc_path} ${pc}"
- export PTXDIST_CROSS_ENV_PKG_CONFIG
}
#
@@ -287,25 +260,6 @@ ptxd_init_host_env() {
export \
PTXDIST_HOST_CPPFLAGS="${cppflags[*]}" \
PTXDIST_HOST_LDFLAGS="${ldflags[*]}"
-
- ######## PKG_CONFIG_LIBDIR, PKG_CONFIG_PATH ########
-
- #
- # PKG_CONFIG_LIBDIR contains the default pkg-config search
- # directories.
- #
-
- # add <DIR>/lib/pkgconfig and <DIR>/share/pkgconfig
- local -a pkg_libdir
- pkg_libdir=( "${prefix[@]/%//${lib_dir}/pkgconfig}" "${prefix[@]/%//share/pkgconfig}" )
-
- IFS=":"
- local pc_path="PKG_CONFIG_PATH=''"
- local pc_libdir="PKG_CONFIG_LIBDIR='${pkg_libdir[*]}'"
- IFS="${orig_IFS}"
- local pc="PKG_CONFIG='$(ptxd_get_ptxconf PTXCONF_SYSROOT_HOST)/bin/pkg-config'"
- PTXDIST_HOST_ENV_PKG_CONFIG="${pc_path} ${pc_libdir} ${pc}"
- export PTXDIST_HOST_ENV_PKG_CONFIG
}
ptxd_init_devpkg()
diff --git a/scripts/lib/ptxd_make_world_common.sh b/scripts/lib/ptxd_make_world_common.sh
index f04d2ed05..86e73538f 100644
--- a/scripts/lib/ptxd_make_world_common.sh
+++ b/scripts/lib/ptxd_make_world_common.sh
@@ -340,12 +340,21 @@ ptxd_make_world_init() {
;;
*) ;;
esac
- local pkgconfig_whitelist
- pkgconfig_whitelist="$(echo $(
- for dep in ${pkg_build_deps}; do
- cat "${ptx_state_dir}/${dep}.pkgconfig" 2>/dev/null;
- done))"
- pkg_env="PKGCONFIG_WHITELIST='${pkgconfig_whitelist}' PKGCONFIG_WHITELIST_SRC='${pkg_label}' ${pkg_env}"
+ local -a deps_host deps_target
+ local whitelist_host whitelist_target
+ for dep in ${pkg_build_deps}; do
+ case "${dep}" in
+ host-*|cross-*)
+ deps_host[${#deps_host[@]}]="${ptx_state_dir}/${dep}.pkgconfig"
+ ;;
+ *)
+ deps_target[${#deps_target[@]}]="${ptx_state_dir}/${dep}.pkgconfig"
+ ;;
+ esac
+ done
+ whitelist_host="$(echo $(cat "${deps_host[@]}" /dev/null 2>/dev/null))"
+ whitelist_target="$(echo $(cat "${deps_target[@]}" /dev/null 2>/dev/null))"
+ pkg_env="PKGCONFIG_WHITELIST_HOST='${whitelist_host}' PKGCONFIG_WHITELIST_TARGET='${whitelist_target}' PKGCONFIG_WHITELIST_SRC='${pkg_label}' ${pkg_env}"
# DESTDIR
if [[ "${pkg_conf_tool}" =~ "python" ]]; then
diff --git a/scripts/lib/ptxd_make_world_install.sh b/scripts/lib/ptxd_make_world_install.sh
index bcc93539c..eaadfadf4 100644
--- a/scripts/lib/ptxd_make_world_install.sh
+++ b/scripts/lib/ptxd_make_world_install.sh
@@ -221,11 +221,20 @@ ptxd_make_world_install_post() {
ptxd_make_world_init &&
(
if [ -n "${pkg_pkg_dir}" -a -d "${pkg_pkg_dir}" ]; then
- find "${pkg_pkg_dir}"/usr/{lib,share}/pkgconfig -name *.pc \
+ find "${pkg_pkg_dir}"{,/usr}/{lib,share}/pkgconfig -name *.pc \
-printf "%f\n" 2>/dev/null | sed 's/\.pc$//'
fi
for dep in ${pkg_build_deps}; do
- cat "${ptx_state_dir}/${dep}.pkgconfig" 2>/dev/null;
+ case "${dep}" in
+ host-*|cross-*)
+ if [ "${pkg_type}" = "target" ]; then
+ continue
+ fi
+ ;&
+ *)
+ cat "${ptx_state_dir}/${dep}.pkgconfig" 2>/dev/null
+ ;;
+ esac
done
) | sort -u > "${ptx_state_dir}/${pkg_label}.pkgconfig"
# do nothing if pkg_pkg_dir does not exist
diff --git a/scripts/pkg-config-wrapper b/scripts/pkg-config-wrapper
index 80656ddd4..11e586a20 100755
--- a/scripts/pkg-config-wrapper
+++ b/scripts/pkg-config-wrapper
@@ -1,8 +1,33 @@
#!/usr/bin/env bash
-declare -a PKG_CONFIG_ARRAY
-PKG_CONFIG_ARRAY=( $(type -a -P pkg-config) )
-PKG_CONFIG="${PKG_CONFIG_ARRAY[1]}"
+basedir="$(basename "$(dirname "$(dirname "$0")")")"
+
+declare -a prefix
+if [ "${basedir}" = "sysroot-cross" ]; then
+ prefix="$(dirname "$(dirname "$(dirname "$0")")")/sysroot-target/usr"
+ whitelist="${PKGCONFIG_WHITELIST_TARGET}"
+elif [ "${basedir}" = "sysroot-host" ]; then
+ prefix="$(dirname "$(dirname "$0")")"
+ whitelist="${PKGCONFIG_WHITELIST_HOST}"
+else
+ echo "$(basename ${0}): failed to determine prefix" >&2
+ exit 1
+fi
+
+declare -a libdir system_path system_incpath
+libdir=( "${prefix/%//lib/pkgconfig}" "${prefix/%//share/pkgconfig}" )
+system_libpath=( "${libdir[@]/%//../../lib}" "${libdir[@]/%//../lib}" "/usr/lib" "/lib" )
+system_incpath=( "${libdir[@]/%//../../include}" "${libdir[@]/%//../include}" "/usr/include" "/include" )
+
+orig_IFS="${IFS}"
+IFS=":"
+# default pkg-config searchs
+export PKG_CONFIG_LIBDIR="${libdir[*]}"
+# default search path that will be dropped from --cflags
+export PKG_CONFIG_SYSTEM_LIBRARY_PATH="${system_libpath[*]}"
+# default search path that will be dropped from --libs
+export PKG_CONFIG_SYSTEM_INCLUDE_PATH="${system_incpath[*]}"
+IFS="${orig_IFS}"
for ((i = 1; i <= ${#}; i++)); do
case "${!i}" in
@@ -34,24 +59,6 @@ if [ -n "${PTXDIST_PKG_CONFIG_VAR_NO_SYSROOT}" -a \
#
args[${#args[@]}]="-e"
args[${#args[@]}]="s~^${SYSROOT}/~/~"
-else
- declare -a sysroot_prefix
- #
- # this shell/sed magic removes "-I$SYSROOT/include" from
- # pkg-config's output
- #
-
- #
- # transform from PATH to array: /foo:/bar -> /foo /bar
- #
- sysroot_prefix=( ${PTXDIST_PATH_SYSROOT_PREFIX//:/ } )
-
- #
- # make sed expression: -e s~-I/foo/include\(\s\|$\)~~
- # remove whitespace
- #
- sysroot_prefix=( ${sysroot_prefix[@]/%//include\\(\\s\\|$\\)~~} )
- args=( ${args[@]} ${sysroot_prefix[@]/#/-e s~-I} -e "s~\s\+~ ~g" -e "s~^\s\+$~~")
fi
check_pipe_status() {
@@ -63,13 +70,13 @@ check_pipe_status() {
}
if [ -n "${PKGCONFIG_WHITELIST_SRC}" ]; then
- pkgs="$("${PKG_CONFIG}" --print-provides "${@}" 2>/dev/null | awk '{print $1}' && check_pipe_status)" &&
+ pkgs="$(pkg-config.real --print-provides "${@}" 2>/dev/null | awk '{print $1}' && check_pipe_status)" &&
for pkg in ${pkgs}; do
- if [[ ! " ${PKGCONFIG_WHITELIST} " =~ " ${pkg} " && ! "${pkg}" =~ '-uninstalled' ]]; then
+ if [[ ! " ${whitelist} " =~ " ${pkg} " && ! "${pkg}" =~ '-uninstalled' ]]; then
echo "$(basename ${0}): warning: blocking '${pkg}': not selected by '${PKGCONFIG_WHITELIST_SRC}'" >&2
exit 1
fi
done
fi
-"${PKG_CONFIG}" "${@}" | sed "${args[@]}"
+pkg-config.real "${@}" | sed "${args[@]}"
check_pipe_status