summaryrefslogtreecommitdiff
path: root/sofort
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2021-06-12 08:21:36 +0000
committermidipix <writeonce@midipix.org>2021-06-12 10:45:07 +0000
commitc45256703d7d3d12de51fc0084175d97107b557f (patch)
treea025ad65e81161a1bb05b5d975cd940fbe8715b1 /sofort
parentf8ab76275be5e7343932983e2d7a66985bf0dde9 (diff)
downloadperk-c45256703d7d3d12de51fc0084175d97107b557f.tar.bz2
perk-c45256703d7d3d12de51fc0084175d97107b557f.tar.xz
build system: added cfgtest_package_exists() & cfgtest_package_config().
Diffstat (limited to 'sofort')
-rw-r--r--sofort/ccenv/ccenv.sh1
-rw-r--r--sofort/cfgtest/cfgtest.sh127
2 files changed, 127 insertions, 1 deletions
diff --git a/sofort/ccenv/ccenv.sh b/sofort/ccenv/ccenv.sh
index 26270f4..d98e87e 100644
--- a/sofort/ccenv/ccenv.sh
+++ b/sofort/ccenv/ccenv.sh
@@ -1489,6 +1489,7 @@ ccenv_output_defs()
eval 'ccenv_'${ccenv_cfgtype}'_cc'=\'$ccenv_cc\'
eval 'ccenv_'${ccenv_cfgtype}'_cc_environment'=\'$ccenv_cc_environment\'
eval 'ccenv_'${ccenv_cfgtype}'_dumpmachine_switch'=\'$ccenv_dumpmachine_switch\'
+ eval 'ccenv_'${ccenv_cfgtype}'_pkgconf'=\'$ccenv_pkgconf\'
}
ccenv_set_cc_switch_vars()
diff --git a/sofort/cfgtest/cfgtest.sh b/sofort/cfgtest/cfgtest.sh
index 80ef06d..53d7cb8 100644
--- a/sofort/cfgtest/cfgtest.sh
+++ b/sofort/cfgtest/cfgtest.sh
@@ -10,6 +10,7 @@
# cfgdefs fraework variables:
# mb_cfgtest_cc: the compiler used for the current test
+# mb_cfgtest_pkgconf: the pkgconf utility used for the current test
# mb_cfgtest_cflags: the compiler flags used for the current test
# mb_cfgtest_cfgtype: the type of the current test (host/native)
# mb_cfgtest_makevar: the make variable affected by the current test
@@ -37,6 +38,7 @@ cfgtest_comment()
cfgtest_host_section()
{
mb_cfgtest_cc="$ccenv_host_cc"
+ mb_cfgtest_pkgconf="${ccenv_host_pkgconf:-false}"
mb_cfgtest_cfgtype='host'
mb_cfgtest_stdin_input=${ccenv_host_stdin_input:-}
mb_cfgtest_environment=${ccenv_host_cc_environment:-}
@@ -62,6 +64,7 @@ cfgtest_host_section()
cfgtest_native_section()
{
mb_cfgtest_cc="$ccenv_native_cc"
+ mb_cfgtest_pkgconf="${ccenv_native_pkgconf:-false}"
mb_cfgtest_cfgtype='native'
mb_cfgtest_stdin_input=${ccenv_native_stdin_input:-}
mb_cfgtest_environment=${ccenv_native_cc_environment:-}
@@ -128,7 +131,7 @@ cfgtest_epilog()
return 1
fi
- if [ "${2}" = '-----' ]; then
+ if [ "${2}" = '-----' ] || [ "${2}" = '(missing)' ]; then
printf '\n\ncfgtest: %s %s is missing or cannot be found.\n' "${1}" "${3}" >&3
printf '%s\n' '------------------------' >&3
return 1
@@ -641,6 +644,128 @@ cfgtest_library_presence()
}
+cfgtest_package_exists()
+{
+ # init
+ cfgtest_pkg=
+
+ for cfgtest_arg in ${@}; do
+ case "$cfgtest_arg" in
+ -*)
+ ;;
+
+ *)
+ cfgtest_pkg="$cfgtest_arg"
+ ;;
+ esac
+ done
+
+ cfgtest_prolog 'package' "$cfgtest_pkg"
+
+ # execute
+ "$mb_cfgtest_pkgconf" "${@}" \
+ > /dev/null 2>&3 \
+ || cfgtest_epilog 'package' '(missing)' "$cfgtest_pkg" \
+ || return 1
+
+ # result
+ printf 'cfgtest: package `%s'"'"' was found.\n' \
+ "$cfgtest_pkg" >&3
+ printf '%s\n' '------------------------' >&3
+
+ cfgtest_epilog 'package' '(exists)' "$cfgtest_pkg"
+
+ return 0
+}
+
+
+cfgtest_package_config()
+{
+ # init
+ if ! cfgtest_package_exists "${@}"; then
+ return 0
+ fi
+
+ cfgtest_pkg=
+
+ for cfgtest_arg in ${@}; do
+ case "$cfgtest_arg" in
+ -*)
+ ;;
+
+ *)
+ cfgtest_pkg="$cfgtest_arg"
+ ;;
+ esac
+ done
+
+ cfgtest_makevar_prefix=
+ cfgtest_pkgconf_prefix=
+
+ if [ "$mb_cfgtest_cfgtype" = 'native' ]; then
+ cfgtest_makevar_prefix='_NATIVE'
+ else
+ if [ -n "${mb_sysroot}" ]; then
+ cfgtest_pkgconf_prefix="--define-variable=prefix=${mb_sysroot}"
+ fi
+ fi
+
+ cfgtest_newline
+ cfgtest_comment 'package config:' "$cfgtest_pkg"
+
+ # foo.pc
+ cfgtest_pkgconf_path=$("$mb_cfgtest_pkgconf" \
+ --path "${@}" \
+ 2>/dev/null || true)
+
+ if [ -z "$cfgtest_pkgconf_path" ]; then
+ cfgtest_pkgconf_path=$("$mb_cfgtest_pkgconf" \
+ --debug "${@}" 2>&1 \
+ | grep ".pc'$" \
+ | head -n1 \
+ || true)
+
+ cfgtest_pkgconf_path="${cfgtest_pkgconf_path##* \'}"
+ cfgtest_pkgconf_path="${cfgtest_pkgconf_path%%\'}"
+ fi
+
+ mb_cfgtest_makevar=$(printf '%s_PKGCONF_%s' \
+ "$cfgtest_makevar_prefix" "$cfgtest_pkg" \
+ | tr '[[:lower:]]' '[[:upper:]]' \
+ | sed -e 's/-/_/g')
+
+ cfgtest_makevar_set "$cfgtest_pkgconf_path"
+
+ # --cflags
+ cfgtest_pkgconf_path=$("$mb_cfgtest_pkgconf" \
+ "$cfgtest_pkgconf_prefix" \
+ --cflags "${@}" \
+ | sed 's/[ \t]*$//')
+
+ mb_cfgtest_makevar=$(printf '%s_CFLAGS_%s' \
+ "$cfgtest_makevar_prefix" "$cfgtest_pkg" \
+ | tr '[[:lower:]]' '[[:upper:]]' \
+ | sed -e 's/-/_/g')
+
+ cfgtest_makevar_set "$cfgtest_pkgconf_path"
+
+ # --ldflags
+ cfgtest_pkgconf_path=$("$mb_cfgtest_pkgconf" \
+ "$cfgtest_pkgconf_prefix" \
+ --libs "${@}" \
+ | sed 's/[ \t]*$//')
+
+ mb_cfgtest_makevar=$(printf '%s_LDFLAGS_%s' \
+ "$cfgtest_makevar_prefix" "$cfgtest_pkg" \
+ | tr '[[:lower:]]' '[[:upper:]]' \
+ | sed -e 's/-/_/g')
+
+ cfgtest_makevar_set "$cfgtest_pkgconf_path"
+
+ return 0
+}
+
+
cfgtest_compiler_switch()
{
# init